1jQuery(document).ready(function( $ ) { 2 3 var bar = $('#wprmenu_bar'), //top bar that shows/hides the menu 4 bar_height = bar.outerHeight(true), //the bar height 5 from_width = wprmenu.from_width, 6 menu = $('#wprmenu_menu'), //the menu div 7 menu_ul = $('#wprmenu_menu_ul'), //the menu ul 8 menu_a = menu.find('a'), //single menu link 9 body = $('body'), 10 html = $('html'), 11 animation_speed = 300, 12 ab = $('#wpadminbar'), 13 menu_enabled = (bar.length > 0 && menu.length > 0)? true : false, 14 menu_width = menu.width(), 15 target_height = (window.innerHeight < body.height())? body.height() : window.innerHeight, 16 target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth; 17 if(menu_enabled) { 18 19 menu_ul.find('li').first().css({'border-top':'none'}); 20 21 22 $(document).mouseup(function (e) { 23 if ( !menu.is(e.target) && menu.has( e.target ).length === 0) { 24 if(menu.is(':visible') && (!menu.hasClass('top'))) { 25 $.sidr('close', 'wprmenu_menu'); 26 } 27 } 28 }); 29 //ENABLE NESTING 30 31 //add arrow element to the parent li items and chide its child uls 32 menu.find('ul.sub-menu').each(function() { 33 var sub_ul = $(this), 34 parent_a = sub_ul.prev('a'), 35 parent_li = parent_a.parent('li').first(); 36 37 parent_a.addClass('wprmenu_parent_item'); 38 parent_li.addClass('wprmenu_parent_item_li'); 39 40 var expand = parent_a.before('<span class="wprmenu_icon wprmenu_icon_par icon_default"></span> ').find('.wprmenu_icon_par'); 41 42 sub_ul.hide(); 43 }); 44 45 //adjust the a width on parent uls so it fits nicely with th eicon elemnt 46 function adjust_expandable_items() { 47 $('.wprmenu_parent_item_li').each(function() { 48 var t = $(this), 49 main_ul_width = 0, 50 icon = t.find('.wprmenu_icon_par').first(), 51 link = t.find('a.wprmenu_parent_item').first(); 52 53 if(menu.hasClass('top')) { 54 main_ul_width = window.innerWidth; 55 } else { 56 main_ul_width = menu_ul.innerWidth(); 57 } 58 59 if(t.find('.wprmenu_clear').length == 0) link.after('<br class="wprmenu_clear"/>'); 60 }); 61 } 62 adjust_expandable_items(); 63 64 //expand / collapse action (SUBLEVELS) 65 $('.wprmenu_icon_par').on('click',function() { 66 var t = $(this), 67 //child_ul = t.next('a').next('ul'); 68 child_ul = t.parent('li').find('ul.sub-menu').first(); 69 child_ul.slideToggle(300); 70 t.toggleClass('wprmenu_par_opened'); 71 t.parent('li').first().toggleClass('wprmenu_no_border_bottom'); 72 }); 73 74 //helper - close all submenus when menu is hiding 75 function close_sub_uls() { 76 menu.find('ul.sub-menu').each(function() { 77 var ul = $(this), 78 icon = ul.parent('li').find('.wprmenu_icon_par'), 79 li = ul.parent('li'); 80 81 if(ul.is(':visible')) ul.slideUp(300); 82 icon.removeClass('wprmenu_par_opened'); 83 li.removeClass('wprmenu_no_border_bottom'); 84 }); 85 } 86 87 //fix the scaling issue by adding/replacing viewport metatag 88 var mt = $('meta[name=viewport]'); 89 mt = mt.length ? mt : $('<meta name="viewport" />').appendTo('head'); 90 if(wprmenu.zooming == 'no') { 91 mt.attr('content', 'user-scalable=no, width=device-width, maximum-scale=1, minimum-scale=1'); 92 } else { 93 mt.attr('content', 'user-scalable=yes, width=device-width, initial-scale=1.0, minimum-scale=1'); 94 } 95 96 //Additional fixes on change device orientation 97 if( $.browser.mozilla ) { 98 screen.addEventListener("orientationchange", function() {updateOrientation()}); //firefox 99 } else if( window.addEventListener ) { 100 window.addEventListener('orientationchange', updateOrientation, false); 101 } 102 else { 103 window.attachEvent( "orientationchange" ); 104 } 105 function updateOrientation() { 106 window.scrollBy(1,1); 107 window.scrollBy(-1,-1); 108 109 menu_width = menu.width(); 110 111 //update the page posion for left menu 112 if(menu.is(':visible') && menu.hasClass('left')) { 113 body.css({'left':menu_width}); 114 body.scrollLeft(0); 115 } 116 } 117 118 119 120 121 //apply the SIDR for the left/right menu 122 if(menu.hasClass('left') || menu.hasClass('right')) { 123 124 //appy sidr 125 var hor_pos = (menu.hasClass('left'))? 'left' : 'right'; 126 bar.sidr({ 127 name:'wprmenu_menu', 128 side: hor_pos, 129 speed: animation_speed, 130 onOpen: function(){ bar.addClass('menu_is_opened'); }, 131 onClose: function(){ bar.removeClass('menu_is_opened'); close_sub_uls(); } 132 }); 133 134 //when link is clicked - hide the menu first and then change location to new page 135 menu_a.on('click', function(e) { 136 $.sidr('close', 'wprmenu_menu'); 137 }); 138 139 if( wprmenu.swipe != 'no' ) { 140 $('body').touchwipe({ 141 wipeLeft: function() { 142 // Close 143 $.sidr('close', 'wprmenu_menu'); 144 }, 145 wipeRight: function() { 146 // Open 147 $.sidr('open', 'wprmenu_menu'); 148 }, 149 min_move_x: 60, 150 min_move_y: 60, 151 preventDefaultEvents: false 152 }); 153 } 154 155 $(window).resize(function(){ 156 target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth; 157 if(target_width > from_width && menu.is(':visible')) { 158 $.sidr('close', 'wprmenu_menu'); 159 } 160 }); 161 162 163 } else if(menu.hasClass('top')) { //The top positioned menu 164 165 body.prepend(menu); 166 167 //show / hide the menu 168 bar.on('click', function(e) { 169 170 //scroll window top 171 $("html, body").animate({ scrollTop: 0 }, animation_speed); 172 173 close_sub_uls(); 174 menu.stop(true, false).slideToggle(animation_speed); 175 176 177 }); 178 179 180 //when link is clicked - hide the menu first and then change location to new page 181 menu_a.on('click', function(e) { 182 e.preventDefault(); 183 var url = $(this).attr('href'); 184 185 menu.slideUp(animation_speed,function() { 186 //go to the url from the link 187 window.location.href = url; 188 }); 189 }); 190 191 192 $(window).resize(function(){ 193 target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth; 194 if(target_width > from_width && menu.is(':visible')) { 195 close_sub_uls(); 196 menu.slideUp(animation_speed, function() {}); 197 } 198 }); 199 200 201 } //end if class left / top /right 202 203 } //end if menu enabled 204});
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.