Welcome to mirror list, hosted at ThFree Co, Russian Federation.

menu.js « templates « CoreHome « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eef1dd5ba424fbdee1bf3a599c2c9ba212d67edb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
function menu()
{
	this.param = {};
}

menu.prototype =
{	
	menuSectionLoaded: function (content, urlLoaded)
	{
		if(urlLoaded == menu.prototype.lastUrlRequested)
		{
			$('#content').html( content ).show();
			piwikHelper.hideAjaxLoading();
			menu.prototype.lastUrlRequested = null;
		}
	},
	
	customAjaxHandleError: function ()
	{
		menu.prototype.lastUrlRequested = null;
		piwikHelper.ajaxHandleError();		
	},
	
	overMainLI: function ()
	{
		$(this).siblings().removeClass('sfHover');
	},
	
	outMainLI: function ()
	{
	},
	
	onClickLI: function ()
	{
		var self = this;
		var urlAjax = $('a',this).attr('name');
		 broadcast.propagateAjax(urlAjax);
	
		return false;
		
	},

	init: function()
	{
		var self = this;
		this.param.superfish = $('.nav')
			.superfish({
				pathClass : 'current',
				animation : {opacity:'show'},
				delay : 2000
			});
		this.param.superfish.find("li")
			.click( self.onClickLI )
			;

		this.param.superfish
			.find("li:has(ul)")
			.hover(self.overMainLI, self.outMainLI)
			;
        // add id to all li menu to suport menu identification.
        // for all sub menu we want to have a unique id based on their module and action
        // for main menu we want to add just the module as its id.
        this.param.superfish.find('li').each(function(){
            var url = $(this).find('a').attr('name');
            var module = broadcast.getValueFromUrl("module",url);
            var action = broadcast.getValueFromUrl("action",url);
            var idGoal = broadcast.getValueFromUrl("idGoal",url);
			
            var main_menu = ($(this).parent().attr("class").match(/nav/)) ? true : false;
            if(main_menu)
            {
                $(this).attr({id: module});
            }
            else
            {
				// so Goals plugin is a little different than other
				// we can't identify by it's modules_action so we uses its idGoals.
				if(idGoal != '') {
					$(this).attr({id: module + '_' + action + '_' + idGoal});
				}
				else {
					$(this).attr({id: module + '_' + action});
				}
            }
        });
	},

    activateMenu : function(module,action,idGoal)
    {
		// getting the right li is a little tricky since goals uses idGoal, and overview is index.
		var $li = '';
		// So, if module is Goals, idGoal is present, and action is not Index, must be one of the goals
		if(module == 'Goals' && idGoal != '' && action != 'index') {
			$li = $("#" + module + "_" + action + "_" + idGoal);
		} else {
			$li = $("#" + module + "_" + action);
		}

		// we can't find this li based on Module_action? then li only be the main menu. e.g Dashboard.
		var no_sub_menu = false;
		if($li.size() == 0) {
			$li = $("#" + module);
			no_sub_menu = true;
		}
		
		piwikMenu.param.superfish.find("li").removeClass('sfHover');
		if($li.find('ul li').size() != 0 || no_sub_menu == true) {
			// we clicked on a MAIN LI
			$.fn.superfish.currentActiveMenu = $li;
			$li.find('>ul li:first').addClass('sfHover');
			$li.find('ul').css({'display':'block','visibility': 'visible'});
		} else {
		// we are in the SUB UL LI
			$.fn.superfish.currentActiveMenu = $li.parents('li');
			$li.addClass('sfHover');
			$li.parents('ul').css({'display':'block','visibility': 'visible'});
		}
	    $.fn.superfish.currentActiveMenu.showSuperfishUl().siblings().hideSuperfishUl();
    },

	loadFirstSection: function()
	{
		var self=this;
        if(broadcast.isHashExists() == false) {
            $('li:first', self.param.superfish)
		    .click()
		    .each(function(){ $(this).showSuperfishUl(); });
        }
	}
};

$(document).ready( function(){
	if($('.nav').size()) {
		piwikMenu = new menu();
		piwikMenu.init();
		piwikMenu.loadFirstSection();
		broadcast.init();
	}
});