1/** 2 * jQuery Sidebar JS 3 * 4 * Adds a toggle icon with slide animation for the sidebar on mobile devices 5 * 6 * Copyright 2015 ThemeZee 7 * Free to use under the GPLv2 and later license. 8 * http://www.gnu.org/licenses/gpl-2.0.html 9 * 10 * Author: Thomas Weichselbaumer (themezee.com) 11 * 12 * @package Merlin 13 */ 14 15(function($) { 16 17 /**-------------------------------------------------------------- 18 # Setup Sidebar Menu 19 --------------------------------------------------------------*/ 20 $( document ).ready( function() { 21 22 /* Show sidebar and fade content area */ 23 function showSidebar() { 24 25 sidebar.show(); 26 sidebar.animate({ 'max-width' : '400px' }, 400 ); 27 28 content.fadeTo('400', 0.5); 29 30 } 31 32 /* Hide sidebar and show full content area */ 33 function hideSidebar() { 34 35 sidebar.animate({ 'max-width': '0' }, 400, function(){ 36 sidebar.hide(); 37 }); 38 39 content.fadeTo('400', 1); 40 } 41 42 /* Reset sidebar on desktop screen sizes */ 43 function resetSidebar() { 44 45 sidebar.show(); 46 sidebar.css({ 'max-width' : '100%' }); 47 48 content.fadeTo('0', 1); 49 } 50 51 /* Only do something if sidebar exists */ 52 if ( $( '.sidebar' ).length > 0 ) { 53 54 /* Add sidebar toggle */ 55 $('.main-navigation-menu').before('<button id=\"sidebar-toggle\" class=\"sidebar-navigation-toggle\"></button>'); 56 57 /* Setup Selectors */ 58 var button = $('#sidebar-toggle'), 59 sidebar = $('.sidebar'), 60 content = $('.content-area, .post-slider-container'); 61 62 /* Add sidebare toggle effect */ 63 button.on('click', function(){ 64 if( sidebar.is(':visible') ) { 65 hideSidebar(); 66 } 67 else { 68 showSidebar(); 69 } 70 }); 71 72 } 73 74 /* Reset sidebar menu on desktop screens */ 75 if(typeof matchMedia == 'function') { 76 var mq = window.matchMedia('(max-width: 55em)'); 77 mq.addListener(widthChange); 78 widthChange(mq); 79 } 80 function widthChange(mq) { 81 82 /* Only do something if sidebar exists */ 83 if ( $( '.sidebar' ).length <= 0 ) { 84 return; 85 } 86 87 if (mq.matches) { 88 89 sidebar.hide(); 90 91 /* Hide Sidebar when Content Area is clicked */ 92 content.on('click', function(e){ 93 if( sidebar.is(':visible') ) { 94 e.preventDefault(); 95 hideSidebar(); 96 } 97 }); 98 99 } 100 else { 101 102 /* Reset Sidebar Menu */ 103 resetSidebar(); 104 content.unbind( 'click' ); 105 106 } 107 108 } 109 110 } ); 111 112}(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.