1 2 3var delay_tab = 300, 4 delay_show_mm = 300, 5 delay_hide_mm = 300; 6 7$("body").append(getFullscreenBg()); 8 9$.fn.initMM = function() { 10 var mmpanel = { 11 $mobilemenu: $(".panel-menu"), 12 mm_close_button: 'Close', 13 mm_back_button: 'Back', 14 mm_breakpoint: 768, 15 mm_enable_breakpoint: false, 16 mm_mobile_button: false, 17 remember_state: false, 18 second_button: false, // class 19 init: function($button, data){ 20 var _this = this; 21 if(!_this.$mobilemenu.length){ 22 console.log('You not have <nav class="panel-menu">menu</nav>. See Documentation') 23 return false; 24 } 25 26 arguments[1] != undefined && _this.parse_arguments(data); 27 _this.$mobilemenu.parse_mm(mmpanel);//_this.mm_close_button, _this.mm_back_button); 28 _this.$mobilemenu.init_mm(mmpanel); 29 _this.mm_enable_breakpoint && _this.$mobilemenu.check_resolution_mm(mmpanel);//_this.mm_breakpoint); 30 $button.mm_handler(mmpanel); 31 }, 32 parse_arguments: function(data){ 33 var _this = this; 34 if(Object(data).hasOwnProperty("menu_class")) _this.$mobilemenu = $("."+data.menu_class); 35 36 $.each(data, function( k, v ) { 37 switch(k) { 38 case 'right': 39 v && _this.$mobilemenu.addClass("mm-right"); 40 break; 41 case 'close_button_name': 42 _this.mm_close_button = v; 43 break; 44 case 'back_button_name': 45 _this.mm_back_button = v; 46 break; 47 case 'width': 48 _this.$mobilemenu.css("width", v); 49 break; 50 case 'breakpoint': 51 _this.mm_breakpoint = v; 52 break; 53 case 'enable_breakpoint': 54 _this.mm_enable_breakpoint = v; 55 break; 56 case 'mobile_button': 57 _this.mm_mobile_button = v; 58 break; 59 case 'remember_state': 60 _this.remember_state = v; 61 break; 62 case 'second_button': 63 _this.second_button = v; 64 break; 65 }; 66 }); 67 }, 68 show_button_in_mobile: function($button){ 69 var _this = this; 70 if(_this.mm_mobile_button) { 71 window.innerWidth > _this.mm_breakpoint ? $button.hide() : $button.show(); 72 $(window).resize(function(){ 73 window.innerWidth > _this.mm_breakpoint ? $button.hide() : $button.show(); 74 }) 75 } 76 } 77 } 78 mmpanel.init($(this), arguments[0]); 79 mmpanel.show_button_in_mobile($(this)); 80} 81 82$.fn.check_resolution_mm = function(mmpanel) { 83 var _this = $(this); 84 $(window).resize(function(){ 85 if(!$("body").hasClass("mm-open") || !_this.hasClass("mmitemopen")) return false; 86 window.innerWidth > mmpanel.mm_breakpoint && _this.closemm(mmpanel); 87 }); 88} 89$.fn.mm_handler = function(mmpanel){ 90 $(this).click(function(e){ 91 e.preventDefault(); 92 mmpanel.$mobilemenu.openmm(); 93 }); 94 95 if(mmpanel.second_button != false){ 96 $(mmpanel.second_button).click(function(e){ 97 e.preventDefault(); 98 mmpanel.$mobilemenu.openmm(); 99 }); 100 }; 101} 102 103$.fn.parse_mm = function(mmpanel) { 104 var $mm_curent = $(this).clone(), 105 $mm_new = $(get_mm_parent()), 106 $mm_block = false, 107 count = 0, 108 _this = false, 109 $btnBack = false, 110 $ul; 111 $(this).empty(); 112 113 $mm_curent.find('a').each(function(){ 114 _this = $(this); 115 $ul = _this.parent().find("ul").first(); 116 if($ul.length) { 117 count++; 118 $ul.prepend("<li></li>").find("li").first().append(_this.clone().addClass("mm-original-link")); 119 _this.attr("href", "#mm"+count).attr("data-target", "#mm"+count).addClass("mm-next-level"); 120 } 121 }); 122 $mm_curent.find('ul').each(function(index){ 123 $btnBack = false; 124 $mm_block = $(get_mm_block()).attr("id", "mm"+index).append($(this)); 125 if (index == 0) { 126 $mm_block.addClass("mmopened").addClass("mmcurrent").removeClass("mmhidden"); 127 $btnBack = getButtonClose($mm_curent.find(".mm-closebtn").html(), mmpanel.mm_close_button); 128 $mm_block.find("ul").first().prepend($btnBack); 129 } 130 else { 131 $btnBack = getButtonBack($mm_curent.find(".mm-backbtn").html(), mmpanel.mm_back_button); 132 $mm_block.find("ul").first().prepend($btnBack); 133 } 134 $mm_new.append($mm_block); 135 }); 136 137 $(this).append($mm_new); 138} 139$.fn.init_mm = function(mmpanel) { 140 var _parent = $(this); 141 _parent.find("a").each(function(){ 142 $(this).click(function(e){
143 var _this = $(this); 144 var $panel = false; 145 var $currobj = false; 146 var lv = ''; 147 if(_this.hasClass("mm-next-level")){ 148 e.preventDefault(); 149 lv = _this.attr("href"); 150 $currobj = _parent.find(".mmcurrent"); 151 $currobj.addClass("mmsubopened").removeClass("mmcurrent"); 152 _parent.find(lv).removeClass("mmhidden"); 153 setTimeout(function(){_parent.find(lv).scrollTop(0).addClass("mmcurrent").addClass("mmopened");}, 0); 154 setTimeout(function(){$currobj.addClass("mmhidden")}, delay_tab); 155 return false; 156 } 157 if(_this.hasClass("mm-prev-level")){ 158 e.preventDefault(); 159 lv = _this.attr("href"); 160 $currobj = _parent.find(".mmcurrent"); 161 $currobj.removeClass("mmcurrent").removeClass("mmopened"); 162 _parent.find(".mmsubopened").last().removeClass("mmhidden").scrollTop(0).removeClass("mmsubopened").addClass("mmcurrent"); 163 setTimeout(function(){$currobj.addClass("mmhidden")}, delay_tab); 164 return false; 165 } 166 if(_this.hasClass("mm-close")){ 167 _parent.closemm(mmpanel); 168 return false; 169 } 170 }) 171 }); 172 $(".mm-fullscreen-bg").click(function(e){ 173 e.preventDefault(); 174 _parent.closemm(mmpanel); 175 }); 176} 177$.fn.openmm = function(){ 178 var _this = $(this); 179 _this.show(); 180 setTimeout(function(){$("body").addClass("mm-open");_this.addClass("mmitemopen");$(".mm-fullscreen-bg").fadeIn(delay_show_mm);}, 0); 181} 182$.fn.closemm = function(mmpanel){ 183 var _this = $(this); 184 _this.addClass("mmhide"); 185 $(".mm-fullscreen-bg").fadeOut(delay_hide_mm); 186 setTimeout(function(){ mm_destroy(_this, mmpanel); }, delay_hide_mm); 187} 188function mm_destroy(_parent, mmpanel){ 189 if(!mmpanel.remember_state) { 190 _parent.find(".mmpanel").toggleClass("mmsubopened mmcurrent mmopened", false).addClass("mmhidden"); 191 _parent.find("#mm0").addClass("mmopened").addClass("mmcurrent").removeClass("mmhidden"); 192 } 193 _parent.toggleClass("mmhide mmitemopen", false).hide(); 194 $("body").removeClass("mm-open"); 195} 196function get_mm_parent(){ 197 return '<div class="mmpanels"></div>'; 198} 199function get_mm_block(){ 200 return '<div class="mmpanel mmhidden">'; 201} 202function getButtonBack(value, _default) { 203 value = value == undefined ? _default : value; 204 return '<li><a href="#" data-target="#" class="mm-prev-level">'+value+'</a></li>'; 205} 206function getButtonClose(value, _default) { 207 value = value == undefined ? _default : value; 208 return '<li class="mm-close-parent"><a href="#close" data-target="#close" class="mm-close">'+value+'</a></li>'; 209} 210function getFullscreenBg() { 211 return '<div class="mm-fullscreen-bg"></div>'; 212}
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.