1!function(a,b){var c=b(a,a.document);a.lazySizes=c,"object"==typeof module&&module.exports&&(module.exports=c)}("undefined"!=typeof window?window:{},function(a,b){"use strict";var c,d;if(function(){var b,c={lazyClass:"lazyload",loadedClass:"lazyloaded",loadingClass:"lazyloading",preloadClass:"lazypreload",errorClass:"lazyerror",autosizesClass:"lazyautosizes",srcAttr:"data-src",srcsetAttr:"data-srcset",sizesAttr:"data-sizes",minSize:40,customMedia:{},init:!0,expFactor:1.5,hFac:.8,loadMode:2,loadHidden:!0,ricTimeout:0,throttleDelay:125};d=a.lazySizesConfig||a.lazysizesConfig||{};for(b in c)b in d||(d[b]=c[b])}(),!b||!b.getElementsByClassName)return{init:function(){},cfg:d,noSupport:!0};var e=b.documentElement,f=a.Date,g=a.HTMLPictureElement,h="addEventListener",i="getAttribute",j=a[h],k=a.setTimeout,l=a.requestAnimationFrame||k,m=a.requestIdleCallback,n=/^picture$/i,o=["load","error","lazyincluded","_lazyloaded"],p={},q=Array.prototype.forEach,r=function(a,b){return p[b]||(p[b]=new RegExp("(\\s|^)"+b+"(\\s|$)")),p[b].test(a[i]("class")||"")&&p[b]},s=function(a,b){r(a,b)||a.setAttribute("class",(a[i]("class")||"").trim()+" "+b)},t=function(a,b){var c;(c=r(a,b))&&a.setAttribute("class",(a[i]("class")||"").replace(c," "))},u=function(a,b,c){var d=c?h:"removeEventListener";c&&u(a,b),o.forEach(function(c){a[d](c,b)})},v=function(a,d,e,f,g){var h=b.createEvent("Event");return e||(e={}),e.instance=c,h.initEvent(d,!f,!g),h.detail=e,a.dispatchEvent(h),h},w=function(b,c){var e;!g&&(e=a.picturefill||d.pf)?(c&&c.src&&!b[i]("srcset")&&b.setAttribute("srcset",c.src),e({reevaluate:!0,elements:[b]})):c&&c.src&&(b.src=c.src)},x=function(a,b){return(getComputedStyle(a,null)||{})[b]},y=function(a,b,c){for(c=c||a.offsetWidth;c<d.minSize&&b&&!a._lazysizesWidth;)c=b.offsetWidth,b=b.parentNode;return c},z=function(){var a,c,d=[],e=[],f=d,g=function(){var b=f;for(f=d.length?e:d,a=!0,c=!1;b.length;)b.shift()();a=!1},h=function(d,e){a&&!e?d.apply(this,arguments):(f.push(d),c||(c=!0,(b.hidden?k:l)(g)))};return h._lsFlush=g,h}(),A=function(a,b){return b?function(){z(a)}:function(){var b=this,c=arguments;z(function(){a.apply(b,c)})}},B=function(a){var b,c=0,e=d.throttleDelay,g=d.ricTimeout,h=function(){b=!1,c=f.now(),a()},i=m&&g>49?function(){m(h,{timeout:g}),g!==d.ricTimeout&&(g=d.ricTimeout)}:A(function(){k(h)},!0);return function(a){var d;(a=!0===a)&&(g=33),b||(b=!0,d=e-(f.now()-c),d<0&&(d=0),a||d<9?i():k(i,d))}},C=function(a){var b,c,d=99,e=function(){b=null,a()},g=function(){var a=f.now()-c;a<d?k(g,d-a):(m||e)(e)};return function(){c=f.now(),b||(b=k(g,d))}},D=function(){var g,l,m,o,p,y,D,F,G,H,I,J,K=/^img$/i,L=/^iframe$/i,M="onscroll"in a&&!/(gle|ing)bot/.test(navigator.userAgent),N=0,O=0,P=0,Q=-1,R=function(a){P--,(!a||P<0||!a.target)&&(P=0)},S=function(a){return null==J&&(J="hidden"==x(b.body,"visibility")),J||"hidden"!=x(a.parentNode,"visibility")&&"hidden"!=x(a,"visibility")},T=function(a,c){var d,f=a,g=S(a);for(F-=c,I+=c,G-=c,H+=c;g&&(f=f.offsetParent)&&f!=b.body&&f!=e;)(g=(x(f,"opacity")||1)>0)&&"visible"!=x(f,"overflow")&&(d=f.getBoundingClientRect(),g=H>d.left&&G<d.right&&I>d.top-1&&F<d.bottom+1);return g},U=function(){var a,f,h,j,k,m,n,p,q,r,s,t,u=c.elements;if((o=d.loadMode)&&P<8&&(a=u.length)){for(f=0,Q++;f<a;f++)if(u[f]&&!u[f]._lazyRace)if(!M||c.prematureUnveil&&c.prematureUnveil(u[f]))aa(u[f]);else if((p=u[f][i]("data-expand"))&&(m=1*p)||(m=O),r||(r=!d.expand||d.expand<1?e.clientHeight>500&&e.clientWidth>500?500:370:d.expand,c._defEx=r,s=r*d.expFactor,t=d.hFac,J=null,O<s&&P<1&&Q>2&&o>2&&!b.hidden?(O=s,Q=0):O=o>1&&Q>1&&P<6?r:N),q!==m&&(y=innerWidth+m*t,D=innerHeight+m,n=-1*m,q=m),h=u[f].getBoundingClientRect(),(I=h.bottom)>=n&&(F=h.top)<=D&&(H=h.right)>=n*t&&(G=h.left)<=y&&(I||H||G||F)&&(d.loadHidden||S(u[f]))&&(l&&P<3&&!p&&(o<3||Q<4)||T(u[f],m))){if(aa(u[f]),k=!0,P>9)break}else!k&&l&&!j&&P<4&&Q<4&&o>2&&(g[0]||d.preloadAfterLoad)&&(g[0]||!p&&(I||H||G||F||"auto"!=u[f][i](d.sizesAttr)))&&(j=g[0]||u[f]);j&&!k&&aa(j)}},V=B(U),W=function(a){var b=a.target;if(b._lazyCache)return void delete b._lazyCache;R(a),s(b,d.loadedClass),t(b,d.loadingClass),u(b,Y),v(b,"lazyloaded")},X=A(W),Y=function(a){X({target:a.target})},Z=function(a,b){try{a.contentWindow.location.replace(b)}catch(c){a.src=b}},$=function(a){var b,c=a[i](d.srcsetAttr);(b=d.customMedia[a[i]("data-media")||a[i]("media")])&&a.setAttribute("media",b),c&&a.setAttribute("srcset",c)},_=A(function(a,b,c,e,f){var g,h,j,l,o,p;
1(o=v(a,"lazybeforeunveil",b)).defaultPrevented||(e&&(c?s(a,d.autosizesClass):a.setAttribute("sizes",e)),h=a[i](d.srcsetAttr),g=a[i](d.srcAttr),f&&(j=a.parentNode,l=j&&n.test(j.nodeName||"")),p=b.firesLoad||"src"in a&&(h||g||l),o={target:a},s(a,d.loadingClass),p&&(clearTimeout(m),m=k(R,2500),u(a,Y,!0)),l&&q.call(j.getElementsByTagName("source"),$),h?a.setAttribute("srcset",h):g&&!l&&(L.test(a.nodeName)?Z(a,g):a.src=g),f&&(h||l)&&w(a,{src:g})),a._lazyRace&&delete a._lazyRace,t(a,d.lazyClass),z(function(){var b=a.complete&&a.naturalWidth>1;p&&!b||(b&&s(a,"ls-is-cached"),W(o),a._lazyCache=!0,k(function(){"_lazyCache"in a&&delete a._lazyCache},9)),"lazy"==a.loading&&P--},!0)}),aa=function(a){if(!a._lazyRace){var b,c=K.test(a.nodeName),e=c&&(a[i](d.sizesAttr)||a[i]("sizes")),f="auto"==e;(!f&&l||!c||!a[i]("src")&&!a.srcset||a.complete||r(a,d.errorClass)||!r(a,d.lazyClass))&&(b=v(a,"lazyunveilread").detail,f&&E.updateElem(a,!0,a.offsetWidth),a._lazyRace=!0,P++,_(a,b,f,e,c))}},ba=C(function(){d.loadMode=3,V()}),ca=function(){3==d.loadMode&&(d.loadMode=2),ba()},da=function(){if(!l){if(f.now()-p<999)return void k(da,999);l=!0,d.loadMode=3,V(),j("scroll",ca,!0)}};return{_:function(){p=f.now(),c.elements=b.getElementsByClassName(d.lazyClass),g=b.getElementsByClassName(d.lazyClass+" "+d.preloadClass),j("scroll",V,!0),j("resize",V,!0),a.MutationObserver?new MutationObserver(V).observe(e,{childList:!0,subtree:!0,attributes:!0}):(e[h]("DOMNodeInserted",V,!0),e[h]("DOMAttrModified",V,!0),setInterval(V,999)),j("hashchange",V,!0),["focus","mouseover","click","load","transitionend","animationend"].forEach(function(a){b[h](a,V,!0)}),/d$|^c/.test(b.readyState)?da():(j("load",da),b[h]("DOMContentLoaded",V),k(da,2e4)),c.elements.length?(U(),z._lsFlush()):V()},checkElems:V,unveil:aa,_aLSL:ca}}(),E=function(){var a,c=A(function(a,b,c,d){var e,f,g;if(a._lazysizesWidth=d,d+="px",a.setAttribute("sizes",d),n.test(b.nodeName||""))for(e=b.getElementsByTagName("source"),f=0,g=e.length;f<g;f++)e[f].setAttribute("sizes",d);c.detail.dataAttr||w(a,c.detail)}),e=function(a,b,d){var e,f=a.parentNode;f&&(d=y(a,f,d),e=v(a,"lazybeforesizes",{width:d,dataAttr:!!b}),e.defaultPrevented||(d=e.detail.width)&&d!==a._lazysizesWidth&&c(a,f,e,d))},f=function(){var b,c=a.length;if(c)for(b=0;b<c;b++)e(a[b])},g=C(f);return{_:function(){a=b.getElementsByClassName(d.autosizesClass),j("resize",g)},checkElems:g,updateElem:e}}(),F=function(){!F.i&&b.getElementsByClassName&&(F.i=!0,E._(),D._())};return k(function(){d.init&&F()}),c={cfg:d,autoSizer:E,loader:D,init:F,uP:w,aC:s,rC:t,hC:r,fire:v,gW:y,rAF:z}}); 2 3 4 5( function( window, factory ) { 6 if ( typeof define == 'function' && define.amd ) { 7 define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) { 8 return factory( window, jQuery ); 9 }); 10 } else if ( typeof module == 'object' && module.exports ) { 11 module.exports = factory( 12 window, 13 require('jquery') 14 ); 15 } else { 16 window.jQueryBridget = factory( 17 window, 18 window.jQuery 19 ); 20 } 21 22}( window, function factory( window, jQuery ) { 23'use strict'; 24 25 26var arraySlice = Array.prototype.slice; 27 28var console = window.console; 29var logError = typeof console == 'undefined' ? function() {} : 30 function( message ) { 31 console.error( message ); 32 }; 33 34 35function jQueryBridget( namespace, PluginClass, $ ) { 36 $ = $ || jQuery || window.jQuery; 37 if ( !$ ) { 38 return; 39 } 40 41 if ( !PluginClass.prototype.option ) { 42 PluginClass.prototype.option = function( opts ) { 43 if ( !$.isPlainObject( opts ) ){ 44 return; 45 } 46 this.options = $.extend( true, this.options, opts ); 47 }; 48 } 49 50 $.fn[ namespace ] = function( arg0 ) { 51 if ( typeof arg0 == 'string' ) { 52 var args = arraySlice.call( arguments, 1 ); 53 return methodCall( this, arg0, args ); 54 } 55 plainCall( this, arg0 ); 56 return this; 57 }; 58 59 function methodCall( $elems, methodName, args ) { 60 var returnValue; 61 var pluginMethodStr = '$().' + namespace + '("' + methodName + '")'; 62 63 $elems.each( function( i, elem ) { 64 var instance = $.data( elem, namespace ); 65 if ( !instance ) { 66 logError( namespace + ' not initialized. Cannot call methods, i.e. ' + 67 pluginMethodStr ); 68 return; 69 } 70 71 var method = instance[ methodName ]; 72 if ( !method || methodName.charAt(0) == '_' ) { 73 logError( pluginMethodStr + ' is not a valid method' ); 74 return; 75 } 76 77 var value = method.apply( instance, args ); 78 returnValue = returnValue === undefined ? value : returnValue; 79 }); 80 81 return returnValue !== undefined ? returnValue : $elems; 82 } 83 84 function plainCall( $elems, options ) { 85 $elems.each( function( i, elem ) { 86 var instance = $.data( elem, namespace ); 87 if ( instance ) { 88 instance.option( options ); 89 instance._init(); 90 } else { 91 instance = new PluginClass( elem, options ); 92 $.data( elem, namespace, instance ); 93 } 94 }); 95 } 96 97 updateJQuery( $ ); 98 99} 100 101 102function updateJQuery( $ ) { 103 if ( !$ || ( $ && $.bridget ) ) { 104 return; 105 } 106 $.bridget = jQueryBridget; 107} 108 109updateJQuery( jQuery || window.jQuery ); 110 111 112return jQueryBridget; 113 114})); 115 116 117 118( function( global, factory ) { 119 if ( typeof define == 'function' && define.amd ) { 120 define( 'ev-emitter/ev-emitter',factory ); 121 } else if ( typeof module == 'object' && module.exports ) { 122 module.exports = factory(); 123 } else { 124 global.EvEmitter = factory(); 125 } 126 127}( typeof window != 'undefined' ? window : this, function() { 128 129 130 131function EvEmitter() {} 132 133var proto = EvEmitter.prototype; 134 135proto.on = function( eventName, listener ) { 136 if ( !eventName || !listener ) { 137 return; 138 } 139 var events = this._events = this._events || {}; 140 var listeners = events[ eventName ] = events[ eventName ] || []; 141 if ( listeners.indexOf( listener ) == -1 ) { 142 listeners.push( listener ); 143 } 144 145 return this; 146}; 147 148proto.once = function( eventName, listener ) { 149 if ( !eventName || !listener ) { 150 return; 151 } 152 this.on( eventName, listener ); 153 var onceEvents = this._onceEvents = this._onceEvents || {}; 154 var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {}; 155 onceListeners[ listener ] = true; 156 157 return this; 158}; 159 160proto.off = function( eventName, listener ) { 161 var listeners = this._events && this._events[ eventName ]; 162 if ( !listeners || !listeners.length ) { 163 return; 164 } 165 var index = listeners.indexOf( listener ); 166 if ( index != -1 ) { 167 listeners.splice( index, 1 ); 168 } 169 170 return this; 171}; 172 173proto.emitEvent = function( eventName, args ) { 174 var listeners = this._events && this._events[ eventName ]; 175 if ( !listeners || !listeners.length ) { 176 return; 177 } 178 listeners = listeners.slice(0); 179 args = args || []; 180 var onceListeners = this._onceEvents && this._onceEvents[ eventName ]; 181 182 for ( var i=0; i < listeners.length; i++ ) { 183 var listener = listeners[i] 184 var isOnce = onceListeners && onceListeners[ listener ]; 185 if ( isOnce ) { 186 this.off( eventName, listener ); 187 delete onceListeners[ listener ]; 188 } 189 listener.apply( this, args ); 190 } 191 192 return this; 193}; 194 195proto.allOff = function() { 196 delete this._events; 197 delete this._onceEvents; 198}; 199 200return EvEmitter; 201 202})); 203 204 205 206( function( window, factory ) { 207 if ( typeof define == 'function' && define.amd ) { 208 define( 'get-size/get-size',factory ); 209 } else if ( typeof module == 'object' && module.exports ) { 210 module.exports = factory(); 211 } else { 212 window.getSize = factory(); 213 } 214 215})( window, function factory() { 216'use strict'; 217 218 219function getStyleSize( value ) { 220 var num = parseFloat( value ); 221 var isValid = value.indexOf('%') == -1 && !isNaN( num ); 222 return isValid && num; 223} 224 225function noop() {} 226 227var logError = typeof console == 'undefined' ? noop : 228 function( message ) { 229 console.error( message ); 230 }; 231 232 233var measurements = [ 234 'paddingLeft', 235 'paddingRight', 236 'paddingTop', 237 'paddingBottom', 238 'marginLeft', 239 'marginRight', 240 'marginTop', 241 'marginBottom', 242 'borderLeftWidth', 243 'borderRightWidth', 244 'borderTopWidth', 245 'borderBottomWidth' 246]; 247 248var measurementsLength = measurements.length; 249 250function getZeroSize() { 251 var size = { 252 width: 0, 253 height: 0, 254 innerWidth: 0, 255 innerHeight: 0, 256 outerWidth: 0, 257 outerHeight: 0 258 }; 259 for ( var i=0; i < measurementsLength; i++ ) { 260 var measurement = measurements[i]; 261 size[ measurement ] = 0; 262 } 263 return size; 264} 265 266 267function getStyle( elem ) { 268 var style = getComputedStyle( elem ); 269 if ( !style ) { 270 logError( 'Style returned ' + style + 271 '. Are you running this code in a hidden iframe on Firefox? ' + 272 'See https://bit.ly/getsizebug1' ); 273 } 274 return style; 275} 276 277 278var isSetup = false;
vendor: 5,187 bytes, lines 279-508
279 280var isBoxSizeOuter; 281 282function setup() { 283 if ( isSetup ) { 284 return; 285 } 286 isSetup = true; 287 288 289 var div = document.createElement('div'); 290 div.style.width = '200px'; 291 div.style.padding = '1px 2px 3px 4px'; 292 div.style.borderStyle = 'solid'; 293 div.style.borderWidth = '1px 2px 3px 4px'; 294 div.style.boxSizing = 'border-box'; 295 296 var body = document.body || document.documentElement; 297 body.appendChild( div ); 298 var style = getStyle( div ); 299 isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200; 300 getSize.isBoxSizeOuter = isBoxSizeOuter; 301 302 body.removeChild( div ); 303} 304 305 306function getSize( elem ) { 307 setup(); 308 309 if ( typeof elem == 'string' ) { 310 elem = document.querySelector( elem ); 311 } 312 313 if ( !elem || typeof elem != 'object' || !elem.nodeType ) { 314 return; 315 } 316 317 var style = getStyle( elem ); 318 319 if ( style.display == 'none' ) { 320 return getZeroSize(); 321 } 322 323 var size = {}; 324 size.width = elem.offsetWidth; 325 size.height = elem.offsetHeight; 326 327 var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box'; 328 329 for ( var i=0; i < measurementsLength; i++ ) { 330 var measurement = measurements[i]; 331 var value = style[ measurement ]; 332 var num = parseFloat( value ); 333 size[ measurement ] = !isNaN( num ) ? num : 0; 334 } 335 336 var paddingWidth = size.paddingLeft + size.paddingRight; 337 var paddingHeight = size.paddingTop + size.paddingBottom; 338 var marginWidth = size.marginLeft + size.marginRight; 339 var marginHeight = size.marginTop + size.marginBottom; 340 var borderWidth = size.borderLeftWidth + size.borderRightWidth; 341 var borderHeight = size.borderTopWidth + size.borderBottomWidth; 342 343 var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter; 344 345 var styleWidth = getStyleSize( style.width ); 346 if ( styleWidth !== false ) { 347 size.width = styleWidth + 348 ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth ); 349 } 350 351 var styleHeight = getStyleSize( style.height ); 352 if ( styleHeight !== false ) { 353 size.height = styleHeight + 354 ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight ); 355 } 356 357 size.innerWidth = size.width - ( paddingWidth + borderWidth ); 358 size.innerHeight = size.height - ( paddingHeight + borderHeight ); 359 360 size.outerWidth = size.width + marginWidth; 361 size.outerHeight = size.height + marginHeight; 362 363 return size; 364} 365 366return getSize; 367 368}); 369 370 371 372( function( window, factory ) { 373 'use strict'; 374 if ( typeof define == 'function' && define.amd ) { 375 define( 'desandro-matches-selector/matches-selector',factory ); 376 } else if ( typeof module == 'object' && module.exports ) { 377 module.exports = factory(); 378 } else { 379 window.matchesSelector = factory(); 380 } 381 382}( window, function factory() { 383 'use strict'; 384 385 var matchesMethod = ( function() { 386 var ElemProto = window.Element.prototype; 387 if ( ElemProto.matches ) { 388 return 'matches'; 389 } 390 if ( ElemProto.matchesSelector ) { 391 return 'matchesSelector'; 392 } 393 var prefixes = [ 'webkit', 'moz', 'ms', 'o' ]; 394 395 for ( var i=0; i < prefixes.length; i++ ) { 396 var prefix = prefixes[i]; 397 var method = prefix + 'MatchesSelector'; 398 if ( ElemProto[ method ] ) { 399 return method; 400 } 401 } 402 })(); 403 404 return function matchesSelector( elem, selector ) { 405 return elem[ matchesMethod ]( selector ); 406 }; 407 408})); 409 410 411 412( function( window, factory ) { 413 414 if ( typeof define == 'function' && define.amd ) { 415 define( 'fizzy-ui-utils/utils',[ 416 'desandro-matches-selector/matches-selector' 417 ], function( matchesSelector ) { 418 return factory( window, matchesSelector ); 419 }); 420 } else if ( typeof module == 'object' && module.exports ) { 421 module.exports = factory( 422 window, 423 require('desandro-matches-selector') 424 ); 425 } else { 426 window.fizzyUIUtils = factory( 427 window, 428 window.matchesSelector 429 ); 430 } 431 432}( window, function factory( window, matchesSelector ) { 433 434 435 436var utils = {}; 437 438 439utils.extend = function( a, b ) { 440 for ( var prop in b ) { 441 a[ prop ] = b[ prop ]; 442 } 443 return a; 444}; 445 446 447utils.modulo = function( num, div ) { 448 return ( ( num % div ) + div ) % div; 449}; 450 451 452var arraySlice = Array.prototype.slice; 453 454utils.makeArray = function( obj ) { 455 if ( Array.isArray( obj ) ) { 456 return obj; 457 } 458 if ( obj === null || obj === undefined ) { 459 return []; 460 } 461 462 var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number'; 463 if ( isArrayLike ) { 464 return arraySlice.call( obj ); 465 } 466 467 return [ obj ]; 468}; 469 470 471utils.removeFrom = function( ary, obj ) { 472 var index = ary.indexOf( obj ); 473 if ( index != -1 ) { 474 ary.splice( index, 1 ); 475 } 476}; 477 478 479utils.getParent = function( elem, selector ) { 480 while ( elem.parentNode && elem != document.body ) { 481 elem = elem.parentNode; 482 if ( matchesSelector( elem, selector ) ) { 483 return elem; 484 } 485 } 486}; 487 488 489utils.getQueryElement = function( elem ) { 490 if ( typeof elem == 'string' ) { 491 return document.querySelector( elem ); 492 } 493 return elem; 494}; 495 496 497utils.handleEvent = function( event ) { 498 var method = 'on' + event.type; 499 if ( this[ method ] ) { 500 this[ method ]( event ); 501 } 502}; 503 504 505utils.filterFindElements = function( elems, selector ) { 506 elems = utils.makeArray( elems ); 507 var ffElems = []; 508
509 elems.forEach( function( elem ) { 510 if ( !( elem instanceof HTMLElement ) ) { 511 return; 512 } 513 if ( !selector ) { 514 ffElems.push( elem ); 515 return; 516 } 517 if ( matchesSelector( elem, selector ) ) { 518 ffElems.push( elem ); 519 } 520 var childElems = elem.querySelectorAll( selector ); 521 for ( var i=0; i < childElems.length; i++ ) { 522 ffElems.push( childElems[i] ); 523 } 524 }); 525 526 return ffElems; 527}; 528 529 530utils.debounceMethod = function( _class, methodName, threshold ) { 531 threshold = threshold || 100; 532 var method = _class.prototype[ methodName ]; 533 var timeoutName = methodName + 'Timeout'; 534 535 _class.prototype[ methodName ] = function() { 536 var timeout = this[ timeoutName ]; 537 clearTimeout( timeout ); 538 539 var args = arguments; 540 var _this = this; 541 this[ timeoutName ] = setTimeout( function() { 542 method.apply( _this, args ); 543 delete _this[ timeoutName ]; 544 }, threshold ); 545 }; 546}; 547 548 549utils.docReady = function( callback ) { 550 var readyState = document.readyState; 551 if ( readyState == 'complete' || readyState == 'interactive' ) { 552 setTimeout( callback ); 553 } else { 554 document.addEventListener( 'DOMContentLoaded', callback ); 555 } 556}; 557 558 559utils.toDashed = function( str ) { 560 return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) { 561 return $1 + '-' + $2; 562 }).toLowerCase(); 563}; 564 565var console = window.console; 566utils.htmlInit = function( WidgetClass, namespace ) { 567 utils.docReady( function() { 568 var dashedNamespace = utils.toDashed( namespace ); 569 var dataAttr = 'data-' + dashedNamespace; 570 var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' ); 571 var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace ); 572 var elems = utils.makeArray( dataAttrElems ) 573 .concat( utils.makeArray( jsDashElems ) ); 574 var dataOptionsAttr = dataAttr + '-options'; 575 var jQuery = window.jQuery; 576 577 elems.forEach( function( elem ) { 578 var attr = elem.getAttribute( dataAttr ) || 579 elem.getAttribute( dataOptionsAttr ); 580 var options; 581 try { 582 options = attr && JSON.parse( attr ); 583 } catch ( error ) { 584 if ( console ) { 585 console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className + 586 ': ' + error ); 587 } 588 return; 589 } 590 var instance = new WidgetClass( elem, options ); 591 if ( jQuery ) { 592 jQuery.data( elem, namespace, instance ); 593 } 594 }); 595 596 }); 597}; 598 599 600return utils; 601 602})); 603 604( function( window, factory ) { 605 if ( typeof define == 'function' && define.amd ) { 606 define( 'flickity/js/cell',[ 607 'get-size/get-size', 608 ], function( getSize ) { 609 return factory( window, getSize ); 610 } ); 611 } else if ( typeof module == 'object' && module.exports ) { 612 module.exports = factory( 613 window, 614 require('get-size') 615 ); 616 } else { 617 window.Flickity = window.Flickity || {}; 618 window.Flickity.Cell = factory( 619 window, 620 window.getSize 621 ); 622 } 623 624}( window, function factory( window, getSize ) { 625 626 627 628function Cell( elem, parent ) { 629 this.element = elem; 630 this.parent = parent; 631 632 this.create(); 633} 634 635var proto = Cell.prototype; 636 637proto.create = function() { 638 this.element.style.position = 'absolute'; 639 this.element.setAttribute( 'aria-hidden', 'true' ); 640 this.x = 0; 641 this.shift = 0; 642 this.element.style[ this.parent.originSide ] = 0; 643}; 644 645proto.destroy = function() { 646 this.unselect(); 647 this.element.style.position = ''; 648 var side = this.parent.originSide; 649 this.element.style[ side ] = ''; 650 this.element.style.transform = ''; 651 this.element.removeAttribute('aria-hidden'); 652}; 653 654proto.getSize = function() { 655 this.size = getSize( this.element ); 656}; 657 658proto.setPosition = function( x ) { 659 this.x = x; 660 this.updateTarget(); 661 this.renderPosition( x ); 662}; 663 664proto.updateTarget = proto.setDefaultTarget = function() { 665 var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight'; 666 this.target = this.x + this.size[ marginProperty ] + 667 this.size.width * this.parent.cellAlign; 668}; 669 670proto.renderPosition = function( x ) { 671 var sideOffset = this.parent.originSide === 'left' ? 1 : -1; 672 673 var adjustedX = this.parent.options.percentPosition ? 674 x * sideOffset * ( this.parent.size.innerWidth / this.size.width ) : 675 x * sideOffset; 676 677 this.element.style.transform = 'translateX(' + 678 this.parent.getPositionValue( adjustedX ) + ')'; 679}; 680 681proto.select = function() { 682 this.element.classList.add('is-selected'); 683 this.element.removeAttribute('aria-hidden'); 684}; 685 686proto.unselect = function() { 687 this.element.classList.remove('is-selected'); 688 this.element.setAttribute( 'aria-hidden', 'true' ); 689}; 690 691proto.wrapShift = function( shift ) { 692 this.shift = shift; 693 this.renderPosition( this.x + this.parent.slideableWidth * shift ); 694}; 695 696proto.remove = function() { 697 this.element.parentNode.removeChild( this.element ); 698}; 699 700return Cell; 701 702} ) ); 703 704( function( window, factory ) { 705 if ( typeof define == 'function' && define.amd ) { 706 define( 'flickity/js/slide',factory ); 707 } else if ( typeof module == 'object' && module.exports ) { 708 module.exports = factory(); 709 } else { 710 window.Flickity = window.Flickity || {}; 711 window.Flickity.Slide = factory(); 712 } 713 714}( window, function factory() { 715'use strict'; 716 717function Slide( parent ) { 718 this.parent = parent; 719 this.isOriginLeft = parent.originSide == 'left'; 720 this.cells = []; 721 this.outerWidth = 0; 722 this.height = 0; 723} 724 725var proto = Slide.prototype; 726 727proto.addCell = function( cell ) { 728 this.cells.push( cell ); 729 this.outerWidth += cell.size.outerWidth; 730 this.height = Math.max( cell.size.outerHeight, this.height ); 731 if ( this.cells.length == 1 ) { 732 this.x = cell.x; 733 var beginMargin = this.isOriginLeft ? 'marginLeft' : 'marginRight'; 734 this.firstMargin = cell.size[ beginMargin ]; 735 } 736}; 737 738proto.updateTarget = function() { 739 var endMargin = this.isOriginLeft ? 'marginRight' : 'marginLeft'; 740 var lastCell = this.getLastCell(); 741 var lastMargin = lastCell ? lastCell.size[ endMargin ] : 0; 742 var slideWidth = this.outerWidth - ( this.firstMargin + lastMargin ); 743 this.target = this.x + this.firstMargin + slideWidth * this.parent.cellAlign; 744}; 745 746proto.getLastCell = function() { 747 return this.cells[ this.cells.length - 1 ]; 748}; 749 750proto.select = function() {
751 this.cells.forEach( function( cell ) { 752 cell.select(); 753 } ); 754}; 755 756proto.unselect = function() { 757 this.cells.forEach( function( cell ) { 758 cell.unselect(); 759 } ); 760}; 761 762proto.getCellElements = function() { 763 return this.cells.map( function( cell ) { 764 return cell.element; 765 } ); 766}; 767 768return Slide; 769 770} ) ); 771 772( function( window, factory ) { 773 if ( typeof define == 'function' && define.amd ) { 774 define( 'flickity/js/animate',[ 775 'fizzy-ui-utils/utils', 776 ], function( utils ) { 777 return factory( window, utils ); 778 } ); 779 } else if ( typeof module == 'object' && module.exports ) { 780 module.exports = factory( 781 window, 782 require('fizzy-ui-utils') 783 ); 784 } else { 785 window.Flickity = window.Flickity || {}; 786 window.Flickity.animatePrototype = factory( 787 window, 788 window.fizzyUIUtils 789 ); 790 } 791 792}( window, function factory( window, utils ) { 793 794 795 796 797var proto = {}; 798 799proto.startAnimation = function() { 800 if ( this.isAnimating ) { 801 return; 802 } 803 804 this.isAnimating = true; 805 this.restingFrames = 0; 806 this.animate(); 807}; 808 809proto.animate = function() { 810 this.applyDragForce(); 811 this.applySelectedAttraction(); 812 813 var previousX = this.x; 814 815 this.integratePhysics(); 816 this.positionSlider(); 817 this.settle( previousX ); 818 if ( this.isAnimating ) { 819 var _this = this; 820 requestAnimationFrame( function animateFrame() { 821 _this.animate(); 822 } ); 823 } 824}; 825 826proto.positionSlider = function() { 827 var x = this.x; 828 if ( this.options.wrapAround && this.cells.length > 1 ) { 829 x = utils.modulo( x, this.slideableWidth ); 830 x -= this.slideableWidth; 831 this.shiftWrapCells( x ); 832 } 833 834 this.setTranslateX( x, this.isAnimating ); 835 this.dispatchScrollEvent(); 836}; 837 838proto.setTranslateX = function( x, is3d ) { 839 x += this.cursorPosition; 840 x = this.options.rightToLeft ? -x : x; 841 var translateX = this.getPositionValue( x ); 842 this.slider.style.transform = is3d ? 843 'translate3d(' + translateX + ',0,0)' : 'translateX(' + translateX + ')'; 844}; 845 846proto.dispatchScrollEvent = function() { 847 var firstSlide = this.slides[0]; 848 if ( !firstSlide ) { 849 return; 850 } 851 var positionX = -this.x - firstSlide.target; 852 var progress = positionX / this.slidesWidth; 853 this.dispatchEvent( 'scroll', null, [ progress, positionX ] ); 854}; 855 856proto.positionSliderAtSelected = function() { 857 if ( !this.cells.length ) { 858 return; 859 } 860 this.x = -this.selectedSlide.target; 861 this.velocity = 0; 862 this.positionSlider(); 863}; 864 865proto.getPositionValue = function( position ) { 866 if ( this.options.percentPosition ) { 867 return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 ) + '%'; 868 } else { 869 return Math.round( position ) + 'px'; 870 } 871}; 872 873proto.settle = function( previousX ) { 874 var isResting = !this.isPointerDown && 875 Math.round( this.x * 100 ) == Math.round( previousX * 100 ); 876 if ( isResting ) { 877 this.restingFrames++; 878 } 879 if ( this.restingFrames > 2 ) { 880 this.isAnimating = false; 881 delete this.isFreeScrolling; 882 this.positionSlider(); 883 this.dispatchEvent( 'settle', null, [ this.selectedIndex ] ); 884 } 885}; 886 887proto.shiftWrapCells = function( x ) { 888 var beforeGap = this.cursorPosition + x; 889 this._shiftCells( this.beforeShiftCells, beforeGap, -1 ); 890 var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition ); 891 this._shiftCells( this.afterShiftCells, afterGap, 1 ); 892}; 893 894proto._shiftCells = function( cells, gap, shift ) { 895 for ( var i = 0; i < cells.length; i++ ) { 896 var cell = cells[i]; 897 var cellShift = gap > 0 ? shift : 0; 898 cell.wrapShift( cellShift ); 899 gap -= cell.size.outerWidth; 900 } 901}; 902 903proto._unshiftCells = function( cells ) { 904 if ( !cells || !cells.length ) { 905 return; 906 } 907 for ( var i = 0; i < cells.length; i++ ) { 908 cells[i].wrapShift( 0 ); 909 } 910}; 911 912 913proto.integratePhysics = function() { 914 this.x += this.velocity; 915 this.velocity *= this.getFrictionFactor(); 916}; 917 918proto.applyForce = function( force ) { 919 this.velocity += force; 920}; 921 922proto.getFrictionFactor = function() { 923 return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ]; 924}; 925 926proto.getRestingPosition = function() { 927 return this.x + this.velocity / ( 1 - this.getFrictionFactor() ); 928}; 929 930proto.applyDragForce = function() { 931 if ( !this.isDraggable || !this.isPointerDown ) { 932 return; 933 } 934 var dragVelocity = this.dragX - this.x; 935 var dragForce = dragVelocity - this.velocity; 936 this.applyForce( dragForce ); 937}; 938 939proto.applySelectedAttraction = function() { 940 var dragDown = this.isDraggable && this.isPointerDown; 941 if ( dragDown || this.isFreeScrolling || !this.slides.length ) { 942 return; 943 } 944 var distance = this.selectedSlide.target * -1 - this.x; 945 var force = distance * this.options.selectedAttraction; 946 this.applyForce( force ); 947}; 948 949return proto; 950 951} ) ); 952 953( function( window, factory ) { 954 if ( typeof define == 'function' && define.amd ) { 955 define( 'flickity/js/flickity',[ 956 'ev-emitter/ev-emitter', 957 'get-size/get-size', 958 'fizzy-ui-utils/utils', 959 './cell', 960 './slide', 961 './animate', 962 ], function( EvEmitter, getSize, utils, Cell, Slide, animatePrototype ) { 963 return factory( window, EvEmitter, getSize, utils, Cell, Slide, animatePrototype ); 964 } ); 965 } else if ( typeof module == 'object' && module.exports ) { 966 module.exports = factory( 967 window, 968 require('ev-emitter'), 969 require('get-size'), 970 require('fizzy-ui-utils'), 971 require('./cell'), 972 require('./slide'), 973 require('./animate') 974 ); 975 } else { 976 var _Flickity = window.Flickity; 977 978 window.Flickity = factory( 979 window, 980 window.EvEmitter, 981 window.getSize, 982 window.fizzyUIUtils, 983 _Flickity.Cell, 984 _Flickity.Slide, 985 _Flickity.animatePrototype 986 ); 987 } 988 989}( window, function factory( window, EvEmitter, getSize, 990 utils, Cell, Slide, animatePrototype ) { 991 992 993 994var jQuery = window.jQuery; 995var getComputedStyle = window.getComputedStyle; 996var console = window.console; 997 998function moveElements( elems, toElem ) { 999 elems = utils.makeArray( elems ); 1000 while ( elems.length ) { 1001 toElem.appendChild( elems.shift() ); 1002 } 1003} 1004 1005 1006var GUID = 0; 1007var instances = {}; 1008 1009function Flickity( element, options ) { 1010 var queryElement = utils.getQueryElement( element ); 1011 if ( !queryElement ) { 1012 if ( console ) { 1013 console.error( 'Bad element for Flickity: ' + ( queryElement || element ) ); 1014 } 1015 return; 1016 } 1017 this.element = queryElement; 1018 if ( this.element.flickityGUID ) { 1019 var instance = instances[ this.element.flickityGUID ]; 1020 if ( instance ) instance.option( options ); 1021 return instance; 1022 } 1023 1024 if ( jQuery ) { 1025 this.$element = jQuery( this.element ); 1026 } 1027 this.options = utils.extend( {}, this.constructor.defaults ); 1028 this.option( options ); 1029 1030 this._create(); 1031} 1032 1033Flickity.defaults = { 1034 accessibility: true, 1035 cellAlign: 'center', 1036 freeScrollFriction: 0.075, 1037 friction: 0.28, 1038 namespaceJQueryEvents: true, 1039 percentPosition: true, 1040 resize: true, 1041 selectedAttraction: 0.025, 1042 setGallerySize: true, 1043}; 1044 1045Flickity.createMethods = []; 1046 1047var proto = Flickity.prototype; 1048utils.extend( proto, EvEmitter.prototype ); 1049 1050proto._create = function() { 1051 var id = this.guid = ++GUID; 1052 this.element.flickityGUID = id; 1053 instances[ id ] = this; 1054 this.selectedIndex = 0; 1055 this.restingFrames = 0; 1056 this.x = 0; 1057 this.velocity = 0; 1058 this.originSide = this.options.rightToLeft ? 'right' : 'left'; 1059 this.viewport = document.createElement('div'); 1060 this.viewport.className = 'flickity-viewport'; 1061 this._createSlider(); 1062 1063 if ( this.options.resize || this.options.watchCSS ) { 1064 window.addEventListener( 'resize', this ); 1065 } 1066 1067 for ( var eventName in this.options.on ) { 1068 var listener = this.options.on[ eventName ]; 1069 this.on( eventName, listener ); 1070 } 1071 1072 Flickity.createMethods.forEach( function( method ) { 1073 this[ method ](); 1074 }, this ); 1075 1076 if ( this.options.watchCSS ) { 1077 this.watchCSS(); 1078 } else { 1079 this.activate(); 1080 } 1081 1082}; 1083 1084proto.option = function( opts ) { 1085 utils.extend( this.options, opts ); 1086}; 1087 1088proto.activate = function() { 1089 if ( this.isActive ) { 1090 return; 1091 } 1092 this.isActive = true; 1093 this.element.classList.add('flickity-enabled'); 1094 if ( this.options.rightToLeft ) { 1095 this.element.classList.add('flickity-rtl'); 1096 } 1097
1098 this.getSize(); 1099 var cellElems = this._filterFindCellElements( this.element.children ); 1100 moveElements( cellElems, this.slider ); 1101 this.viewport.appendChild( this.slider ); 1102 this.element.appendChild( this.viewport ); 1103 this.reloadCells(); 1104 1105 if ( this.options.accessibility ) { 1106 this.element.tabIndex = 0; 1107 this.element.addEventListener( 'keydown', this ); 1108 } 1109 1110 this.emitEvent('activate'); 1111 this.selectInitialIndex(); 1112 this.isInitActivated = true; 1113 this.dispatchEvent('ready'); 1114}; 1115 1116proto._createSlider = function() { 1117 var slider = document.createElement('div'); 1118 slider.className = 'flickity-slider'; 1119 slider.style[ this.originSide ] = 0; 1120 this.slider = slider; 1121}; 1122 1123proto._filterFindCellElements = function( elems ) { 1124 return utils.filterFindElements( elems, this.options.cellSelector ); 1125}; 1126 1127proto.reloadCells = function() { 1128 this.cells = this._makeCells( this.slider.children ); 1129 this.positionCells(); 1130 this._getWrapShiftCells(); 1131 this.setGallerySize(); 1132}; 1133 1134proto._makeCells = function( elems ) { 1135 var cellElems = this._filterFindCellElements( elems ); 1136 1137 var cells = cellElems.map( function( cellElem ) { 1138 return new Cell( cellElem, this ); 1139 }, this ); 1140 1141 return cells; 1142}; 1143 1144proto.getLastCell = function() { 1145 return this.cells[ this.cells.length - 1 ]; 1146}; 1147 1148proto.getLastSlide = function() { 1149 return this.slides[ this.slides.length - 1 ]; 1150}; 1151 1152proto.positionCells = function() { 1153 this._sizeCells( this.cells ); 1154 this._positionCells( 0 ); 1155}; 1156 1157proto._positionCells = function( index ) { 1158 index = index || 0; 1159 this.maxCellHeight = index ? this.maxCellHeight || 0 : 0; 1160 var cellX = 0; 1161 if ( index > 0 ) { 1162 var startCell = this.cells[ index - 1 ]; 1163 cellX = startCell.x + startCell.size.outerWidth; 1164 } 1165 var len = this.cells.length; 1166 for ( var i = index; i < len; i++ ) { 1167 var cell = this.cells[i]; 1168 cell.setPosition( cellX ); 1169 cellX += cell.size.outerWidth; 1170 this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight ); 1171 } 1172 this.slideableWidth = cellX; 1173 this.updateSlides(); 1174 this._containSlides(); 1175 this.slidesWidth = len ? this.getLastSlide().target - this.slides[0].target : 0; 1176}; 1177 1178proto._sizeCells = function( cells ) { 1179 cells.forEach( function( cell ) { 1180 cell.getSize(); 1181 } ); 1182}; 1183 1184 1185proto.updateSlides = function() { 1186 this.slides = []; 1187 if ( !this.cells.length ) { 1188 return; 1189 } 1190 1191 var slide = new Slide( this ); 1192 this.slides.push( slide ); 1193 var isOriginLeft = this.originSide == 'left'; 1194 var nextMargin = isOriginLeft ? 'marginRight' : 'marginLeft'; 1195 1196 var canCellFit = this._getCanCellFit(); 1197 1198 this.cells.forEach( function( cell, i ) { 1199 if ( !slide.cells.length ) { 1200 slide.addCell( cell ); 1201 return; 1202 } 1203 1204 var slideWidth = ( slide.outerWidth - slide.firstMargin ) + 1205 ( cell.size.outerWidth - cell.size[ nextMargin ] ); 1206 1207 if ( canCellFit.call( this, i, slideWidth ) ) { 1208 slide.addCell( cell ); 1209 } else { 1210 slide.updateTarget(); 1211 1212 slide = new Slide( this ); 1213 this.slides.push( slide ); 1214 slide.addCell( cell ); 1215 } 1216 }, this ); 1217 slide.updateTarget(); 1218 this.updateSelectedSlide(); 1219}; 1220 1221proto._getCanCellFit = function() { 1222 var groupCells = this.options.groupCells; 1223 if ( !groupCells ) { 1224 return function() { 1225 return false; 1226 }; 1227 } else if ( typeof groupCells == 'number' ) { 1228 var number = parseInt( groupCells, 10 ); 1229 return function( i ) { 1230 return ( i % number ) !== 0; 1231 }; 1232 } 1233 var percentMatch = typeof groupCells == 'string' && 1234 groupCells.match( /^(\d+)%$/ ); 1235 var percent = percentMatch ? parseInt( percentMatch[1], 10 ) / 100 : 1; 1236 return function( i, slideWidth ) { 1237 return slideWidth <= ( this.size.innerWidth + 1 ) * percent; 1238 }; 1239}; 1240 1241proto._init = 1242proto.reposition = function() { 1243 this.positionCells(); 1244 this.positionSliderAtSelected(); 1245}; 1246 1247proto.getSize = function() { 1248 this.size = getSize( this.element ); 1249 this.setCellAlign(); 1250 this.cursorPosition = this.size.innerWidth * this.cellAlign; 1251}; 1252 1253var cellAlignShorthands = { 1254 center: { 1255 left: 0.5, 1256 right: 0.5, 1257 }, 1258 left: { 1259 left: 0, 1260 right: 1, 1261 }, 1262 right: { 1263 right: 0, 1264 left: 1, 1265 }, 1266}; 1267 1268proto.setCellAlign = function() { 1269 var shorthand = cellAlignShorthands[ this.options.cellAlign ]; 1270 this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign; 1271}; 1272 1273proto.setGallerySize = function() { 1274 if ( this.options.setGallerySize ) { 1275 var height = this.options.adaptiveHeight && this.selectedSlide ? 1276 this.selectedSlide.height : this.maxCellHeight; 1277 this.viewport.style.height = height + 'px'; 1278 } 1279}; 1280 1281proto._getWrapShiftCells = function() { 1282 if ( !this.options.wrapAround ) { 1283 return; 1284 } 1285 this._unshiftCells( this.beforeShiftCells ); 1286 this._unshiftCells( this.afterShiftCells ); 1287 var gapX = this.cursorPosition; 1288 var cellIndex = this.cells.length - 1; 1289 this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );
1290 gapX = this.size.innerWidth - this.cursorPosition; 1291 this.afterShiftCells = this._getGapCells( gapX, 0, 1 ); 1292}; 1293 1294proto._getGapCells = function( gapX, cellIndex, increment ) { 1295 var cells = []; 1296 while ( gapX > 0 ) { 1297 var cell = this.cells[ cellIndex ]; 1298 if ( !cell ) { 1299 break; 1300 } 1301 cells.push( cell ); 1302 cellIndex += increment; 1303 gapX -= cell.size.outerWidth; 1304 } 1305 return cells; 1306}; 1307 1308 1309proto._containSlides = function() { 1310 if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) { 1311 return; 1312 } 1313 var isRightToLeft = this.options.rightToLeft; 1314 var beginMargin = isRightToLeft ? 'marginRight' : 'marginLeft'; 1315 var endMargin = isRightToLeft ? 'marginLeft' : 'marginRight'; 1316 var contentWidth = this.slideableWidth - this.getLastCell().size[ endMargin ]; 1317 var isContentSmaller = contentWidth < this.size.innerWidth; 1318 var beginBound = this.cursorPosition + this.cells[0].size[ beginMargin ]; 1319 var endBound = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign ); 1320 this.slides.forEach( function( slide ) { 1321 if ( isContentSmaller ) { 1322 slide.target = contentWidth * this.cellAlign; 1323 } else { 1324 slide.target = Math.max( slide.target, beginBound ); 1325 slide.target = Math.min( slide.target, endBound ); 1326 } 1327 }, this ); 1328}; 1329 1330 1331proto.dispatchEvent = function( type, event, args ) { 1332 var emitArgs = event ? [ event ].concat( args ) : args; 1333 this.emitEvent( type, emitArgs ); 1334 1335 if ( jQuery && this.$element ) { 1336 type += this.options.namespaceJQueryEvents ? '.flickity' : ''; 1337 var $event = type; 1338 if ( event ) { 1339 var jQEvent = new jQuery.Event( event ); 1340 jQEvent.type = type; 1341 $event = jQEvent; 1342 } 1343 this.$element.trigger( $event, args ); 1344 } 1345}; 1346 1347 1348proto.select = function( index, isWrap, isInstant ) { 1349 if ( !this.isActive ) { 1350 return; 1351 } 1352 index = parseInt( index, 10 ); 1353 this._wrapSelect( index ); 1354 1355 if ( this.options.wrapAround || isWrap ) { 1356 index = utils.modulo( index, this.slides.length ); 1357 } 1358 if ( !this.slides[ index ] ) { 1359 return; 1360 } 1361 var prevIndex = this.selectedIndex; 1362 this.selectedIndex = index; 1363 this.updateSelectedSlide(); 1364 if ( isInstant ) { 1365 this.positionSliderAtSelected(); 1366 } else { 1367 this.startAnimation(); 1368 } 1369 if ( this.options.adaptiveHeight ) { 1370 this.setGallerySize(); 1371 } 1372 this.dispatchEvent( 'select', null, [ index ] ); 1373 if ( index != prevIndex ) { 1374 this.dispatchEvent( 'change', null, [ index ] ); 1375 } 1376 this.dispatchEvent('cellSelect'); 1377}; 1378 1379proto._wrapSelect = function( index ) { 1380 var len = this.slides.length; 1381 var isWrapping = this.options.wrapAround && len > 1; 1382 if ( !isWrapping ) { 1383 return index; 1384 } 1385 var wrapIndex = utils.modulo( index, len ); 1386 var delta = Math.abs( wrapIndex - this.selectedIndex ); 1387 var backWrapDelta = Math.abs( ( wrapIndex + len ) - this.selectedIndex ); 1388 var forewardWrapDelta = Math.abs( ( wrapIndex - len ) - this.selectedIndex ); 1389 if ( !this.isDragSelect && backWrapDelta < delta ) { 1390 index += len; 1391 } else if ( !this.isDragSelect && forewardWrapDelta < delta ) { 1392 index -= len; 1393 } 1394 if ( index < 0 ) { 1395 this.x -= this.slideableWidth; 1396 } else if ( index >= len ) { 1397 this.x += this.slideableWidth; 1398 } 1399}; 1400 1401proto.previous = function( isWrap, isInstant ) { 1402 this.select( this.selectedIndex - 1, isWrap, isInstant ); 1403}; 1404 1405proto.next = function( isWrap, isInstant ) { 1406 this.select( this.selectedIndex + 1, isWrap, isInstant ); 1407}; 1408 1409proto.updateSelectedSlide = function() { 1410 var slide = this.slides[ this.selectedIndex ]; 1411 if ( !slide ) { 1412 return; 1413 } 1414 this.unselectSelectedSlide(); 1415 this.selectedSlide = slide; 1416 slide.select(); 1417 this.selectedCells = slide.cells; 1418 this.selectedElements = slide.getCellElements(); 1419 this.selectedCell = slide.cells[0]; 1420 this.selectedElement = this.selectedElements[0]; 1421}; 1422 1423proto.unselectSelectedSlide = function() { 1424 if ( this.selectedSlide ) { 1425 this.selectedSlide.unselect(); 1426 } 1427}; 1428 1429proto.selectInitialIndex = function() { 1430 var initialIndex = this.options.initialIndex; 1431 if ( this.isInitActivated ) { 1432 this.select( this.selectedIndex, false, true ); 1433 return; 1434 } 1435 if ( initialIndex && typeof initialIndex == 'string' ) { 1436 var cell = this.queryCell( initialIndex ); 1437 if ( cell ) { 1438 this.selectCell( initialIndex, false, true ); 1439 return; 1440 } 1441 } 1442 1443 var index = 0; 1444 if ( initialIndex && this.slides[ initialIndex ] ) { 1445 index = initialIndex; 1446 } 1447 this.select( index, false, true ); 1448}; 1449 1450proto.selectCell = function( value, isWrap, isInstant ) { 1451 var cell = this.queryCell( value ); 1452 if ( !cell ) { 1453 return; 1454 } 1455 1456 var index = this.getCellSlideIndex( cell ); 1457 this.select( index, isWrap, isInstant ); 1458}; 1459 1460proto.getCellSlideIndex = function( cell ) { 1461 for ( var i = 0; i < this.slides.length; i++ ) { 1462 var slide = this.slides[i]; 1463 var index = slide.cells.indexOf( cell ); 1464 if ( index != -1 ) { 1465 return i; 1466 } 1467 } 1468}; 1469 1470 1471proto.getCell = function( elem ) { 1472 for ( var i = 0; i < this.cells.length; i++ ) { 1473 var cell = this.cells[i]; 1474 if ( cell.element == elem ) { 1475 return cell; 1476 } 1477 } 1478}; 1479 1480proto.getCells = function( elems ) { 1481 elems = utils.makeArray( elems ); 1482 var cells = [];
1483 elems.forEach( function( elem ) { 1484 var cell = this.getCell( elem ); 1485 if ( cell ) { 1486 cells.push( cell ); 1487 } 1488 }, this ); 1489 return cells; 1490}; 1491 1492proto.getCellElements = function() { 1493 return this.cells.map( function( cell ) { 1494 return cell.element; 1495 } ); 1496}; 1497 1498proto.getParentCell = function( elem ) { 1499 var cell = this.getCell( elem ); 1500 if ( cell ) { 1501 return cell; 1502 } 1503 elem = utils.getParent( elem, '.flickity-slider > *' ); 1504 return this.getCell( elem ); 1505}; 1506 1507proto.getAdjacentCellElements = function( adjCount, index ) { 1508 if ( !adjCount ) { 1509 return this.selectedSlide.getCellElements(); 1510 } 1511 index = index === undefined ? this.selectedIndex : index; 1512 1513 var len = this.slides.length; 1514 if ( 1 + ( adjCount * 2 ) >= len ) { 1515 return this.getCellElements(); 1516 } 1517 1518 var cellElems = []; 1519 for ( var i = index - adjCount; i <= index + adjCount; i++ ) { 1520 var slideIndex = this.options.wrapAround ? utils.modulo( i, len ) : i; 1521 var slide = this.slides[ slideIndex ]; 1522 if ( slide ) { 1523 cellElems = cellElems.concat( slide.getCellElements() ); 1524 } 1525 } 1526 return cellElems; 1527}; 1528 1529proto.queryCell = function( selector ) { 1530 if ( typeof selector == 'number' ) { 1531 return this.cells[ selector ]; 1532 } 1533 if ( typeof selector == 'string' ) { 1534 if ( selector.match( /^[#.]?[\d/]/ ) ) { 1535 return; 1536 } 1537 selector = this.element.querySelector( selector ); 1538 } 1539 return this.getCell( selector ); 1540}; 1541 1542 1543proto.uiChange = function() { 1544 this.emitEvent('uiChange'); 1545}; 1546 1547proto.childUIPointerDown = function( event ) { 1548 if ( event.type != 'touchstart' ) { 1549 event.preventDefault(); 1550 } 1551 this.focus(); 1552}; 1553 1554 1555proto.onresize = function() { 1556 this.watchCSS(); 1557 this.resize(); 1558}; 1559 1560utils.debounceMethod( Flickity, 'onresize', 150 ); 1561 1562proto.resize = function() { 1563 if ( !this.isActive || this.isAnimating || this.isDragging ) { 1564 return; 1565 } 1566 this.getSize(); 1567 if ( this.options.wrapAround ) { 1568 this.x = utils.modulo( this.x, this.slideableWidth ); 1569 } 1570 this.positionCells(); 1571 this._getWrapShiftCells(); 1572 this.setGallerySize(); 1573 this.emitEvent('resize'); 1574 var selectedElement = this.selectedElements && this.selectedElements[0]; 1575 this.selectCell( selectedElement, false, true ); 1576}; 1577 1578proto.watchCSS = function() { 1579 var watchOption = this.options.watchCSS; 1580 if ( !watchOption ) { 1581 return; 1582 } 1583 1584 var afterContent = getComputedStyle( this.element, ':after' ).content; 1585 if ( afterContent.indexOf('flickity') != -1 ) { 1586 this.activate(); 1587 } else { 1588 this.deactivate(); 1589 } 1590}; 1591 1592 1593proto.onkeydown = function( event ) { 1594 var isNotFocused = document.activeElement && document.activeElement != this.element; 1595 if ( !this.options.accessibility || isNotFocused ) { 1596 return; 1597 } 1598 1599 var handler = Flickity.keyboardHandlers[ event.keyCode ]; 1600 if ( handler ) { 1601 handler.call( this ); 1602 } 1603}; 1604 1605Flickity.keyboardHandlers = { 1606 37: function() { 1607 var leftMethod = this.options.rightToLeft ? 'next' : 'previous'; 1608 this.uiChange(); 1609 this[ leftMethod ](); 1610 }, 1611 39: function() { 1612 var rightMethod = this.options.rightToLeft ? 'previous' : 'next'; 1613 this.uiChange(); 1614 this[ rightMethod ](); 1615 }, 1616}; 1617 1618 1619proto.focus = function() { 1620 var prevScrollY = window.pageYOffset; 1621 this.element.focus({ preventScroll: true }); 1622 if ( window.pageYOffset != prevScrollY ) { 1623 window.scrollTo( window.pageXOffset, prevScrollY ); 1624 } 1625}; 1626 1627 1628proto.deactivate = function() { 1629 if ( !this.isActive ) { 1630 return; 1631 } 1632 this.element.classList.remove('flickity-enabled'); 1633 this.element.classList.remove('flickity-rtl'); 1634 this.unselectSelectedSlide(); 1635 this.cells.forEach( function( cell ) { 1636 cell.destroy(); 1637 } ); 1638 this.element.removeChild( this.viewport ); 1639 moveElements( this.slider.children, this.element ); 1640 if ( this.options.accessibility ) { 1641 this.element.removeAttribute('tabIndex'); 1642 this.element.removeEventListener( 'keydown', this ); 1643 } 1644 this.isActive = false; 1645 this.emitEvent('deactivate'); 1646}; 1647 1648proto.destroy = function() { 1649 this.deactivate(); 1650 window.removeEventListener( 'resize', this ); 1651 this.allOff(); 1652 this.emitEvent('destroy'); 1653 if ( jQuery && this.$element ) { 1654 jQuery.removeData( this.element, 'flickity' ); 1655 } 1656 delete this.element.flickityGUID; 1657 delete instances[ this.guid ]; 1658}; 1659 1660 1661utils.extend( proto, animatePrototype ); 1662 1663 1664Flickity.data = function( elem ) { 1665 elem = utils.getQueryElement( elem ); 1666 var id = elem && elem.flickityGUID; 1667 return id && instances[ id ]; 1668}; 1669 1670utils.htmlInit( Flickity, 'flickity' ); 1671 1672if ( jQuery && jQuery.bridget ) { 1673 jQuery.bridget( 'flickity', Flickity ); 1674} 1675 1676Flickity.setJQuery = function( jq ) { 1677 jQuery = jq; 1678}; 1679 1680Flickity.Cell = Cell; 1681Flickity.Slide = Slide; 1682 1683return Flickity; 1684 1685} ) ); 1686 1687 1688 1689( function( window, factory ) { 1690 if ( typeof define == 'function' && define.amd ) { 1691 define( 'unipointer/unipointer',[ 1692 'ev-emitter/ev-emitter' 1693 ], function( EvEmitter ) { 1694 return factory( window, EvEmitter ); 1695 }); 1696 } else if ( typeof module == 'object' && module.exports ) { 1697 module.exports = factory( 1698 window, 1699 require('ev-emitter') 1700 ); 1701 } else { 1702 window.Unipointer = factory( 1703 window, 1704 window.EvEmitter 1705 ); 1706 } 1707 1708}( window, function factory( window, EvEmitter ) { 1709 1710 1711 1712function noop() {} 1713 1714function Unipointer() {} 1715 1716var proto = Unipointer.prototype = Object.create( EvEmitter.prototype ); 1717 1718proto.bindStartEvent = function( elem ) { 1719 this._bindStartEvent( elem, true ); 1720}; 1721 1722proto.unbindStartEvent = function( elem ) { 1723 this._bindStartEvent( elem, false ); 1724}; 1725 1726proto._bindStartEvent = function( elem, isAdd ) { 1727 isAdd = isAdd === undefined ? true : isAdd; 1728 var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener'; 1729 1730 var startEvent = 'mousedown'; 1731 if ( 'ontouchstart' in window ) { 1732 startEvent = 'touchstart'; 1733 } else if ( window.PointerEvent ) { 1734 startEvent = 'pointerdown'; 1735 } 1736 elem[ bindMethod ]( startEvent, this ); 1737}; 1738 1739proto.handleEvent = function( event ) { 1740 var method = 'on' + event.type; 1741 if ( this[ method ] ) { 1742 this[ method ]( event ); 1743 } 1744}; 1745 1746proto.getTouch = function( touches ) { 1747 for ( var i=0; i < touches.length; i++ ) { 1748 var touch = touches[i]; 1749 if ( touch.identifier == this.pointerIdentifier ) { 1750 return touch; 1751 } 1752 } 1753}; 1754 1755 1756proto.onmousedown = function( event ) { 1757 var button = event.button; 1758 if ( button && ( button !== 0 && button !== 1 ) ) { 1759 return; 1760 } 1761 this._pointerDown( event, event ); 1762}; 1763 1764proto.ontouchstart = function( event ) { 1765 this._pointerDown( event, event.changedTouches[0] ); 1766}; 1767 1768proto.onpointerdown = function( event ) { 1769 this._pointerDown( event, event ); 1770}; 1771 1772proto._pointerDown = function( event, pointer ) { 1773 if ( event.button || this.isPointerDown ) { 1774 return; 1775 } 1776 1777 this.isPointerDown = true; 1778 this.pointerIdentifier = pointer.pointerId !== undefined ? 1779 pointer.pointerId : pointer.identifier; 1780 1781 this.pointerDown( event, pointer ); 1782}; 1783 1784proto.pointerDown = function( event, pointer ) { 1785 this._bindPostStartEvents( event ); 1786 this.emitEvent( 'pointerDown', [ event, pointer ] ); 1787}; 1788 1789var postStartEvents = {
1790 mousedown: [ 'mousemove', 'mouseup' ], 1791 touchstart: [ 'touchmove', 'touchend', 'touchcancel' ], 1792 pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ], 1793}; 1794 1795proto._bindPostStartEvents = function( event ) { 1796 if ( !event ) { 1797 return; 1798 } 1799 var events = postStartEvents[ event.type ]; 1800 events.forEach( function( eventName ) { 1801 window.addEventListener( eventName, this ); 1802 }, this ); 1803 this._boundPointerEvents = events; 1804}; 1805 1806proto._unbindPostStartEvents = function() { 1807 if ( !this._boundPointerEvents ) { 1808 return; 1809 } 1810 this._boundPointerEvents.forEach( function( eventName ) { 1811 window.removeEventListener( eventName, this ); 1812 }, this ); 1813 1814 delete this._boundPointerEvents; 1815}; 1816 1817 1818proto.onmousemove = function( event ) { 1819 this._pointerMove( event, event ); 1820}; 1821 1822proto.onpointermove = function( event ) { 1823 if ( event.pointerId == this.pointerIdentifier ) { 1824 this._pointerMove( event, event ); 1825 } 1826}; 1827 1828proto.ontouchmove = function( event ) { 1829 var touch = this.getTouch( event.changedTouches ); 1830 if ( touch ) { 1831 this._pointerMove( event, touch ); 1832 } 1833}; 1834 1835proto._pointerMove = function( event, pointer ) { 1836 this.pointerMove( event, pointer ); 1837}; 1838 1839proto.pointerMove = function( event, pointer ) { 1840 this.emitEvent( 'pointerMove', [ event, pointer ] ); 1841}; 1842 1843 1844 1845proto.onmouseup = function( event ) { 1846 this._pointerUp( event, event ); 1847}; 1848 1849proto.onpointerup = function( event ) { 1850 if ( event.pointerId == this.pointerIdentifier ) { 1851 this._pointerUp( event, event ); 1852 } 1853}; 1854 1855proto.ontouchend = function( event ) { 1856 var touch = this.getTouch( event.changedTouches ); 1857 if ( touch ) { 1858 this._pointerUp( event, touch ); 1859 } 1860}; 1861 1862proto._pointerUp = function( event, pointer ) { 1863 this._pointerDone(); 1864 this.pointerUp( event, pointer ); 1865}; 1866 1867proto.pointerUp = function( event, pointer ) { 1868 this.emitEvent( 'pointerUp', [ event, pointer ] ); 1869}; 1870 1871 1872proto._pointerDone = function() { 1873 this._pointerReset(); 1874 this._unbindPostStartEvents(); 1875 this.pointerDone(); 1876}; 1877 1878proto._pointerReset = function() { 1879 this.isPointerDown = false; 1880 delete this.pointerIdentifier; 1881}; 1882 1883proto.pointerDone = noop; 1884 1885 1886proto.onpointercancel = function( event ) { 1887 if ( event.pointerId == this.pointerIdentifier ) { 1888 this._pointerCancel( event, event ); 1889 } 1890}; 1891 1892proto.ontouchcancel = function( event ) { 1893 var touch = this.getTouch( event.changedTouches ); 1894 if ( touch ) { 1895 this._pointerCancel( event, touch ); 1896 } 1897}; 1898 1899proto._pointerCancel = function( event, pointer ) { 1900 this._pointerDone(); 1901 this.pointerCancel( event, pointer ); 1902}; 1903 1904proto.pointerCancel = function( event, pointer ) { 1905 this.emitEvent( 'pointerCancel', [ event, pointer ] ); 1906}; 1907 1908 1909Unipointer.getPointerPoint = function( pointer ) { 1910 return { 1911 x: pointer.pageX, 1912 y: pointer.pageY 1913 }; 1914}; 1915 1916 1917return Unipointer; 1918 1919})); 1920 1921 1922 1923( function( window, factory ) { 1924 1925 if ( typeof define == 'function' && define.amd ) { 1926 define( 'unidragger/unidragger',[ 1927 'unipointer/unipointer' 1928 ], function( Unipointer ) { 1929 return factory( window, Unipointer ); 1930 }); 1931 } else if ( typeof module == 'object' && module.exports ) { 1932 module.exports = factory( 1933 window, 1934 require('unipointer') 1935 ); 1936 } else { 1937 window.Unidragger = factory( 1938 window, 1939 window.Unipointer 1940 ); 1941 } 1942 1943}( window, function factory( window, Unipointer ) { 1944 1945 1946 1947 1948function Unidragger() {} 1949 1950var proto = Unidragger.prototype = Object.create( Unipointer.prototype ); 1951 1952 1953proto.bindHandles = function() { 1954 this._bindHandles( true ); 1955}; 1956 1957proto.unbindHandles = function() { 1958 this._bindHandles( false ); 1959}; 1960 1961proto._bindHandles = function( isAdd ) { 1962 isAdd = isAdd === undefined ? true : isAdd; 1963 var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener'; 1964 var touchAction = isAdd ? this._touchActionValue : ''; 1965 for ( var i=0; i < this.handles.length; i++ ) { 1966 var handle = this.handles[i]; 1967 this._bindStartEvent( handle, isAdd ); 1968 handle[ bindMethod ]( 'click', this ); 1969 if ( window.PointerEvent ) { 1970 handle.style.touchAction = touchAction; 1971 } 1972 } 1973}; 1974 1975proto._touchActionValue = 'none'; 1976 1977 1978proto.pointerDown = function( event, pointer ) { 1979 var isOkay = this.okayPointerDown( event ); 1980 if ( !isOkay ) { 1981 return; 1982 } 1983 this.pointerDownPointer = { 1984 pageX: pointer.pageX, 1985 pageY: pointer.pageY, 1986 }; 1987 1988 event.preventDefault(); 1989 this.pointerDownBlur(); 1990 this._bindPostStartEvents( event ); 1991 this.emitEvent( 'pointerDown', [ event, pointer ] ); 1992}; 1993 1994var cursorNodes = { 1995 TEXTAREA: true, 1996 INPUT: true, 1997 SELECT: true, 1998 OPTION: true, 1999}; 2000 2001var clickTypes = { 2002 radio: true, 2003 checkbox: true, 2004 button: true, 2005 submit: true, 2006 image: true, 2007 file: true, 2008}; 2009 2010proto.okayPointerDown = function( event ) { 2011 var isCursorNode = cursorNodes[ event.target.nodeName ];
2012 var isClickType = clickTypes[ event.target.type ]; 2013 var isOkay = !isCursorNode || isClickType; 2014 if ( !isOkay ) { 2015 this._pointerReset(); 2016 } 2017 return isOkay; 2018}; 2019 2020proto.pointerDownBlur = function() { 2021 var focused = document.activeElement; 2022 var canBlur = focused && focused.blur && focused != document.body; 2023 if ( canBlur ) { 2024 focused.blur(); 2025 } 2026}; 2027 2028 2029proto.pointerMove = function( event, pointer ) { 2030 var moveVector = this._dragPointerMove( event, pointer ); 2031 this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] ); 2032 this._dragMove( event, pointer, moveVector ); 2033}; 2034 2035proto._dragPointerMove = function( event, pointer ) { 2036 var moveVector = { 2037 x: pointer.pageX - this.pointerDownPointer.pageX, 2038 y: pointer.pageY - this.pointerDownPointer.pageY 2039 }; 2040 if ( !this.isDragging && this.hasDragStarted( moveVector ) ) { 2041 this._dragStart( event, pointer ); 2042 } 2043 return moveVector; 2044}; 2045 2046proto.hasDragStarted = function( moveVector ) { 2047 return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3; 2048}; 2049 2050 2051proto.pointerUp = function( event, pointer ) { 2052 this.emitEvent( 'pointerUp', [ event, pointer ] ); 2053 this._dragPointerUp( event, pointer ); 2054}; 2055 2056proto._dragPointerUp = function( event, pointer ) { 2057 if ( this.isDragging ) { 2058 this._dragEnd( event, pointer ); 2059 } else { 2060 this._staticClick( event, pointer ); 2061 } 2062}; 2063 2064 2065proto._dragStart = function( event, pointer ) { 2066 this.isDragging = true;
2067 this.isPreventingClicks = true; 2068 this.dragStart( event, pointer ); 2069}; 2070 2071proto.dragStart = function( event, pointer ) { 2072 this.emitEvent( 'dragStart', [ event, pointer ] ); 2073}; 2074 2075proto._dragMove = function( event, pointer, moveVector ) { 2076 if ( !this.isDragging ) { 2077 return; 2078 } 2079 2080 this.dragMove( event, pointer, moveVector ); 2081}; 2082 2083proto.dragMove = function( event, pointer, moveVector ) { 2084 event.preventDefault(); 2085 this.emitEvent( 'dragMove', [ event, pointer, moveVector ] ); 2086}; 2087 2088proto._dragEnd = function( event, pointer ) { 2089 this.isDragging = false; 2090 setTimeout( function() { 2091 delete this.isPreventingClicks; 2092 }.bind( this ) ); 2093 2094 this.dragEnd( event, pointer ); 2095}; 2096 2097proto.dragEnd = function( event, pointer ) { 2098 this.emitEvent( 'dragEnd', [ event, pointer ] ); 2099}; 2100 2101 2102proto.onclick = function( event ) { 2103 if ( this.isPreventingClicks ) { 2104 event.preventDefault(); 2105 } 2106}; 2107 2108 2109proto._staticClick = function( event, pointer ) { 2110 if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) { 2111 return; 2112 } 2113 2114 this.staticClick( event, pointer ); 2115 2116 if ( event.type != 'mouseup' ) { 2117 this.isIgnoringMouseUp = true; 2118 setTimeout( function() { 2119 delete this.isIgnoringMouseUp; 2120 }.bind( this ), 400 ); 2121 } 2122}; 2123 2124proto.staticClick = function( event, pointer ) { 2125 this.emitEvent( 'staticClick', [ event, pointer ] ); 2126}; 2127 2128 2129Unidragger.getPointerPoint = Unipointer.getPointerPoint; 2130 2131 2132return Unidragger; 2133 2134})); 2135 2136( function( window, factory ) { 2137 if ( typeof define == 'function' && define.amd ) { 2138 define( 'flickity/js/drag',[ 2139 './flickity', 2140 'unidragger/unidragger', 2141 'fizzy-ui-utils/utils', 2142 ], function( Flickity, Unidragger, utils ) { 2143 return factory( window, Flickity, Unidragger, utils ); 2144 } ); 2145 } else if ( typeof module == 'object' && module.exports ) { 2146 module.exports = factory( 2147 window, 2148 require('./flickity'), 2149 require('unidragger'), 2150 require('fizzy-ui-utils') 2151 ); 2152 } else { 2153 window.Flickity = factory( 2154 window, 2155 window.Flickity, 2156 window.Unidragger, 2157 window.fizzyUIUtils 2158 ); 2159 } 2160 2161}( window, function factory( window, Flickity, Unidragger, utils ) { 2162 2163 2164 2165 2166utils.extend( Flickity.defaults, { 2167 draggable: '>1', 2168 dragThreshold: 3, 2169} ); 2170 2171 2172Flickity.createMethods.push('_createDrag'); 2173 2174 2175var proto = Flickity.prototype; 2176utils.extend( proto, Unidragger.prototype ); 2177proto._touchActionValue = 'pan-y'; 2178 2179 2180proto._createDrag = function() { 2181 this.on( 'activate', this.onActivateDrag ); 2182 this.on( 'uiChange', this._uiChangeDrag ); 2183 this.on( 'deactivate', this.onDeactivateDrag ); 2184 this.on( 'cellChange', this.updateDraggable ); 2185}; 2186 2187proto.onActivateDrag = function() { 2188 this.handles = [ this.viewport ]; 2189 this.bindHandles(); 2190 this.updateDraggable(); 2191}; 2192 2193proto.onDeactivateDrag = function() { 2194 this.unbindHandles(); 2195 this.element.classList.remove('is-draggable'); 2196}; 2197 2198proto.updateDraggable = function() { 2199 if ( this.options.draggable == '>1' ) { 2200 this.isDraggable = this.slides.length > 1; 2201 } else { 2202 this.isDraggable = this.options.draggable; 2203 } 2204 if ( this.isDraggable ) { 2205 this.element.classList.add('is-draggable'); 2206 } else { 2207 this.element.classList.remove('is-draggable'); 2208 } 2209}; 2210 2211proto.bindDrag = function() { 2212 this.options.draggable = true; 2213 this.updateDraggable(); 2214}; 2215 2216proto.unbindDrag = function() { 2217 this.options.draggable = false; 2218 this.updateDraggable(); 2219}; 2220 2221proto._uiChangeDrag = function() { 2222 delete this.isFreeScrolling; 2223}; 2224 2225 2226proto.pointerDown = function( event, pointer ) { 2227 if ( !this.isDraggable ) { 2228 this._pointerDownDefault( event, pointer ); 2229 return; 2230 } 2231 var isOkay = this.okayPointerDown( event ); 2232 if ( !isOkay ) { 2233 return; 2234 } 2235 2236 this._pointerDownPreventDefault( event ); 2237 this.pointerDownFocus( event ); 2238 if ( document.activeElement != this.element ) { 2239 this.pointerDownBlur(); 2240 } 2241 2242 this.dragX = this.x; 2243 this.viewport.classList.add('is-pointer-down'); 2244 this.pointerDownScroll = getScrollPosition(); 2245 window.addEventListener( 'scroll', this ); 2246 2247 this._pointerDownDefault( event, pointer ); 2248}; 2249 2250proto._pointerDownDefault = function( event, pointer ) { 2251 this.pointerDownPointer = { 2252 pageX: pointer.pageX, 2253 pageY: pointer.pageY, 2254 }; 2255 this._bindPostStartEvents( event ); 2256 this.dispatchEvent( 'pointerDown', event, [ pointer ] ); 2257}; 2258 2259var focusNodes = { 2260 INPUT: true, 2261 TEXTAREA: true, 2262 SELECT: true, 2263}; 2264 2265proto.pointerDownFocus = function( event ) { 2266 var isFocusNode = focusNodes[ event.target.nodeName ]; 2267 if ( !isFocusNode ) { 2268 this.focus(); 2269 } 2270}; 2271 2272proto._pointerDownPreventDefault = function( event ) { 2273 var isTouchStart = event.type == 'touchstart'; 2274 var isTouchPointer = event.pointerType == 'touch'; 2275 var isFocusNode = focusNodes[ event.target.nodeName ]; 2276 if ( !isTouchStart && !isTouchPointer && !isFocusNode ) { 2277 event.preventDefault(); 2278 } 2279}; 2280 2281 2282proto.hasDragStarted = function( moveVector ) { 2283 return Math.abs( moveVector.x ) > this.options.dragThreshold; 2284}; 2285 2286 2287proto.pointerUp = function( event, pointer ) { 2288 delete this.isTouchScrolling; 2289 this.viewport.classList.remove('is-pointer-down'); 2290 this.dispatchEvent( 'pointerUp', event, [ pointer ] ); 2291 this._dragPointerUp( event, pointer ); 2292}; 2293 2294proto.pointerDone = function() { 2295 window.removeEventListener( 'scroll', this ); 2296 delete this.pointerDownScroll; 2297}; 2298 2299 2300proto.dragStart = function( event, pointer ) { 2301 if ( !this.isDraggable ) { 2302 return; 2303 } 2304 this.dragStartPosition = this.x; 2305 this.startAnimation(); 2306 window.removeEventListener( 'scroll', this ); 2307 this.dispatchEvent( 'dragStart', event, [ pointer ] ); 2308}; 2309 2310proto.pointerMove = function( event, pointer ) { 2311 var moveVector = this._dragPointerMove( event, pointer ); 2312 this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] ); 2313 this._dragMove( event, pointer, moveVector ); 2314}; 2315 2316proto.dragMove = function( event, pointer, moveVector ) { 2317 if ( !this.isDraggable ) { 2318 return; 2319 } 2320 event.preventDefault(); 2321 2322 this.previousDragX = this.dragX; 2323 var direction = this.options.rightToLeft ? -1 : 1; 2324 if ( this.options.wrapAround ) { 2325 moveVector.x %= this.slideableWidth; 2326 } 2327 var dragX = this.dragStartPosition + moveVector.x * direction; 2328 2329 if ( !this.options.wrapAround && this.slides.length ) { 2330 var originBound = Math.max( -this.slides[0].target, this.dragStartPosition ); 2331 dragX = dragX > originBound ? ( dragX + originBound ) * 0.5 : dragX; 2332 var endBound = Math.min( -this.getLastSlide().target, this.dragStartPosition ); 2333 dragX = dragX < endBound ? ( dragX + endBound ) * 0.5 : dragX; 2334 } 2335 2336 this.dragX = dragX; 2337 2338 this.dragMoveTime = new Date(); 2339 this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] ); 2340}; 2341 2342proto.dragEnd = function( event, pointer ) { 2343 if ( !this.isDraggable ) { 2344 return; 2345 } 2346 if ( this.options.freeScroll ) { 2347 this.isFreeScrolling = true; 2348 } 2349 var index = this.dragEndRestingSelect(); 2350 2351 if ( this.options.freeScroll && !this.options.wrapAround ) { 2352 var restingX = this.getRestingPosition(); 2353 this.isFreeScrolling = -restingX > this.slides[0].target && 2354 -restingX < this.getLastSlide().target; 2355 } else if ( !this.options.freeScroll && index == this.selectedIndex ) { 2356 index += this.dragEndBoostSelect(); 2357 } 2358 delete this.previousDragX; 2359 this.isDragSelect = this.options.wrapAround; 2360 this.select( index ); 2361 delete this.isDragSelect; 2362 this.dispatchEvent( 'dragEnd', event, [ pointer ] ); 2363}; 2364 2365proto.dragEndRestingSelect = function() { 2366 var restingX = this.getRestingPosition();
2367 var distance = Math.abs( this.getSlideDistance( -restingX, this.selectedIndex ) ); 2368 var positiveResting = this._getClosestResting( restingX, distance, 1 ); 2369 var negativeResting = this._getClosestResting( restingX, distance, -1 ); 2370 var index = positiveResting.distance < negativeResting.distance ? 2371 positiveResting.index : negativeResting.index; 2372 return index; 2373}; 2374 2375proto._getClosestResting = function( restingX, distance, increment ) { 2376 var index = this.selectedIndex; 2377 var minDistance = Infinity; 2378 var condition = this.options.contain && !this.options.wrapAround ? 2379 function( dist, minDist ) { 2380 return dist <= minDist; 2381 } : function( dist, minDist ) { 2382 return dist < minDist; 2383 }; 2384 while ( condition( distance, minDistance ) ) { 2385 index += increment; 2386 minDistance = distance; 2387 distance = this.getSlideDistance( -restingX, index ); 2388 if ( distance === null ) { 2389 break; 2390 } 2391 distance = Math.abs( distance ); 2392 } 2393 return { 2394 distance: minDistance, 2395 index: index - increment, 2396 }; 2397}; 2398 2399proto.getSlideDistance = function( x, index ) { 2400 var len = this.slides.length; 2401 var isWrapAround = this.options.wrapAround && len > 1; 2402 var slideIndex = isWrapAround ? utils.modulo( index, len ) : index; 2403 var slide = this.slides[ slideIndex ]; 2404 if ( !slide ) { 2405 return null; 2406 } 2407 var wrap = isWrapAround ? this.slideableWidth * Math.floor( index/len ) : 0; 2408 return x - ( slide.target + wrap ); 2409}; 2410 2411proto.dragEndBoostSelect = function() { 2412 if ( this.previousDragX === undefined || !this.dragMoveTime || 2413 new Date() - this.dragMoveTime > 100 ) { 2414 return 0; 2415 } 2416 2417 var distance = this.getSlideDistance( -this.dragX, this.selectedIndex ); 2418 var delta = this.previousDragX - this.dragX; 2419 if ( distance > 0 && delta > 0 ) { 2420 return 1; 2421 } else if ( distance < 0 && delta < 0 ) { 2422 return -1; 2423 } 2424 return 0; 2425}; 2426 2427 2428proto.staticClick = function( event, pointer ) { 2429 var clickedCell = this.getParentCell( event.target ); 2430 var cellElem = clickedCell && clickedCell.element; 2431 var cellIndex = clickedCell && this.cells.indexOf( clickedCell ); 2432 this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] ); 2433}; 2434 2435 2436proto.onscroll = function() { 2437 var scroll = getScrollPosition(); 2438 var scrollMoveX = this.pointerDownScroll.x - scroll.x; 2439 var scrollMoveY = this.pointerDownScroll.y - scroll.y; 2440 if ( Math.abs( scrollMoveX ) > 3 || Math.abs( scrollMoveY ) > 3 ) { 2441 this._pointerDone(); 2442 } 2443}; 2444 2445 2446function getScrollPosition() { 2447 return { 2448 x: window.pageXOffset, 2449 y: window.pageYOffset, 2450 }; 2451} 2452 2453 2454return Flickity; 2455 2456} ) ); 2457 2458( function( window, factory ) { 2459 if ( typeof define == 'function' && define.amd ) { 2460 define( 'flickity/js/prev-next-button',[ 2461 './flickity', 2462 'unipointer/unipointer', 2463 'fizzy-ui-utils/utils', 2464 ], function( Flickity, Unipointer, utils ) { 2465 return factory( window, Flickity, Unipointer, utils ); 2466 } ); 2467 } else if ( typeof module == 'object' && module.exports ) { 2468 module.exports = factory( 2469 window, 2470 require('./flickity'), 2471 require('unipointer'), 2472 require('fizzy-ui-utils') 2473 ); 2474 } else { 2475 factory( 2476 window, 2477 window.Flickity, 2478 window.Unipointer, 2479 window.fizzyUIUtils 2480 ); 2481 } 2482 2483}( window, function factory( window, Flickity, Unipointer, utils ) { 2484'use strict'; 2485 2486var svgURI = 'http://www.w3.org/2000/svg'; 2487 2488 2489function PrevNextButton( direction, parent ) { 2490 this.direction = direction; 2491 this.parent = parent; 2492 this._create(); 2493} 2494 2495PrevNextButton.prototype = Object.create( Unipointer.prototype ); 2496 2497PrevNextButton.prototype._create = function() { 2498 this.isEnabled = true; 2499 this.isPrevious = this.direction == -1; 2500 var leftDirection = this.parent.options.rightToLeft ? 1 : -1; 2501 this.isLeft = this.direction == leftDirection; 2502 2503 var element = this.element = document.createElement('button'); 2504 element.className = 'flickity-button flickity-prev-next-button'; 2505 element.className += this.isPrevious ? ' previous' : ' next'; 2506 element.setAttribute( 'type', 'button' ); 2507 this.disable(); 2508 2509 element.setAttribute( 'aria-label', this.isPrevious ? 'Previous' : 'Next' ); 2510 2511 var svg = this.createSVG(); 2512 element.appendChild( svg ); 2513 this.parent.on( 'select', this.update.bind( this ) ); 2514 this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) ); 2515}; 2516 2517PrevNextButton.prototype.activate = function() { 2518 this.bindStartEvent( this.element ); 2519 this.element.addEventListener( 'click', this ); 2520 this.parent.element.appendChild( this.element ); 2521}; 2522 2523PrevNextButton.prototype.deactivate = function() { 2524 this.parent.element.removeChild( this.element ); 2525 this.unbindStartEvent( this.element ); 2526 this.element.removeEventListener( 'click', this ); 2527}; 2528 2529PrevNextButton.prototype.createSVG = function() { 2530 var svg = document.createElementNS( svgURI, 'svg' ); 2531 svg.setAttribute( 'class', 'flickity-button-icon' ); 2532 svg.setAttribute( 'viewBox', '0 0 100 100' ); 2533 var path = document.createElementNS( svgURI, 'path' ); 2534 var pathMovements = getArrowMovements( this.parent.options.arrowShape ); 2535 path.setAttribute( 'd', pathMovements ); 2536 path.setAttribute( 'class', 'arrow' ); 2537 if ( !this.isLeft ) { 2538 path.setAttribute( 'transform', 'translate(100, 100) rotate(180) ' ); 2539 } 2540 svg.appendChild( path ); 2541 return svg; 2542}; 2543 2544function getArrowMovements( shape ) { 2545 if ( typeof shape == 'string' ) { 2546 return shape; 2547 } 2548 return 'M ' + shape.x0 + ',50' + 2549 ' L ' + shape.x1 + ',' + ( shape.y1 + 50 ) + 2550 ' L ' + shape.x2 + ',' + ( shape.y2 + 50 ) + 2551 ' L ' + shape.x3 + ',50 ' + 2552 ' L ' + shape.x2 + ',' + ( 50 - shape.y2 ) + 2553 ' L ' + shape.x1 + ',' + ( 50 - shape.y1 ) + 2554 ' Z'; 2555} 2556 2557PrevNextButton.prototype.handleEvent = utils.handleEvent; 2558 2559PrevNextButton.prototype.onclick = function() { 2560 if ( !this.isEnabled ) { 2561 return; 2562 } 2563 this.parent.uiChange(); 2564 var method = this.isPrevious ? 'previous' : 'next'; 2565 this.parent[ method ](); 2566}; 2567 2568 2569PrevNextButton.prototype.enable = function() { 2570 if ( this.isEnabled ) { 2571 return; 2572 } 2573 this.element.disabled = false;
2574 this.isEnabled = true; 2575}; 2576 2577PrevNextButton.prototype.disable = function() { 2578 if ( !this.isEnabled ) { 2579 return; 2580 } 2581 this.element.disabled = true; 2582 this.isEnabled = false; 2583}; 2584 2585PrevNextButton.prototype.update = function() { 2586 var slides = this.parent.slides; 2587 if ( this.parent.options.wrapAround && slides.length > 1 ) { 2588 this.enable(); 2589 return; 2590 } 2591 var lastIndex = slides.length ? slides.length - 1 : 0; 2592 var boundIndex = this.isPrevious ? 0 : lastIndex; 2593 var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable'; 2594 this[ method ](); 2595}; 2596 2597PrevNextButton.prototype.destroy = function() { 2598 this.deactivate(); 2599 this.allOff(); 2600}; 2601 2602 2603utils.extend( Flickity.defaults, { 2604 prevNextButtons: true, 2605 arrowShape: { 2606 x0: 10, 2607 x1: 60, y1: 50, 2608 x2: 70, y2: 40, 2609 x3: 30, 2610 }, 2611} ); 2612 2613Flickity.createMethods.push('_createPrevNextButtons'); 2614var proto = Flickity.prototype; 2615 2616proto._createPrevNextButtons = function() { 2617 if ( !this.options.prevNextButtons ) { 2618 return; 2619 } 2620 2621 this.prevButton = new PrevNextButton( -1, this ); 2622 this.nextButton = new PrevNextButton( 1, this ); 2623 2624 this.on( 'activate', this.activatePrevNextButtons ); 2625}; 2626 2627proto.activatePrevNextButtons = function() { 2628 this.prevButton.activate(); 2629 this.nextButton.activate(); 2630 this.on( 'deactivate', this.deactivatePrevNextButtons ); 2631}; 2632 2633proto.deactivatePrevNextButtons = function() { 2634 this.prevButton.deactivate(); 2635 this.nextButton.deactivate(); 2636 this.off( 'deactivate', this.deactivatePrevNextButtons ); 2637}; 2638 2639 2640Flickity.PrevNextButton = PrevNextButton; 2641 2642return Flickity; 2643 2644} ) ); 2645 2646( function( window, factory ) { 2647 if ( typeof define == 'function' && define.amd ) { 2648 define( 'flickity/js/page-dots',[ 2649 './flickity', 2650 'unipointer/unipointer', 2651 'fizzy-ui-utils/utils', 2652 ], function( Flickity, Unipointer, utils ) { 2653 return factory( window, Flickity, Unipointer, utils ); 2654 } ); 2655 } else if ( typeof module == 'object' && module.exports ) { 2656 module.exports = factory( 2657 window, 2658 require('./flickity'), 2659 require('unipointer'), 2660 require('fizzy-ui-utils') 2661 ); 2662 } else { 2663 factory( 2664 window, 2665 window.Flickity, 2666 window.Unipointer, 2667 window.fizzyUIUtils 2668 ); 2669 } 2670 2671}( window, function factory( window, Flickity, Unipointer, utils ) { 2672 2673 2674 2675 2676function PageDots( parent ) { 2677 this.parent = parent; 2678 this._create(); 2679} 2680 2681PageDots.prototype = Object.create( Unipointer.prototype ); 2682 2683PageDots.prototype._create = function() { 2684 this.holder = document.createElement('ol'); 2685 this.holder.className = 'flickity-page-dots'; 2686 this.dots = []; 2687 this.handleClick = this.onClick.bind( this ); 2688 this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) ); 2689}; 2690 2691PageDots.prototype.activate = function() { 2692 this.setDots(); 2693 this.holder.addEventListener( 'click', this.handleClick ); 2694 this.bindStartEvent( this.holder ); 2695 this.parent.element.appendChild( this.holder ); 2696}; 2697 2698PageDots.prototype.deactivate = function() { 2699 this.holder.removeEventListener( 'click', this.handleClick ); 2700 this.unbindStartEvent( this.holder ); 2701 this.parent.element.removeChild( this.holder ); 2702}; 2703 2704PageDots.prototype.setDots = function() { 2705 var delta = this.parent.slides.length - this.dots.length; 2706 if ( delta > 0 ) { 2707 this.addDots( delta ); 2708 } else if ( delta < 0 ) { 2709 this.removeDots( -delta ); 2710 } 2711}; 2712 2713PageDots.prototype.addDots = function( count ) { 2714 var fragment = document.createDocumentFragment(); 2715 var newDots = []; 2716 var length = this.dots.length; 2717 var max = length + count; 2718 2719 for ( var i = length; i < max; i++ ) { 2720 var dot = document.createElement('li'); 2721 dot.className = 'dot'; 2722 dot.setAttribute( 'aria-label', 'Page dot ' + ( i + 1 ) ); 2723 fragment.appendChild( dot ); 2724 newDots.push( dot ); 2725 } 2726 2727 this.holder.appendChild( fragment ); 2728 this.dots = this.dots.concat( newDots ); 2729}; 2730 2731PageDots.prototype.removeDots = function( count ) { 2732 var removeDots = this.dots.splice( this.dots.length - count, count ); 2733 removeDots.forEach( function( dot ) { 2734 this.holder.removeChild( dot ); 2735 }, this ); 2736}; 2737 2738PageDots.prototype.updateSelected = function() { 2739 if ( this.selectedDot ) { 2740 this.selectedDot.className = 'dot'; 2741 this.selectedDot.removeAttribute('aria-current'); 2742 } 2743 if ( !this.dots.length ) { 2744 return; 2745 } 2746 this.selectedDot = this.dots[ this.parent.selectedIndex ]; 2747 this.selectedDot.className = 'dot is-selected'; 2748 this.selectedDot.setAttribute( 'aria-current', 'step' ); 2749}; 2750 2751PageDots.prototype.onTap = 2752PageDots.prototype.onClick = function( event ) { 2753 var target = event.target; 2754 if ( target.nodeName != 'LI' ) { 2755 return; 2756 } 2757 2758 this.parent.uiChange(); 2759 var index = this.dots.indexOf( target ); 2760 this.parent.select( index ); 2761}; 2762 2763PageDots.prototype.destroy = function() { 2764 this.deactivate(); 2765 this.allOff(); 2766}; 2767 2768Flickity.PageDots = PageDots; 2769 2770 2771utils.extend( Flickity.defaults, { 2772 pageDots: true, 2773} ); 2774 2775Flickity.createMethods.push('_createPageDots'); 2776 2777var proto = Flickity.prototype; 2778 2779proto._createPageDots = function() { 2780 if ( !this.options.pageDots ) { 2781 return; 2782 } 2783 this.pageDots = new PageDots( this ); 2784 this.on( 'activate', this.activatePageDots ); 2785 this.on( 'select', this.updateSelectedPageDots ); 2786 this.on( 'cellChange', this.updatePageDots ); 2787 this.on( 'resize', this.updatePageDots ); 2788 this.on( 'deactivate', this.deactivatePageDots ); 2789}; 2790 2791proto.activatePageDots = function() { 2792 this.pageDots.activate(); 2793}; 2794 2795proto.updateSelectedPageDots = function() { 2796 this.pageDots.updateSelected(); 2797}; 2798 2799proto.updatePageDots = function() { 2800 this.pageDots.setDots(); 2801}; 2802 2803proto.deactivatePageDots = function() { 2804 this.pageDots.deactivate(); 2805}; 2806 2807 2808Flickity.PageDots = PageDots; 2809 2810return Flickity; 2811 2812} ) ); 2813 2814( function( window, factory ) { 2815 if ( typeof define == 'function' && define.amd ) { 2816 define( 'flickity/js/player',[ 2817 'ev-emitter/ev-emitter', 2818 'fizzy-ui-utils/utils', 2819 './flickity', 2820 ], function( EvEmitter, utils, Flickity ) { 2821 return factory( EvEmitter, utils, Flickity ); 2822 } ); 2823 } else if ( typeof module == 'object' && module.exports ) { 2824 module.exports = factory( 2825 require('ev-emitter'), 2826 require('fizzy-ui-utils'), 2827 require('./flickity') 2828 ); 2829 } else { 2830 factory( 2831 window.EvEmitter, 2832 window.fizzyUIUtils, 2833 window.Flickity 2834 ); 2835 } 2836 2837}( window, function factory( EvEmitter, utils, Flickity ) { 2838 2839 2840 2841 2842function Player( parent ) { 2843 this.parent = parent; 2844 this.state = 'stopped'; 2845 this.onVisibilityChange = this.visibilityChange.bind( this ); 2846 this.onVisibilityPlay = this.visibilityPlay.bind( this ); 2847} 2848 2849Player.prototype = Object.create( EvEmitter.prototype ); 2850 2851Player.prototype.play = function() { 2852 if ( this.state == 'playing' ) { 2853 return; 2854 } 2855 var isPageHidden = document.hidden; 2856 if ( isPageHidden ) { 2857 document.addEventListener( 'visibilitychange', this.onVisibilityPlay ); 2858 return; 2859 } 2860 2861 this.state = 'playing'; 2862 document.addEventListener( 'visibilitychange', this.onVisibilityChange ); 2863 this.tick(); 2864}; 2865 2866Player.prototype.tick = function() { 2867 if ( this.state != 'playing' ) { 2868 return; 2869 } 2870 2871 var time = this.parent.options.autoPlay; 2872 time = typeof time == 'number' ? time : 3000; 2873 var _this = this; 2874 this.clear(); 2875 this.timeout = setTimeout( function() { 2876 _this.parent.next( true ); 2877 _this.tick(); 2878 }, time ); 2879}; 2880 2881Player.prototype.stop = function() { 2882 this.state = 'stopped'; 2883 this.clear(); 2884 document.removeEventListener( 'visibilitychange', this.onVisibilityChange ); 2885}; 2886 2887Player.prototype.clear = function() { 2888 clearTimeout( this.timeout ); 2889}; 2890 2891Player.prototype.pause = function() { 2892 if ( this.state == 'playing' ) { 2893 this.state = 'paused'; 2894 this.clear(); 2895 } 2896}; 2897 2898Player.prototype.unpause = function() { 2899 if ( this.state == 'paused' ) { 2900 this.play(); 2901 } 2902}; 2903 2904Player.prototype.visibilityChange = function() { 2905 var isPageHidden = document.hidden; 2906 this[ isPageHidden ? 'pause' : 'unpause' ](); 2907}; 2908 2909Player.prototype.visibilityPlay = function() { 2910 this.play(); 2911 document.removeEventListener( 'visibilitychange', this.onVisibilityPlay ); 2912}; 2913 2914 2915utils.extend( Flickity.defaults, { 2916 pauseAutoPlayOnHover: true, 2917} ); 2918 2919Flickity.createMethods.push('_createPlayer'); 2920var proto = Flickity.prototype; 2921 2922proto._createPlayer = function() { 2923 this.player = new Player( this ); 2924 2925 this.on( 'activate', this.activatePlayer ); 2926 this.on( 'uiChange', this.stopPlayer ); 2927 this.on( 'pointerDown', this.stopPlayer ); 2928 this.on( 'deactivate', this.deactivatePlayer ); 2929}; 2930 2931proto.activatePlayer = function() { 2932 if ( !this.options.autoPlay ) { 2933 return; 2934 } 2935 this.player.play(); 2936 this.element.addEventListener( 'mouseenter', this ); 2937}; 2938 2939 2940proto.playPlayer = function() { 2941 this.player.play(); 2942}; 2943 2944proto.stopPlayer = function() { 2945 this.player.stop(); 2946}; 2947 2948proto.pausePlayer = function() { 2949 this.player.pause(); 2950}; 2951 2952proto.unpausePlayer = function() { 2953 this.player.unpause(); 2954}; 2955 2956proto.deactivatePlayer = function() { 2957 this.player.stop(); 2958 this.element.removeEventListener( 'mouseenter', this ); 2959}; 2960 2961 2962proto.onmouseenter = function() { 2963 if ( !this.options.pauseAutoPlayOnHover ) { 2964 return; 2965 } 2966 this.player.pause(); 2967 this.element.addEventListener( 'mouseleave', this ); 2968}; 2969 2970proto.onmouseleave = function() { 2971 this.player.unpause(); 2972 this.element.removeEventListener( 'mouseleave', this ); 2973}; 2974 2975 2976Flickity.Player = Player; 2977 2978return Flickity; 2979 2980} ) ); 2981 2982( function( window, factory ) { 2983 if ( typeof define == 'function' && define.amd ) { 2984 define( 'flickity/js/add-remove-cell',[ 2985 './flickity', 2986 'fizzy-ui-utils/utils', 2987 ], function( Flickity, utils ) { 2988 return factory( window, Flickity, utils ); 2989 } ); 2990 } else if ( typeof module == 'object' && module.exports ) { 2991 module.exports = factory( 2992 window, 2993 require('./flickity'), 2994 require('fizzy-ui-utils') 2995 ); 2996 } else { 2997 factory( 2998 window, 2999 window.Flickity, 3000 window.fizzyUIUtils 3001 ); 3002 } 3003 3004}( window, function factory( window, Flickity, utils ) { 3005 3006 3007 3008function getCellsFragment( cells ) { 3009 var fragment = document.createDocumentFragment();
3010 cells.forEach( function( cell ) { 3011 fragment.appendChild( cell.element ); 3012 } ); 3013 return fragment; 3014} 3015 3016 3017var proto = Flickity.prototype; 3018 3019proto.insert = function( elems, index ) { 3020 var cells = this._makeCells( elems ); 3021 if ( !cells || !cells.length ) { 3022 return; 3023 } 3024 var len = this.cells.length; 3025 index = index === undefined ? len : index; 3026 var fragment = getCellsFragment( cells ); 3027 var isAppend = index == len; 3028 if ( isAppend ) { 3029 this.slider.appendChild( fragment ); 3030 } else { 3031 var insertCellElement = this.cells[ index ].element; 3032 this.slider.insertBefore( fragment, insertCellElement ); 3033 } 3034 if ( index === 0 ) { 3035 this.cells = cells.concat( this.cells ); 3036 } else if ( isAppend ) { 3037 this.cells = this.cells.concat( cells ); 3038 } else { 3039 var endCells = this.cells.splice( index, len - index ); 3040 this.cells = this.cells.concat( cells ).concat( endCells ); 3041 } 3042 3043 this._sizeCells( cells ); 3044 this.cellChange( index, true ); 3045}; 3046 3047proto.append = function( elems ) { 3048 this.insert( elems, this.cells.length ); 3049}; 3050 3051proto.prepend = function( elems ) { 3052 this.insert( elems, 0 ); 3053}; 3054 3055proto.remove = function( elems ) { 3056 var cells = this.getCells( elems ); 3057 if ( !cells || !cells.length ) { 3058 return; 3059 } 3060 3061 var minCellIndex = this.cells.length - 1; 3062 cells.forEach( function( cell ) { 3063 cell.remove(); 3064 var index = this.cells.indexOf( cell ); 3065 minCellIndex = Math.min( index, minCellIndex ); 3066 utils.removeFrom( this.cells, cell ); 3067 }, this ); 3068 3069 this.cellChange( minCellIndex, true ); 3070}; 3071 3072proto.cellSizeChange = function( elem ) { 3073 var cell = this.getCell( elem ); 3074 if ( !cell ) { 3075 return; 3076 } 3077 cell.getSize(); 3078 3079 var index = this.cells.indexOf( cell ); 3080 this.cellChange( index ); 3081}; 3082 3083proto.cellChange = function( changedCellIndex, isPositioningSlider ) { 3084 var prevSelectedElem = this.selectedElement; 3085 this._positionCells( changedCellIndex ); 3086 this._getWrapShiftCells(); 3087 this.setGallerySize(); 3088 var cell = this.getCell( prevSelectedElem ); 3089 if ( cell ) { 3090 this.selectedIndex = this.getCellSlideIndex( cell ); 3091 } 3092 this.selectedIndex = Math.min( this.slides.length - 1, this.selectedIndex ); 3093 3094 this.emitEvent( 'cellChange', [ changedCellIndex ] ); 3095 this.select( this.selectedIndex ); 3096 if ( isPositioningSlider ) { 3097 this.positionSliderAtSelected(); 3098 } 3099}; 3100 3101 3102return Flickity; 3103 3104} ) ); 3105 3106( function( window, factory ) { 3107 if ( typeof define == 'function' && define.amd ) { 3108 define( 'flickity/js/lazyload',[ 3109 './flickity', 3110 'fizzy-ui-utils/utils', 3111 ], function( Flickity, utils ) { 3112 return factory( window, Flickity, utils ); 3113 } ); 3114 } else if ( typeof module == 'object' && module.exports ) { 3115 module.exports = factory( 3116 window, 3117 require('./flickity'), 3118 require('fizzy-ui-utils') 3119 ); 3120 } else { 3121 factory( 3122 window, 3123 window.Flickity, 3124 window.fizzyUIUtils 3125 ); 3126 } 3127 3128}( window, function factory( window, Flickity, utils ) { 3129'use strict'; 3130 3131Flickity.createMethods.push('_createLazyload'); 3132var proto = Flickity.prototype; 3133 3134proto._createLazyload = function() { 3135 this.on( 'select', this.lazyLoad ); 3136}; 3137 3138proto.lazyLoad = function() { 3139 var lazyLoad = this.options.lazyLoad; 3140 if ( !lazyLoad ) { 3141 return; 3142 } 3143 var adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0; 3144 var cellElems = this.getAdjacentCellElements( adjCount ); 3145 var lazyImages = [];
3146 cellElems.forEach( function( cellElem ) { 3147 var lazyCellImages = getCellLazyImages( cellElem ); 3148 lazyImages = lazyImages.concat( lazyCellImages ); 3149 } ); 3150 lazyImages.forEach( function( img ) { 3151 new LazyLoader( img, this ); 3152 }, this ); 3153}; 3154 3155function getCellLazyImages( cellElem ) { 3156 if ( cellElem.nodeName == 'IMG' ) { 3157 var lazyloadAttr = cellElem.getAttribute('data-flickity-lazyload'); 3158 var srcAttr = cellElem.getAttribute('data-flickity-lazyload-src'); 3159 var srcsetAttr = cellElem.getAttribute('data-flickity-lazyload-srcset'); 3160 if ( lazyloadAttr || srcAttr || srcsetAttr ) { 3161 return [ cellElem ]; 3162 } 3163 } 3164 var lazySelector = 'img[data-flickity-lazyload], ' + 3165 'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]'; 3166 var imgs = cellElem.querySelectorAll( lazySelector ); 3167 return utils.makeArray( imgs ); 3168} 3169 3170 3171function LazyLoader( img, flickity ) { 3172 this.img = img; 3173 this.flickity = flickity; 3174 this.load(); 3175} 3176 3177LazyLoader.prototype.handleEvent = utils.handleEvent; 3178 3179LazyLoader.prototype.load = function() { 3180 this.img.addEventListener( 'load', this ); 3181 this.img.addEventListener( 'error', this ); 3182 var src = this.img.getAttribute('data-flickity-lazyload') || 3183 this.img.getAttribute('data-flickity-lazyload-src'); 3184 var srcset = this.img.getAttribute('data-flickity-lazyload-srcset'); 3185 this.img.src = src; 3186 if ( srcset ) { 3187 this.img.setAttribute( 'srcset', srcset ); 3188 } 3189 this.img.removeAttribute('data-flickity-lazyload'); 3190 this.img.removeAttribute('data-flickity-lazyload-src'); 3191 this.img.removeAttribute('data-flickity-lazyload-srcset'); 3192}; 3193 3194LazyLoader.prototype.onload = function( event ) { 3195 this.complete( event, 'flickity-lazyloaded' ); 3196}; 3197 3198LazyLoader.prototype.onerror = function( event ) { 3199 this.complete( event, 'flickity-lazyerror' ); 3200}; 3201 3202LazyLoader.prototype.complete = function( event, className ) { 3203 this.img.removeEventListener( 'load', this ); 3204 this.img.removeEventListener( 'error', this ); 3205 3206 var cell = this.flickity.getParentCell( this.img ); 3207 var cellElem = cell && cell.element; 3208 this.flickity.cellSizeChange( cellElem ); 3209 3210 this.img.classList.add( className ); 3211 this.flickity.dispatchEvent( 'lazyLoad', event, cellElem ); 3212}; 3213 3214 3215Flickity.LazyLoader = LazyLoader; 3216 3217return Flickity; 3218 3219} ) ); 3220 3221 3222( function( window, factory ) { 3223 if ( typeof define == 'function' && define.amd ) { 3224 define( 'flickity/js/index',[ 3225 './flickity', 3226 './drag', 3227 './prev-next-button', 3228 './page-dots', 3229 './player', 3230 './add-remove-cell', 3231 './lazyload', 3232 ], factory ); 3233 } else if ( typeof module == 'object' && module.exports ) { 3234 module.exports = factory( 3235 require('./flickity'), 3236 require('./drag'), 3237 require('./prev-next-button'), 3238 require('./page-dots'), 3239 require('./player'), 3240 require('./add-remove-cell'), 3241 require('./lazyload') 3242 ); 3243 } 3244 3245} )( window, function factory( Flickity ) { 3246 return Flickity; 3247} ); 3248 3249 3250 3251( function( window, factory ) { 3252 if ( typeof define == 'function' && define.amd ) { 3253 define( 'flickity-as-nav-for/as-nav-for',[ 3254 'flickity/js/index', 3255 'fizzy-ui-utils/utils' 3256 ], factory ); 3257 } else if ( typeof module == 'object' && module.exports ) { 3258 module.exports = factory( 3259 require('flickity'), 3260 require('fizzy-ui-utils') 3261 ); 3262 } else { 3263 window.Flickity = factory( 3264 window.Flickity, 3265 window.fizzyUIUtils 3266 ); 3267 } 3268 3269}( window, function factory( Flickity, utils ) { 3270 3271 3272 3273 3274 3275Flickity.createMethods.push('_createAsNavFor'); 3276 3277var proto = Flickity.prototype; 3278 3279proto._createAsNavFor = function() { 3280 this.on( 'activate', this.activateAsNavFor ); 3281 this.on( 'deactivate', this.deactivateAsNavFor ); 3282 this.on( 'destroy', this.destroyAsNavFor ); 3283 3284 var asNavForOption = this.options.asNavFor; 3285 if ( !asNavForOption ) { 3286 return; 3287 } 3288 var _this = this; 3289 setTimeout( function initNavCompanion() { 3290 _this.setNavCompanion( asNavForOption ); 3291 }); 3292}; 3293 3294proto.setNavCompanion = function( elem ) { 3295 elem = utils.getQueryElement( elem ); 3296 var companion = Flickity.data( elem ); 3297 if ( !companion || companion == this ) { 3298 return; 3299 } 3300 3301 this.navCompanion = companion; 3302 var _this = this; 3303 this.onNavCompanionSelect = function() { 3304 _this.navCompanionSelect(); 3305 }; 3306 companion.on( 'select', this.onNavCompanionSelect ); 3307 this.on( 'staticClick', this.onNavStaticClick ); 3308 3309 this.navCompanionSelect( true ); 3310}; 3311 3312proto.navCompanionSelect = function( isInstant ) { 3313 var companionCells = this.navCompanion && this.navCompanion.selectedCells; 3314 if ( !companionCells ) { 3315 return; 3316 } 3317 var selectedCell = companionCells[0]; 3318 var firstIndex = this.navCompanion.cells.indexOf( selectedCell ); 3319 var lastIndex = firstIndex + companionCells.length - 1; 3320 var selectIndex = Math.floor( lerp( firstIndex, lastIndex, 3321 this.navCompanion.cellAlign ) ); 3322 this.selectCell( selectIndex, false, isInstant ); 3323 this.removeNavSelectedElements(); 3324 if ( selectIndex >= this.cells.length ) { 3325 return; 3326 } 3327 3328 var selectedCells = this.cells.slice( firstIndex, lastIndex + 1 ); 3329 this.navSelectedElements = selectedCells.map( function( cell ) { 3330 return cell.element; 3331 }); 3332 this.changeNavSelectedClass('add'); 3333}; 3334 3335function lerp( a, b, t ) { 3336 return ( b - a ) * t + a; 3337} 3338 3339proto.changeNavSelectedClass = function( method ) {
vendor: 4,280 bytes, lines 3340-3534
3340 this.navSelectedElements.forEach( function( navElem ) { 3341 navElem.classList[ method ]('is-nav-selected'); 3342 }); 3343}; 3344 3345proto.activateAsNavFor = function() { 3346 this.navCompanionSelect( true ); 3347}; 3348 3349proto.removeNavSelectedElements = function() { 3350 if ( !this.navSelectedElements ) { 3351 return; 3352 } 3353 this.changeNavSelectedClass('remove'); 3354 delete this.navSelectedElements; 3355}; 3356 3357proto.onNavStaticClick = function( event, pointer, cellElement, cellIndex ) { 3358 if ( typeof cellIndex == 'number' ) { 3359 this.navCompanion.selectCell( cellIndex ); 3360 } 3361}; 3362 3363proto.deactivateAsNavFor = function() { 3364 this.removeNavSelectedElements(); 3365}; 3366 3367proto.destroyAsNavFor = function() { 3368 if ( !this.navCompanion ) { 3369 return; 3370 } 3371 this.navCompanion.off( 'select', this.onNavCompanionSelect ); 3372 this.off( 'staticClick', this.onNavStaticClick ); 3373 delete this.navCompanion; 3374}; 3375 3376 3377return Flickity; 3378 3379})); 3380 3381 3382( function( window, factory ) { 'use strict'; 3383 3384 3385 if ( typeof define == 'function' && define.amd ) { 3386 define( 'imagesloaded/imagesloaded',[ 3387 'ev-emitter/ev-emitter' 3388 ], function( EvEmitter ) { 3389 return factory( window, EvEmitter ); 3390 }); 3391 } else if ( typeof module == 'object' && module.exports ) { 3392 module.exports = factory( 3393 window, 3394 require('ev-emitter') 3395 ); 3396 } else { 3397 window.imagesLoaded = factory( 3398 window, 3399 window.EvEmitter 3400 ); 3401 } 3402 3403})( typeof window !== 'undefined' ? window : this, 3404 3405 3406function factory( window, EvEmitter ) { 3407 3408 3409 3410var $ = window.jQuery; 3411var console = window.console; 3412 3413 3414function extend( a, b ) { 3415 for ( var prop in b ) { 3416 a[ prop ] = b[ prop ]; 3417 } 3418 return a; 3419} 3420 3421var arraySlice = Array.prototype.slice; 3422 3423function makeArray( obj ) { 3424 if ( Array.isArray( obj ) ) { 3425 return obj; 3426 } 3427 3428 var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number'; 3429 if ( isArrayLike ) { 3430 return arraySlice.call( obj ); 3431 } 3432 3433 return [ obj ]; 3434} 3435 3436 3437function ImagesLoaded( elem, options, onAlways ) { 3438 if ( !( this instanceof ImagesLoaded ) ) { 3439 return new ImagesLoaded( elem, options, onAlways ); 3440 } 3441 var queryElem = elem; 3442 if ( typeof elem == 'string' ) { 3443 queryElem = document.querySelectorAll( elem ); 3444 } 3445 if ( !queryElem ) { 3446 console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) ); 3447 return; 3448 } 3449 3450 this.elements = makeArray( queryElem ); 3451 this.options = extend( {}, this.options ); 3452 if ( typeof options == 'function' ) { 3453 onAlways = options; 3454 } else { 3455 extend( this.options, options ); 3456 } 3457 3458 if ( onAlways ) { 3459 this.on( 'always', onAlways ); 3460 } 3461 3462 this.getImages(); 3463 3464 if ( $ ) { 3465 this.jqDeferred = new $.Deferred(); 3466 } 3467 3468 setTimeout( this.check.bind( this ) ); 3469} 3470 3471ImagesLoaded.prototype = Object.create( EvEmitter.prototype ); 3472 3473ImagesLoaded.prototype.options = {}; 3474 3475ImagesLoaded.prototype.getImages = function() { 3476 this.images = []; 3477 3478 this.elements.forEach( this.addElementImages, this ); 3479}; 3480 3481ImagesLoaded.prototype.addElementImages = function( elem ) { 3482 if ( elem.nodeName == 'IMG' ) { 3483 this.addImage( elem ); 3484 } 3485 if ( this.options.background === true ) { 3486 this.addElementBackgroundImages( elem ); 3487 } 3488 3489 var nodeType = elem.nodeType; 3490 if ( !nodeType || !elementNodeTypes[ nodeType ] ) { 3491 return; 3492 } 3493 var childImgs = elem.querySelectorAll('img'); 3494 for ( var i=0; i < childImgs.length; i++ ) { 3495 var img = childImgs[i]; 3496 this.addImage( img ); 3497 } 3498 3499 if ( typeof this.options.background == 'string' ) { 3500 var children = elem.querySelectorAll( this.options.background ); 3501 for ( i=0; i < children.length; i++ ) { 3502 var child = children[i]; 3503 this.addElementBackgroundImages( child ); 3504 } 3505 } 3506}; 3507 3508var elementNodeTypes = { 3509 1: true, 3510 9: true, 3511 11: true 3512}; 3513 3514ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) { 3515 var style = getComputedStyle( elem ); 3516 if ( !style ) { 3517 return; 3518 } 3519 var reURL = /url\((['"])?(.*?)\1\)/gi; 3520 var matches = reURL.exec( style.backgroundImage ); 3521 while ( matches !== null ) { 3522 var url = matches && matches[2]; 3523 if ( url ) { 3524 this.addBackground( url, elem ); 3525 } 3526 matches = reURL.exec( style.backgroundImage ); 3527 } 3528}; 3529 3530ImagesLoaded.prototype.addImage = function( img ) { 3531 var loadingImage = new LoadingImage( img ); 3532 this.images.push( loadingImage ); 3533}; 3534
3535ImagesLoaded.prototype.addBackground = function( url, elem ) { 3536 var background = new Background( url, elem ); 3537 this.images.push( background ); 3538}; 3539 3540ImagesLoaded.prototype.check = function() { 3541 var _this = this; 3542 this.progressedCount = 0; 3543 this.hasAnyBroken = false; 3544 if ( !this.images.length ) { 3545 this.complete(); 3546 return; 3547 } 3548 3549 function onProgress( image, elem, message ) { 3550 setTimeout( function() { 3551 _this.progress( image, elem, message ); 3552 }); 3553 } 3554 3555 this.images.forEach( function( loadingImage ) { 3556 loadingImage.once( 'progress', onProgress ); 3557 loadingImage.check(); 3558 }); 3559}; 3560 3561ImagesLoaded.prototype.progress = function( image, elem, message ) { 3562 this.progressedCount++; 3563 this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded; 3564 this.emitEvent( 'progress', [ this, image, elem ] ); 3565 if ( this.jqDeferred && this.jqDeferred.notify ) { 3566 this.jqDeferred.notify( this, image ); 3567 } 3568 if ( this.progressedCount == this.images.length ) { 3569 this.complete(); 3570 } 3571 3572 if ( this.options.debug && console ) { 3573 console.log( 'progress: ' + message, image, elem ); 3574 } 3575}; 3576 3577ImagesLoaded.prototype.complete = function() { 3578 var eventName = this.hasAnyBroken ? 'fail' : 'done'; 3579 this.isComplete = true; 3580 this.emitEvent( eventName, [ this ] ); 3581 this.emitEvent( 'always', [ this ] ); 3582 if ( this.jqDeferred ) { 3583 var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve'; 3584 this.jqDeferred[ jqMethod ]( this ); 3585 } 3586}; 3587 3588 3589function LoadingImage( img ) { 3590 this.img = img; 3591} 3592 3593LoadingImage.prototype = Object.create( EvEmitter.prototype ); 3594 3595LoadingImage.prototype.check = function() { 3596 var isComplete = this.getIsImageComplete(); 3597 if ( isComplete ) { 3598 this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 3599 return; 3600 } 3601 3602 this.proxyImage = new Image(); 3603 this.proxyImage.addEventListener( 'load', this ); 3604 this.proxyImage.addEventListener( 'error', this ); 3605 this.img.addEventListener( 'load', this ); 3606 this.img.addEventListener( 'error', this ); 3607 this.proxyImage.src = this.img.src; 3608}; 3609 3610LoadingImage.prototype.getIsImageComplete = function() { 3611 return this.img.complete && this.img.naturalWidth; 3612}; 3613 3614LoadingImage.prototype.confirm = function( isLoaded, message ) { 3615 this.isLoaded = isLoaded; 3616 this.emitEvent( 'progress', [ this, this.img, message ] ); 3617}; 3618 3619 3620LoadingImage.prototype.handleEvent = function( event ) { 3621 var method = 'on' + event.type; 3622 if ( this[ method ] ) { 3623 this[ method ]( event ); 3624 } 3625}; 3626 3627LoadingImage.prototype.onload = function() { 3628 this.confirm( true, 'onload' ); 3629 this.unbindEvents(); 3630}; 3631 3632LoadingImage.prototype.onerror = function() { 3633 this.confirm( false, 'onerror' ); 3634 this.unbindEvents(); 3635}; 3636 3637LoadingImage.prototype.unbindEvents = function() { 3638 this.proxyImage.removeEventListener( 'load', this ); 3639 this.proxyImage.removeEventListener( 'error', this ); 3640 this.img.removeEventListener( 'load', this ); 3641 this.img.removeEventListener( 'error', this ); 3642}; 3643 3644 3645function Background( url, element ) { 3646 this.url = url; 3647 this.element = element; 3648 this.img = new Image(); 3649} 3650 3651Background.prototype = Object.create( LoadingImage.prototype ); 3652 3653Background.prototype.check = function() { 3654 this.img.addEventListener( 'load', this ); 3655 this.img.addEventListener( 'error', this ); 3656 this.img.src = this.url; 3657 var isComplete = this.getIsImageComplete(); 3658 if ( isComplete ) { 3659 this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' ); 3660 this.unbindEvents(); 3661 } 3662}; 3663 3664Background.prototype.unbindEvents = function() { 3665 this.img.removeEventListener( 'load', this ); 3666 this.img.removeEventListener( 'error', this ); 3667}; 3668 3669Background.prototype.confirm = function( isLoaded, message ) { 3670 this.isLoaded = isLoaded; 3671 this.emitEvent( 'progress', [ this, this.element, message ] ); 3672}; 3673 3674 3675ImagesLoaded.makeJQueryPlugin = function( jQuery ) { 3676 jQuery = jQuery || window.jQuery; 3677 if ( !jQuery ) { 3678 return; 3679 } 3680 $ = jQuery; 3681 $.fn.imagesLoaded = function( options, callback ) { 3682 var instance = new ImagesLoaded( this, options, callback ); 3683 return instance.jqDeferred.promise( $(this) ); 3684 }; 3685}; 3686ImagesLoaded.makeJQueryPlugin(); 3687 3688 3689return ImagesLoaded; 3690 3691}); 3692 3693 3694 3695( function( window, factory ) { 3696 if ( typeof define == 'function' && define.amd ) { 3697 define( [ 3698 'flickity/js/index', 3699 'imagesloaded/imagesloaded' 3700 ], function( Flickity, imagesLoaded ) { 3701 return factory( window, Flickity, imagesLoaded ); 3702 }); 3703 } else if ( typeof module == 'object' && module.exports ) { 3704 module.exports = factory( 3705 window, 3706 require('flickity'), 3707 require('imagesloaded') 3708 ); 3709 } else { 3710 window.Flickity = factory( 3711 window, 3712 window.Flickity, 3713 window.imagesLoaded 3714 ); 3715 } 3716 3717}( window, function factory( window, Flickity, imagesLoaded ) { 3718'use strict'; 3719 3720Flickity.createMethods.push('_createImagesLoaded'); 3721 3722var proto = Flickity.prototype; 3723 3724proto._createImagesLoaded = function() { 3725 this.on( 'activate', this.imagesLoaded ); 3726}; 3727 3728proto.imagesLoaded = function() { 3729 if ( !this.options.imagesLoaded ) { 3730 return; 3731 } 3732 var _this = this; 3733 function onImagesLoadedProgress( instance, image ) { 3734 var cell = _this.getParentCell( image.img ); 3735 _this.cellSizeChange( cell && cell.element ); 3736 if ( !_this.options.freeScroll ) { 3737 _this.positionSliderAtSelected(); 3738 } 3739 } 3740 imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress ); 3741}; 3742 3743return Flickity; 3744 3745})); 3746 3747 3748 3749( function( window, factory ) { 3750 if ( typeof define == 'function' && define.amd ) { 3751 define( [ 3752 'flickity/js/index', 3753 'fizzy-ui-utils/utils', 3754 ], factory ); 3755 } else if ( typeof module == 'object' && module.exports ) { 3756 module.exports = factory( 3757 require('flickity'), 3758 require('fizzy-ui-utils') 3759 ); 3760 } else { 3761 factory( 3762 window.Flickity, 3763 window.fizzyUIUtils 3764 ); 3765 } 3766 3767}( this, function factory( Flickity, utils ) { 3768 3769 3770var Slide = Flickity.Slide; 3771 3772var slideUpdateTarget = Slide.prototype.updateTarget; 3773Slide.prototype.updateTarget = function() { 3774 slideUpdateTarget.apply( this, arguments ); 3775 if ( !this.parent.options.fade ) { 3776 return; 3777 } 3778 var slideTargetX = this.target - this.x; 3779 var firstCellX = this.cells[0].x;
3780 this.cells.forEach( function( cell ) { 3781 var targetX = cell.x - firstCellX - slideTargetX; 3782 cell.renderPosition( targetX ); 3783 }); 3784}; 3785 3786Slide.prototype.setOpacity = function( alpha ) { 3787 this.cells.forEach( function( cell ) { 3788 cell.element.style.opacity = alpha; 3789 }); 3790}; 3791 3792 3793var proto = Flickity.prototype; 3794 3795Flickity.createMethods.push('_createFade'); 3796 3797proto._createFade = function() { 3798 this.fadeIndex = this.selectedIndex; 3799 this.prevSelectedIndex = this.selectedIndex; 3800 this.on( 'select', this.onSelectFade ); 3801 this.on( 'dragEnd', this.onDragEndFade ); 3802 this.on( 'settle', this.onSettleFade ); 3803 this.on( 'activate', this.onActivateFade ); 3804 this.on( 'deactivate', this.onDeactivateFade ); 3805}; 3806 3807var updateSlides = proto.updateSlides; 3808proto.updateSlides = function() { 3809 updateSlides.apply( this, arguments ); 3810 if ( !this.options.fade ) { 3811 return; 3812 } 3813 this.slides.forEach( function( slide, i ) { 3814 var alpha = i == this.selectedIndex ? 1 : 0; 3815 slide.setOpacity( alpha ); 3816 }, this ); 3817}; 3818 3819 3820proto.onSelectFade = function() { 3821 this.fadeIndex = Math.min( this.prevSelectedIndex, this.slides.length - 1 ); 3822 this.prevSelectedIndex = this.selectedIndex; 3823}; 3824 3825proto.onSettleFade = function() { 3826 delete this.didDragEnd; 3827 if ( !this.options.fade ) { 3828 return; 3829 } 3830 this.selectedSlide.setOpacity( 1 ); 3831 var fadedSlide = this.slides[ this.fadeIndex ]; 3832 if ( fadedSlide && this.fadeIndex != this.selectedIndex ) { 3833 this.slides[ this.fadeIndex ].setOpacity( 0 ); 3834 } 3835}; 3836 3837proto.onDragEndFade = function() { 3838 this.didDragEnd = true; 3839}; 3840 3841proto.onActivateFade = function() { 3842 if ( this.options.fade ) { 3843 this.element.classList.add('is-fade'); 3844 } 3845}; 3846 3847proto.onDeactivateFade = function() { 3848 if ( !this.options.fade ) { 3849 return; 3850 } 3851 this.element.classList.remove('is-fade'); 3852 this.slides.forEach( function( slide ) { 3853 slide.setOpacity(''); 3854 }); 3855}; 3856 3857 3858var positionSlider = proto.positionSlider; 3859proto.positionSlider = function() { 3860 if ( !this.options.fade ) { 3861 positionSlider.apply( this, arguments ); 3862 return; 3863 } 3864 3865 this.fadeSlides(); 3866 this.dispatchScrollEvent(); 3867}; 3868 3869var positionSliderAtSelected = proto.positionSliderAtSelected; 3870proto.positionSliderAtSelected = function() { 3871 if ( this.options.fade ) { 3872 this.setTranslateX( 0 ); 3873 } 3874 positionSliderAtSelected.apply( this, arguments ); 3875}; 3876 3877proto.fadeSlides = function() { 3878 if ( this.slides.length < 2 ) { 3879 return; 3880 } 3881 var indexes = this.getFadeIndexes(); 3882 var fadeSlideA = this.slides[ indexes.a ]; 3883 var fadeSlideB = this.slides[ indexes.b ]; 3884 var distance = this.wrapDifference( fadeSlideA.target, fadeSlideB.target ); 3885 var progress = this.wrapDifference( fadeSlideA.target, -this.x ); 3886 progress = progress / distance; 3887 3888 fadeSlideA.setOpacity( 1 - progress ); 3889 fadeSlideB.setOpacity( progress ); 3890 3891 var fadeHideIndex = indexes.a; 3892 if ( this.isDragging ) { 3893 fadeHideIndex = progress > 0.5 ? indexes.a : indexes.b; 3894 } 3895 var isNewHideIndex = this.fadeHideIndex != undefined && 3896 this.fadeHideIndex != fadeHideIndex && 3897 this.fadeHideIndex != indexes.a && 3898 this.fadeHideIndex != indexes.b; 3899 if ( isNewHideIndex ) { 3900 this.slides[ this.fadeHideIndex ].setOpacity( 0 ); 3901 } 3902 this.fadeHideIndex = fadeHideIndex; 3903}; 3904 3905proto.getFadeIndexes = function() { 3906 if ( !this.isDragging && !this.didDragEnd ) { 3907 return { 3908 a: this.fadeIndex, 3909 b: this.selectedIndex, 3910 }; 3911 } 3912 if ( this.options.wrapAround ) { 3913 return this.getFadeDragWrapIndexes(); 3914 } else { 3915 return this.getFadeDragLimitIndexes(); 3916 } 3917}; 3918 3919proto.getFadeDragWrapIndexes = function() { 3920 var distances = this.slides.map( function( slide, i ) { 3921 return this.getSlideDistance( -this.x, i ); 3922 }, this ); 3923 var absDistances = distances.map( function( distance ) { 3924 return Math.abs( distance ); 3925 }); 3926 var minDistance = Math.min.apply( Math, absDistances ); 3927 var closestIndex = absDistances.indexOf( minDistance ); 3928 var distance = distances[ closestIndex ]; 3929 var len = this.slides.length; 3930 3931 var delta = distance >= 0 ? 1 : -1; 3932 return { 3933 a: closestIndex, 3934 b: utils.modulo( closestIndex + delta, len ), 3935 }; 3936}; 3937 3938proto.getFadeDragLimitIndexes = function() { 3939 var dragIndex = 0; 3940 for ( var i=0; i < this.slides.length - 1; i++ ) { 3941 var slide = this.slides[i]; 3942 if ( -this.x < slide.target ) { 3943 break; 3944 } 3945 dragIndex = i; 3946 } 3947 return { 3948 a: dragIndex, 3949 b: dragIndex + 1, 3950 }; 3951}; 3952 3953proto.wrapDifference = function( a, b ) { 3954 var diff = b - a; 3955 3956 if ( !this.options.wrapAround ) { 3957 return diff; 3958 } 3959 3960 var diffPlus = diff + this.slideableWidth; 3961 var diffMinus = diff - this.slideableWidth; 3962 if ( Math.abs( diffPlus ) < Math.abs( diff ) ) { 3963 diff = diffPlus; 3964 } 3965 if ( Math.abs( diffMinus ) < Math.abs( diff ) ) { 3966 diff = diffMinus; 3967 } 3968 return diff; 3969}; 3970 3971 3972var _getWrapShiftCells = proto._getWrapShiftCells; 3973proto._getWrapShiftCells = function() { 3974 if ( !this.options.fade ) { 3975 _getWrapShiftCells.apply( this, arguments ); 3976 } 3977}; 3978 3979var shiftWrapCells = proto.shiftWrapCells; 3980proto.shiftWrapCells = function() { 3981 if ( !this.options.fade ) { 3982 shiftWrapCells.apply( this, arguments ); 3983 } 3984}; 3985 3986return Flickity; 3987 3988})); 3989 3990function formatMoney(cents, format) { 3991 if (typeof cents === 'string') { 3992 cents = cents.replace('.', ''); 3993 } 3994 let value = ''; 3995 const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/; 3996 const formatString = format || moneyFormat; 3997 3998 function formatWithDelimiters( 3999 number, 4000 precision = 2, 4001 thousands = ',', 4002 decimal = '.' 4003 ) { 4004 if (isNaN(number) || number == null) { 4005 return 0; 4006 } 4007 4008 number = (number / 100.0).toFixed(precision); 4009 4010 const parts = number.split('.'); 4011 const dollarsAmount = parts[0].replace( 4012 /(\d)(?=(\d\d\d)+(?!\d))/g, 4013 `$1${thousands}` 4014 ); 4015 const centsAmount = parts[1] ? decimal + parts[1] : ''; 4016 4017 return dollarsAmount + centsAmount; 4018 } 4019 4020 switch (formatString.match(placeholderRegex)[1]) { 4021 case 'amount': 4022 value = formatWithDelimiters(cents, 2); 4023 break; 4024 case 'amount_no_decimals': 4025 value = formatWithDelimiters(cents, 0); 4026 break; 4027 case 'amount_with_comma_separator': 4028 value = formatWithDelimiters(cents, 2, '.', ','); 4029 break; 4030 case 'amount_no_decimals_with_comma_separator': 4031 value = formatWithDelimiters(cents, 0, '.', ','); 4032 break; 4033 case "amount_with_apostrophe_separator": 4034 value = formatWithDelimiters(cents, 2, "'", "."); 4035 break; 4036 } 4037 4038 return formatString.replace(placeholderRegex, value); 4039} 4040 4041var Cell = Flickity.Cell; 4042 4043Cell.prototype.create = function () { 4044 this.element.style.position = 'absolute'; 4045 this.x = 0; 4046 this.shift = 0; 4047 this.element.style[this.parent.originSide] = 0; 4048}; 4049 4050Cell.prototype.unselect = function () { 4051 this.element.classList.remove('is-selected'); 4052};
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.