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 Dynamic News Lite 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' }, 300 ); 27 28 overlay.show(); 29 30 } 31 32 /* Hide sidebar and show full content area */ 33 function hideSidebar() { 34 35 sidebar.animate({ 'max-width': '0' }, 300, function(){ 36 sidebar.hide(); 37 }); 38 39 overlay.hide(); 40 } 41 42 /* Reset sidebar on desktop screen sizes */ 43 function resetSidebar() { 44 45 sidebar.show(); 46 sidebar.css( { 'max-width' : '100%' } ); 47 48 overlay.hide(); 49 } 50 51 /* Only do something if sidebar exists */ 52 if ( $( '#sidebar' ).length > 0 ) { 53 54 /* Add sidebar toggle */ 55 $( '#navi-wrap' ).before( '<button id=\"sidebar-toggle\" class=\"sidebar-navigation-toggle\">' + dynamicnews_sidebar_title.text + '</button>' ); 56 57 /* Add sidebar closing toggle */ 58 $( '#sidebar' ).prepend( '<button id=\"sidebar-close\" class=\"sidebar-closing-toggle\">' + dynamicnews_sidebar_title.text + '</button>' ); 59 60 /* Add Overlay */ 61 $( 'body' ).append( '<div id=\"sidebar-overlay\"></div>' ); 62 63 /* Setup Selectors */ 64 var button = $( '#sidebar-toggle' ), 65 close = $( '#sidebar-close' ), 66 sidebar = $( '#sidebar' ), 67 overlay = $( '#sidebar-overlay' ); 68 69 /* Add sidebar toggle effect */ 70 button.on('click', function(){ 71 if ( sidebar.is( ':visible' ) ) { 72 hideSidebar(); 73 } else { 74 showSidebar(); 75 } 76 }); 77 78 /* Sidebar Close */ 79 close.on('click', function(){ 80 hideSidebar(); 81 }); 82 83 } 84 85 /* Reset sidebar menu on desktop screens */ 86 if (typeof matchMedia == 'function') { 87 var mq = window.matchMedia( '(max-width: 60em)' ); 88 mq.addListener( widthChange ); 89 widthChange( mq ); 90 } 91 function widthChange(mq) { 92 93 /* Only do something if sidebar exists */ 94 if ( $( '#sidebar' ).length <= 0 ) { 95 return; 96 } 97 98 if (mq.matches) { 99 100 sidebar.hide(); 101 102 /* Hide Sidebar when Content Area is clicked */ 103 overlay.on('click', function(e){ 104 if ( sidebar.is( ':visible' ) ) { 105 e.preventDefault(); 106 hideSidebar(); 107 } 108 }); 109 110 } else { 111 112 /* Reset Sidebar Menu */ 113 resetSidebar(); 114 overlay.unbind( 'click' ); 115 116 } 117 118 } 119 120 } ); 121 122}(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.