1(function($){ 2 3 jQuery.fn.crumegamenu = function(options){ 4 var settings; 5 $.extend( settings = { 6 showSpeed: 400, 7 hideSpeed: 300, 8 trigger: "hover", 9 showDelay: 0, 10 hideDelay: 0, 11 effect: "fade", 12 align: "left", 13 responsive: true, 14 animation: "drop-left", 15 indentChildren: true, 16 indicatorFirstLevel: "", 17 indicatorSecondLevel: "", 18 scrollable: true, 19 scrollableMaxHeight: 460 20 }, options); 21 22 // variables 23 var menu_container = $(this); 24 var menu = $(menu_container).find(".primary-menu-menu"); 25 var menu_li = $(menu).find("li"); 26 var showHideButton; 27 var mobileWidthBase = 1023; 28 var bigScreenFlag = 2000; // a number greater than "mobileWidthBase" 29 var smallScreenFlag = 200; // a number less than "mobileWidthBase" 30 31 // sub-menu/megamenu indicators 32 $(menu).children("li").children("a").each(function(){ 33 if($(this).siblings(".sub-menu, .megamenu").length > 0){ 34 $(this).append("<span class='indicator'>" + settings.indicatorFirstLevel + "</span>"); 35 } 36 }); 37 $(menu).children("li").children(".megamenu").each(function(){ 38 $(this).find('ul').removeClass('sub-menu'); 39 }); 40 $(menu).find(".sub-menu").children("li").children("a").each(function(){ 41 if($(this).siblings(".sub-menu").length > 0){ 42 $(this).append("<span class='indicator'>" + settings.indicatorSecondLevel + "</span>"); 43 } 44 }); 45 46 // navigation alignment 47 if(settings.align == "right"){ 48 $(menu).addClass("primary-menu-right"); 49 } 50 51 // sub-menu indentation (mobile mode) 52 if(settings.indentChildren){ 53 $(menu).addClass("primary-menu-indented"); 54 } 55 56 // responsive behavior 57 if(settings.responsive){ 58 $(menu_container).addClass("primary-menu-responsive"); 59 showHideButton = $(menu_container).children(".showhide"); 60 } 61 62 // scrollable menu 63 if(settings.scrollable){ 64 if(settings.responsive){ 65 $(menu).css("max-height", settings.scrollableMaxHeight).addClass("scrollable").append("<li class='scrollable-fix'></li>"); 66 } 67 } 68 69 // shows a sub-menu 70 function showDropdown(item){ 71 if(settings.effect == "fade") 72 $(item).children(".sub-menu, .megamenu").stop(true, true).delay(settings.showDelay).fadeIn(settings.showSpeed).addClass(settings.animation); 73 else 74 $(item).children(".sub-menu, .megamenu").stop(true, true).delay(settings.showDelay).slideDown(settings.showSpeed).addClass(settings.animation); 75 } 76 77 // hides a sub-menu 78 function hideDropdown(item){ 79 if(settings.effect == "fade") 80 $(item).children(".sub-menu, .megamenu").stop(true, true).delay(settings.hideDelay).fadeOut(settings.hideSpeed).removeClass(settings.animation); 81 else 82 $(item).children(".sub-menu, .megamenu").stop(true, true).delay(settings.hideDelay).slideUp(settings.hideSpeed).removeClass(settings.animation); 83 $(item).children(".sub-menu, .megamenu").find(".sub-menu, .megamenu").stop(true, true).delay(settings.hideDelay).fadeOut(settings.hideSpeed); 84 } 85 86 // landscape mode 87 function landscapeMode(){ 88 $(menu).find(".sub-menu, .megamenu").hide(0); 89 if(navigator.userAgent.match(/Mobi/i) || window.navigator.msMaxTouchPoints > 0 || settings.trigger == "click"){ 90 $(".primary-menu-menu > li > a, .primary-menu ul.sub-menu li a").bind("click touchstart", function(e){ 91 e.stopPropagation(); 92 e.preventDefault(); 93 $(this).parent("li").siblings("li").find(".sub-menu, .megamenu").stop(true, true).fadeOut(300); 94 if($(this).siblings(".sub-menu, .megamenu").css("display") == "none"){ 95 showDropdown($(this).parent("li")); 96 return false; 97 } 98 else{ 99 hideDropdown($(this).parent("li")); 100 } 101 window.location.href = $(this).attr("href"); 102 }); 103 $(document).bind("click.menu touchstart.menu", function(ev){ 104 if($(ev.target).closest(".primary-menu").length == 0){ 105 $(".primary-menu-menu").find(".sub-menu, .megamenu").fadeOut(300); 106 } 107 }); 108 } 109 else{ 110 $(menu_li).bind("mouseenter", function(){ 111 showDropdown(this); 112 }).bind("mouseleave", function(){ 113 hideDropdown(this); 114 }); 115 } 116 } 117 118 // portrait mode 119 function portraitMode(){ 120 $(menu).find(".sub-menu, .megamenu").hide(0); 121 $(menu).find(".indicator").each(function(){ 122 if($(this).parent("a").siblings(".sub-menu, .megamenu").length > 0){ 123 $(this).bind("click", function(e){
124 $(menu).scrollTo({top: 45, left: 0}, 600); 125 if($(this).parent().prop("tagName") == "A"){ 126 e.preventDefault(); 127 } 128 if($(this).parent("a").siblings(".sub-menu, .megamenu").css("display") == "none"){ 129 $(this).parent("a").siblings(".sub-menu, .megamenu").delay(settings.showDelay).slideDown(settings.showSpeed); 130 $(this).parent("a").parent("li").siblings("li").find(".sub-menu, .megamenu").slideUp(settings.hideSpeed); 131 } 132 else{ 133 $(this).parent("a").siblings(".sub-menu, .megamenu").slideUp(settings.hideSpeed); 134 } 135 }); 136 } 137 }); 138 } 139 140 // Fix the submenu on the right side 141 function fixSubmenuRight(){ 142 var submenus = $(menu).children("li").children(".sub-menu, .megamenu"); 143 if($(window).innerWidth() > mobileWidthBase){ 144 var menu_width = $(menu_container).outerWidth(true); 145 for(var i = 0; i < submenus.length; i++){ 146 if($(submenus[i]).parent("li").position().left + $(submenus[i]).outerWidth() > menu_width){ 147 $(submenus[i]).css("right", 0); 148 } 149 else{ 150 if(menu_width == $(submenus[i]).outerWidth() || (menu_width - $(submenus[i]).outerWidth()) < 20){ 151 $(submenus[i]).css("left", 0); 152 } 153 if($(submenus[i]).parent("li").position().left + $(submenus[i]).outerWidth() < menu_width){ 154 $(submenus[i]).css("right", "auto"); 155 } 156 } 157 } 158 } 159 } 160 161 // show the bar to show/hide menu items on mobile 162 function showMobileBar(){ 163 $(menu).hide(0); 164 $(showHideButton).show(0).click(function(){ 165 if($(menu).css("display") == "none") 166 $(menu).slideDown(settings.showSpeed); 167 else 168 $(menu).slideUp(settings.hideSpeed).find(".sub-menu, .megamenu").hide(settings.hideSpeed); 169 }); 170 } 171 172 // hide the bar to show/hide menu items on mobile 173 function hideMobileBar(){ 174 $(menu).show(0); 175 $(showHideButton).hide(0); 176 } 177 178 // unbind events 179 function unbindEvents(){ 180 $(menu).find("li, a").unbind(); 181 $(document).unbind("click.menu touchstart.menu"); 182 } 183 184 // return window's width 185 function windowWidth(){ 186 return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; 187 } 188 189 // navigation start function 190 function startMenu(){ 191 fixSubmenuRight(); 192 if(windowWidth() <= mobileWidthBase && bigScreenFlag > mobileWidthBase){ 193 unbindEvents(); 194 if(settings.responsive){ 195 showMobileBar(); 196 portraitMode(); 197 } 198 else{ 199 landscapeMode(); 200 } 201 } 202 if(windowWidth() > mobileWidthBase && smallScreenFlag <= mobileWidthBase){ 203 unbindEvents(); 204 hideMobileBar(); 205 landscapeMode(); 206 } 207 bigScreenFlag = windowWidth(); 208 smallScreenFlag = windowWidth(); 209 /* IE8 fix */ 210 if(/MSIE (\d+\.\d+);/.test(navigator.userAgent) && windowWidth() < mobileWidthBase){ 211 var ieversion = new Number(RegExp.$1); 212 if(ieversion == 8){ 213 $(showHideButton).hide(0); 214 $(menu).show(0); 215 unbindEvents(); 216 landscapeMode(); 217 } 218 } 219 } 220 221 startMenu(); 222 $(window).resize(function(){ 223 startMenu(); 224 fixSubmenuRight(); 225 }); 226 227 } 228}(jQuery)); 229 230/** 231 * jquery.scrollTo 232 * Copyright (c) 2007-2014 Ariel Flesler - aflesler<a>gmail<d>com | http://flesler.blogspot.com 233 * Licensed under MIT 234 * @author Ariel Flesler 235 * @version 1.4.13 236 */ 237 238(function(k){'use strict';k(['jquery'],function($){var j=$.scrollTo=function(a,b,c){return $(window).scrollTo(a,b,c)};j.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:!0};j.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(f,g,h){if(typeof g=='object'){h=g;g=0}if(typeof h=='function')h={onAfter:h};if(f=='max')f=9e9;h=$.extend({},j.defaults,h);g=g||h.duration;h.queue=h.queue&&h.axis.length>1;if(h.queue)g/=2;h.offset=both(h.offset);h.over=both(h.over);return this._scrollable().each(function(){if(f==null)return;var d=this,$elem=$(d),targ=f,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=win?$(targ):$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}
238var e=$.isFunction(h.offset)&&h.offset(d,targ)||h.offset;$.each(h.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=j.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(h.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=e[pos]||0;if(h.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*h.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(h.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&h.queue){if(old!=attr[key])animate(h.onAfterFirst);delete attr[key]}});animate(h.onAfter);function animate(a){$elem.animate(attr,g,h.easing,a&&function(){a.call(this,targ,h)})}}).end()};j.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return $.isFunction(a)||typeof a=='object'?a:{top:a,left:a}}return j})}(typeof define==='function'&&define.amd?define:function(a,b){if(typeof module!=='undefined'&&module.exports){module.exports=b(require('jquery'))}else{b(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.