vendor: 14,909 bytes, lines 1-521
1/** 2 * 3 * jPanelMenu 1.4.1 (http://jpanelmenu.com) 4 * By Anthony Colangelo (http://acolangelo.com) 5 * 6* */ 7 8(function($){ 9 $.jPanelMenu = function(options) { 10 if ( typeof(options) == "undefined" || options == null ) { options = {}; }; 11 12 var jP = { 13 options: $.extend({ 14 menu: '#menu', 15 panel: 'body', 16 trigger: '.menu-trigger', 17 excludedPanelContent: 'style, script', 18 clone: true, 19 keepEventHandlers: false, 20 21 direction: 'left', 22 openPosition: '250px', 23 animated: true, 24 closeOnContentClick: true, 25 26 keyboardShortcuts: [ 27 { 28 code: 27, 29 open: false, 30 close: true 31 }, 32 { 33 code: 37, 34 open: false, 35 close: true 36 }, 37 { 38 code: 39, 39 open: true, 40 close: true 41 }, 42 { 43 code: 77, 44 open: true, 45 close: true 46 } 47 ], 48 49 duration: 150, 50 openDuration: options.duration || 150, 51 closeDuration: options.duration || 150, 52 53 easing: 'ease-in-out', 54 openEasing: options.easing || 'ease-in-out', 55 closeEasing: options.easing || 'ease-in-out', 56 57 before: function(){ }, 58 beforeOpen: function(){ }, 59 beforeClose: function(){ }, 60 61 after: function(){ }, 62 afterOpen: function(){ }, 63 afterClose: function(){ }, 64 65 beforeOn: function(){ }, 66 afterOn: function(){ }, 67 68 beforeOff: function(){ }, 69 afterOff: function(){ } 70 },options), 71 72 settings: { 73 transitionsSupported: 'WebkitTransition' in document.body.style || 74 'MozTransition' in document.body.style || 75 'msTransition' in document.body.style || 76 'OTransition' in document.body.style || 77 'Transition' in document.body.style 78 , 79 transformsSupported: 'WebkitTransform' in document.body.style || 80 'MozTransform' in document.body.style || 81 'msTransform' in document.body.style || 82 'OTransform' in document.body.style || 83 'Transform' in document.body.style 84 , 85 cssPrefix: '', 86 panelPosition: 'static', 87 positionUnits: 'px' 88 }, 89 90 menu: '#jPanelMenu-menu', 91 92 panel: '.jPanelMenu-panel', 93 94 timeouts: {}, 95 96 clearTimeouts: function() { 97 clearTimeout(jP.timeouts.open); 98 clearTimeout(jP.timeouts.afterOpen); 99 clearTimeout(jP.timeouts.afterClose); 100 }, 101 102 setPositionUnits: function() { 103 var foundUnit = false, 104 allowedUnits = ['%','px','em'] 105 ; 106 107 for (var unitID = 0; unitID < allowedUnits.length; unitID++) { 108 var unit = allowedUnits[unitID]; 109 if ( jP.options.openPosition.toString().substr(-unit.length) == unit ) 110 { 111 foundUnit = true; 112 jP.settings.positionUnits = unit; 113 } 114 } 115 116 if ( !foundUnit ) { jP.options.openPosition = parseInt(jP.options.openPosition) + jP.settings.positionUnits } 117 }, 118 119 computePositionStyle: function(open, string) { 120 var position = (open)?jP.options.openPosition:'0' + jP.settings.positionUnits; 121 var property = {}; 122 if ( jP.settings.transformsSupported ) { 123 var direction = (open && jP.options.direction == 'right')?'-':''; 124 var translate = 'translate3d(' + direction + position + ',0,0)'; 125 var transform = 'transform'; 126 127 if ( string ) { 128 property = ''; 129 if ( jP.settings.cssPrefix != '' ) { property = jP.settings.cssPrefix + transform + ':' + translate + ';' } 130 property += transform + ':' + translate + ';'; 131 } else { 132 if ( jP.settings.cssPrefix != '' ) { property[jP.settings.cssPrefix + transform] = translate; } 133 property[transform] = translate; 134 } 135 } else { 136 if ( string ) { 137 property = ''; 138 property = jP.options.direction + ': ' + position + ';'; 139 } else { 140 property[jP.options.direction] = position; 141 } 142 } 143 return property; 144 }, 145 146 setCSSPrefix: function() { 147 jP.settings.cssPrefix = jP.getCSSPrefix(); 148 }, 149 150 setjPanelMenuStyles: function() { 151 var bg = 'background:#fff', 152 htmlBG = $('html').css('background-color'), 153 bodyBG = $('body').css('background-color'); 154 155 var backgroundGenerator = function(element){ 156 var bgs = []; 157 $.each(['background-color','background-image','background-position','background-repeat','background-attachment','background-size','background-clip'], function(i,value){ 158 if( element.css(value) !== '' ) { 159 bgs.push(value+':'+element.css(value)); 160 } 161 }); 162 return bgs.join(';'); 163 }; 164 165 if ( bodyBG !== 'transparent' && bodyBG !== "rgba(0, 0, 0, 0)") { 166 bg = backgroundGenerator($('body')); 167 } else if ( htmlBG !== 'transparent' && htmlBG !== "rgba(0, 0, 0, 0)") { 168 bg = backgroundGenerator($('html')); 169 } 170 171 if ( $('#jPanelMenu-style-master').length == 0 ) { 172 $('body').append('<style id="jPanelMenu-style-master">body{width:100%}.jPanelMenu,body{overflow-x:hidden}#jPanelMenu-menu{display:block;position:fixed;top:0;'+jP.options.direction+':0;height:100%;z-index:-1;overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch}.jPanelMenu-panel{position:static;'+jP.options.direction+':0;top:0;z-index:2;width:100%;min-height:100%;' + bg + ';}</style>'); 173 } 174 }, 175 176 setMenuState: function(open) { 177 var position = (open)?'open':'closed'; 178 $(jP.options.panel).attr('data-menu-position', position); 179 }, 180 181 getMenuState: function() { 182 return $(jP.options.panel).attr('data-menu-position'); 183 }, 184 185 menuIsOpen: function() { 186 if ( jP.getMenuState() == 'open' ) return true; 187 else return false; 188 }, 189 190 setMenuStyle: function(styles) { 191 $(jP.menu).css(styles); 192 }, 193 194 setPanelStyle: function(styles) { 195 $(jP.panel).css(styles); 196 }, 197 198 showMenu: function() { 199 jP.setMenuStyle({ 200 display: 'block' 201 }); 202 jP.setMenuStyle({ 203 'z-index': '1' 204 }); 205 }, 206 207 hideMenu: function() { 208 jP.setMenuStyle({ 209 'z-index': '-1' 210 }); 211 jP.setMenuStyle({ 212 display: 'none' 213 }); 214 }, 215 216 enableTransitions: function(duration, easing) { 217 var formattedDuration = duration/1000; 218 var formattedEasing = jP.getCSSEasingFunction(easing); 219 jP.disableTransitions(); 220 $('body').append('<style id="jPanelMenu-style-transitions">.jPanelMenu-panel{' + jP.settings.cssPrefix + 'transition: all ' + formattedDuration + 's ' + formattedEasing + '; transition: all ' + formattedDuration + 's ' + formattedEasing + ';}</style>'); 221 }, 222 223 disableTransitions: function() { 224 $('#jPanelMenu-style-transitions').remove(); 225 }, 226 227 getCSSEasingFunction: function(name) { 228 switch ( name ) 229 { 230 case 'linear': 231 return name; 232 break; 233 234 case 'ease': 235 return name; 236 break; 237 238 case 'ease-in': 239 return name; 240 break; 241 242 case 'ease-out': 243 return name; 244 break; 245 246 case 'ease-in-out': 247 return name; 248 break; 249 250 default: 251 return 'ease-in-out'; 252 break; 253 } 254 }, 255 256 getJSEasingFunction: function(name) { 257 switch ( name ) 258 { 259 case 'linear': 260 return name; 261 break; 262 263 default: 264 return 'swing'; 265 break; 266 } 267 }, 268 269 getVendorPrefix: function() { 270 // Thanks to Lea Verou for this beautiful function. (http://lea.verou.me/2009/02/find-the-vendor-prefix-of-the-current-browser) 271 if('result' in arguments.callee) return arguments.callee.result; 272 273 var regex = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/; 274 275 var someScript = document.getElementsByTagName('script')[0]; 276 277 for(var prop in someScript.style) 278 { 279 if(regex.test(prop)) 280 { 281 // test is faster than match, so it's better to perform 282 // that on the lot and match only when necessary 283 return arguments.callee.result = prop.match(regex)[0]; 284 } 285 286 } 287 288 // Nothing found so far? Webkit does not enumerate over the CSS properties of the style object. 289 // However (prop in style) returns the correct value, so we'll have to test for 290 // the precence of a specific property 291 if('WebkitOpacity' in someScript.style) return arguments.callee.result = 'Webkit'; 292 if('KhtmlOpacity' in someScript.style) return arguments.callee.result = 'Khtml'; 293 294 return arguments.callee.result = ''; 295 }, 296 297 getCSSPrefix: function() { 298 var prefix = jP.getVendorPrefix(); 299 if ( prefix != '' ) { return '-' + prefix.toLowerCase() + '-'; } 300 return ''; 301 }, 302 303 openMenu: function(animated) { 304 if ( typeof(animated) == "undefined" || animated == null ) { animated = jP.options.animated }; 305 306 jP.clearTimeouts(); 307 308 jP.options.before(); 309 jP.options.beforeOpen(); 310 311 jP.setMenuState(true); 312 313 jP.showMenu(); 314 315 var animationChecks = { 316 none: (!animated)?true:false, 317 transitions: (animated && jP.settings.transitionsSupported)?true:false 318 }; 319 320 if ( animationChecks.transitions || animationChecks.none ) { 321 if ( animationChecks.none ) jP.disableTransitions(); 322 if ( animationChecks.transitions ) jP.enableTransitions(jP.options.openDuration, jP.options.openEasing); 323 324 var newPanelStyle = jP.computePositionStyle(true); 325 jP.setPanelStyle(newPanelStyle); 326 327 jP.timeouts.afterOpen = setTimeout(function(){ 328 jP.options.after(); 329 jP.options.afterOpen(); 330 jP.initiateContentClickListeners(); 331 }, jP.options.openDuration); 332 } 333 else { 334 var formattedEasing = jP.getJSEasingFunction(jP.options.openEasing); 335 336 var animationOptions = {}; 337 animationOptions[jP.options.direction] = jP.options.openPosition; 338 $(jP.panel).stop().animate(animationOptions, jP.options.openDuration, formattedEasing, function(){ 339 jP.options.after(); 340 jP.options.afterOpen(); 341 jP.initiateContentClickListeners(); 342 }); 343 } 344 }, 345 346 closeMenu: function(animated) { 347 if ( typeof(animated) == "undefined" || animated == null ) { animated = jP.options.animated }; 348 349 jP.clearTimeouts(); 350 351 jP.options.before(); 352 jP.options.beforeClose(); 353 354 jP.setMenuState(false); 355 356 var animationChecks = { 357 none: (!animated)?true:false, 358 transitions: (animated && jP.settings.transitionsSupported)?true:false 359 }; 360 361 if ( animationChecks.transitions || animationChecks.none ) { 362 if ( animationChecks.none ) jP.disableTransitions(); 363 if ( animationChecks.transitions ) jP.enableTransitions(jP.options.closeDuration, jP.options.closeEasing); 364 365 var newPanelStyle = jP.computePositionStyle(); 366 jP.setPanelStyle(newPanelStyle); 367 368 jP.timeouts.afterClose = setTimeout(function(){ 369 jP.disableTransitions(); 370 371 jP.hideMenu(); 372 jP.options.after(); 373 jP.options.afterClose(); 374 jP.destroyContentClickListeners(); 375 }, jP.options.closeDuration); 376 } 377 else { 378 var formattedEasing = jP.getJSEasingFunction(jP.options.closeEasing); 379 380 var animationOptions = {}; 381 animationOptions[jP.options.direction] = 0 + jP.settings.positionUnits; 382 $(jP.panel).stop().animate(animationOptions, jP.options.closeDuration, formattedEasing, function(){ 383 jP.hideMenu(); 384 jP.options.after(); 385 jP.options.afterClose(); 386 jP.destroyContentClickListeners(); 387 }); 388 } 389 }, 390 391 triggerMenu: function(animated) { 392 if ( jP.menuIsOpen() ) jP.closeMenu(animated); 393 else jP.openMenu(animated); 394 }, 395 396 initiateClickListeners: function() { 397 $(document).on('click touchend',jP.options.trigger,function(e){ 398 jP.triggerMenu(jP.options.animated); e.preventDefault(); 399 }); 400 }, 401 402 destroyClickListeners: function() { 403 $(document).off('click touchend',jP.options.trigger,null); 404 }, 405 406 initiateContentClickListeners: function() { 407 if ( !jP.options.closeOnContentClick ) return false; 408 409 $(document).on('click touchend',jP.panel,function(e){ 410 if ( jP.menuIsOpen() ) jP.closeMenu(jP.options.animated); 411 e.preventDefault(); 412 }); 413 }, 414 415 destroyContentClickListeners: function() { 416 if ( !jP.options.closeOnContentClick ) return false; 417 418 $(document).off('click touchend',jP.panel,null); 419 }, 420 421 initiateKeyboardListeners: function() { 422 var preventKeyListeners = ['input', 'textarea', 'select']; 423 $(document).on('keydown',function(e){ 424 var target = $(e.target), 425 prevent = false; 426 427 $.each(preventKeyListeners, function(){ 428 if (target.is(this.toString())) { 429 prevent = true; 430 } 431 }); 432 433 if ( prevent ) return true; 434 435 for ( mapping in jP.options.keyboardShortcuts ) { 436 if ( e.which == jP.options.keyboardShortcuts[mapping].code ) { 437 var key = jP.options.keyboardShortcuts[mapping]; 438 439 if ( key.open && key.close ) { jP.triggerMenu(jP.options.animated); } 440 else if ( (key.open && !key.close) && !jP.menuIsOpen() ) { jP.openMenu(jP.options.animated); } 441 else if ( (!key.open && key.close) && jP.menuIsOpen() ) { jP.closeMenu(jP.options.animated); } 442 443 e.preventDefault(); 444 } 445 } 446 }); 447 }, 448 449 destroyKeyboardListeners: function() { 450 $(document).off('keydown',null); 451 }, 452 453 setupMarkup: function() { 454 $('html').addClass('jPanelMenu'); 455 $(jP.options.panel + ' > *').not(jP.menu + ', ' + jP.options.excludedPanelContent).wrapAll('<div class="' + jP.panel.replace('.','') + '"/>'); 456 var menu = ( jP.options.clone )?$(jP.options.menu).clone(jP.options.keepEventHandlers):$(jP.options.menu); 457 menu.attr('id', jP.menu.replace('#','')).insertAfter(jP.options.panel + ' > ' + jP.panel); 458 }, 459 460 resetMarkup: function() { 461 $('html').removeClass('jPanelMenu'); 462 $(jP.options.panel + ' > ' + jP.panel + ' > *').unwrap(); 463 $(jP.menu).remove(); 464 }, 465 466 init: function() { 467 jP.options.beforeOn(); 468 469 jP.setPositionUnits(); 470 jP.setCSSPrefix(); 471 jP.initiateClickListeners(); 472 if ( Object.prototype.toString.call(jP.options.keyboardShortcuts) === '[object Array]' ) { jP.initiateKeyboardListeners(); } 473 474 jP.setjPanelMenuStyles(); 475 jP.setMenuState(false); 476 jP.setupMarkup(); 477 478 jP.setPanelStyle({ position: (( jP.options.animated && jP.settings.panelPosition === 'static' )?'relative':jP.settings.panelPosition) }); 479 jP.setMenuStyle({ width: jP.options.openPosition }); 480 481 jP.closeMenu(false); 482 483 jP.options.afterOn(); 484 }, 485 486 destroy: function() { 487 jP.options.beforeOff(); 488 489 jP.closeMenu(); 490 jP.destroyClickListeners(); 491 if ( Object.prototype.toString.call(jP.options.keyboardShortcuts) === '[object Array]' ) { jP.destroyKeyboardListeners(); } 492 493 jP.resetMarkup(); 494 var childrenStyles = {}; 495 childrenStyles[jP.options.direction] = 'auto'; 496 497 jP.options.afterOff(); 498 } 499 }; 500 501 return { 502 on: jP.init, 503 off: jP.destroy, 504 trigger: jP.triggerMenu, 505 open: jP.openMenu, 506 close: jP.closeMenu, 507 isOpen: jP.menuIsOpen, 508 menu: jP.menu, 509 getMenu: function() { return $(jP.menu); }, 510 panel: jP.panel, 511 getPanel: function() { return $(jP.panel); }, 512 setPosition: function(position) { 513 if ( typeof(position) == "undefined" || position == null ) { 514 position = jP.options.openPosition 515 } 516 jP.options.openPosition = position; 517 jP.setMenuStyle({ width: jP.options.openPosition }); 518 } 519 }; 520 }; 521})(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.