1(function ($) { 2 var $this; 3 var widthWindow = $(window).width(); 4 var responsive, clickable, skin, speed, vertical, easing, hoverIn, hoverOut; 5 var heightOfMenu, widthOfMenu, topOfMenu, leftOfMenu, rightOfMenu, bottomOfMenu; 6 7 $.cssEase = { 8 'default': 'ease', 9 'in': 'ease-in', 10 'out': 'ease-out', 11 'in-out': 'ease-in-out', 12 'snap': 'cubic-bezier(0,1,.5,1)', 13 // Penner equations 14 'easeOutCubic': 'cubic-bezier(.215,.61,.355,1)', 15 'easeInOutCubic': 'cubic-bezier(.645,.045,.355,1)', 16 'easeInCirc': 'cubic-bezier(.6,.04,.98,.335)', 17 'easeOutCirc': 'cubic-bezier(.075,.82,.165,1)', 18 'easeInOutCirc': 'cubic-bezier(.785,.135,.15,.86)', 19 'easeInExpo': 'cubic-bezier(.95,.05,.795,.035)', 20 'easeOutExpo': 'cubic-bezier(.19,1,.22,1)', 21 'easeInOutExpo': 'cubic-bezier(1,0,0,1)', 22 'easeInQuad': 'cubic-bezier(.55,.085,.68,.53)', 23 'easeOutQuad': 'cubic-bezier(.25,.46,.45,.94)', 24 'easeInOutQuad': 'cubic-bezier(.455,.03,.515,.955)', 25 'easeInQuart': 'cubic-bezier(.895,.03,.685,.22)', 26 'easeOutQuart': 'cubic-bezier(.165,.84,.44,1)', 27 'easeInOutQuart': 'cubic-bezier(.77,0,.175,1)', 28 'easeInQuint': 'cubic-bezier(.755,.05,.855,.06)', 29 'easeOutQuint': 'cubic-bezier(.23,1,.32,1)', 30 'easeInOutQuint': 'cubic-bezier(.86,0,.07,1)', 31 'easeInSine': 'cubic-bezier(.47,0,.745,.715)', 32 'easeOutSine': 'cubic-bezier(.39,.575,.565,1)', 33 'easeInOutSine': 'cubic-bezier(.445,.05,.55,.95)', 34 'easeInBack': 'cubic-bezier(.6,-.28,.735,.045)', 35 'easeOutBack': 'cubic-bezier(.175, .885,.32,1.275)', 36 'easeInOutBack': 'cubic-bezier(.68,-.55,.265,1.55)' 37 }; 38 $.fn.menu3d = function (options) { 39 40 $this = $(this); 41 var opts = $.extend({}, $.fn.menu3d.defaults, options); 42 opts.easing = $.cssEase[opts.easing]; 43 44 responsive = opts.responsive; 45 clickable = opts.clickable; 46 skin = opts.skin; 47 speed = opts.speed; 48 vertical = opts.vertical; 49 easing = opts.easing; 50 hoverIn = opts.hoverIn; 51 hoverOut = opts.hoverOut; 52 53 54 55 56 if (clickable) { 57 $(document).click(function (e) { 58 var liOpen = $(e.target).parents(); 59 if (!$(liOpen).hasClass('open')) { 60 $.fn.menu3d.closeDropdown(); 61 }; 62 63 }); 64 }; 65 66 67 68 if (opts.responsive) { 69 $this.addClass('responsive'); 70 } 71 else { 72 $this.removeClass('responsive'); 73 } 74 75 76 77 $.fn.menu3d.init($this); 78 $.fn.menu3d.setVertical($this, opts.vertical, widthWindow); 79 80 81 82 83 $this.removeClass(function (index, css) { 84 return (css.match(/\bskin-\S+/g) || []).join(' '); 85 }); 86 $this.addClass(opts.skin); 87 88 89 //Sub menu 90 heightOfMenu = $this.outerHeight(); 91 widthOfMenu = $this.outerWidth(); 92 topOfMenu = $this.offset().top; 93 leftOfMenu = $this.offset().left; 94 rightOfMenu = leftOfMenu + widthOfMenu; 95 bottomOfMenu = topOfMenu + heightOfMenu; 96 97 98 $this.find('li > ul.sub').parent().prepend('<span class="arrow-icon"></span>'); 99 100 101 102 103 // Animate for all menu 104 // Click feature 105 if(opts.clickable){ 106 107 108 109 110 //main menu 111 $this.find('> ul > li:not(.menu-non-dropdown):not(.no-link)').find('>a,>span').click( 112 function(){ 113 114 var li = $(this).parent(); 115 var isOpen = $(li).hasClass('open'); 116 117 118 // close li menu 119 if(!isOpen){ 120 $.fn.menu3d.closeDropdown(li); 121 $.fn.menu3d.hoverIn(li); 122 $(li).addClass('open'); 123 124 return false; 125 } 126 else{ 127 $.fn.menu3d.closeDropdown(); 128 return false; 129 } 130 } 131 ); 132 133 134 135 //Sub menu 136 $this.find('li > ul.sub').parent().click( 137 function () { 138 var li = $(this); 139 var isOpenSub = $(li).hasClass('open'); 140 141 var dropdown = $(li).find('> ul'); 142 $(dropdown).click(function(){ isOpenSub = false; $(li).removeClass('open') }); 143 144 if(isOpenSub){ 145 $.fn.menu3d.hoverOutSub(this); 146 $(li).removeClass('open'); 147 $(li).find('ul.dropdown-menu').hide(); //close all sub menu 148 } 149 else{ 150 $.fn.menu3d.hoverInSub(this);
151 $(li).addClass('open'); 152 153 } 154 } 155 ); 156 157 } 158 else{ 159 // Hover feature 160 //Sub menu 161 $this.find('li > ul.sub').parent().hover(function () { 162 $.fn.menu3d.hoverInSub(this); 163 }, function () { 164 $.fn.menu3d.hoverOutSub(this); 165 }); 166 167 168 $this.find('> ul > li:not(.menu-non-dropdown):not(.no-link)').hover( 169 function () { 170 $.fn.menu3d.hoverIn(this); 171 }, 172 function () { 173 $.fn.menu3d.hoverOut(this); 174 } 175 ); 176 } 177 178 179 }; 180 181 $.fn.menu3d.init = function (obj) { 182 $this = $(obj); 183 184 185 $this.prepend('<div class="menuToggle">Menu <span class="megaMenuToggle-icon"></span></div>'); 186 $this.find(".txtSearch").focus(function () { $(this).val(''); }).blur(function () { $(this).val('Search...'); }) 187 $this.find('> ul > li:not(.menu-non-dropdown):not(.no-link):last').addClass('last'); 188 $this.find('> ul > li:first').addClass('first'); 189 190 //Mobile menu 191 $this.find('.menuToggle').click(function () { 192 $this.find('> ul').toggle(); 193 }); 194 }; 195 $.fn.menu3d.closeDropdown = function(notthis){ 196 var menu = $this.find(' > ul > .open'); 197 if (notthis) { 198 menu = $this.find(' > ul > .open').not(notthis); 199 }; 200 201 $(menu).removeClass('open'); 202 $.fn.menu3d.hoverOut(menu); 203 $(menu).find('.open').removeClass('open'); 204 $(menu).find('ul.dropdown-menu').hide(); //close all sub menu 205 206 } 207 $.fn.menu3d.hoverIn = function(li){ 208 var obj = $(li).find("> div:not(.movingout)"); 209 var hoverInOfMenu = hoverIn; 210 var hoverOutOfMenu = hoverOut; 211 212 213 //Animate custom for a menu 214 if ($(obj).attr('animate-in') != undefined && $(obj).attr('animate-in').length != 0) { 215 hoverInOfMenu = $(obj).attr('animate-in'); 216 } 217 if ($(obj).attr('animate-out') != undefined && $(obj).attr('animate-out').length != 0) { 218 hoverOutOfMenu = $(obj).attr('animate-in'); 219 } 220 221 222 223 if (hoverInOfMenu == 'slideDown') { 224 $(obj) 225 .css('z-index', 100) 226 .removeClass(hoverOutOfMenu) 227 .slideDown(speed / 2) 228 .addClass(hoverInOfMenu); 229 } 230 else { 231 $(obj) 232 .css('z-index', 100) 233 .show().removeClass(hoverOutOfMenu) 234 .css({ 235 'animation-fill-mode': 'both', 236 'animation-duration': speed + 'ms', 237 'animation-timing-function': easing 238 }) 239 .addClass(hoverInOfMenu); 240 241 242 var dropdownmenu = $(li).find('> .dropdown-menu'); 243 var width = $(dropdownmenu).outerWidth(); 244 var height = $(dropdownmenu).outerHeight(); 245 var left = $(dropdownmenu).parent().offset().left; 246 var right = left + width; 247 var top = $(dropdownmenu).parent().offset().top; 248 var bottom = top + height; 249 250 $(dropdownmenu).css('left', ''); 251 252 if (widthWindow > 768) { 253 if (vertical) { 254 if (bottom >= bottomOfMenu) { 255 var newTop = bottom - bottomOfMenu + 1; 256 if (height > heightOfMenu) {
257 $(li).css('position', 'static'); 258 $(dropdownmenu).css('top', '0px'); 259 } 260 else { 261 $(dropdownmenu).css('top', -newTop); 262 } 263 } 264 } 265 else { 266 if (right >= rightOfMenu) { 267 $(dropdownmenu).css('right', '-1px'); 268 } 269 } 270 } 271 } 272 }; 273 274 $.fn.menu3d.hoverOut = function(li) 275 { 276 if($(li).length > 0){ 277 var div = $(li).find("> div"); 278 var hoverInOfMenu = hoverIn; 279 var hoverOutOfMenu = hoverOut; 280 if ($(div).attr('animate-in') != undefined && $(div).attr('animate-in').length != 0) { 281 hoverInOfMenu = $(div).attr('animate-in'); 282 } 283 if ($(div).attr('animate-out') != undefined && $(div).attr('animate-out').length != 0) { 284 hoverOutOfMenu = $(div).attr('animate-out'); 285 } 286 287 var obj = $(li).find("> div." + hoverInOfMenu); 288 289 if (hoverOutOfMenu == 'none') { 290 $(obj).removeClass(hoverInOfMenu).hide((speed / 2)); 291 } 292 else if (hoverOutOfMenu == 'slideUp') { 293 $(obj).removeClass(hoverInOfMenu).slideUp((speed / 2)); 294 } 295 else { 296 $(obj).css('z-index', 1) 297 .removeClass(hoverInOfMenu) 298 .css({ 299 'animation-fill-mode': 'both', 300 'animation-duration': (speed / 2) + 'ms', 301 'animation-timing-function': easing 302 303 }) 304 .addClass(hoverOutOfMenu + ' movingout'); 305 } 306 307 animateRun(obj, hoverOutOfMenu, speed); 308 309 var dropdownmenu = $(li).find('.dropdown-menu'); 310 var left = $(dropdownmenu).offset().left; 311 var width = $(dropdownmenu).outerWidth(); 312 var right = left + width; 313 314 if (widthWindow > 768) { 315 if (right >= widthWindow) { 316 $(dropdownmenu).css('left', '-1px'); 317 } 318 } 319 $(dropdownmenu).parent().width(''); 320 $(dropdownmenu).width(''); 321 } 322 }; 323 324 $.fn.menu3d.hoverInSub = function(li){ 325 326 $(li).find('> ul').stop(true, true).slideDown(100); 327 328 var dropdownmenu = $(li).find('> ul'); 329 var left = $(li).offset().left; 330 var width = $(li).outerWidth(); 331 var right = left + width + width + 80; 332 var widthWindow = $(window).width(); 333 if (widthWindow > 768) { 334 if (right > widthWindow) { 335 $(dropdownmenu).css('left', 'auto'); 336 $(dropdownmenu).css('right', '100%'); 337 } 338 else { 339 $(dropdownmenu).css('left', '100%'); 340 $(dropdownmenu).css('right', 'auto'); 341 } 342 } 343 }; 344 345 $.fn.menu3d.hoverOutSub = function(li){ 346 $(li).find('> ul').stop(false, false).slideUp(100); 347 } 348 349 $.fn.menu3d.setVertical = function (obj, vertical, widthWindow) { 350 $this = $(obj); 351 352 //HORIZONTAL OR VERTICAL 353 if (vertical && widthWindow > 768) { 354 $this.addClass('vertical'); 355 $this.find('> ul > li').css({ 'float': 'none', 'display': 'block' }); 356 } 357 else { 358 $this.removeClass('vertical'); 359 } 360 }; 361 362 // Default options 363 $.fn.menu3d.defaults = { 364 //responsive in mobile devices 365 responsive: true, 366 367 //click or hover? 368 clickable: false, 369 370 skin: 'skin-gray', 371 372 // Duration per element 373 speed: 600, 374 375 //Horizontal or vertical 376 vertical: false, 377 378 // Animation curve 379 easing: 'default', 380 381 //Animation keyframe for hover in 382 hoverIn: 'flipInX', 383 384 //Animation keyframe for hover out 385 hoverOut: 'slideUp' 386 }; 387 388 function animateRun(obj, animateClass, s) { 389 setTimeout(function () { $(obj).removeClass('movingout ' + animateClass).hide(); }, s / 2); 390 } 391})(jQuery); 392 393 394
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.