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 /* 98 if( $.browser.mozilla ) { 99 screen.addEventListener("orientationchange", function() {updateOrientation()}); //firefox 100 } else if( window.addEventListener ) { 101 window.addEventListener('orientationchange', updateOrientation, false); 102 } 103 else { 104 window.attachEvent( "orientationchange" ); 105 } 106 */ 107 function updateOrientation() { 108 window.scrollBy(1,1); 109 window.scrollBy(-1,-1); 110 111 menu_width = menu.width(); 112 113 //update the page posion for left menu 114 if(menu.is(':visible') && menu.hasClass('left')) { 115 body.css({'left':menu_width}); 116 body.scrollLeft(0); 117 } 118 } 119 120 121 122 123 //apply the SIDR for the left/right menu 124 if(menu.hasClass('left') || menu.hasClass('right')) { 125 126 //appy sidr 127 var hor_pos = (menu.hasClass('left'))? 'left' : 'right'; 128 bar.sidr({ 129 name:'wprmenu_menu', 130 side: hor_pos, 131 speed: animation_speed, 132 onOpen: function(){ bar.addClass('menu_is_opened'); }, 133 onClose: function(){ bar.removeClass('menu_is_opened'); close_sub_uls(); } 134 }); 135 136 //when link is clicked - hide the menu first and then change location to new page 137 menu_a.on('click', function(e) { 138 $.sidr('close', 'wprmenu_menu'); 139 }); 140 141 if( wprmenu.swipe != 'no' ) { 142 $('body').touchwipe({ 143 wipeLeft: function() { 144 // Close 145 $.sidr('close', 'wprmenu_menu'); 146 }, 147 wipeRight: function() { 148 // Open 149 $.sidr('open', 'wprmenu_menu'); 150 }, 151 min_move_x: 60, 152 min_move_y: 60, 153 preventDefaultEvents: false 154 }); 155 } 156 157 $(window).resize(function(){ 158 target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth; 159 if(target_width > from_width && menu.is(':visible')) { 160 $.sidr('close', 'wprmenu_menu'); 161 } 162 }); 163 164 165 } else if(menu.hasClass('top')) { //The top positioned menu 166 167 body.prepend(menu); 168 169 //show / hide the menu 170 bar.on('click', function(e) { 171 172 //scroll window top 173 $("html, body").animate({ scrollTop: 0 }, animation_speed); 174 175 close_sub_uls(); 176 menu.stop(true, false).slideToggle(animation_speed); 177 178 179 }); 180 181 182 //when link is clicked - hide the menu first and then change location to new page 183 menu_a.on('click', function(e) { 184 e.preventDefault(); 185 var url = $(this).attr('href'); 186 187 menu.slideUp(animation_speed,function() { 188 //go to the url from the link 189 window.location.href = url; 190 }); 191 }); 192 193 194 $(window).resize(function(){ 195 target_width = (window.innerWidth < body.width())? body.width() : window.innerWidth; 196 if(target_width > from_width && menu.is(':visible')) { 197 close_sub_uls(); 198 menu.slideUp(animation_speed, function() {}); 199 } 200 }); 201 202 203 } //end if class left / top /right 204 205 } //end if menu enabled 206});
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.