1/*! Pushy - v1.1.0 - 2017-1-30 2* Pushy is a responsive off-canvas navigation menu using CSS transforms & transitions. 3* https://github.com/christophery/pushy/ 4* by Christopher Yee */ 5 6(function ($) { 7 var pushy = $('.pushy'), //menu css class 8 body = $('body'), 9 container = $('#container'), //container css class 10 push = $('.push'), //css class to add pushy capability 11 pushyLeft = 'pushy-left', //css class for left menu position 12 pushyOpenLeft = 'pushy-open-left', //css class when menu is open (left position) 13 pushyOpenRight = 'pushy-open-right', //css class when menu is open (right position) 14 siteOverlay = $('.site-overlay'), //site overlay 15 menuBtn = $('.menu-btn, .pushy-link'), //css classes to toggle the menu 16 menuBtnFocus = $('.menu-btn'), //css class to focus when menu is closed w/ esc key 17 menuLinkFocus = $(pushy.data('focus')), //focus on link when menu is open 18 menuSpeed = 200, //jQuery fallback menu speed 19 menuWidth = pushy.width() + 'px', //jQuery fallback menu width 20 submenuClass = '.pushy-submenu', 21 submenuOpenClass = 'pushy-submenu-open', 22 submenuClosedClass = 'pushy-submenu-closed', 23 submenu = $(submenuClass); 24 25 //close menu w/ esc key 26 $(document).keyup(function(e) { 27 //check if esc key is pressed 28 if (e.keyCode == 27) { 29 30 //check if menu is open 31 if( body.hasClass(pushyOpenLeft) || body.hasClass(pushyOpenRight) ){ 32 if(cssTransforms3d){ 33 closePushy(); //close pushy 34 }else{ 35 closePushyFallback(); 36 opened = false; //set menu state 37 } 38 39 //focus on menu button after menu is closed 40 if(menuBtnFocus){ 41 menuBtnFocus.focus(); 42 } 43 44 } 45 46 } 47 }); 48 49 function togglePushy(){ 50 //add class to body based on menu position 51 if( pushy.hasClass(pushyLeft) ){ 52 body.toggleClass(pushyOpenLeft); 53 }else{ 54 body.toggleClass(pushyOpenRight); 55 } 56 57 //focus on link in menu after css transition ends 58 if(menuLinkFocus){ 59 pushy.one('transitionend', function() { 60 menuLinkFocus.focus(); 61 }); 62 } 63 64 } 65 66 function closePushy(){ 67 if( pushy.hasClass(pushyLeft) ){ 68 body.removeClass(pushyOpenLeft); 69 }else{ 70 body.removeClass(pushyOpenRight); 71 } 72 } 73 74 function openPushyFallback(){ 75 //animate menu position based on CSS class 76 if( pushy.hasClass(pushyLeft) ){ 77 body.addClass(pushyOpenLeft); 78 pushy.animate({left: "0px"}, menuSpeed); 79 container.animate({left: menuWidth}, menuSpeed); 80 //css class to add pushy capability 81 push.animate({left: menuWidth}, menuSpeed); 82 }else{ 83 body.addClass(pushyOpenRight); 84 pushy.animate({right: '0px'}, menuSpeed); 85 container.animate({right: menuWidth}, menuSpeed); 86 push.animate({right: menuWidth}, menuSpeed); 87 } 88 89 //focus on link in menu 90 if(menuLinkFocus){ 91 menuLinkFocus.focus(); 92 } 93 } 94 95 function closePushyFallback(){ 96 //animate menu position based on CSS class 97 if( pushy.hasClass(pushyLeft) ){ 98 body.removeClass(pushyOpenLeft); 99 pushy.animate({left: "-" + menuWidth}, menuSpeed); 100 container.animate({left: "0px"}, menuSpeed); 101 //css class to add pushy capability 102 push.animate({left: "0px"}, menuSpeed); 103 }else{ 104 body.removeClass(pushyOpenRight); 105 pushy.animate({right: "-" + menuWidth}, menuSpeed); 106 container.animate({right: "0px"}, menuSpeed); 107 push.animate({right: "0px"}, menuSpeed); 108 } 109 } 110 111 function toggleSubmenu(){ 112 //hide submenu by default 113 $(submenuClass).addClass(submenuClosedClass); 114 115 $(submenuClass).on('click', function(){ 116 var selected = $(this); 117 118 if( selected.hasClass(submenuClosedClass) ) { 119 //hide opened submenus 120 $(submenuClass).addClass(submenuClosedClass).removeClass(submenuOpenClass); 121 //show submenu 122 selected.removeClass(submenuClosedClass).addClass(submenuOpenClass); 123 }else{ 124 //hide submenu 125 selected.addClass(submenuClosedClass).removeClass(submenuOpenClass); 126 } 127 }); 128 } 129 130 //checks if 3d transforms are supported removing the modernizr dependency 131 var cssTransforms3d = (function csstransforms3d(){ 132 var el = document.createElement('p'), 133 supported = false, 134 transforms = { 135 'webkitTransform':'-webkit-transform', 136 'OTransform':'-o-transform', 137 'msTransform':'-ms-transform', 138 'MozTransform':'-moz-transform', 139 'transform':'transform' 140 }; 141 142 if(document.body !== null) { 143 // Add it to the body to get the computed style 144 document.body.insertBefore(el, null); 145 146 for(var t in transforms){ 147 if( el.style[t] !== undefined ){ 148 el.style[t] = 'translate3d(1px,1px,1px)'; 149 supported = window.getComputedStyle(el).getPropertyValue(transforms[t]); 150 } 151 } 152 153 document.body.removeChild(el); 154 155 return (supported !== undefined && supported.length > 0 && supported !== "none"); 156 }else{ 157 return false;
158 } 159 })(); 160 161 if(cssTransforms3d){ 162 //toggle submenu 163 toggleSubmenu(); 164 165 //toggle menu 166 menuBtn.on('click', function(){ 167 togglePushy(); 168 }); 169 //close menu when clicking site overlay 170 siteOverlay.on('click', function(){ 171 togglePushy(); 172 }); 173 }else{ 174 //add css class to body 175 body.addClass('no-csstransforms3d'); 176 177 //hide menu by default 178 if( pushy.hasClass(pushyLeft) ){ 179 pushy.css({left: "-" + menuWidth}); 180 }else{ 181 pushy.css({right: "-" + menuWidth}); 182 } 183 184 //fixes IE scrollbar issue 185 container.css({"overflow-x": "hidden"}); 186 187 //keep track of menu state (open/close) 188 var opened = false; 189 190 //toggle submenu 191 toggleSubmenu(); 192 193 //toggle menu 194 menuBtn.on('click', function(){ 195 if (opened) { 196 closePushyFallback(); 197 opened = false; 198 } else { 199 openPushyFallback(); 200 opened = true; 201 } 202 }); 203 204 //close menu when clicking site overlay 205 siteOverlay.on('click', function(){ 206 if (opened) { 207 closePushyFallback(); 208 opened = false; 209 } else { 210 openPushyFallback(); 211 opened = true; 212 } 213 }); 214 } 215}(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.