PageSourceSearch

https://passivehouseplus.ie/templates/gk_technews/js/gk.menu.js

js passivehouseplus.ie collected 2026-10-02 07:53:11 UTC 12,254 bytes, 336 lines download raw bytes

1jQuery(document).ready(function() {
2	// Aside menu
3	if(jQuery('#aside-menu').length > 0) {
4		var staticToggler = jQuery('#gkMobileMenu');
5	 
6		staticToggler.click(function() {
7	    	gkOpenAsideMenu();
8		});
9	 
10		jQuery('#close-menu').click( function() {
11	    	gkOpenAsideMenu();
12		});
13		
14		jQuery('#aside-menu').find('a[href^="#"]').click(function() {
15			jQuery('#close-menu').trigger('click');
16		});
17	
18		// detect android browser
19		var ua = navigator.userAgent.toLowerCase();
20		var isAndroid = ua.indexOf("android") > -1 && !window.chrome;
21		if(isAndroid) {
22			jQuery('body').addClass('android-stock-browser');
23		}
24		// Android stock browser fix for the aside menu
25		if(jQuery('body').hasClass('android-stock-browser') && jQuery('#aside-menu').length > 0) {
26			jQuery('#gkMobileMenu').click( function() {
27				window.scrollTo(0, 0);
28			});
29			// menu dimensions
30			var asideMenu = jQuery('#aside-menu');
31			var menuHeight = jQuery('#aside-menu').height();
32			//
33			jQuery(window).scroll( function(e) {
34				if(asideMenu.hasClass('menu-open')) {
35			    	// get the necessary values and positions
36			    	var currentPosition = jQuery(window).scrollTop();
37			    	var windowHeight = jQuery(window).height();
38			
39			    	// compare the values
40			    	if(currentPosition > menuHeight - windowHeight) {
41			        	jQuery('#close-menu').trigger('click');
42			    	}
43				}
44			});
45		}
46		
47		function gkOpenAsideMenu() {
48			jQuery('#gkBg').toggleClass('menu-open');
49			
50			if(jQuery('#aside-menu').hasClass('menu-open')) {
51				setTimeout(function() {
52					jQuery('#aside-menu').removeClass('menu-open');
53					jQuery('#gkBg').removeClass('menu-visible');
54				}, 350);
55			} else {
56				jQuery('#aside-menu').addClass('menu-open');
57				jQuery('#gkBg').addClass('menu-visible');
58			}
59			
60			if(!jQuery('#close-menu').hasClass('menu-open')) {
61				setTimeout(function() {
62			    	jQuery('#close-menu').toggleClass('menu-open');
63				}, 300);
64			} else {
65				jQuery('#close-menu').removeClass('menu-open');
66			}
67		}
68	}
69	
70	// Classic menu
71	if(jQuery('.gkMainMenu').length > 0) {
72		// set the menu config only if it is visible
73        if(jQuery(window).outerWidth() > jQuery(document.body).attr('data-tablet-width')) {
74        	gk_hotel_classic_menu_init();
75        }
76        // evaluate the menu initialization on every window resize
77        jQuery(window).resize(function() {
78        	// it will be evaluated only if it wasn't evaluated earlier
79        	if(jQuery(window).outerWidth() > jQuery(document.body).attr('data-tablet-width')) {
80        		gk_hotel_classic_menu_init();
81        	}
82        });
83        
84        // Overlay menu
85        jQuery('#gkMobileMenu').click(function(e) {
86        	e.preventDefault();
87        	
88        	if(jQuery('#gk-menu-overlay').length === 0) {
89        		var menu_wrap = jQuery('<div id="gk-menu-overlay">&nbsp;</div><div id="gk-menu-overlay-wrap"><span id="gk-menu-overlay-close">&times;</span></div>');
90        		jQuery(document.body).append(menu_wrap);
91        		jQuery('#gk-menu-overlay-wrap').append(jQuery('.gkMainMenu').clone());
92        		
93        		jQuery('#gk-menu-overlay-wrap').click(function(e) {
94        			e.stopPropagation();
95        		});
96        		
97        		jQuery('#gk-menu-overlay-close').click(function() {
98        			jQuery('#gk-menu-overlay').removeClass('gk-active');
99        			jQuery('#gk-menu-overlay-wrap').removeClass('gk-active');
100        			
101        			setTimeout(function() {
102        				jQuery('#gk-menu-overlay').removeClass('gk-show');
103        				jQuery('#gk-menu-overlay-wrap').removeClass('gk-show');	
104        			}, 350);
105        		});
106        		
107        		jQuery('#gk-menu-overlay').click(function() {
108        			jQuery('#gk-menu-overlay-close').trigger('click');
109        		});
110        		
111        		jQuery('#gk-menu-overlay-wrap').find('a[href^="#"]').click(function() {
112        			jQuery('#gk-menu-overlay-close').trigger('click');
113        		});
114        	}
115    		
116    		jQuery('#gk-menu-overlay-wrap').css('top', jQuery(window).scrollTop());
117    		jQuery('#gk-menu-overlay').addClass('gk-show');
118    		jQuery('#gk-menu-overlay').css('height', jQuery('body').outerHeight() + jQuery('#gk-menu-overlay-wrap').outerHeight() + "px");
119    		jQuery('#gk-menu-overlay-wrap').addClass('gk-show');
120    		
121    		setTimeout(function() {
122    			jQuery('#gk-menu-overlay').addClass('gk-active');
123    			jQuery('#gk-menu-overlay-wrap').addClass('gk-active');
124    		}, 50);
125        });
126    }
127    
128    // Fixed menu
129    if(jQuery('#gkHeaderNav').attr('data-fixed') === '1') {
130    	var page_nav = jQuery('#gkHeaderNav');
131    	var prev_scroll_value = 0;
132    	page_nav.css('top', 0);	
133    		
134		function menu_scroll() {
135			var new_scroll_value = jQuery(window).scrollTop() >= 0 ? jQuery(window).scrollTop() : 0;	
136			var local_diff = new_scroll_value - prev_scroll_value;
137			var current = parseInt(page_nav.css('top'));
138			var h = 62;
139			
140			if(new_scroll_value >= 0) {
141				//if(
142					//!page_nav.hasClass('gk-fixed-nav')
143				//) {
144					//page_nav.addClass('gk-fixed-nav');
145					//page_nav.css('top', '-62px');
146					//current = -62;
147				//}
148			
149				if(new_scroll_value >= prev_scroll_value) {
150					page_nav.css('top', (current - local_diff >= -62 ? current - local_diff : -62) + "px");
151				} else {
152					page_nav.css('top', (current - local_diff <= 0 ? current - local_diff : 0) + "px");
153				}
154			} else {
155				if(page_nav.hasClass('gk-fixed-nav')) {
156					page_nav.removeClass('gk-fixed-nav');
157					page_nav.css('top', 0);	
158				}
159			}
160			
161			prev_scroll_value = new_scroll_value;
162		}
163		
164		jQuery(window).scroll(menu_scroll);
165    }
166}); 
167
168function gk_hotel_classic_menu_init() {
169	if(!jQuery('.gkMainMenu').attr('data-loaded')) {
170		jQuery('.gkMainMenu').attr('data-loaded', true);
171		// fix for the iOS devices     
172	    jQuery('.gkMainMenu ul li span').each(function(i, el) {
173	        jQuery(el).attr('onmouseover', '');
174	    });
175	
176	    jQuery('.gkMainMenu ul li a').each(function(i, el) {
177	        el = jQuery(el);
178	        el.attr('onmouseover', '');
179	        
180	        if(el.parent().hasClass('haschild') && jQuery('body').attr('data-tablet') !== undefined) {
181	            el.click(function(e) {
182	                if(el.attr("dblclick") === undefined) {
183	                    e.preventDefault();
184	                    e.stopPropagation();
185	                    el.attr("dblclick", new Date().getTime());
186	                } else {
187	                    if(el.parent().find('div.childcontent').eq(0).css('overflow') === 'visible') {
188	                        window.location = el.attr('href');
189	                    }
190	                    var now = new Date().getTime();
191	                    if(now - el.attr("dblclick", 0) < 500) {
192	                        window.location = el.attr('href');
193	                    } else {
194	                       e.preventDefault();
195	                       e.stopPropagation();
196	                       el.attr("dblclick", new Date().getTime());
197	                    }
198	                }
199	            });
200	        }
201	    });
202	
203	    var base = jQuery('.gkMainMenu');
204	
205	    base.find('.childcontent-inner').each(function(i, submenu) {
206	        var cols = jQuery(submenu).children('.gkcol');
207	        
208	        if(cols.length > 1) {
209	            var max = jQuery(cols[0]).outerHeight();
210	            
211	            for(i = 0; i < cols.length; i++) {
212	                max = jQuery(cols[i]).outerHeight() > max ? jQuery(cols[i]).outerHeight() : max;
213	            }
214	            
215	            cols.css('height', max + "px");
216	        }
217	    });
218	    
219	    base.find('li.haschild').each(function(i, el){   
220	        el = jQuery(el);  
221	        if(el.children('.childcontent').length > 0) {
222	            var content = el.children('.childcontent').first();
223	            var prevh = content.outerHeight();
224	            var prevw = content.outerWidth();
225	            var duration = base.attr('data-duration');
226	            var heightAnim = base.attr('data-height') == '1';
227	            var widthAnim = base.attr('data-width') == '1';
228	            var opacityAnim = base.attr('data-opacity') == '1'; 
229	            
230	            if(!opacityAnim && !widthAnim && !heightAnim) {
231	            	duration = 0;
232	            }
233	            
234	            // hide the menu till opened
235	            if(content.parent().parent().hasClass('level0')) {
236	                content.css('margin-left', "-9999px");
237	            }
238	
239	            var fxStart = { 
240	                'height' : heightAnim ? 0 : prevh, 
241	                'width' : widthAnim ? 0 : prevw, 
242	                'opacity' : opacityAnim ? 0 : 1 
243	            };
244	            var fxEnd = { 
245	                'height' : prevh, 
246	                'width' : prevw, 
247	                'opacity' : 1 
248	            };  
249	            
250	            
251	            content.css(fxStart);
252	            content.css({'left' : 'auto', 'overflow' : 'hidden' });
253	            //                      
254	            el.mouseenter(function() {                    
255	                var content = el.children('.childcontent').first();
256	                var basicMargin = (el.parent().hasClass('level0')) ? -1 * ((prevw / 2) - (el.outerWidth() / 2)) : 0;
257	                content.css('display', 'block');
258	            
259	                var pos = content.offset();
260	                var winWidth = jQuery(window).outerWidth();
261	                var winScroll = jQuery(window).scrollLeft();
262	                
263	                // calculations
264	                var posStart = pos.left;
265	                var posEnd = pos.left + prevw;
266	                var diff;
267					
268					content.addClass('active');
269					
270	                if(el.parent().hasClass('level0')) {
271	                    content.css('margin-left', basicMargin + "px");
272	                    pos = content.offset();
273	                    posStart = pos.left;
274	                    posEnd = pos.left + prevw;
275	                    
276	                    if(posStart < 0) {
277	                        content.css('margin-left', parseInt(content.css('margin-left')) + (-1 * posStart) + 10);
278	                    }
279	                    
280	                    if(posEnd > winWidth + winScroll) {
281	                        diff = (winWidth + winScroll) - posEnd;
282	                        content.css('margin-left', parseInt(content.css('margin-left')) + diff - 24);
283	                    }
284	                } else {
285	                    diff = (winWidth + winScroll) - posEnd;
286	                    
287	                    if(posEnd > winWidth + winScroll) {
288	                        content.css('margin-left', diff - 150 + "px");
289	                    }
290	                }
291	                //
292	                content.stop().animate(
293	                    fxEnd, 
294	                    {
295		                    "duration": duration, 
296		                    "queue": false,
297		                    "complete": function() { 
298					                        if(content.outerHeight() === 0){ 
299					                            content.css('overflow', 'hidden'); 
300					                        } else {
301					                            content.css('overflow', 'visible');
302					                        }
303					                    }
304	                    }
305	                );
306	            });
307	            
308	        	el.mouseleave(function(){
309	                content.css({
310	                    'overflow': 'hidden'
311	                });
312	                //
313	                content.stop().animate(
314	                    fxStart, 
315	                    {
316	                        "duration": duration, 
317	                        "queue": false,
318	                        "complete": function() { 
319					                        if(content.outerHeight() === 0){ 
320					                            content.css('overflow', 'hidden'); 
321					                        } else if(
322					                            content.outerHeight(true) - prevh < 30 && 
323					                            content.outerHeight(true) - prevh >= 0
324					                        ) {
325					                            content.css('overflow', 'visible');
326					                        }
327					                        content.removeClass('active');
328					                        content.css('display', 'none');
329					                    }
330					    }
331	                );
332	            });
333	        }
334	    });  
335    }  
336}

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.