1/* Swipe Box 2(function(w){ var ua = navigator.userAgent; if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && /OS [1-5]_[0-9_]* like Mac OS X/i.test(ua) && ua.indexOf( "AppleWebKit" ) > -1 ) ){ return; } var doc = w.document; if( !doc.querySelector ){ return; } var meta = doc.querySelector( "meta[name=viewport]" ), initialContent = meta && meta.getAttribute( "content" ), disabledZoom = initialContent + ",maximum-scale=1", enabledZoom = initialContent + ",maximum-scale=10", enabled = true, x, y, z, aig; if( !meta ){ return; } function restoreZoom(){ meta.setAttribute( "content", enabledZoom ); enabled = true; } function disableZoom(){ meta.setAttribute( "content", disabledZoom ); enabled = false; } function checkTilt( e ){ aig = e.accelerationIncludingGravity; x = Math.abs( aig.x ); y = Math.abs( aig.y ); z = Math.abs( aig.z ); if( (!w.orientation || w.orientation === 180) && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){ if( enabled ){ disableZoom(); } } else if( !enabled ){ restoreZoom(); } } w.addEventListener( "orientationchange", restoreZoom, false ); w.addEventListener( "devicemotion", checkTilt, false ); })( this ); ;( function ( window, document, $, undefined ) { $.swipebox = function( elem, options ) { var ui, defaults = { useCSS : true, useSVG : true, initialIndexOnArray : 0, removeBarsOnMobile : false, hideCloseButtonOnMobile : false, hideBarsDelay : 3000, videoMaxWidth : 1140, vimeoColor : 'cccccc', beforeOpen: null, afterOpen: null, afterClose: null, afterMedia: null, nextSlide: null, prevSlide: null, loopAtEnd: false, autoplayVideos: false, queryStringData: {}, toggleClassOnLoad: '' }, plugin = this, elements = [], $elem, selector = elem.selector, isMobile = navigator.userAgent.match( /(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i ), isTouch = isMobile !== null || document.createTouch !== undefined || ( 'ontouchstart' in window ) || ( 'onmsgesturechange' in window ) || navigator.msMaxTouchPoints, supportSVG = !! document.createElementNS && !! document.createElementNS( 'http://www.w3.org/2000/svg', 'svg').createSVGRect, winWidth = window.innerWidth ? window.innerWidth : $( window ).width(), winHeight = window.innerHeight ? window.innerHeight : $( window ).height(), currentX = 0, html = '<div id="swipebox-overlay">\ <div id="swipebox-container">\ <div id="swipebox-slider"></div>\ <div id="swipebox-top-bar">\ <div id="swipebox-title"></div>\ </div>\ <div id="swipebox-bottom-bar">\ <div id="swipebox-arrows">\ <a id="swipebox-prev"></a>\ <a id="swipebox-next"></a>\ </div>\ </div>\ <a id="swipebox-close"></a>\ </div>\ </div>'; plugin.settings = {}; $.swipebox.close = function () { ui.closeSlide(); }; $.swipebox.extend = function () { return ui; }; plugin.init = function() { plugin.settings = $.extend( {}, defaults, options ); if ( $.isArray( elem ) ) { elements = elem; ui.target = $( window ); ui.init( plugin.settings.initialIndexOnArray ); } else { $( document ).on( 'click', selector, function( event ) { if ( event.target.parentNode.className === 'slide current' ) { return false; } if ( ! $.isArray( elem ) ) { ui.destroy(); $elem = $( selector ); ui.actions(); } elements = []; var index, relType, relVal; if ( ! relVal ) { relType = 'data-rel'; relVal = $( this ).attr( relType ); } if ( ! relVal ) { relType = 'rel'; relVal = $( this ).attr( relType ); } if ( relVal && relVal !== '' && relVal !== 'nofollow' ) { $elem = $( selector ).filter( '[' + relType + '="' + relVal + '"]' ); } else { $elem = $( selector ); } $elem.each( function() { var title = null, href = null; data = null; if ( $( this ).attr( 'title' ) ) { title = $( this ).attr( 'title' ); } if ( $( this ).attr( 'href' ) ) { href = $( this ).attr( 'href' ); } if ( $( this ).attr( 'data' ) ) { data = $( this ).attr( 'data' ); } elements.push( { href: href, title: title, data: data } ); } ); index = $elem.index( $( this ) ); event.preventDefault(); event.stopPropagation(); ui.target = $( event.target ); ui.init( index ); } ); } }; ui = { init : function( index ) { if ( plugin.settings.beforeOpen ) { plugin.settings.beforeOpen(); } this.target.trigger( 'swipebox-start' ); $.swipebox.isOpen = true; this.build(); this.openSlide( index ); this.openMedia( index ); this.preloadMedia( index+1 ); this.preloadMedia( index-1 ); if ( plugin.settings.afterOpen ) { plugin.settings.afterOpen(index); } }, build : function () { var $this = this, bg; $( 'body' ).append( html ); if ( supportSVG && plugin.settings.useSVG === true ) { bg = $( '#swipebox-close' ).css( 'background-image' ); bg = bg.replace( 'png', 'svg' ); $( '#swipebox-prev, #swipebox-next, #swipebox-close' ).css( { 'background-image' : bg } ); } if ( isMobile && plugin.settings.removeBarsOnMobile ) { $( '#swipebox-bottom-bar, #swipebox-top-bar' ).remove(); } $.each( elements, function() { $( '#swipebox-slider' ).append( '<div class="slide"></div>' ); } ); $this.setDim(); $this.actions(); if ( isTouch ) { $this.gesture(); } $this.keyboard(); $this.animBars(); $this.resize(); }, setDim : function () { var width, height, sliderCss = {}; if ( 'onorientationchange' in window ) { window.addEventListener( 'orientationchange', function() { if ( window.orientation === 0 ) { width = winWidth; height = winHeight; } else if ( window.orientation === 90 || window.orientation === -90 ) { width = winHeight; height = winWidth; } }, false ); } else { width = window.innerWidth ? window.innerWidth : $( window ).width(); height = window.innerHeight ? window.innerHeight : $( window ).height(); } sliderCss = { width : width, height : height }; $( '#swipebox-overlay' ).css( sliderCss ); }, resize : function () { var $this = this; $( window ).resize( function() { $this.setDim(); } ).resize(); }, supportTransition : function () { var prefixes = 'transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition'.split( ' ' ), i; for ( i = 0; i < prefixes.length; i++ ) { if ( document.createElement( 'div' ).style[ prefixes[i] ] !== undefined ) { return prefixes[i]; } } return false; }, doCssTrans : function () { if ( plugin.settings.useCSS && this.supportTransition() ) { return true; } }, gesture : function () { var $this = this, index, hDistance, vDistance, hDistanceLast, vDistanceLast, hDistancePercent, vSwipe = false, hSwipe = false, hSwipMinDistance = 10, vSwipMinDistance = 50, startCoords = {}, endCoords = {}, bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ), slider = $( '#swipebox-slider' ); bars.addClass( 'visible-bars' ); $this.setTimeout(); $( 'body' ).bind( 'touchstart', function( event ) { $( this ).addClass( 'touching' ); index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ); endCoords = event.originalEvent.targetTouches[0]; startCoords.pageX = event.originalEvent.targetTouches[0].pageX; startCoords.pageY = event.originalEvent.targetTouches[0].pageY; $( '#swipebox-slider' ).css( { '-webkit-transform' : 'translate3d(' + currentX +'%, 0, 0)', 'transform' : 'translate3d(' + currentX + '%, 0, 0)' } ); $( '.touching' ).bind( 'touchmove',function( event ) { event.preventDefault(); event.stopPropagation(); endCoords = event.originalEvent.targetTouches[0]; if ( ! hSwipe ) { vDistanceLast = vDistance; vDistance = endCoords.pageY - startCoords.pageY; if ( Math.abs( vDistance ) >= vSwipMinDistance || vSwipe ) { var opacity = 0.75 - Math.abs(vDistance) / slider.height(); slider.css( { 'top': vDistance + 'px' } ); slider.css( { 'opacity': opacity } ); vSwipe = true; } } hDistanceLast = hDistance;
2 hDistance = endCoords.pageX - startCoords.pageX; hDistancePercent = hDistance * 100 / winWidth; if ( ! hSwipe && ! vSwipe && Math.abs( hDistance ) >= hSwipMinDistance ) { $( '#swipebox-slider' ).css( { '-webkit-transition' : '', 'transition' : '' } ); hSwipe = true; } if ( hSwipe ) { if ( 0 < hDistance ) { if ( 0 === index ) { $( '#swipebox-overlay' ).addClass( 'leftSpringTouch' ); } else { $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' ); $( '#swipebox-slider' ).css( { '-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)', 'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)' } ); } } else if ( 0 > hDistance ) { if ( elements.length === index +1 ) { $( '#swipebox-overlay' ).addClass( 'rightSpringTouch' ); } else { $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' ); $( '#swipebox-slider' ).css( { '-webkit-transform' : 'translate3d(' + ( currentX + hDistancePercent ) +'%, 0, 0)', 'transform' : 'translate3d(' + ( currentX + hDistancePercent ) + '%, 0, 0)' } ); } } } } ); return false; } ).bind( 'touchend',function( event ) { event.preventDefault(); event.stopPropagation(); $( '#swipebox-slider' ).css( { '-webkit-transition' : '-webkit-transform 0.4s ease', 'transition' : 'transform 0.4s ease' } ); vDistance = endCoords.pageY - startCoords.pageY;
2 hDistance = endCoords.pageX - startCoords.pageX; hDistancePercent = hDistance*100/winWidth; if ( vSwipe ) { vSwipe = false; if ( Math.abs( vDistance ) >= 2 * vSwipMinDistance && Math.abs( vDistance ) > Math.abs( vDistanceLast ) ) { var vOffset = vDistance > 0 ? slider.height() : - slider.height(); slider.animate( { top: vOffset + 'px', 'opacity': 0 }, 300, function () { $this.closeSlide(); } ); } else { slider.animate( { top: 0, 'opacity': 1 }, 300 ); } } else if ( hSwipe ) { hSwipe = false; if( hDistance >= hSwipMinDistance && hDistance >= hDistanceLast) { $this.getPrev(); } else if ( hDistance <= -hSwipMinDistance && hDistance <= hDistanceLast) { $this.getNext(); } } else { if ( ! bars.hasClass( 'visible-bars' ) ) { $this.showBars(); $this.setTimeout(); } else { $this.clearTimeout(); $this.hideBars(); } } $( '#swipebox-slider' ).css( { '-webkit-transform' : 'translate3d(' + currentX + '%, 0, 0)', 'transform' : 'translate3d(' + currentX + '%, 0, 0)' } ); $( '#swipebox-overlay' ).removeClass( 'leftSpringTouch' ).removeClass( 'rightSpringTouch' ); $( '.touching' ).off( 'touchmove' ).removeClass( 'touching' ); } ); }, setTimeout: function () { if ( plugin.settings.hideBarsDelay > 0 ) { var $this = this; $this.clearTimeout(); $this.timeout = window.setTimeout( function() { $this.hideBars(); }, plugin.settings.hideBarsDelay ); } }, clearTimeout: function () { window.clearTimeout( this.timeout ); this.timeout = null; }, showBars : function () { var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ); if ( this.doCssTrans() ) { bars.addClass( 'visible-bars' ); } else { $( '#swipebox-top-bar' ).animate( { top : 0 }, 500 ); $( '#swipebox-bottom-bar' ).animate( { bottom : 0 }, 500 ); setTimeout( function() { bars.addClass( 'visible-bars' ); }, 1000 ); } }, hideBars : function () { var bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ); if ( this.doCssTrans() ) { bars.removeClass( 'visible-bars' ); } else { $( '#swipebox-top-bar' ).animate( { top : '-50px' }, 500 ); $( '#swipebox-bottom-bar' ).animate( { bottom : '-50px' }, 500 ); setTimeout( function() { bars.removeClass( 'visible-bars' ); }, 1000 ); } }, animBars : function () { var $this = this, bars = $( '#swipebox-top-bar, #swipebox-bottom-bar' ); bars.addClass( 'visible-bars' ); $this.setTimeout(); $( '#swipebox-slider' ).click( function() { if ( ! bars.hasClass( 'visible-bars' ) ) { $this.showBars(); $this.setTimeout(); } } ); $( '#swipebox-bottom-bar' ).hover( function() { $this.showBars(); bars.addClass( 'visible-bars' ); $this.clearTimeout(); }, function() { if ( plugin.settings.hideBarsDelay > 0 ) { bars.removeClass( 'visible-bars' ); $this.setTimeout(); } } ); }, keyboard : function () { var $this = this; $( window ).bind( 'keyup', function( event ) { event.preventDefault(); event.stopPropagation(); if ( event.keyCode === 37 ) { $this.getPrev(); } else if ( event.keyCode === 39 ) { $this.getNext(); } else if ( event.keyCode === 27 ) { $this.closeSlide(); } } ); }, actions : function () { var $this = this, action = 'touchend click'; if ( elements.length < 2 ) { $( '#swipebox-bottom-bar' ).hide(); if ( undefined === elements[ 1 ] ) { $( '#swipebox-top-bar' ).hide(); } } else { $( '#swipebox-prev' ).bind( action, function( event ) { event.preventDefault(); event.stopPropagation(); $this.getPrev(); $this.setTimeout(); } ); $( '#swipebox-next' ).bind( action, function( event ) { event.preventDefault(); event.stopPropagation(); $this.getNext(); $this.setTimeout(); } ); } $( '#swipebox-close' ).bind( action, function() { $this.closeSlide(); } ); }, setSlide : function ( index, isFirst ) { isFirst = isFirst || false; var slider = $( '#swipebox-slider' ); currentX = -index*100; if ( this.doCssTrans() ) { slider.css( { '-webkit-transform' : 'translate3d(' + (-index*100)+'%, 0, 0)', 'transform' : 'translate3d(' + (-index*100)+'%, 0, 0)' } ); } else { slider.animate( { left : ( -index*100 )+'%' } ); } $( '#swipebox-slider .slide' ).removeClass( 'current' ); $( '#swipebox-slider .slide' ).eq( index ).addClass( 'current' ); this.setTitle( index ); if ( isFirst ) { slider.fadeIn(); } $( '#swipebox-prev, #swipebox-next' ).removeClass( 'disabled' ); if ( index === 0 ) { $( '#swipebox-prev' ).addClass( 'disabled' ); } else if ( index === elements.length - 1 && plugin.settings.loopAtEnd !== true ) { $( '#swipebox-next' ).addClass( 'disabled' ); } }, openSlide : function ( index ) { $( 'html' ).addClass( 'swipebox-html' ); if ( isTouch ) { $( 'html' ).addClass( 'swipebox-touch' ); if ( plugin.settings.hideCloseButtonOnMobile ) { $( 'html' ).addClass( 'swipebox-no-close-button' ); } } else { $( 'html' ).addClass( 'swipebox-no-touch' ); } $( window ).trigger( 'resize' ); this.setSlide( index, true ); }, preloadMedia : function ( index ) { var $this = this, src = null; if ( elements[ index ] !== undefined ) { src = elements[ index ].href; } if ( ! $this.isVideo( src ) ) { setTimeout( function() { $this.openMedia( index ); }, 1000); } else { $this.openMedia( index ); } }, openMedia : function ( index ) { var $this = this, src, slide; if ( elements[ index ] !== undefined ) { src = elements[ index ].href; } if ( index < 0 || index >= elements.length ) { return false; } slide = $( '#swipebox-slider .slide' ).eq( index ); if ( ! $this.isVideo( src ) ) { slide.addClass( 'slide-loading' ); $this.loadMedia( src, function() { slide.removeClass( 'slide-loading' ); slide.html( this ); if ( plugin.settings.afterMedia ) { plugin.settings.afterMedia( index ); } } ); } else { slide.html( $this.getVideo( src ) ); if ( plugin.settings.afterMedia ) { plugin.settings.afterMedia( index ); } } }, setTitle : function ( index ) { var title = null; var data = null; $( '#swipebox-title' ).empty(); if ( elements[ index ] !== undefined ) { title = elements[ index ].title; data = elements[ index ].data; } if ( title ) { $( '#swipebox-top-bar' ).show(); if ( data ) { $( '#swipebox-title' ).html('<a href="' + data +'">' + title + '</a>'); } else { $( '#swipebox-title' ).append( title ); } } else { $( '#swipebox-top-bar' ).hide(); } }, isVideo : function ( src ) { if ( src ) { if ( src.match( /(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || src.match( /vimeo\.com\/([0-9]*)/ ) || src.match( /youtu\.be\/([a-zA-Z0-9\-_]+)/ ) ) { return true; } if ( src.toLowerCase().indexOf( 'swipeboxvideo=1' ) >= 0 ) { return true; } } }, parseUri : function (uri, customData) { var a = document.createElement('a'), qs = {}; a.href = decodeURIComponent( uri ); if ( a.search ) { qs = JSON.parse( '{"' + a.search.toLowerCase().replace('?','').replace(/&/g,'","').replace(/=/g,'":"') + '"}' ); } if ( $.isPlainObject( customData ) ) { qs = $.extend( qs, customData, plugin.settings.queryStringData ); } return $ .map( qs, function (val, key) { if ( val && val > '' ) { return encodeURIComponent( key ) + '=' + encodeURIComponent( val ); } }) .join('&'); }, getVideo : function( url ) { var iframe = '', youtubeUrl = url.match( /((?:www\.)?youtube\.com|(?:www\.)?youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/ ), youtubeShortUrl = url.match(/(?:www\.)?youtu\.be\/([a-zA-Z0-9\-_]+)/), vimeoUrl = url.match( /(?:www\.)?vimeo\.com\/([0-9]*)/ ), qs = ''; if ( youtubeUrl || youtubeShortUrl) { if ( youtubeShortUrl ) { youtubeUrl = youtubeShortUrl; } qs = ui.parseUri( url, { 'autoplay' : ( plugin.settings.autoplayVideos ? '1' : '0' ), 'v' : '' }); iframe = '<iframe width="560" height="315" src="//' + youtubeUrl[1] + '/embed/' + youtubeUrl[2] + '?' + qs + '" frameborder="0" allowfullscreen></iframe>'; } else if ( vimeoUrl ) { qs = ui.parseUri( url, { 'autoplay' : ( plugin.settings.autoplayVideos ? '1' : '0' ), 'byline' : '0', 'portrait' : '0', 'color': plugin.settings.vimeoColor }); iframe = '<iframe width="560" height="315" src="//player.vimeo.com/video/' + vimeoUrl[1] + '?' + qs + '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'; } else { iframe = '<iframe width="560" height="315" src="' + url + '" frameborder="0" allowfullscreen></iframe>'; } return '<div class="swipebox-video-container" style="max-width:' + plugin.settings.videoMaxWidth + 'px"><div class="swipebox-video">' + iframe + '</div></div>'; }, loadMedia : function ( src, callback ) { if ( src.trim().indexOf('#') === 0 ) { callback.call( $('<div>', { 'class' : 'swipebox-inline-container' }) .append( $(src) .clone() .toggleClass( plugin.settings.toggleClassOnLoad ) ) ); } else { if ( ! this.isVideo( src ) ) { var img = $( '<img>' ).on( 'load', function() { callback.call( img ); } ); img.attr( 'src', src ); } } }, getNext : function () { var $this = this, src, index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ); if ( index + 1 < elements.length ) { src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' ); $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src ); index++; $this.setSlide( index ); $this.preloadMedia( index+1 ); if ( plugin.settings.nextSlide ) { plugin.settings.nextSlide(index); } } else { if ( plugin.settings.loopAtEnd === true ) { src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src' ); $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src ); index = 0; $this.preloadMedia( index ); $this.setSlide( index ); $this.preloadMedia( index + 1 ); if ( plugin.settings.nextSlide ) { plugin.settings.nextSlide(index); } } else { $( '#swipebox-overlay' ).addClass( 'rightSpring' ); setTimeout( function() { $( '#swipebox-overlay' ).removeClass( 'rightSpring' ); }, 500 ); } } }, getPrev : function () { var index = $( '#swipebox-slider .slide' ).index( $( '#swipebox-slider .slide.current' ) ), src; if ( index > 0 ) { src = $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe').attr( 'src' ); $( '#swipebox-slider .slide' ).eq( index ).contents().find( 'iframe' ).attr( 'src', src ); index--; this.setSlide( index ); this.preloadMedia( index-1 ); if ( plugin.settings.prevSlide ) { plugin.settings.prevSlide(index); } } else { $( '#swipebox-overlay' ).addClass( 'leftSpring' ); setTimeout( function() { $( '#swipebox-overlay' ).removeClass( 'leftSpring' ); }, 500 ); } }, nextSlide : function ( index ) { }, prevSlide : function ( index ) { }, closeSlide : function () { $( 'html' ).removeClass( 'swipebox-html' ); $( 'html' ).removeClass( 'swipebox-touch' ); $( window ).trigger( 'resize' ); this.destroy(); }, destroy : function () { $( window ).unbind( 'keyup' ); $( 'body' ).unbind( 'touchstart' ); $( 'body' ).unbind( 'touchmove' ); $( 'body' ).unbind( 'touchend' ); $( '#swipebox-slider' ).unbind(); $( '#swipebox-overlay' ).remove(); if ( ! $.isArray( elem ) ) { elem.removeData( '_swipebox' ); } if ( this.target ) { this.target.trigger( 'swipebox-destroy' ); } $.swipebox.isOpen = false; if ( plugin.settings.afterClose ) { plugin.settings.afterClose(); } } }; plugin.init(); }; $.fn.swipebox = function( options ) { if ( ! $.data( this, '_swipebox' ) ) { var swipebox = new $.swipebox( this, options ); this.data( '_swipebox', swipebox ); } return this.data( '_swipebox' ); }; }( window, document, jQuery ) ); */ 3 4/*! 5 * Lightbox v2.11.1 6 * by Lokesh Dhakar 7 * 8 * More info: 9 * http://lokeshdhakar.com/projects/lightbox2/ 10 * 11 * Copyright Lokesh Dhakar 12 * Released under the MIT license 13 * https://github.com/lokesh/lightbox2/blob/master/LICENSE 14 * 15 * @preserve 16 */ 17 18// Uses Node, AMD or browser globals to create a module. 19(function (root, factory) { 20 if (typeof define === 'function' && define.amd) { 21 // AMD. Register as an anonymous module. 22 define(['jquery'], factory); 23 } else if (typeof exports === 'object') { 24 // Node. Does not work with strict CommonJS, but 25 // only CommonJS-like environments that support module.exports, 26 // like Node. 27 module.exports = factory(require('jquery')); 28 } else { 29 // Browser globals (root is window) 30 root.lightbox = factory(root.jQuery); 31 } 32}(this, function ($) { 33 34 function Lightbox(options) { 35 this.album = []; 36 this.currentImageIndex = void 0; 37 this.init(); 38 39 // options 40 this.options = $.extend({}, this.constructor.defaults); 41 this.option(options); 42 } 43 44 // Descriptions of all options available on the demo site: 45 // http://lokeshdhakar.com/projects/lightbox2/index.html#options 46 Lightbox.defaults = { 47 albumLabel: 'Image %1 of %2', 48 alwaysShowNavOnTouchDevices: false, 49 fadeDuration: 600,
vendor: 4,317 bytes, lines 50-145
50 fitImagesInViewport: true, 51 imageFadeDuration: 600, 52 // maxWidth: 800, 53 // maxHeight: 600, 54 positionFromTop: 50, 55 resizeDuration: 700, 56 showImageNumberLabel: true, 57 wrapAround: false, 58 disableScrolling: false, 59 /* 60 Sanitize Title 61 If the caption data is trusted, for example you are hardcoding it in, then leave this to false. 62 This will free you to add html tags, such as links, in the caption. 63 64 If the caption data is user submitted or from some other untrusted source, then set this to true 65 to prevent xss and other injection attacks. 66 */ 67 sanitizeTitle: false 68 }; 69 70 Lightbox.prototype.option = function(options) { 71 $.extend(this.options, options); 72 }; 73 74 Lightbox.prototype.imageCountLabel = function(currentImageNum, totalImages) { 75 return this.options.albumLabel.replace(/%1/g, currentImageNum).replace(/%2/g, totalImages); 76 }; 77 78 Lightbox.prototype.init = function() { 79 var self = this; 80 // Both enable and build methods require the body tag to be in the DOM. 81 $(document).ready(function() { 82 self.enable(); 83 self.build(); 84 }); 85 }; 86 87 // Loop through anchors and areamaps looking for either data-lightbox attributes or rel attributes 88 // that contain 'lightbox'. When these are clicked, start lightbox. 89 Lightbox.prototype.enable = function() { 90 var self = this; 91 $('body').on('click', 'a[rel^=lightbox], area[rel^=lightbox], a[data-lightbox], area[data-lightbox]', function(event) { 92 self.start($(event.currentTarget)); 93 return false; 94 }); 95 }; 96 97 // Build html for the lightbox and the overlay. 98 // Attach event handlers to the new DOM elements. click click click 99 Lightbox.prototype.build = function() { 100 if ($('#lightbox').length > 0) { 101 return; 102 } 103 104 var self = this; 105 106 // The two root notes generated, #lightboxOverlay and #lightbox are given 107 // tabindex attrs so they are focusable. We attach our keyboard event 108 // listeners to these two elements, and not the document. Clicking anywhere 109 // while Lightbox is opened will keep the focus on or inside one of these 110 // two elements. 111 // 112 // We do this so we can prevent propogation of the Esc keypress when 113 // Lightbox is open. This prevents it from intefering with other components 114 // on the page below. 115 // 116 // Github issue: https://github.com/lokesh/lightbox2/issues/663 117 $('<div id="lightboxOverlay" tabindex="-1" class="lightboxOverlay"></div><div id="lightbox" tabindex="-1" class="lightbox"><div class="lb-outerContainer"><div class="lb-container"><img class="lb-image" src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==" alt=""/><div class="lb-nav"><a class="lb-prev" aria-label="Previous image" href="" ></a><a class="lb-next" aria-label="Next image" href="" ></a></div><div class="lb-loader"><a class="lb-cancel"></a></div></div></div><div class="lb-dataContainer"><div class="lb-data"><div class="lb-details"><span class="lb-caption"></span><span class="lb-number"></span></div><div class="lb-closeContainer"><a class="lb-close"></a></div></div></div></div>').appendTo($('body')); 118 119 // Cache jQuery objects 120 this.$lightbox = $('#lightbox'); 121 this.$overlay = $('#lightboxOverlay'); 122 this.$outerContainer = this.$lightbox.find('.lb-outerContainer'); 123 this.$container = this.$lightbox.find('.lb-container'); 124 this.$image = this.$lightbox.find('.lb-image'); 125 this.$nav = this.$lightbox.find('.lb-nav'); 126 127 // Store css values for future lookup 128 this.containerPadding = { 129 top: parseInt(this.$container.css('padding-top'), 10), 130 right: parseInt(this.$container.css('padding-right'), 10), 131 bottom: parseInt(this.$container.css('padding-bottom'), 10), 132 left: parseInt(this.$container.css('padding-left'), 10) 133 }; 134 135 this.imageBorderWidth = { 136 top: parseInt(this.$image.css('border-top-width'), 10), 137 right: parseInt(this.$image.css('border-right-width'), 10), 138 bottom: parseInt(this.$image.css('border-bottom-width'), 10), 139 left: parseInt(this.$image.css('border-left-width'), 10) 140 }; 141 142 // Attach event handlers to the newly minted DOM elements 143 this.$overlay.hide().on('click', function() { 144 self.end(); 145 return false;
146 }); 147 148 this.$lightbox.hide().on('click', function(event) { 149 if ($(event.target).attr('id') === 'lightbox') { 150 self.end(); 151 } 152 }); 153 154 this.$outerContainer.on('click', function(event) { 155 if ($(event.target).attr('id') === 'lightbox') { 156 self.end(); 157 } 158 return false; 159 }); 160 161 this.$lightbox.find('.lb-prev').on('click', function() { 162 if (self.currentImageIndex === 0) { 163 self.changeImage(self.album.length - 1); 164 } else { 165 self.changeImage(self.currentImageIndex - 1); 166 } 167 return false; 168 }); 169 170 this.$lightbox.find('.lb-next').on('click', function() { 171 if (self.currentImageIndex === self.album.length - 1) { 172 self.changeImage(0); 173 } else { 174 self.changeImage(self.currentImageIndex + 1); 175 } 176 return false; 177 }); 178 179 /* 180 Show context menu for image on right-click 181 182 There is a div containing the navigation that spans the entire image and lives above of it. If 183 you right-click, you are right clicking this div and not the image. This prevents users from 184 saving the image or using other context menu actions with the image. 185 186 To fix this, when we detect the right mouse button is pressed down, but not yet clicked, we 187 set pointer-events to none on the nav div. This is so that the upcoming right-click event on 188 the next mouseup will bubble down to the image. Once the right-click/contextmenu event occurs 189 we set the pointer events back to auto for the nav div so it can capture hover and left-click 190 events as usual. 191 */ 192 this.$nav.on('mousedown', function(event) { 193 if (event.which === 3) { 194 self.$nav.css('pointer-events', 'none'); 195 196 self.$lightbox.one('contextmenu', function() { 197 setTimeout(function() { 198 this.$nav.css('pointer-events', 'auto'); 199 }.bind(self), 0); 200 }); 201 } 202 }); 203 204 205 this.$lightbox.find('.lb-loader, .lb-close').on('click', function() { 206 self.end(); 207 return false; 208 }); 209 }; 210 211 // Show overlay and lightbox. If the image is part of a set, add siblings to album array. 212 Lightbox.prototype.start = function($link) { 213 var self = this; 214 var $window = $(window); 215 216 $window.on('resize', $.proxy(this.sizeOverlay, this)); 217 218 this.sizeOverlay(); 219 220 this.album = []; 221 var imageNumber = 0; 222 223 function addToAlbum($link) { 224 self.album.push({ 225 alt: $link.attr('data-alt'), 226 link: $link.attr('href'), 227 title: $link.attr('data-title') || $link.attr('title') 228 }); 229 } 230 231 // Support both data-lightbox attribute and rel attribute implementations 232 var dataLightboxValue = $link.attr('data-lightbox'); 233 var $links; 234 235 if (dataLightboxValue) { 236 $links = $($link.prop('tagName') + '[data-lightbox="' + dataLightboxValue + '"]'); 237 for (var i = 0; i < $links.length; i = ++i) { 238 addToAlbum($($links[i])); 239 if ($links[i] === $link[0]) { 240 imageNumber = i; 241 } 242 } 243 } else { 244 if ($link.attr('rel') === 'lightbox') { 245 // If image is not part of a set 246 addToAlbum($link); 247 } else { 248 // If image is part of a set 249 $links = $($link.prop('tagName') + '[rel="' + $link.attr('rel') + '"]'); 250 for (var j = 0; j < $links.length; j = ++j) { 251 addToAlbum($($links[j])); 252 if ($links[j] === $link[0]) { 253 imageNumber = j; 254 } 255 } 256 } 257 } 258 259 // Position Lightbox 260 var top = $window.scrollTop() + this.options.positionFromTop; 261 var left = $window.scrollLeft(); 262 this.$lightbox.css({ 263 top: top + 'px', 264 left: left + 'px' 265 }).fadeIn(this.options.fadeDuration); 266 267 // Disable scrolling of the page while open 268 if (this.options.disableScrolling) { 269 $('body').addClass('lb-disable-scrolling'); 270 } 271 272 this.changeImage(imageNumber); 273 }; 274 275 // Hide most UI elements in preparation for the animated resizing of the lightbox. 276 Lightbox.prototype.changeImage = function(imageNumber) { 277 var self = this; 278 var filename = this.album[imageNumber].link; 279 var filetype = filename.split('.').slice(-1)[0]; 280 var $image = this.$lightbox.find('.lb-image'); 281 282 // Disable keyboard nav during transitions 283 this.disableKeyboardNav(); 284 285 // Show loading state 286 this.$overlay.fadeIn(this.options.fadeDuration); 287 $('.lb-loader').fadeIn('slow'); 288 this.$lightbox.find('.lb-image, .lb-nav, .lb-prev, .lb-next, .lb-dataContainer, .lb-numbers, .lb-caption').hide(); 289 this.$outerContainer.addClass('animating'); 290 291 // When image to show is preloaded, we send the width and height to sizeContainer() 292 var preloader = new Image(); 293 preloader.onload = function() { 294 var $preloader; 295 var imageHeight; 296 var imageWidth; 297 var maxImageHeight; 298 var maxImageWidth; 299 var windowHeight; 300 var windowWidth; 301 302 $image.attr({ 303 'alt': self.album[imageNumber].alt, 304 'src': filename 305 }); 306 307 $preloader = $(preloader); 308 309 $image.width(preloader.width); 310 $image.height(preloader.height); 311 windowWidth = $(window).width(); 312 windowHeight = $(window).height(); 313 314 // Calculate the max image dimensions for the current viewport. 315 // Take into account the border around the image and an additional 10px gutter on each side. 316 maxImageWidth = windowWidth - self.containerPadding.left - self.containerPadding.right - self.imageBorderWidth.left - self.imageBorderWidth.right - 20; 317 maxImageHeight = windowHeight - self.containerPadding.top - self.containerPadding.bottom - self.imageBorderWidth.top - self.imageBorderWidth.bottom - self.options.positionFromTop - 70; 318 319 /* 320 SVGs that don't have width and height attributes specified are reporting width and height 321 values of 0 in Firefox 47 and IE11 on Windows. To fix, we set the width and height to the max 322 dimensions for the viewport rather than 0 x 0. 323 324 https://github.com/lokesh/lightbox2/issues/552 325 */ 326 327 if (filetype === 'svg') { 328 if ((preloader.width === 0) || preloader.height === 0) { 329 $image.width(maxImageWidth); 330 $image.height(maxImageHeight); 331 } 332 } 333 334 // Fit image inside the viewport. 335 if (self.options.fitImagesInViewport) { 336 337 // Check if image size is larger then maxWidth|maxHeight in settings 338 if (self.options.maxWidth && self.options.maxWidth < maxImageWidth) { 339 maxImageWidth = self.options.maxWidth; 340 } 341 if (self.options.maxHeight && self.options.maxHeight < maxImageHeight) { 342 maxImageHeight = self.options.maxHeight; 343 } 344 345 } else { 346 maxImageWidth = self.options.maxWidth || preloader.width || maxImageWidth; 347 maxImageHeight = self.options.maxHeight || preloader.height || maxImageHeight; 348 } 349 350 // Is the current image's width or height is greater than the maxImageWidth or maxImageHeight 351 // option than we need to size down while maintaining the aspect ratio. 352 if ((preloader.width > maxImageWidth) || (preloader.height > maxImageHeight)) { 353 if ((preloader.width / maxImageWidth) > (preloader.height / maxImageHeight)) { 354 imageWidth = maxImageWidth; 355 imageHeight = parseInt(preloader.height / (preloader.width / imageWidth), 10); 356 $image.width(imageWidth); 357 $image.height(imageHeight); 358 } else { 359 imageHeight = maxImageHeight; 360 imageWidth = parseInt(preloader.width / (preloader.height / imageHeight), 10); 361 $image.width(imageWidth); 362 $image.height(imageHeight); 363 } 364 } 365 self.sizeContainer($image.width(), $image.height()); 366 }; 367 368 // Preload image before showing 369 preloader.src = this.album[imageNumber].link; 370 this.currentImageIndex = imageNumber; 371 }; 372 373 // Stretch overlay to fit the viewport 374 Lightbox.prototype.sizeOverlay = function() { 375 var self = this; 376 /* 377 We use a setTimeout 0 to pause JS execution and let the rendering catch-up. 378 Why do this? If the `disableScrolling` option is set to true, a class is added to the body 379 tag that disables scrolling and hides the scrollbar. We want to make sure the scrollbar is 380 hidden before we measure the document width, as the presence of the scrollbar will affect the 381 number. 382 */ 383 setTimeout(function() { 384 self.$overlay 385 .width($(document).width()) 386 .height($(document).height()); 387 388 }, 0); 389 }; 390 391 // Animate the size of the lightbox to fit the image we are showing 392 // This method also shows the the image. 393 Lightbox.prototype.sizeContainer = function(imageWidth, imageHeight) { 394 var self = this; 395 396 var oldWidth = this.$outerContainer.outerWidth(); 397 var oldHeight = this.$outerContainer.outerHeight(); 398 var newWidth = imageWidth + this.containerPadding.left + this.containerPadding.right + this.imageBorderWidth.left + this.imageBorderWidth.right; 399 var newHeight = imageHeight + this.containerPadding.top + this.containerPadding.bottom + this.imageBorderWidth.top + this.imageBorderWidth.bottom; 400 401 function postResize() { 402 self.$lightbox.find('.lb-dataContainer').width(newWidth); 403 self.$lightbox.find('.lb-prevLink').height(newHeight); 404 self.$lightbox.find('.lb-nextLink').height(newHeight); 405 406 // Set focus on one of the two root nodes so keyboard events are captured. 407 self.$overlay.focus(); 408 409 self.showImage(); 410 } 411 412 if (oldWidth !== newWidth || oldHeight !== newHeight) { 413 this.$outerContainer.animate({ 414 width: newWidth, 415 height: newHeight 416 }, this.options.resizeDuration, 'swing', function() { 417 postResize(); 418 }); 419 } else { 420 postResize(); 421 } 422 }; 423 424 // Display the image and its details and begin preload neighboring images. 425 Lightbox.prototype.showImage = function() { 426 this.$lightbox.find('.lb-loader').stop(true).hide(); 427 this.$lightbox.find('.lb-image').fadeIn(this.options.imageFadeDuration); 428 429 this.updateNav(); 430 this.updateDetails(); 431 this.preloadNeighboringImages(); 432 this.enableKeyboardNav(); 433 }; 434 435 // Display previous and next navigation if appropriate. 436 Lightbox.prototype.updateNav = function() { 437 // Check to see if the browser supports touch events. If so, we take the conservative approach 438 // and assume that mouse hover events are not supported and always show prev/next navigation 439 // arrows in image sets. 440 var alwaysShowNav = false;
441 try { 442 document.createEvent('TouchEvent'); 443 alwaysShowNav = (this.options.alwaysShowNavOnTouchDevices) ? true : false; 444 } catch (e) {} 445 446 this.$lightbox.find('.lb-nav').show(); 447 448 if (this.album.length > 1) { 449 if (this.options.wrapAround) { 450 if (alwaysShowNav) { 451 this.$lightbox.find('.lb-prev, .lb-next').css('opacity', '1'); 452 } 453 this.$lightbox.find('.lb-prev, .lb-next').show(); 454 } else { 455 if (this.currentImageIndex > 0) { 456 this.$lightbox.find('.lb-prev').show(); 457 if (alwaysShowNav) { 458 this.$lightbox.find('.lb-prev').css('opacity', '1'); 459 } 460 } 461 if (this.currentImageIndex < this.album.length - 1) { 462 this.$lightbox.find('.lb-next').show(); 463 if (alwaysShowNav) { 464 this.$lightbox.find('.lb-next').css('opacity', '1'); 465 } 466 } 467 } 468 } 469 }; 470 471 // Display caption, image number, and closing button. 472 Lightbox.prototype.updateDetails = function() { 473 var self = this; 474 475 // Enable anchor clicks in the injected caption html. 476 // Thanks Nate Wright for the fix. @https://github.com/NateWr 477 if (typeof this.album[this.currentImageIndex].title !== 'undefined' && 478 this.album[this.currentImageIndex].title !== '') { 479 var $caption = this.$lightbox.find('.lb-caption'); 480 if (this.options.sanitizeTitle) { 481 $caption.text(this.album[this.currentImageIndex].title); 482 } else { 483 $caption.html(this.album[this.currentImageIndex].title); 484 } 485 $caption.fadeIn('fast'); 486 } 487 488 if (this.album.length > 1 && this.options.showImageNumberLabel) { 489 var labelText = this.imageCountLabel(this.currentImageIndex + 1, this.album.length); 490 this.$lightbox.find('.lb-number').text(labelText).fadeIn('fast'); 491 } else { 492 this.$lightbox.find('.lb-number').hide(); 493 } 494 495 this.$outerContainer.removeClass('animating'); 496 497 this.$lightbox.find('.lb-dataContainer').fadeIn(this.options.resizeDuration, function() { 498 return self.sizeOverlay(); 499 }); 500 }; 501 502 // Preload previous and next images in set. 503 Lightbox.prototype.preloadNeighboringImages = function() { 504 if (this.album.length > this.currentImageIndex + 1) { 505 var preloadNext = new Image(); 506 preloadNext.src = this.album[this.currentImageIndex + 1].link; 507 } 508 if (this.currentImageIndex > 0) { 509 var preloadPrev = new Image(); 510 preloadPrev.src = this.album[this.currentImageIndex - 1].link; 511 } 512 }; 513 514 Lightbox.prototype.enableKeyboardNav = function() { 515 this.$lightbox.on('keyup.keyboard', $.proxy(this.keyboardAction, this)); 516 this.$overlay.on('keyup.keyboard', $.proxy(this.keyboardAction, this)); 517 }; 518 519 Lightbox.prototype.disableKeyboardNav = function() { 520 this.$lightbox.off('.keyboard'); 521 this.$overlay.off('.keyboard'); 522 }; 523 524 Lightbox.prototype.keyboardAction = function(event) { 525 var KEYCODE_ESC = 27; 526 var KEYCODE_LEFTARROW = 37; 527 var KEYCODE_RIGHTARROW = 39; 528 529 var keycode = event.keyCode; 530 if (keycode === KEYCODE_ESC) { 531 // Prevent bubbling so as to not affect other components on the page. 532 event.stopPropagation(); 533 this.end(); 534 } else if (keycode === KEYCODE_LEFTARROW) { 535 if (this.currentImageIndex !== 0) { 536 this.changeImage(this.currentImageIndex - 1); 537 } else if (this.options.wrapAround && this.album.length > 1) { 538 this.changeImage(this.album.length - 1); 539 } 540 } else if (keycode === KEYCODE_RIGHTARROW) { 541 if (this.currentImageIndex !== this.album.length - 1) { 542 this.changeImage(this.currentImageIndex + 1); 543 } else if (this.options.wrapAround && this.album.length > 1) { 544 this.changeImage(0); 545 } 546 } 547 }; 548 549 // Closing time. :-( 550 Lightbox.prototype.end = function() { 551 this.disableKeyboardNav(); 552 $(window).off('resize', this.sizeOverlay); 553 this.$lightbox.fadeOut(this.options.fadeDuration); 554 this.$overlay.fadeOut(this.options.fadeDuration); 555 556 if (this.options.disableScrolling) { 557 $('body').removeClass('lb-disable-scrolling'); 558 } 559 }; 560 561 return new Lightbox(); 562})); 563 564 565 566/*! waitForImages jQuery Plugin 2017-02-20 */ 567!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){var b="waitForImages",c=function(a){return a.srcset&&a.sizes}(new Image);a.waitForImages={hasImageProperties:["backgroundImage","listStyleImage","borderImage","borderCornerImage","cursor"],hasImageAttributes:["srcset"]},a.expr[":"]["has-src"]=function(b){return a(b).is('img[src][src!=""]')},a.expr[":"].uncached=function(b){return!!a(b).is(":has-src")&&!b.complete},a.fn.waitForImages=function(){var d,e,f,g=0,h=0,i=a.Deferred(),j=this,k=[],l=a.waitForImages.hasImageProperties||[],m=a.waitForImages.hasImageAttributes||[],n=/url\(\s*(['"]?)(.*?)\1\s*\)/g;if(a.isPlainObject(arguments[0])?(f=arguments[0].waitForAll,e=arguments[0].each,d=arguments[0].finished):1===arguments.length&&"boolean"===a.type(arguments[0])?f=arguments[0]:(d=arguments[0],e=arguments[1],f=arguments[2]),d=d||a.noop,e=e||a.noop,f=!!f,!a.isFunction(d)||!a.isFunction(e))throw new TypeError("An invalid callback was supplied.");return this.each(function(){var b=a(this);f?b.find("*").addBack().each(function(){var b=a(this);b.is("img:has-src")&&!b.is("[srcset]")&&k.push({src:b.attr("src"),element:b[0]}),a.each(l,function(a,c){var d,e=b.css(c);if(!e)return!0;for(;d=n.exec(e);)k.push({src:d[2],element:b[0]})}),a.each(m,function(a,c){var d=b.attr(c);return!d||void k.push({src:b.attr("src"),srcset:b.attr("srcset"),element:b[0]})})}):b.find("img:has-src").each(function(){k.push({src:this.src,element:this})})}),g=k.length,h=0,0===g&&(d.call(j),i.resolveWith(j)),a.each(k,function(f,k){var l=new Image,m="load."+b+" error."+b;a(l).one(m,function b(c){var f=[h,g,"load"==c.type];
567if(h++,e.apply(k.element,f),i.notifyWith(k.element,f),a(this).off(m,b),h==g)return d.call(j[0]),i.resolveWith(j[0]),!1}),c&&k.srcset&&(l.srcset=k.srcset,l.sizes=k.sizes),l.src=k.src}),i.promise()}}); 568 569/* Sticky Columns */ 570(function(){var b,f;b=this.jQuery||window.jQuery;f=b(window);b.fn.stick_in_parent=function(d){var A,w,J,n,B,K,p,q,k,E,t;null==d&&(d={});t=d.sticky_class;B=d.inner_scrolling;E=d.recalc_every;k=d.parent;q=d.offset_top;p=d.spacer;w=d.bottoming;null==q&&(q=0);null==k&&(k=void 0);null==B&&(B=!0);null==t&&(t="is_stuck");A=b(document);null==w&&(w=!0);J=function(a,d,n,C,F,u,r,G){var v,H,m,D,I,c,g,x,y,z,h,l;if(!a.data("sticky_kit")){a.data("sticky_kit",!0);I=A.height();g=a.parent();null!=k&&(g=g.closest(k)); 571if(!g.length)throw"failed to find stick parent";v=m=!1;(h=null!=p?p&&a.closest(p):b("<div />"))&&h.css("position",a.css("position"));x=function(){var c,f,e;if(!G&&(I=A.height(),c=parseInt(g.css("border-top-width"),10),f=parseInt(g.css("padding-top"),10),d=parseInt(g.css("padding-bottom"),10),n=g.offset().top+c+f,C=g.height(),m&&(v=m=!1,null==p&&(a.insertAfter(h),h.detach()),a.css({position:"",top:"",width:"",bottom:""}).removeClass(t),e=!0),F=a.offset().top-(parseInt(a.css("margin-top"),10)||0)-q, 572u=a.outerHeight(!0),r=a.css("float"),h&&h.css({width:a.outerWidth(!0)-1,height:u,display:a.css("display"),"vertical-align":a.css("vertical-align"),"float":r}),e))return l()};x();if(u!==C)return D=void 0,c=q,z=E,l=function(){var b,l,e,k;if(!G&&(e=!1,null!=z&&(--z,0>=z&&(z=E,x(),e=!0)),e||A.height()===I||x(),e=f.scrollTop(),null!=D&&(l=e-D),D=e,m?(w&&(k=e+u+c>C+n,v&&!k&&(v=!1,a.css({position:"fixed",bottom:"",top:c}).trigger("sticky_kit:unbottom"))),e<F&&(m=!1,c=q,null==p&&("left"!==r&&"right"!==r||a.insertAfter(h), 573h.detach()),b={position:"",width:"",top:""},a.css(b).removeClass(t).trigger("sticky_kit:unstick")),B&&(b=f.height(),u+q>b&&!v&&(c-=l,c=Math.max(b-u,c),c=Math.min(q,c),m&&a.css({top:c+"px"})))):e>F&&(m=!0,b={position:"fixed",top:c},b.width="border-box"===a.css("box-sizing")?a.outerWidth()+"px":a.width()+"px",a.css(b).addClass(t),null==p&&(a.after(h),"left"!==r&&"right"!==r||h.append(a)),a.trigger("sticky_kit:stick")),m&&w&&(null==k&&(k=e+u+c>C+n),!v&&k)))return v=!0,"static"===g.css("position")&&g.css({position:"initial"}), 574a.css({position:"absolute",bottom:d,top:"auto"}).trigger("sticky_kit:bottom")},y=function(){x();return l()},H=function(){G=!0;f.off("touchmove",l);f.off("scroll",l);f.off("resize",y);b(document.body).off("sticky_kit:recalc",y);a.off("sticky_kit:detach",H);a.removeData("sticky_kit");a.css({position:"",bottom:"",top:"",width:""});g.position("position","");if(m)return null==p&&("left"!==r&&"right"!==r||a.insertAfter(h),h.remove()),a.removeClass(t)},f.on("touchmove",l),f.on("scroll",l),f.on("resize", 575y),b(document.body).on("sticky_kit:recalc",y),a.on("sticky_kit:detach",H),setTimeout(l,0)}};n=0;for(K=this.length;n<K;n++)d=this[n],J(b(d));return this}}).call(this); 576 577/* Plugin Scripts */ 578var $ = jQuery.noConflict(); 579 580jQuery(function ($) { 'use strict'; 581 582if (jQuery(".gusta-sticky-column").length > 0) { 583 jQuery(".gusta-sticky-column").stick_in_parent(); 584} 585 586if (jQuery('body').hasClass('admin-bar')) { 587 jQuery(window).on('load resize scroll',function(){ 588 var admBar = 0; 589 var scwidth = jQuery( window ).width(); 590 if (scwidth<782) { admBar = 46; } else { admBar = 32; } 591 var scrolled = jQuery(this).scrollTop();; 592 if (scrolled<admBar) { 593 if (scwidth<600) { 594 var toppos = admBar - scrolled; 595 jQuery('.admin-bar div[class*="sticky-top"]').css('top', toppos + 'px'); 596 } else { 597 jQuery('.admin-bar div[class*="sticky-top"]').css('top', admBar + 'px'); 598 } 599 } else { 600 if (scwidth<600) { jQuery('.admin-bar div[class*="sticky-top"]').css('top', '0px'); } 601 } 602 }); 603} 604 605/* Product Review */ 606$('.gusta-product-reviews .comment-form-rating #rating, .gusta-product-reviews .gusta_wc_rate_wrapper input').change(gustaupdateElements); 607 608function gustaupdateElements(e) { 609 var valueAttribute = '[value="' + e.target.value + '"]'; 610 $('.gusta-product-reviews .comment-form-rating #rating option' + valueAttribute).prop('selected', true); 611 $('.gusta-product-reviews .gusta_wc_rate_wrapper input' + valueAttribute).prop('checked', true); 612} 613 614/* For the Second level Dropdown menu, highlight the parent */ 615(function () { $(".dropdown-menu") .mouseenter(function () { $(this).parent('li').addClass('active'); }) .mouseleave(function () { $(this).parent('li').removeClass('active'); }); }()); 616 617/* iOS Click Fix */ 618(function () { if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { $('*').css('cursor', 'pointer'); } }()); 619 620/* Fix Full Width for Custom vc_row */ 621jQuery(function() { jQuery('.gusta-full-width').each(function() { jQuery(this).addClass('vc_row-full-width').attr( 'data-vc-full-width', 'true' ); jQuery(this).find('div').first().css('position','initial'); }); }); 622 623/* Section Toggle */ 624(function () { jQuery(".gusta-section-toggle:not(.gusta-toggle-on-hover)").on("click", function() { 625 var data_toggle = jQuery(this).data("toggle"); 626 if (jQuery(this).hasClass('active')) { 627 jQuery(".gusta-section-toggle").removeClass("active"); 628 } else { 629 jQuery(".gusta-section-toggle").removeClass("active"); 630 jQuery("[data-toggle='" + data_toggle + "']").addClass("active"); 631 } 632 if (jQuery("#" + data_toggle + "").hasClass("section-vertical")) { 633 jQuery('body[class*="gusta-vertical-header"]').toggleClass('gusta-body-zero-margin'); 634 } 635 window.dispatchEvent(new Event('resize')); 636}); 637$( ".gusta-section-toggle.gusta-toggle-on-hover" ).mouseover(function() { 638 var data_toggle = jQuery(this).data("toggle"); 639 var disable_scroll = jQuery(this).data('disable-scroll'); 640 jQuery('.hide-by-default, .gusta-show-section').addClass('gusta-hide-section').removeClass('gusta-show-section gusta-higher'); 641 jQuery("#" + data_toggle + "").removeClass('gusta-hide-section').addClass('gusta-show-section gusta-higher'); 642 if (disable_scroll) { 643 jQuery('html,body').addClass('disable-scroll'); 644 } else { 645 jQuery('html,body').removeClass('disable-scroll'); 646 } 647 if (jQuery("#" + data_toggle + "").hasClass("section-vertical")) { 648 jQuery('body[class*="gusta-vertical-header"]').addClass('gusta-body-zero-margin'); 649 } 650 jQuery(".gusta-section-toggle").removeClass("active"); 651 jQuery("[data-toggle='" + data_toggle + "']").addClass("active"); 652 gusta_fix_vc_full_width(); 653 }) 654 .mouseout(function() {}); 655}()); 656 657jQuery('.gusta-section-toggle:not(.gusta-toggle-on-hover)').click(function(){ 658 var section = '#' + jQuery(this).data('toggle'); 659 var disable_scroll = jQuery(this).data('disable-scroll'); 660 /*if (jQuery(this).hasClass('active')) { 661 jQuery('.hide-by-default').addClass('gusta-hide-section').removeClass('gusta-show-section gusta-higher'); 662 jQuery(section).addClass('gusta-hide-section').removeClass('gusta-show-section gusta-higher'); 663 jQuery('html,body').removeClass('disable-scroll'); 664 } else { */ 665 jQuery('.hide-by-default:not('+section+')').addClass('gusta-hide-section').removeClass('gusta-show-section gusta-higher'); 666 jQuery(section).toggleClass('gusta-hide-section').toggleClass('gusta-show-section gusta-higher'); 667 668 if (disable_scroll) { 669 jQuery('html,body').toggleClass('disable-scroll'); 670 } else { 671 jQuery('html,body').removeClass('disable-scroll'); 672 } 673 //} 674 gusta_fix_vc_full_width(); 675}); 676 677/*$(document).click(function(e) { 678 $(".gusta-show-section").each(function() { 679 var section_id = $(this).attr('id'); 680 if ($('[data-toggle="'+section_id+'"]').hasClass('.gusta-toggle-on-hover')) { 681 if (!section_id.is(e.target) && section_id.has(e.target).length === 0) { 682 jQuery(".gusta-section-toggle").removeClass("active"); 683 section_id.removeClass('gusta-show-section gusta-higher').addClass('gusta-hide-section hide-by-default'); 684 jQuery('body, html').removeClass('disable-scroll'); 685 if (jQuery(section_id).hasClass("section-vertical")) { 686 jQuery('body[class*="gusta-vertical-header"]').toggleClass('gusta-body-zero-margin'); 687 } 688 } 689 } 690 }); 691});*/ 692 693/* Close Button */ 694jQuery('.gusta-close-button').on('click', function() { 695 var container = jQuery(this).closest('.gusta-section'); 696 jQuery(".gusta-section-toggle").removeClass("active"); 697 container.removeClass('gusta-show-section gusta-higher').addClass('gusta-hide-section hide-by-default'); 698 jQuery('body, html').removeClass('disable-scroll');
699 if (jQuery(container).hasClass("section-vertical")) { 700 jQuery('body[class*="gusta-vertical-header"]').toggleClass('gusta-body-zero-margin'); 701 } 702}); 703 704jQuery('.gusta-nav').find('select').on('change', function() { var selected = jQuery(this).find(':selected').val(); if (selected!='') { window.location.href = selected; } }); 705 706jQuery.fn.element_cover = function() { 707 jQuery('.gusta-cover-row').each(function() { 708 jQuery(this).parentsUntil('.wpb_row').css('position','initial'); 709 jQuery(this).closest('.wpb_row').css({'position':'relative', 'z-index':'0'}); 710 }); 711 jQuery('.gusta-cover-column').each(function() { 712 jQuery(this).parentsUntil('.wpb_column').css('position','initial'); 713 jQuery(this).closest('.wpb_column').css({'position':'relative', 'z-index':'0'}); 714 }); 715}; 716jQuery(function() { jQuery('body').element_cover(); }); 717/*jQuery ('.gusta-mega-menu, .gusta-dropdown-menu').parentsUntil('.wpb_row').css('position','initial');*/ 718jQuery ('.gusta-mega-menu, .gusta-dropdown-menu').closest('.wpb_row').css({'position':'relative', 'overflow':'initial'}); 719 720(function () { jQuery(document).ready(function() { 721/* Swipe Box (Lightbox) */ 722//jQuery( '.swipebox' ).swipebox(); 723 724jQuery('.post-listing-container').addClass('show-container'); }); }()); 725 726/* Smooth Scroll */ 727(function () { $(".smooth-scroll:not(body),.smooth-scroll:not(body) a").click(function(event){ event.preventDefault(); var dest=0; var hash = this.hash; if (hash=='undefined') { var offs = $(hash).offset(); var offtop = offs.top; if(offtop > $(document).height()-$(window).height()){ dest=$(document).height()-$(window).height(); } else { dest=offs.top; } $('html,body').animate({scrollTop:dest}, 1000,'swing'); } }); }()); 728 729(function () { $('.gusta-mega-menu-item').hover(function(e) { gusta_fix_vc_full_width() }); }()); 730 731(function() { 732 $('.gusta-nav.horizontal:not(.no-child)').hover(function(){ 733 $(this).gusta_higher(); 734 }); 735 736 $('.gusta-search-form').hover(function(){ 737 $(this).gusta_higher(); 738 }); 739 740 $('.vertical .gusta-dropdown i').click(function(){ 741 $(this).parent().toggleClass('gusta-children-open'); 742 $(this).toggleClass('fa-minus fa-plus'); 743 }); 744 745 $(window).on('load resize scroll',function(){ 746 if ($(window).width() < 751) { 747 $('.gusta-nav.gusta-nav-responsive').addClass('select').removeClass('horizontal'); 748 } else { 749 $('.gusta-nav.gusta-nav-responsive').removeClass('select').addClass('horizontal'); 750 } 751 }); 752}()); 753 754/* Mega Menu On Click 755(function () { jQuery(".gusta-mega-menu-on-click a").on("click", function() { if (jQuery(this).parent().hasClass('gusta-mega-menu-active')) { jQuery(this).parent().removeClass('gusta-mega-menu-active'); } else { jQuery(this).parent().addClass('gusta-mega-menu-active'); gusta_fix_vc_full_width(); } }); }());*/ 756$('li[class*="gusta-menu-item"]').each(function() { 757 $(this).addClass('menu-item'); 758}); 759$('.menu-item').click(function () { 760if ($(this).parent().parent().find(".gusta-mega-menu").length > 0){ 761 var menu_item_id = $(this).attr('class'); 762 var mega_menu_id = ''; 763 var splitString = menu_item_id.split(" "); 764 $.each(splitString, function( index, value ) { 765 if (value.indexOf("menu-item-") >= 0) { 766 mega_menu_id = value.replace('gusta-',''); 767 mega_menu_id = mega_menu_id.replace('menu-item-','gusta-mega-menu-'); 768 } 769 }); 770 if( $('#' + mega_menu_id).length ) { 771 if ($('#' + mega_menu_id).hasClass('gusta-trigger-on-click')) { 772 $('#' + mega_menu_id).toggleClass('gusta-mega-menu-active'); 773 $(this).toggleClass('current-menu-item'); 774 } 775 } 776 } 777}); 778$('.menu-item').hover(function () { 779if ($(this).parent().parent().find(".gusta-mega-menu").length > 0){ 780 var menu_item_id = $(this).attr('class'); 781 var mega_menu_id = ''; 782 var splitString = menu_item_id.split(" "); 783 $.each(splitString, function( index, value ) { 784 if (value.indexOf("menu-item-") >= 0) { 785 mega_menu_id = value.replace('gusta-',''); 786 mega_menu_id = mega_menu_id.replace('menu-item-','gusta-mega-menu-'); 787 } 788 }); 789 790 if( $('#' + mega_menu_id).length ) { 791 if ($(this).parent().parent().find('#' + mega_menu_id).hasClass('gusta-trigger-on-
791hover')) { 792 $(this).parent().parent().find('#' + mega_menu_id).addClass('gusta-mega-menu-active'); 793 $(this).addClass('current-menu-item'); 794 gusta_fix_vc_full_width(); 795 } 796 } 797 } 798}, function() { 799 if ($(this).parent().parent().find(".gusta-mega-menu").length > 0){ 800 if ( $('.gusta-mega-menu.gusta-trigger-on-hover:hover').length === 0 ) { 801 $( '.gusta-trigger-on-hover' ).removeClass( "gusta-mega-menu-active" ); 802 var menu_item_id = $(this).attr('class'); 803 var mega_menu_id = ''; 804 var splitString = menu_item_id.split(" "); 805 $.each(splitString, function( index, value ) { 806 if (value.indexOf("menu-item-") >= 0) { 807 mega_menu_id = value.replace('gusta-',''); 808 mega_menu_id = mega_menu_id.replace('menu-item-','gusta-mega-menu-'); 809 } 810 }); 811 if ($('#' + mega_menu_id).length > 0) { 812 $(this).removeClass('current-menu-item'); 813 } 814 } 815 } 816}); 817$('.gusta-mega-menu.gusta-trigger-on-hover').hover(function () { 818 var mega_menu_id = $(this).attr('id'); 819 var menu_item_id = mega_menu_id.replace('gusta-mega-menu-','menu-item-'); 820 $(this).addClass('gusta-mega-menu-active'); 821 $('#' + menu_item_id).addClass('current-menu-item'); 822}, function () { 823 if(!$('input').is(':focus')) { 824 var mega_menu_id = $(this).attr('id'); 825 var menu_item_id = mega_menu_id.replace('gusta-mega-menu-','menu-item-'); 826 $(this).removeClass('gusta-mega-menu-active'); 827 $('#' + menu_item_id).removeClass('current-menu-item'); 828 $('#gusta-' + menu_item_id+', .gusta-' + menu_item_id).removeClass('current-menu-item'); 829 } 830}); 831 832}); // JQuery end 833 834jQuery(window).on('load resize', function(event) { 835 setTimeout( 836 function() 837 { 838 jQuery('.owl-carousel').each(function() { 839 var $this = jQuery(this); 840 var theight = $this.find('.owl-item.active').height(); 841 842 $this.find('.owl-height').css('height', theight ); 843 }); 844 }, 100); 845}); 846 847jQuery.fn.gusta_higher = function() { 848 jQuery('.ss-element').removeClass('gusta-higher'); 849 jQuery('.vc_row').removeClass('gusta-higher'); 850 jQuery('.gusta-section').removeClass('gusta-higher'); 851 jQuery(this).addClass('gusta-higher'); 852 jQuery(this).closest('.vc_row').addClass('gusta-higher'); 853 jQuery(this).closest('.gusta-section').addClass('gusta-higher'); 854 jQuery(this).parent().parent().parent().parent().parent().closest('.vc_row').addClass('gusta-higher'); 855}; 856 857jQuery.fn.auto_suggest = function( options ) { 858 859 var results = jQuery(this).find('.results'); 860 var search_term = jQuery(this).find('input').val(); 861 var post_types = jQuery(this).find('input').data('posttypes'); 862 var curr = 0; 863 864 var auto_suggest = function(){ 865 jQuery.ajax({ 866 type : 'post', 867 data : { 868 search_term: search_term, 869 post_types: post_types, 870 action: 'gusta_auto_suggest' 871 }, 872 dataType : 'html', 873 url : smart_sections.ajaxurl, 874 success : function(response){ 875 if (response) { 876 var newItems = jQuery(response); 877 results.html( newItems ); 878 } else { 879 results.html( '' ); 880 } 881 }, 882 error : function(jqXHR, textStatus, errorThrown) { 883 console.log(jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown); 884 } 885 }); 886 }; 887 auto_suggest(); 888 889 jQuery(document).mouseup(function(e) { 890 if (!jQuery('.results').parent().is(e.target) && jQuery('.results').parent().has(e.target).length === 0) { 891 jQuery('.results').html(''); 892 } 893 }); 894 895}; 896 897jQuery.fn.update_cart = function( options ) { 898 var results = jQuery(this); 899 var current_cart_count = jQuery(this).find('.gusta-cart-count').html(); 900 var cart_type = jQuery(this).data('.cart-type'); 901 var update_cart = function(){ 902 jQuery.ajax({ 903 type : 'post', 904 data : { 905 current_cart_count: current_cart_count, 906 cart_type: cart_type, 907 action: 'gusta_update_cart' 908 }, 909 dataType : 'html', 910 url : smart_sections.ajaxurl, 911 success : function(response){ 912 if (response) { 913 var newItems = jQuery(response); 914 results.html( newItems ); 915 } 916 }, 917 error : function(jqXHR, textStatus, errorThrown) { 918 console.log(jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown); 919 } 920 }); 921 }; 922 update_cart(); 923 924}; 925 926jQuery.fn.update_cart_count = function( options ) { 927 var results = jQuery(this); 928 var update_cart_count = function(){ 929 jQuery.ajax({ 930 type : 'post', 931 data : { 932 action: 'gusta_update_cart_count' 933 }, 934 dataType : 'html', 935 url : smart_sections.ajaxurl, 936 success : function(response){ 937 if (response) { 938 results.html( response ); 939 } 940 }, 941 error : function(jqXHR, textStatus, errorThrown) { 942 console.log(jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown); 943 } 944 }); 945 }; 946 update_cart_count(); 947 948}; 949 950window.setInterval(function(){ 951 jQuery('.gusta-cart-icon').each(function() { 952 jQuery(this).find('.gusta-cart-count').update_cart_count(); 953 jQuery(this).find('.gusta-shopping-cart').update_cart(); 954 }); 955 }, 10000);
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.