PageSourceSearch

https://www.ccip.pt/plugins/system/t3/base/js/menu.js

js ccip.pt collected 2026-10-02 04:59:15 UTC 7,604 bytes, 244 lines download raw bytes

1/** 
2 *------------------------------------------------------------------------------
3 * @package       T3 Framework for Joomla!
4 *------------------------------------------------------------------------------
5 * @copyright     Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved.
6 * @license       GNU General Public License version 2 or later; see LICENSE.txt
7 * @authors       JoomlArt, JoomlaBamboo, (contribute to this project at github 
8 *                & Google group to become co-author)
9 * @Google group: https://groups.google.com/forum/#!forum/t3fw
10 * @Link:         http://t3-framework.org 
11 *------------------------------------------------------------------------------
12 */
13
14!function($){
15	var has_touch = 'ontouchstart' in window;
16
17	if(!has_touch){
18		$(document).ready(function($){
19			// detect animation duration
20			var mm_duration = $('.t3-megamenu').data('duration') || 0;
21			if (mm_duration) {
22
23				$('<style type="text/css">' +
24						'.t3-megamenu.animate .animating > .mega-dropdown-menu,' +
25						'.t3-megamenu.animate.slide .animating > .mega-dropdown-menu > div {' +
26							'transition-duration: ' + mm_duration + 'ms !important;' +
27							'-webkit-transition-duration: ' + mm_duration + 'ms !important;' +
28						'}' +
29					'</style>').appendTo ('head');
30			}
31
32			var mm_timeout = mm_duration ? 100 + mm_duration : 500,
33				mm_rtl = $('html').attr('dir') == 'rtl',
34				sb_width = (function () { 
35				var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
36					child = parent.children(),
37					width = child.innerWidth() - child.height(100).innerWidth();
38
39				parent.remove();
40
41				return width;
42			})();
43
44			//lt IE 10
45			if(!$.support.transition){
46				//it is not support animate
47				$('.t3-megamenu').removeClass('animate');
48				
49				mm_timeout = 100;
50			}
51
52			function position_menu(item){
53
54				var sub = item.children('.mega-dropdown-menu'),
55					is_show = sub.is(':visible');
56
57				if(!is_show){
58					sub.show();
59				}
60
61				var offset = item.offset(),
62					width = item.outerWidth(),
63					screen_width = $(window).width() - sb_width,
64					sub_width = sub.outerWidth(),
65					level = item.data('level');
66
67				if(!is_show){
68					sub.css('display', '');
69				}
70
71				//reset custom align
72				sub.css({left : '', right : ''});
73
74				if(level == 1){
75
76					var align = item.data('alignsub'),
77						align_offset = 0,
78						align_delta = 0,
79						align_trans = 0;
80
81					if(align == 'justify'){
82						return;	//do nothing
83					}
84
85					if(!align){
86						align = 'left';
87					}
88
89					if(align == 'center'){
90						align_offset = offset.left + (width /2);
91
92						if(!$.support.t3transform){
93							align_trans = -sub_width /2;
94							sub.css(mm_rtl ? 'right' : 'left', align_trans + width /2);
95						}
96
97					} else {
98						align_offset = offset.left + ((align == 'left' && mm_rtl || align == 'right' && !mm_rtl) ? width : 0);
99					}
100			
101					if (mm_rtl) {
102
103						if(align == 'right'){
104							if(align_offset + sub_width > screen_width){
105								align_delta = screen_width - align_offset - sub_width;
106								sub.css('left', align_delta);
107
108								if(screen_width < sub_width){
109									sub.css('left', align_delta + sub_width - screen_width);
110								}
111							}
112						} else {
113							if(align_offset < (align == 'center' ? sub_width /2 : sub_width)){
114								align_delta = align_offset - (align == 'center' ? sub_width /2 : sub_width);
115								sub.css('right', align_delta + align_trans);
116							}
117
118							if(align_offset + (align == 'center' ? sub_width /2 : 0) - align_delta > screen_width){
119								sub.css('right', align_offset + (align == 'center' ? (sub_width + width) /2 : 0) + align_trans - screen_width);
120							}
121						}
122
123					} else {
124
125						if(align == 'right'){
126							if(align_offset < sub_width){
127								align_delta = align_offset - sub_width;
128								sub.css('right', align_delta);
129
130								if(sub_width > screen_width){
131									sub.css('right', sub_width - screen_width + align_delta);
132								}
133							}
134						} else {
135
136							if(align_offset + (align == 'center' ? sub_width /2 : sub_width) > screen_width){
137								align_delta = screen_width - align_offset -(align == 'center' ? sub_width /2 : sub_width);
138								sub.css('left', align_delta + align_trans);
139							}
140
141							if(align_offset - (align == 'center' ? sub_width /2 : 0) + align_delta < 0){
142								sub.css('left', (align == 'center' ? (sub_width + width) /2 : 0) + align_trans - align_offset);
143							}
144						}
145					}
146				} else {
147
148					if (mm_rtl) {
149						if (item.closest('.mega-dropdown-menu').parent().hasClass('mega-align-right')) {
150
151							//should be align to the right as parent
152							item.removeClass('mega-align-left').addClass('mega-align-right');
153
154							// check if not able => revert the direction
155							if (offset.left + width + sub_width > screen_width) {
156								item.removeClass('mega-align-right'); //should we add align left ? it is th default now
157
158								if(offset.left - sub_width < 0){
159									sub.css('right', offset.left + width - sub_width);
160								}
161							}
162						} else {
163							if (offset.left - sub_width < 0) {
164								item.removeClass('mega-align-left').addClass('mega-align-right');
165
166								if(offset.left + width + sub_width > screen_width){
167									sub.css('left', screen_width - offset.left - sub_width);
168								}
169							}
170						}
171					} else {
172
173						if (item.closest('.mega-dropdown-menu').parent().hasClass('mega-align-right')) {
174							//should be align to the right as parent
175							item.removeClass('mega-align-left').addClass('mega-align-right');
176
177							// check if not able => revert the direction
178							if (offset.left - sub_width < 0) {
179								item.removeClass('mega-align-right'); //should we add align left ? it is th default now
180
181								if(offset.left + width + sub_width > screen_width){
182									sub.css('left', screen_width - offset.left - sub_width);
183								}
184							}
185						} else {
186
187							if (offset.left + width + sub_width > screen_width) {
188								item.removeClass('mega-align-left').addClass('mega-align-right');
189
190								if(offset.left - sub_width < 0){
191									sub.css('right', offset.left + width - sub_width);
192								}
193							}
194						}
195					}
196				}
197			}
198
199
200			// only work with dropdown and mega
201			$('.nav').has('.dropdown-menu').children('li').add('li.mega').hover(function(event) {
202				var $this = $(this);
203				if ($this.hasClass ('mega')) {
204
205					//place menu
206					position_menu($this);
207
208					// add class animate
209					setTimeout(function(){$this.addClass ('animating')}, 10);
210
211					clearTimeout ($this.data('animatingTimeout'));
212					$this.data('animatingTimeout', 
213						setTimeout(function(){$this.removeClass ('animating')}, mm_timeout + 50));
214
215					clearTimeout ($this.data('hoverTimeout'));
216					$this.data('hoverTimeout', 
217						setTimeout(function(){$this.addClass ('open')}, 100));
218				} else {
219					clearTimeout ($this.data('hoverTimeout'));
220					$this.data('hoverTimeout', 
221						setTimeout(function(){$this.addClass ('open')}, 100));
222				}
223			},
224			function(event) {
225				var $this = $(this);
226				if ($this.hasClass ('mega')) {
227					$this.addClass ('animating');
228					clearTimeout ($this.data('animatingTimeout'));
229					$this.data('animatingTimeout', 
230						setTimeout(function(){$this.removeClass ('animating')}, mm_timeout));
231					clearTimeout ($this.data('hoverTimeout'));
232					$this.data('hoverTimeout', 
233						setTimeout(function(){$this.removeClass ('open')}, 100));
234				} else {
235					clearTimeout ($this.data('hoverTimeout'));
236					$this.data('hoverTimeout', 
237						setTimeout(function(){$this.removeClass ('open')}, 100));
238				}
239			});
240		});
241
242	}
243	
244}(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.