1;(function($) { 2 3 'use strict'; 4 5 var defaults = { 6 panel: '#mobile-menu', 7 close: '', 8 side: 'right', 9 speed: 250 10 }; 11 12 function SideMenu ( element, options ) { 13 this.element = element; 14 this.settings = $.extend( {}, defaults, options ); 15 this._defaults = defaults; 16 this.panelVisible = false; 17 this.panelCleanName = this.settings.panel.replace( /#|\.|\s/g, function(match) { 18 var replacements = { '#':'', '\.':'', ' ':'-' }; 19 return replacements[match]; } ); 20 this.init(); 21 } 22 23 SideMenu.prototype = { 24 init: function () { 25 var self = this; 26 $(this.element).on('click', function(e) { 27 e.preventDefault(); 28 if ( self.panelVisible ) { 29 self.hidePanel(); 30 } else { 31 self.showPanel(); 32 } 33 }); 34 if ( '' !== self.settings.close ) { 35 $(self.settings.close).on('click', function(e) { 36 e.preventDefault(); 37 self.hidePanel(); 38 }); 39 } 40 Themify.body.addClass('sidemenu-active').on( 'scrollhighlightstart.themify', function() { 41 /* Take a slight pause before hiding the panel; 42 * this prevents accidental clicks on elements below the panel. 43 */ 44 setTimeout( function(){ 45 if ( self.panelVisible ) { 46 self.hidePanel(); 47 } 48 }, 50 ); 49 }).on( 'sidemenushow.themify', function(e, emitterPanel, side) { 50 if ( emitterPanel !== self.settings.panel ) { 51 self.hidePanel( side ); 52 } 53 }); 54 }, 55 showPanel: function () { 56 var thisPanel = this.settings.panel; 57 $(thisPanel).removeClass('sidemenu-off').addClass('sidemenu-on').one('transitionend', function(){ 58 $(this).trigger( 'sidemenuaftershow.themify', [thisPanel] ); 59 }); 60 Themify.body.addClass(this.panelCleanName + '-visible sidemenu-' + this.settings.side).triggerHandler('sidemenushow.themify', [thisPanel, this.settings.side]); 61 this.panelVisible = true; 62 }, 63 hidePanel: function ( side ) { 64 var thisPanel = this.settings.panel, cssClass = this.panelCleanName + '-visible'; 65 $(thisPanel).removeClass('sidemenu-on').addClass('sidemenu-off'); 66 if ( side !== this.settings.side ) { 67 cssClass += ' sidemenu-' + this.settings.side; 68 } 69 Themify.body.removeClass(cssClass).triggerHandler('sidemenuhide.themify', [thisPanel]); 70 this.panelVisible = false; 71 } 72 }; 73 74 $.fn.themifySideMenu = function ( options ) { 75 if ( 'string' === typeof options ) { 76 var self = $( this ).data( 'SideMenu' ); 77 if ( self ) { 78 if ( 'show' == options ) { 79 self.showPanel(); 80 } 81 if ( 'hide' == options ) { 82 self.hidePanel(); 83 } 84 } 85 } else { 86 return this.each(function() { 87 if ( !$.data( this, 'SideMenu' ) ) { 88 $.data( this, 'SideMenu', new SideMenu( this, options ) ); 89 } 90 }); 91 } 92 }; 93 94})(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.