1( function( window ) { 2 3'use strict'; 4 5// class helper functions from bonzo https://github.com/ded/bonzo 6 7function classReg( className ) { 8 return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); 9} 10 11// classList support for class management 12// altho to be fair, the api sucks because it won't accept multiple classes at once 13var hasClass, addClass, removeClass; 14 15if ( 'classList' in document.documentElement ) { 16 hasClass = function( elem, c ) { 17 return elem.classList.contains( c ); 18 }; 19 addClass = function( elem, c ) { 20 elem.classList.add( c ); 21 }; 22 removeClass = function( elem, c ) { 23 elem.classList.remove( c ); 24 }; 25} 26else { 27 hasClass = function( elem, c ) { 28 return classReg( c ).test( elem.className ); 29 }; 30 addClass = function( elem, c ) { 31 if ( !hasClass( elem, c ) ) { 32 elem.className = elem.className + ' ' + c; 33 } 34 }; 35 removeClass = function( elem, c ) { 36 elem.className = elem.className.replace( classReg( c ), ' ' ); 37 }; 38} 39 40function toggleClass( elem, c ) { 41 var fn = hasClass( elem, c ) ? removeClass : addClass; 42 fn( elem, c ); 43} 44 45window.classie = { 46 // full names 47 hasClass: hasClass, 48 addClass: addClass, 49 removeClass: removeClass, 50 toggleClass: toggleClass, 51 // short names 52 has: hasClass, 53 add: addClass, 54 remove: removeClass, 55 toggle: toggleClass 56}; 57 58})( window ); 59 60jQuery( document ).ready( function( $ ) { 61 var Mgwprm = document.getElementById( 'mg-wprm-wrap' ); 62 var wprm_menuDir = document.getElementById( 'wprMenu' ); 63 body = document.body; 64 65 //Body slide from one side ( left, right or top ) 66 if( ! $('.wprmenu_bar').hasClass('normalslide') ) 67 $('body').addClass('cbp-spmenu-push'); 68 69 $('.wprmenu_bar').click( function(event) { 70 if( $(event.target).hasClass('bar_logo') ) 71 return; 72 classie.toggle( this, 'active' ); 73 $(this).find('div.hamburger').toggleClass('is-active'); 74 // For the right side body push 75 if (!$(this).hasClass('normalslide') && $(this).hasClass('left')) { 76 doc_width = $(document).width()*(wprmenu.menu_width/100); 77 push_width = (wprmenu.push_width != '' && wprmenu.push_width < doc_width) ? wprmenu.push_width : doc_width; 78 classie.toggle(body, 'cbp-spmenu-push-toright'); 79 if( $('body').hasClass('cbp-spmenu-push-toright') ) 80 $('body').css('left',push_width+'px'); 81 else 82 $('body').css('left','0px'); 83 } 84 // For the left side body push 85 if (!$(this).hasClass('normalslide') && $(this).hasClass('right')) { 86 doc_width = $(document).width()*(wprmenu.menu_width/100); 87 push_width = (wprmenu.push_width != '' && wprmenu.push_width < doc_width) ? wprmenu.push_width : doc_width; 88 classie.toggle(body, 'cbp-spmenu-push-toleft'); 89 if( $('body').hasClass('cbp-spmenu-push-toleft') ) 90 $('body').css('left','-'+push_width+'px'); 91 else 92 $('body').css('left','0px'); 93 } 94 classie.toggle(Mgwprm, 'cbp-spmenu-open'); 95 96 close_sub_uls(); 97 98 }); 99 100 //fix the scaling issue by adding/replacing viewport metatag 101 var mt = $('meta[name=viewport]'); 102 mt = mt.length ? mt : $('<meta name="viewport" />').appendTo('head'); 103 if(wprmenu.zooming == 'no') { 104 mt.attr('content', 'user-scalable=no, width=device-width, maximum-scale=1, minimum-scale=1'); 105 } else { 106 mt.attr('content', 'user-scalable=yes, width=device-width, initial-scale=1.0, minimum-scale=1'); 107 } 108 109 110 // Click on body remove the menu 111 $('body').click( function( event ) { 112 if ( $( '#wprmenu_bar' ).hasClass( 'active' ) ) { 113 $('#wprmenu_bar .wprmenu_icon').addClass('open'); 114 } 115 else { 116 $('#wprmenu_bar .wprmenu_icon').removeClass('open'); 117 } 118 }); 119 120 menu = $('#mg-wprm-wrap'); 121 menu_ul = $('#wprmenu_menu_ul'), //the menu ul 122 123 $(document).mouseup(function (e) { 124 if ( ($(e.target).hasClass('wprmenu_bar') || $(e.target).parents('.wprmenu_bar').length == 0) && 125 ($(e.target).hasClass('cbp-spmenu') || $(e.target).parents('.cbp-spmenu').length == 0)) { 126 if(menu.is(':visible') ) { 127 $('.hamburger.is-active').trigger('click'); 128 } 129 } 130 }); 131 132 //add arrow element to the parent li items and chide its child uls 133 menu.find('ul.sub-menu').each(function() { 134 var sub_ul = $(this), 135 parent_a = sub_ul.prev('a'), 136 parent_li = parent_a.parent('li').first(); 137 138 parent_a.addClass('wprmenu_parent_item'); 139 parent_li.addClass('wprmenu_parent_item_li'); 140 141 var expand = parent_a.before('<span class="wprmenu_icon wprmenu_icon_par icon_default"></span> ').find('.wprmenu_icon_par'); 142 sub_ul.hide(); 143 }); 144 145 146 //expand / collapse action (SUBLEVELS) 147 $('.wprmenu_icon_par').on('click',function() { 148 var t = $(this), 149 child_ul = t.parent('li').find('ul.sub-menu').first(); 150 child_ul.slideToggle('300'); 151 t.toggleClass('wprmenu_par_opened'); 152 t.parent('li').first().toggleClass('wprmenu_no_border_bottom'); 153 }); 154 155 //helper - close all submenus when menu is hiding 156 function close_sub_uls() { 157 menu.find('ul.sub-menu').each(function() { 158 var ul = $(this), 159 icon = ul.parent('li').find('.wprmenu_icon_par'), 160 li = ul.parent('li'); 161 162 if(ul.is(':visible')) ul.slideUp(300); 163 icon.removeClass('wprmenu_par_opened'); 164 li.removeClass('wprmenu_no_border_bottom'); 165 }); 166 } 167 168 //submenu opened 169 function open_sub_uls() { 170 menu.find('ul.sub-menu').each(function() { 171 var ul = $(this), 172 icon = ul.parent('li').find('.wprmenu_icon_par'), 173 li = ul.parent('li'); 174 175 ul.slideDown(300); 176 icon.removeClass('wprmenu_par_opened'); 177 icon.addClass('wprmenu_par_opened'); 178 }); 179 } 180 181 if( menu.hasClass('cbp-spmenu-top') && $('body').hasClass('cbp-spmenu-push') ){ 182 $('body').prepend(menu); 183 //show / hide the menu 184 $('#wprmenu_bar,#custom_menu_icon').on('click', function(e) { 185 if( $(e.target).hasClass('bar_logo') ) 186 return; 187 //scroll window top 188 $("html, body").animate({ scrollTop: 0 }, 300); 189 190 close_sub_uls(); 191 menu.stop(true, false).slideToggle(300); 192 }); 193 } 194 if( wprmenu.parent_click == 'yes' ) { 195 $('a.wprmenu_parent_item').on('click', function(e){ 196 e.preventDefault(); 197 $(this).prev('.wprmenu_icon_par').trigger('click'); 198 }); 199 } 200 $('#wprmenu_menu_ul a').click(function(){ 201 if( wprmenu.parent_click !='yes' || (wprmenu.parent_click == 'yes' && !$(this).hasClass('wprmenu_parent_item')) ) 202 $('.hamburger.is-active').trigger('click'); 203 }); 204 if( wprmenu.swipe == 'yes' ) { 205 $('body').swipe({ 206 excludedElements: "button, input, select, textarea, .noSwipe", 207 threshold: 200, 208 swipe:function(event, direction, distance, duration, fingerCount, fingerData) { 209 menu_el = $('.wprmenu_bar .hamburger, .wprmenu_bar .wpr-custom-menu'); 210 if( direction =='left' && menu_el.hasClass('is-active') ) 211 menu_el.trigger('click'); 212 213 if( direction =='right' && !menu_el.hasClass('is-active') ) 214 menu_el.trigger('click'); 215 } 216 }); 217 } 218 219});
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.