1/** 2 * @file 3 * Mobile_navigation Library functionality. 4 * 5 * Author - Christian Galicia 6 * Licenses: GPLv2 7 */ 8 9/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ 10 11window.matchMedia || (window.matchMedia = function() { 12 "use strict"; 13 14 // For browsers that support matchMedium api such as IE 9 and webkit 15 var styleMedia = (window.styleMedia || window.media); 16 17 // For those that don't support matchMedium 18 if (!styleMedia) { 19 var style = document.createElement('style'), 20 script = document.getElementsByTagName('script')[0], 21 info = null; 22 23 style.type = 'text/css'; 24 style.id = 'matchmediajs-test'; 25 26 script.parentNode.insertBefore(style, script); 27 28 // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers 29 info = ('getComputedStyle' in window) && window.getComputedStyle(style) || style.currentStyle; 30 31 styleMedia = { 32 matchMedium: function(media) { 33 var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }'; 34 35 // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers 36 if (style.styleSheet) { 37 style.styleSheet.cssText = text; 38 } else { 39 style.textContent = text; 40 } 41 42 // Test if media query is true or false 43 return info.width === '1px'; 44 } 45 }; 46 } 47 48 return function(media) { 49 return { 50 matches: styleMedia.matchMedium(media || 'all'), 51 media: media || 'all' 52 }; 53 }; 54}()); 55 56 57(function($) { 58 // Check for iPad/Iphone/Andriod 59 var instances = {}; 60 61 // Default options 62 var defaults = { 63 breakpoint : "all and (min-width: 740px) and (min-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)", 64 //"all and (max-width: 740px) and (max-device-width: 740px), (max-device-width: 800px) and (min-width: 740px) and (orientation:landscape)", 65 66 //menuSelector : "#superfish-1", 67 //"#megamenu-main-menu", 68 //"#main-menu", 69 70 mainPageSelector : "body", 71 72 menuPlugin : "slideMenu", 73 //"default", 74 //"accordion", 75 76 showEffect : "fixed_left", 77 //"expand_down", /* Expanded from the position where the menu collapsed button is */ 78 //"fixed_top", 79 //"fixed_right", 80 //"fixed_bottom", 81 //"drawer_left", 82 //"drawer_right", 83 //"drawer_top", 84 showItems : "all", 85 //"active_trail", 86 tabHandler : false, 87 88 menuWidth : "65", 89 90 specialClasses : true, 91 92 useMask : true, 93 94 menuLabel : "Menu" 95 }; 96 97 $(document).ready(function() { 98 $("body").prepend("<div id='debugInfo'></div>"); 99 $("#debugInfo").css({ 100 position : "fixed", 101 right : "50px", 102 top : "50px" 103 }); 104 }); 105 106 // Main Class 107 var mobile_menu = function(elem, options) { 108 var settings, current = "", width, height; 109 110 this.methods = { 111 112 /* destroy */ 113 destroy : function() { 114 115 }, 116 117 cloneMenu : function() { 118 119 switch (_this.settings.showEffect) { 120 case "expand_down": 121 $(_this.target).before("<div id='mobile-menu-wrapper'><div id='mobile-menu-inner'></div></div>"); 122 //_this.settings.useMask = false; 123 break; 124 125 case "fixed_top": 126 case "drawer_top": 127 case "fixed_left": 128 case "drawer_left": 129 case "fixed_right": 130 case "drawer_right": 131 case "fixed_bottom": 132 $("body").prepend("<div id='mobile-menu-wrapper'><div id='mobile-menu-inner'></div></div>"); 133 break; 134 135 } 136 137 var classes = ""; 138 switch (_this.settings.menuPlugin) { 139 case "basic": 140 classes = "mobile-menu-basic"; 141 break; 142 143 case "accordion": 144 classes = "mobile-menu-accordion"; 145 break; 146 147 case "slideMenu": 148 classes = "mobile-menu-slide"; 149 break; 150 151 } 152 153 // Cloning 154 $('#mobile-menu-inner').append("<ul id='mobile-menu' class='" + classes + "'>" + $(_this.target).html() + "</ul>"); 155 // Clearing up other plugins classes 156 $('#mobile-menu li, #mobile-menu ul, #mobile-menu a').attr({ 157 id : "", 158 style : "" 159 }).removeClass('active'); 160 // Adding item-with-ul to submenu items 161 $("#mobile-menu li").each(function() { 162 if ($(this).find("ul").length) { 163 $(this).addClass("item-with-ul"); 164 } 165 }); 166 $('.item-with-ul span').click(function(){ 167 $(this).parent().find('ul.menu').fadeToggle(); 168 $(this).toggleClass('ulactive'); 169 }); 170 171 $("#mobile-menu li.item-with-ul > *:first-child").each(function() { 172 if ($(this).get(0).tagName == "A") { 173 $(this).wrap("<div></div>"); 174 } 175 $(this).parent().addClass("submenu-title"); 176 }); 177 178 if (_this.settings.tabHandler) { 179 var show = true, dir_class = ""; 180 switch (_this.settings.showEffect) { 181 case "expand_down": 182 show = false;
183 break; 184 185 case "fixed_top": 186 case "drawer_top": 187 dir_class = "top"; 188 break; 189 190 case "fixed_left": 191 case "drawer_left": 192 dir_class = "left"; 193 break; 194 195 case "fixed_right": 196 case "drawer_right": 197 dir_class = "right"; 198 break; 199 200 case "fixed_bottom": 201 dir_class = "bottom"; 202 break; 203 204 } 205 if (show) { 206 $("#mobile-menu-inner").prepend("<a id='menu-attached-button' class='mobile-menu-button " + dir_class + "'>" + _this.settings.menuLabel + "</a>"); 207 $("#menu-attached-button").click(function(e) { 208 _this.menuToggle(this); 209 e.stopPropagation(); 210 e.preventDefault(); 211 }); 212 } 213 } 214 215 $('#mobile-menu-inner').hide(); 216 217 // Add special classes to menu. 218 if (_this.settings.specialClasses) { 219 function addClassesToUl(ul, parentClass) { 220 221 var ii = 1; 222 $(ul).find("> li").each(function() { 223 if (parentClass == "") { 224 var cls = "menuitem-" + ii; 225 } else { 226 var cls = "menuitem-" + parentClass + "-" + ii; 227 } 228 229 $(this).addClass(cls); 230 231 if ($(this).hasClass("item-with-ul")) { 232 233 if (parentClass == "") { 234 addClassesToUl($(this).find("> ul"), ii); 235 } else { 236 addClassesToUl($(this).find("> ul"), parentClass + "-" + ii); 237 } 238 239 } 240 ii++; 241 242 }); 243 244 } 245 246 addClassesToUl($("#mobile-menu"), ""); 247 } 248 249 }, 250 251 collapseInAButton : function() { 252 253 if (!$("#collapsed-menu-button").length) { 254 // Create button 255 if (_this.settings.showEffect == "expand_down") { 256 $("#mobile-menu-wrapper").before("<a id='collapsed-menu-button' class='mobile-menu-button'>" + _this.settings.menuLabel + "</a>"); 257 } else { 258 $(_this.target).before("<a id='collapsed-menu-button' class='mobile-menu-button'>" + _this.settings.menuLabel + "</a>"); 259 } 260 261 $("#mobile-menu-inner").hide(); 262/* 263 $("#collapsed-menu-button").unbind("click").click(function(e) { 264 _this.menuToggle(this); 265 e.stopPropagation(); 266 e.preventDefault(); 267 }); 268 */ 269 if ('ontouchstart' in document.documentElement) { 270 $('#collapsed-menu-button').on('touchstart', function(e) { 271 _this.menuToggle(this); 272 e.stopPropagation(); 273 e.preventDefault(); 274 }); 275 } else { 276 $("#collapsed-menu-button").unbind('click').click(function(e) { 277 _this.menuToggle(this); 278 e.stopPropagation(); 279 e.preventDefault(); 280 }); 281 } 282 } 283 }, 284 285 // Build Slide Menu plugin 286 slideMenuBuild : function() { 287 288 if (!$("#mobile-menu").length) { 289 _this.cloneMenu(); 290 $("#mobile-menu-inner").addClass("slidemenu"); 291 $("#mobile-menu .item-with-ul ul").hide(); 292 $("#mobile-menu").addClass("mobile-menu-slide").wrap("<div id='mobile-menu-display'></div>").wrap("<div id='slide-menu-clip'></div>"); 293 $("#mobile-menu-display").css({ 294 overflow : "hidden" 295 }); 296 $("#mobile-menu-inner").css({ 297 width : _this.settings.menuWidth + "%" 298 }); 299 300 function buildNewSub(sub) { 301 var no = $(".mobile-menu-slide").length, id = "mobile-menu-" + no, mm_w = $("#mobile-menu-inner").width(); 302 303 var ul = $($('<div></div>').html($(sub).clone())).html(); 304 305 $("#slide-menu-clip").append("<ul id='" + id + "' class='mobile-menu mobile-menu-slide'>" + ul + "</ul>"); 306 $("#" + id + " > li > ul").show(); 307 $("#" + id + " > li > *").first().addClass("return-link"); 308 $("#" + id + " > li > ul").css({ 309 padding : 0 310 }); 311 312 $("#slide-menu-clip").css({ 313 width : (mm_w * (no + 1)), 314 float : "left" 315 }); 316 $(".mobile-menu-slide").css({ 317 width : mm_w, 318 float : "left" 319 }); 320 321 $('#slide-menu-clip').animate({ 322 "marginLeft" : -(mm_w * no) 323 }, 'normal'); 324 325 //$("#"+id+" .item-with-ul").unbind('click'); 326 bindClick("#" + id); 327 328 $("#" + id + " .return-link").unbind('click').click(function(e) { 329 $('#slide-menu-clip').animate({ 330 "marginLeft" : -($("#mobile-menu-inner").width() * ($(".mobile-menu-slide").length - 2)) 331 }, 'normal', function() { 332 $(".mobile-menu-slide:last").remove(); 333 $("#slide-menu-clip").css({ 334 width : ($("#mobile-menu-inner").width() * ($(".mobile-menu-slide").length + 1)), 335 float : "left" 336 }); 337 }); 338 339 e.preventDefault(); 340 e.stopPropagation(); 341 }); 342 343 } 344 345 function bindClick(item) { 346 $(item).find(".item-with-ul").unbind('click').click(function(e) { 347 buildNewSub(this); 348 e.preventDefault(); 349 e.stopPropagation(); 350 }); 351 $(item).find("li a").unbind('click').click(function(e) { 352 e.stopPropagation(); 353 }); 354 } 355 356 bindClick("#mobile-menu"); 357 } 358 359 }, 360 361 accordionBuild : function() { 362 if (!$("#mobile-menu").length) { 363 //var menu = ; 364 _this.cloneMenu(); 365 $("#mobile-menu-inner").addClass("accordion").css({ 366 width : _this.settings.menuWidth + "%" 367 }); 368 $("#mobile-menu").width(_this.width); 369 // _this.settings.showItems possible values: all, active_trail 370 if (_this.settings.expandActive) { 371 $("#mobile-menu .item-with-ul:not(.active-trail) ul").hide(); 372 $("#mobile-menu .item-with-ul.active-trail").addClass("active"); 373 } else { 374 $("#mobile-menu .item-with-ul ul").hide(); 375 } 376 377 $("#mobile-menu .item-with-ul").unbind('click').click(function(e) { 378 if (_this.settings.showItems == "active_trail") { 379 $("#mobile-menu .item-with-ul ul").not($(this).find("ul")).not($(this).parents()).slideUp("fast"); 380 } 381 $(this).find("ul").first().slideToggle(function() { 382 $("#mobile-menu .item-with-ul").removeClass("active"); 383 $("#mobile-menu .item-with-ul ul").each(function() { 384 if ($(this).css("display") != "none") { 385 $(this).parent("li").addClass("active"); 386 } 387 }); 388 389 switch (_this.settings.showEffect) { 390 case "drawer_right": 391 $(_this.settings.mainPageSelector).css({ 392 overflow : "hidden", 393 height : $("#mobile-menu").height() 394 }); 395 break; 396 397 } 398 }); 399 400 e.stopPropagation(); 401 }); 402 $("#mobile-menu .item-with-ul a").unbind('click').click(function(e) { 403 e.stopPropagation(); 404 }); 405 } 406 }, 407 408 basicBuild : function() { 409 if (!$("#mobile-menu").length) { 410 _this.cloneMenu(); 411 } 412 }, 413 414 menuToggle : function(button) { 415 if ($(button).hasClass("active")) {/* If it's openned */ 416 if (_this.settings.menuPlugin == "accordion" && _this.settings.showItems == "active_trail") { 417 $("#mobile-menu .item-with-ul:not(.active-trail) ul").slideUp().parent("li").removeClass("active"); 418 } 419 420 if (_this.settings.useMask) { 421 $("#mobile-navigation-mask").fadeOut("slow"); 422 } 423 424 switch (_this.settings.showEffect) { 425 case "expand_down": 426 $("#mobile-menu-inner").slideUp("fast"); 427 break; 428 429 case "drawer_top": 430 $('#slide-menu-clip').animate({ 431 marginLeft : 0, 432 }, 'fast', function() { 433 $(".mobile-menu-slide").not("#mobile-menu").remove(); 434 435 }); 436 $("#mobile-menu-inner #mobile-menu").slideUp(); 437 438 break; 439 440 case "drawer_left": 441 $("#mobile-menu-inner").animate({ 442 left : "-" + _this.settings.menuWidth + "%" 443 }, "slow", function() { 444 // Animation complete. 445 }); 446 $(_this.settings.mainPageSelector).animate({ 447 left : "0" 448 }, "slow", function() { 449 // Animation complete. 450 $(this).css({ 451 overflow : "inherit", 452 height : "auto", 453 position : "relative", 454 width : "auto" 455 }) 456 }); 457 break; 458 459 case "drawer_right": 460 // cerrar 461 $("#mobile-menu-inner").animate({ 462 left : "100%" 463 }, "slow", function() { 464 // Animation complete. 465 $("#mobile-menu").css({ 466 display : "none", 467 width : 0 468 }); 469 $(this).css({ 470 width : 0 471 }); 472 }); 473 $(_this.settings.mainPageSelector).animate({ 474 left : "0" 475 }, "slow", function() { 476 // Animation complete. 477 $(this).css({ 478 overflow : "auto", 479 height : "auto" 480 }) 481 }); 482 483 $('#slide-menu-clip').animate({ 484 marginLeft : 0, 485 486 }, 'normal', function() { 487 $(".mobile-menu-slide").not("#mobile-menu").remove(); 488 }); 489 490 break; 491 492 case "fixed_top": 493 $("#mobile-menu-inner").animate({ 494 top : "-" + _this.height + "px" 495 }, "fast", function() { 496 // Animation complete. 497 }); 498 break; 499 500 case "fixed_left": 501 $("#mobile-menu-inner").animate({ 502 left : "-" + _this.settings.menuWidth + "%" 503 }, "fast", function() { 504 // Animation complete. 505 }); 506 break; 507 508 case "fixed_right": 509 $("#mobile-menu-inner").animate({ 510 right : "-" + _this.settings.menuWidth + "%" 511 }, "fast", function() { 512 // Animation complete. 513 }); 514 break; 515 516 case "fixed_bottom": 517 $("#mobile-menu-inner").animate({ 518 bottom : "-" + _this.height + "px" 519 }, "fast", function() { 520 // Animation complete. 521 }); 522 break; 523 524 } 525 $(".mobile-menu-button").removeClass("active"); 526 527 } else { 528 if (_this.settings.useMask) { 529 $("#mobile-navigation-mask").fadeIn("slow").addClass("active"); 530 } 531 532 switch (_this.settings.showEffect) { 533 case "expand_down": 534 $("#mobile-menu-inner").slideDown("fast"); 535 break; 536 537 case "drawer_top": 538 $("#mobile-menu-inner #mobile-menu").slideDown(); 539 break; 540 541 case "drawer_left": 542 $(_this.settings.mainPageSelector).css({ 543 overflow : "hidden", 544 height : $("#mobile-menu").height(), 545 position : "fixed", 546 width: "100%" 547 }).animate({ 548 left : _this.settings.menuWidth + "%", 549 }, "slow", function() { 550 }); 551 $("#mobile-menu-inner").animate({ 552 left : 0 553 }, "slow", function() { 554 // Animation complete. 555 }); 556 break; 557 558 case "drawer_right": 559 $("#mobile-menu").show().css({ 560 display : "block", 561 width : "100%" 562 }); 563 564 $("#mobile-menu-inner").css({ 565 width : _this.settings.menuWidth + "%" 566 }).animate({ 567 left : (100 - _this.settings.menuWidth) + "%" 568 }, "slow", function() { 569 // Animation complete. 570 }); 571 572 $('#slide-menu-clip').animate({ 573 width : $("#mobile-menu-inner").width() + "px" 574 }); 575 $(_this.settings.mainPageSelector).animate({ 576 left : "-" + _this.settings.menuWidth + "%" 577 }, "slow", function() { 578 // Animation complete. 579 $(this).css({ 580 overflow : "hidden", 581 height : $("#mobile-menu").height() 582 }); 583 }); 584 break; 585 586 case "fixed_top": 587 $("#mobile-menu-inner").animate({ 588 top : "0" 589 }, "fast", function() { 590 // Animation complete. 591 }); 592 break; 593 594 case "fixed_left": 595 $("#mobile-menu-inner").animate({ 596 left : "0" 597 }, "fast", function() { 598 // Animation complete. 599 }); 600 break; 601 602 case "fixed_right": 603 $("#mobile-menu-inner").animate({ 604 right : "0" 605 }, "fast", function() { 606 // Animation complete. 607 }); 608 break; 609 610 case "fixed_bottom": 611 $("#mobile-menu-inner").animate({ 612 bottom : "0" 613 }, "fast", function() { 614 // Animation complete. 615 }); 616 break; 617 618 } 619 620 $(".mobile-menu-button").addClass("active"); 621 } 622 }, 623 624 mobileSet : function() { 625 $(_this.target).hide(); 626 627 $("#mobile-menu-wrapper").show(); 628 $("#collapsed-menu-button").show(); 629 630 if ($("#collapsed-menu-button.active").length > 0) { 631 if (_this.settings.useMask) { 632 $("#mobile-navigation-mask").show(); 633 } 634 } else { 635 if (_this.settings.useMask) { 636 $("#mobile-navigation-mask").hide(); 637 } 638 } 639 640 switch (_this.settings.showEffect) { 641 case "expand_down": 642 //$("#mobile-menu.inner").css({width: "100%"}); 643 break; 644 645 case "drawer_right": 646 $("#mobile-menu").css({ 647 minHeight : $(window).height() + "px" 648 }); 649 if ($("#collapsed-menu-button.active").length > 0) { 650 $(_this.settings.mainPageSelector).css({ 651 left : "-" + _this.settings.menuWidth + "%" 652 }); 653 $("#mobile-menu-inner").css({ 654 width : _this.settings.menuWidth + "%" 655 }); 656 657 $(_this.settings.mainPageSelector).css({ 658 left : "-" + _this.settings.menuWidth + "%", 659 overflow : "hidden", 660 height : $("#mobile-menu").height() 661 }); 662 $("#mobile-menu-inner").css({ 663 left : (100 - _this.settings.menuWidth) + "%" 664 }); 665 666 /*if (_this.settings.useMask) { 667 $("#mobile-navigation-mask").show(); 668 }*/ 669 } else { 670 $("#mobile-menu-inner").css({ 671 width : 0 672 }); 673 $("#mobile-menu").css({ 674 display : "none", 675 width : 0 676 }); 677 /* 678 if (_this.settings.useMask) { 679 $("#mobile-navigation-mask").hide(); 680 }*/ 681 } 682 683 break; 684 685 case "drawer_left": 686 $("#mobile-menu").css({ 687 minHeight : $(window).height() + "px" 688 }); 689 if ($("#collapsed-menu-button.active").length > 0) { 690 $(_this.settings.mainPageSelector).css({ 691 left : _this.settings.menuWidth + "%", 692 width: "100%" 693 }); 694 $(_this.settings.mainPageSelector).css({ 695
695 position : "fixed" 696 }); 697 } 698 break; 699 700 case "drawer_top": 701 $(_this.settings.mainPageSelector).css({ 702 left : "0", 703 overflow : "visible", 704 height : "auto" 705 }); 706 707 $("#mobile-menu-wrapper").css({ 708 width : "100%", 709 float : "left" 710 }); 711 712 break; 713 714 case "fixed_top": 715 //$("#mobile-menu.inner").css({width: "100%"}); 716 break; 717 718 case "fixed_left": 719 if ($("#collapsed-menu-button.active").length > 0) { 720 $("#mobile-menu-inner").animate({ 721 left : "0" 722 }, "fast", function() { 723 // Animation complete. 724 }); 725 726 } else { 727 $("#mobile-menu-inner").css({ 728 left : "-" + _this.settings.menuWidth + "%" 729 }, "fast", function() { 730 // Animation complete. 731 }); 732 } 733 break; 734 735 case "fixed_right": 736 $("#mobile-menu-wrapper").show(); 737 break; 738 739 case "fixed_bottom": 740 $("#mobile-menu-wrapper").show(); 741 $("#mobile-menu-inner").css({ 742 width : _this.settings.menuWidth + "%" 743 }); 744 break; 745 746 } 747 748 switch (_this.settings.menuPlugin) { 749 case "slideMenu": 750 var no = $(".mobile-menu-slide").length, mm_w = $("#mobile-menu-inner").width(); 751 752 $("#slide-menu-clip").css({ 753 width : (mm_w * no) 754 }); 755 $(".mobile-menu-slide").css({ 756 width : mm_w 757 }); 758 759 $('#slide-menu-clip').css({ 760 "marginLeft" : -(mm_w * (no - 1)) 761 }, 'normal'); 762 763 break; 764 765 case "accordion": 766 break; 767 768 } 769 770 }, 771 772 mobileUnset : function() { 773 $("#mobile-menu-wrapper").hide(); 774 $("#collapsed-menu-button").hide(); 775 776 switch (_this.settings.showEffect) { 777 case "expand_down": 778 break; 779 780 case "drawer_right": 781 $(_this.settings.mainPageSelector).css({ 782 left : 0, 783 height : "auto", 784 overflow : "auto" 785 }); 786 break; 787 788 case "drawer_left": 789 $(_this.settings.mainPageSelector).css({ 790 left : 0, 791 position : "relative", 792 height : "auto", 793 width : "auto" 794 }); 795 break; 796 797 case "drawer_top": 798 case "fixed_top": 799 case "fixed_left": 800 case "fixed_right": 801 case "fixed_bottom": 802 break; 803 804 } 805 806 if (_this.settings.useMask) { 807 $("#mobile-navigation-mask").hide(); 808 } 809 810 $(_this.target).show(); 811 }, 812 813 // Verify if a query is valid for current browser width. 814 checkQuery : function(query) { 815 return window.matchMedia(query).matches; 816 }, // End of checkQuery 817 initialSet : function() { 818 var menu_width = _this.width = $("#mobile-menu-inner").outerWidth() + ($("#mobile-menu-inner").outerWidth() / 10), menu_height = _this.height = $("#mobile-menu-inner").outerHeight(); 819 820 if (_this.settings.useMask) { 821 //$(_this.settings.mainPageSelector). 822 $("#mobile-menu-wrapper").css({ 823 position : "relative" 824 }).after("<div id='mobile-navigation-mask'></div>"); 825 $("#mobile-navigation-mask").click(function() { 826 _this.menuToggle(this); 827 }).hide(); 828 } 829 830 switch (_this.settings.showEffect) { 831 case "expand_down": 832 break; 833 834 case "fixed_top": 835 $("#mobile-menu-inner").css({ 836 position : "absolute", 837 top : "-" + menu_height + "px", 838 left : "0", 839 display : "block" 840 }); 841 break; 842 843 case "drawer_top": 844 $("#mobile-menu-inner").css({ 845 position : "relative", 846 display : "block" 847 }); 848 $("#mobile-menu-inner #mobile-menu").slideUp(); 849 break; 850 851 case "fixed_left": 852 $("#mobile-menu-inner").css({ 853 position : "absolute", 854 left : "-" + _this.settings.menuWidth + "%", 855 top : "0", 856 display : "block" 857 }); 858 859 break; 860 861 case "fixed_right": 862 $("#mobile-menu-inner").css({ 863 position : "fixed", 864 right : "-" + _this.settings.menuWidth + "%", 865 top : "0", 866 display : "block" 867 }); 868 break; 869 870 case "drawer_left": 871 $("#mobile-menu-inner").css({ 872 position : "absolute", 873 left : "-" + _this.settings.menuWidth + "%", 874 top : "0", 875 display : "block" 876 }); 877 break; 878 879 case "drawer_right": 880 $("#mobile-menu-inner").css({ 881 position : "absolute", 882 left : "100%", 883 top : "0", 884 display : "block" 885 }); 886 $(_this.settings.mainPageSelector).css({ 887 position : "relative" 888 889 }); 890 891 break; 892 893 case "fixed_bottom": 894 $("#mobile-menu-inner").css({ 895 position : "fixed", 896 bottom : "-" + menu_height + "px", 897 left : "0", 898 display : "block" 899 }); 900 break; 901 } 902 }, 903 onResize : function() { 904 if (_this.checkQuery(_this.settings.breakpoint)) { 905 if (current != "normal") { 906 _this.mobileUnset(); 907 } 908 _this.current = "normal"; 909 910 } else { 911 if (current != "mobile" && !$("#mobile-menu").length) { 912 switch (_this.settings.menuPlugin) { 913 case "basic": 914 _this.basicBuild(); 915 break; 916 917 case "accordion": 918 _this.accordionBuild(); 919 break; 920 921 case "slideMenu": 922 _this.slideMenuBuild(); 923 break; 924 925 } 926 _this.collapseInAButton(); 927 _this.initialSet(); 928 } 929 _this.current = "mobile"; 930 _this.mobileSet(); 931 932 } 933 }, 934 935 // INIT 936 init : function(elem, opts) { 937 _this.target = elem; 938 939 // Merge Default options with the specified 940 _this.settings = $.extend(true, {}, defaults, opts); 941 _this.onResize(); 942 943 $(window).resize(_this.onResize); 944 } // end of init 945 }; 946 // end of methods 947 948 var _this = this.methods; 949 950 }; 951 // end of mobile_menu class 952 953 // $.FN 954 $.fn.mobile_menu = function(opts) { 955 var id = $(this).attr('id'); 956 957 if (!(!$.support.leadingWhitespace)) { 958 //Not IE7 nor IE8. 959 if (instances[id] === undefined) { 960 instances[id] = new mobile_menu(this, opts); 961 return instances[id].methods.init(this, opts); 962 } else if (instances[id]) { 963 return instances[id].methods; 964 } else { 965 return $(this); 966 } 967 } 968 }; 969 // end of $.fn.mapSvg 970 971})(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.