PageSourceSearch

https://atackcontrol.de/_relaunch/wp-content/themes/salient/js/flickity.min.js

js atackcontrol.de collected 2026-10-04 03:31:36 UTC 126,588 bytes, 4,718 lines download raw bytes

vendor: 16,710 bytes, lines 1-656
1/*!
2 * Flickity PACKAGED v2.1.2
3 * Touch, responsive, flickable carousels
4 *
5 * Licensed GPLv3 for open source use
6 * or Flickity Commercial License for commercial use
7 *
8 * https://flickity.metafizzy.co
9 * Copyright 2015-2018 Metafizzy
10 */
11
12/**
13 * Bridget makes jQuery widgets
14 * v2.0.1
15 * MIT license
16 */
17
18/* jshint browser: true, strict: true, undef: true, unused: true */
19
20( function( window, factory ) {
21  // universal module definition
22  /*jshint strict: false */ /* globals define, module, require */
23  if ( typeof define == 'function' && define.amd ) {
24    // AMD
25    define( 'jquery-bridget/jquery-bridget',[ 'jquery' ], function( jQuery ) {
26      return factory( window, jQuery );
27    });
28  } else if ( typeof module == 'object' && module.exports ) {
29    // CommonJS
30    module.exports = factory(
31      window,
32      require('jquery')
33    );
34  } else {
35    // browser global
36    window.jQueryBridget = factory(
37      window,
38      window.jQuery
39    );
40  }
41
42}( window, function factory( window, jQuery ) {
43'use strict';
44
45// ----- utils ----- //
46
47var arraySlice = Array.prototype.slice;
48
49// helper function for logging errors
50// $.error breaks jQuery chaining
51var console = window.console;
52var logError = typeof console == 'undefined' ? function() {} :
53  function( message ) {
54    console.error( message );
55  };
56
57// ----- jQueryBridget ----- //
58
59function jQueryBridget( namespace, PluginClass, $ ) {
60  $ = $ || jQuery || window.jQuery;
61  if ( !$ ) {
62    return;
63  }
64
65  // add option method -> $().plugin('option', {...})
66  if ( !PluginClass.prototype.option ) {
67    // option setter
68    PluginClass.prototype.option = function( opts ) {
69      // bail out if not an object
70      if ( !$.isPlainObject( opts ) ){
71        return;
72      }
73      this.options = $.extend( true, this.options, opts );
74    };
75  }
76
77  // make jQuery plugin
78  $.fn[ namespace ] = function( arg0 /*, arg1 */ ) {
79    if ( typeof arg0 == 'string' ) {
80      // method call $().plugin( 'methodName', { options } )
81      // shift arguments by 1
82      var args = arraySlice.call( arguments, 1 );
83      return methodCall( this, arg0, args );
84    }
85    // just $().plugin({ options })
86    plainCall( this, arg0 );
87    return this;
88  };
89
90  // $().plugin('methodName')
91  function methodCall( $elems, methodName, args ) {
92    var returnValue;
93    var pluginMethodStr = '$().' + namespace + '("' + methodName + '")';
94
95    $elems.each( function( i, elem ) {
96      // get instance
97      var instance = $.data( elem, namespace );
98      if ( !instance ) {
99        logError( namespace + ' not initialized. Cannot call methods, i.e. ' +
100          pluginMethodStr );
101        return;
102      }
103
104      var method = instance[ methodName ];
105      if ( !method || methodName.charAt(0) == '_' ) {
106        logError( pluginMethodStr + ' is not a valid method' );
107        return;
108      }
109
110      // apply method, get return value
111      var value = method.apply( instance, args );
112      // set return value if value is returned, use only first value
113      returnValue = returnValue === undefined ? value : returnValue;
114    });
115
116    return returnValue !== undefined ? returnValue : $elems;
117  }
118
119  function plainCall( $elems, options ) {
120    $elems.each( function( i, elem ) {
121      var instance = $.data( elem, namespace );
122      if ( instance ) {
123        // set options & init
124        instance.option( options );
125        instance._init();
126      } else {
127        // initialize new instance
128        instance = new PluginClass( elem, options );
129        $.data( elem, namespace, instance );
130      }
131    });
132  }
133
134  updateJQuery( $ );
135
136}
137
138// ----- updateJQuery ----- //
139
140// set $.bridget for v1 backwards compatibility
141function updateJQuery( $ ) {
142  if ( !$ || ( $ && $.bridget ) ) {
143    return;
144  }
145  $.bridget = jQueryBridget;
146}
147
148updateJQuery( jQuery || window.jQuery );
149
150// -----  ----- //
151
152return jQueryBridget;
153
154}));
155
156/**
157 * EvEmitter v1.1.0
158 * Lil' event emitter
159 * MIT License
160 */
161
162/* jshint unused: true, undef: true, strict: true */
163
164( function( global, factory ) {
165  // universal module definition
166  /* jshint strict: false */ /* globals define, module, window */
167  if ( typeof define == 'function' && define.amd ) {
168    // AMD - RequireJS
169    define( 'ev-emitter/ev-emitter',factory );
170  } else if ( typeof module == 'object' && module.exports ) {
171    // CommonJS - Browserify, Webpack
172    module.exports = factory();
173  } else {
174    // Browser globals
175    global.EvEmitter = factory();
176  }
177
178}( typeof window != 'undefined' ? window : this, function() {
179
180
181
182function EvEmitter() {}
183
184var proto = EvEmitter.prototype;
185
186proto.on = function( eventName, listener ) {
187  if ( !eventName || !listener ) {
188    return;
189  }
190  // set events hash
191  var events = this._events = this._events || {};
192  // set listeners array
193  var listeners = events[ eventName ] = events[ eventName ] || [];
194  // only add once
195  if ( listeners.indexOf( listener ) == -1 ) {
196    listeners.push( listener );
197  }
198
199  return this;
200};
201
202proto.once = function( eventName, listener ) {
203  if ( !eventName || !listener ) {
204    return;
205  }
206  // add event
207  this.on( eventName, listener );
208  // set once flag
209  // set onceEvents hash
210  var onceEvents = this._onceEvents = this._onceEvents || {};
211  // set onceListeners object
212  var onceListeners = onceEvents[ eventName ] = onceEvents[ eventName ] || {};
213  // set flag
214  onceListeners[ listener ] = true;
215
216  return this;
217};
218
219proto.off = function( eventName, listener ) {
220  var listeners = this._events && this._events[ eventName ];
221  if ( !listeners || !listeners.length ) {
222    return;
223  }
224  var index = listeners.indexOf( listener );
225  if ( index != -1 ) {
226    listeners.splice( index, 1 );
227  }
228
229  return this;
230};
231
232proto.emitEvent = function( eventName, args ) {
233  var listeners = this._events && this._events[ eventName ];
234  if ( !listeners || !listeners.length ) {
235    return;
236  }
237  // copy over to avoid interference if .off() in listener
238  listeners = listeners.slice(0);
239  args = args || [];
240  // once stuff
241  var onceListeners = this._onceEvents && this._onceEvents[ eventName ];
242
243  for ( var i=0; i < listeners.length; i++ ) {
244    var listener = listeners[i]
245    var isOnce = onceListeners && onceListeners[ listener ];
246    if ( isOnce ) {
247      // remove listener
248      // remove before trigger to prevent recursion
249      this.off( eventName, listener );
250      // unset once flag
251      delete onceListeners[ listener ];
252    }
253    // trigger listener
254    listener.apply( this, args );
255  }
256
257  return this;
258};
259
260proto.allOff = function() {
261  delete this._events;
262  delete this._onceEvents;
263};
264
265return EvEmitter;
266
267}));
268
269/*!
270 * getSize v2.0.3
271 * measure size of elements
272 * MIT license
273 */
274
275/* jshint browser: true, strict: true, undef: true, unused: true */
276/* globals console: false */
277
278( function( window, factory ) {
279  /* jshint strict: false */ /* globals define, module */
280  if ( typeof define == 'function' && define.amd ) {
281    // AMD
282    define( 'get-size/get-size',factory );
283  } else if ( typeof module == 'object' && module.exports ) {
284    // CommonJS
285    module.exports = factory();
286  } else {
287    // browser global
288    window.getSize = factory();
289  }
290
291})( window, function factory() {
292'use strict';
293
294// -------------------------- helpers -------------------------- //
295
296// get a number from a string, not a percentage
297function getStyleSize( value ) {
298  var num = parseFloat( value );
299  // not a percent like '100%', and a number
300  var isValid = value.indexOf('%') == -1 && !isNaN( num );
301  return isValid && num;
302}
303
304function noop() {}
305
306var logError = typeof console == 'undefined' ? noop :
307  function( message ) {
308    console.error( message );
309  };
310
311// -------------------------- measurements -------------------------- //
312
313var measurements = [
314  'paddingLeft',
315  'paddingRight',
316  'paddingTop',
317  'paddingBottom',
318  'marginLeft',
319  'marginRight',
320  'marginTop',
321  'marginBottom',
322  'borderLeftWidth',
323  'borderRightWidth',
324  'borderTopWidth',
325  'borderBottomWidth'
326];
327
328var measurementsLength = measurements.length;
329
330function getZeroSize() {
331  var size = {
332    width: 0,
333    height: 0,
334    innerWidth: 0,
335    innerHeight: 0,
336    outerWidth: 0,
337    outerHeight: 0
338  };
339  for ( var i=0; i < measurementsLength; i++ ) {
340    var measurement = measurements[i];
341    size[ measurement ] = 0;
342  }
343  return size;
344}
345
346// -------------------------- getStyle -------------------------- //
347
348/**
349 * getStyle, get style of element, check for Firefox bug
350 * https://bugzilla.mozilla.org/show_bug.cgi?id=548397
351 */
352function getStyle( elem ) {
353  var style = getComputedStyle( elem );
354  if ( !style ) {
355    logError( 'Style returned ' + style +
356      '. Are you running this code in a hidden iframe on Firefox? ' +
357      'See https://bit.ly/getsizebug1' );
358  }
359  return style;
360}
361
362// -------------------------- setup -------------------------- //
363
364var isSetup = false;
365
366var isBoxSizeOuter;
367
368/**
369 * setup
370 * check isBoxSizerOuter
371 * do on first getSize() rather than on page load for Firefox bug
372 */
373function setup() {
374  // setup once
375  if ( isSetup ) {
376    return;
377  }
378  isSetup = true;
379
380  // -------------------------- box sizing -------------------------- //
381
382  /**
383   * Chrome & Safari measure the outer-width on style.width on border-box elems
384   * IE11 & Firefox<29 measures the inner-width
385   */
386  var div = document.createElement('div');
387  div.style.width = '200px';
388  div.style.padding = '1px 2px 3px 4px';
389  div.style.borderStyle = 'solid';
390  div.style.borderWidth = '1px 2px 3px 4px';
391  div.style.boxSizing = 'border-box';
392
393  var body = document.body || document.documentElement;
394  body.appendChild( div );
395  var style = getStyle( div );
396  // round value for browser zoom. desandro/masonry#928
397  isBoxSizeOuter = Math.round( getStyleSize( style.width ) ) == 200;
398  getSize.isBoxSizeOuter = isBoxSizeOuter;
399
400  body.removeChild( div );
401}
402
403// -------------------------- getSize -------------------------- //
404
405function getSize( elem ) {
406  setup();
407
408  // use querySeletor if elem is string
409  if ( typeof elem == 'string' ) {
410    elem = document.querySelector( elem );
411  }
412
413  // do not proceed on non-objects
414  if ( !elem || typeof elem != 'object' || !elem.nodeType ) {
415    return;
416  }
417
418  var style = getStyle( elem );
419
420  // if hidden, everything is 0
421  if ( style.display == 'none' ) {
422    return getZeroSize();
423  }
424
425  var size = {};
426  size.width = elem.offsetWidth;
427  size.height = elem.offsetHeight;
428
429  var isBorderBox = size.isBorderBox = style.boxSizing == 'border-box';
430
431  // get all measurements
432  for ( var i=0; i < measurementsLength; i++ ) {
433    var measurement = measurements[i];
434    var value = style[ measurement ];
435    var num = parseFloat( value );
436    // any 'auto', 'medium' value will be 0
437    size[ measurement ] = !isNaN( num ) ? num : 0;
438  }
439
440  var paddingWidth = size.paddingLeft + size.paddingRight;
441  var paddingHeight = size.paddingTop + size.paddingBottom;
442  var marginWidth = size.marginLeft + size.marginRight;
443  var marginHeight = size.marginTop + size.marginBottom;
444  var borderWidth = size.borderLeftWidth + size.borderRightWidth;
445  var borderHeight = size.borderTopWidth + size.borderBottomWidth;
446
447  var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
448
449  // overwrite width and height if we can get it from style
450  var styleWidth = getStyleSize( style.width );
451  if ( styleWidth !== false ) {
452    size.width = styleWidth +
453      // add padding and border unless it's already including it
454      ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
455  }
456
457  var styleHeight = getStyleSize( style.height );
458  if ( styleHeight !== false ) {
459    size.height = styleHeight +
460      // add padding and border unless it's already including it
461      ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
462  }
463
464  size.innerWidth = size.width - ( paddingWidth + borderWidth );
465  size.innerHeight = size.height - ( paddingHeight + borderHeight );
466
467  size.outerWidth = size.width + marginWidth;
468  size.outerHeight = size.height + marginHeight;
469
470  return size;
471}
472
473return getSize;
474
475});
476
477/**
478 * matchesSelector v2.0.2
479 * matchesSelector( element, '.selector' )
480 * MIT license
481 */
482
483/*jshint browser: true, strict: true, undef: true, unused: true */
484
485( function( window, factory ) {
486  /*global define: false, module: false */
487  'use strict';
488  // universal module definition
489  if ( typeof define == 'function' && define.amd ) {
490    // AMD
491    define( 'desandro-matches-selector/matches-selector',factory );
492  } else if ( typeof module == 'object' && module.exports ) {
493    // CommonJS
494    module.exports = factory();
495  } else {
496    // browser global
497    window.matchesSelector = factory();
498  }
499
500}( window, function factory() {
501  'use strict';
502
503  var matchesMethod = ( function() {
504    var ElemProto = window.Element.prototype;
505    // check for the standard method name first
506    if ( ElemProto.matches ) {
507      return 'matches';
508    }
509    // check un-prefixed
510    if ( ElemProto.matchesSelector ) {
511      return 'matchesSelector';
512    }
513    // check vendor prefixes
514    var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
515
516    for ( var i=0; i < prefixes.length; i++ ) {
517      var prefix = prefixes[i];
518      var method = prefix + 'MatchesSelector';
519      if ( ElemProto[ method ] ) {
520        return method;
521      }
522    }
523  })();
524
525  return function matchesSelector( elem, selector ) {
526    return elem[ matchesMethod ]( selector );
527  };
528
529}));
530
531/**
532 * Fizzy UI utils v2.0.7
533 * MIT license
534 */
535
536/*jshint browser: true, undef: true, unused: true, strict: true */
537
538( function( window, factory ) {
539  // universal module definition
540  /*jshint strict: false */ /*globals define, module, require */
541
542  if ( typeof define == 'function' && define.amd ) {
543    // AMD
544    define( 'fizzy-ui-utils/utils',[
545      'desandro-matches-selector/matches-selector'
546    ], function( matchesSelector ) {
547      return factory( window, matchesSelector );
548    });
549  } else if ( typeof module == 'object' && module.exports ) {
550    // CommonJS
551    module.exports = factory(
552      window,
553      require('desandro-matches-selector')
554    );
555  } else {
556    // browser global
557    window.fizzyUIUtils = factory(
558      window,
559      window.matchesSelector
560    );
561  }
562
563}( window, function factory( window, matchesSelector ) {
564
565
566
567var utils = {};
568
569// ----- extend ----- //
570
571// extends objects
572utils.extend = function( a, b ) {
573  for ( var prop in b ) {
574    a[ prop ] = b[ prop ];
575  }
576  return a;
577};
578
579// ----- modulo ----- //
580
581utils.modulo = function( num, div ) {
582  return ( ( num % div ) + div ) % div;
583};
584
585// ----- makeArray ----- //
586
587var arraySlice = Array.prototype.slice;
588
589// turn element or nodeList into an array
590utils.makeArray = function( obj ) {
591  if ( Array.isArray( obj ) ) {
592    // use object if already an array
593    return obj;
594  }
595  // return empty array if undefined or null. #6
596  if ( obj === null || obj === undefined ) {
597    return [];
598  }
599
600  var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
601  if ( isArrayLike ) {
602    // convert nodeList to array
603    return arraySlice.call( obj );
604  }
605
606  // array of single index
607  return [ obj ];
608};
609
610// ----- removeFrom ----- //
611
612utils.removeFrom = function( ary, obj ) {
613  var index = ary.indexOf( obj );
614  if ( index != -1 ) {
615    ary.splice( index, 1 );
616  }
617};
618
619// ----- getParent ----- //
620
621utils.getParent = function( elem, selector ) {
622  while ( elem.parentNode && elem != document.body ) {
623    elem = elem.parentNode;
624    if ( matchesSelector( elem, selector ) ) {
625      return elem;
626    }
627  }
628};
629
630// ----- getQueryElement ----- //
631
632// use element as selector string
633utils.getQueryElement = function( elem ) {
634  if ( typeof elem == 'string' ) {
635    return document.querySelector( elem );
636  }
637  return elem;
638};
639
640// ----- handleEvent ----- //
641
642// enable .ontype to trigger from .addEventListener( elem, 'type' )
643utils.handleEvent = function( event ) {
644  var method = 'on' + event.type;
645  if ( this[ method ] ) {
646    this[ method ]( event );
647  }
648};
649
650// ----- filterFindElements ----- //
651
652utils.filterFindElements = function( elems, selector ) {
653  // make array of elems
654  elems = utils.makeArray( elems );
655  var ffElems = [];
656
vendor: 4,947 bytes, lines 657-839
657  elems.forEach( function( elem ) {
658    // check that elem is an actual element
659    if ( !( elem instanceof HTMLElement ) ) {
660      /*nectar addition*/
661      if(jQuery('body.compose-mode').length == 0) {
662        return;
663      }
664      /*nectar addition end*/
665    }
666    // add elem if no selector
667    if ( !selector ) {
668      ffElems.push( elem );
669      return;
670    }
671    // filter & find items if we have a selector
672    // filter
673    if ( matchesSelector( elem, selector ) ) {
674      ffElems.push( elem );
675    }
676    // find children
677    var childElems = elem.querySelectorAll( selector );
678    // concat childElems to filterFound array
679    for ( var i=0; i < childElems.length; i++ ) {
680      ffElems.push( childElems[i] );
681    }
682  });
683
684  return ffElems;
685};
686
687// ----- debounceMethod ----- //
688
689utils.debounceMethod = function( _class, methodName, threshold ) {
690  threshold = threshold || 100;
691  // original method
692  var method = _class.prototype[ methodName ];
693  var timeoutName = methodName + 'Timeout';
694
695  _class.prototype[ methodName ] = function() {
696    var timeout = this[ timeoutName ];
697    clearTimeout( timeout );
698
699    var args = arguments;
700    var _this = this;
701    this[ timeoutName ] = setTimeout( function() {
702      method.apply( _this, args );
703      delete _this[ timeoutName ];
704    }, threshold );
705  };
706};
707
708// ----- docReady ----- //
709
710utils.docReady = function( callback ) {
711  var readyState = document.readyState;
712  if ( readyState == 'complete' || readyState == 'interactive' ) {
713    // do async to allow for other scripts to run. metafizzy/flickity#441
714    setTimeout( callback );
715  } else {
716    document.addEventListener( 'DOMContentLoaded', callback );
717  }
718};
719
720// ----- htmlInit ----- //
721
722// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
723utils.toDashed = function( str ) {
724  return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
725    return $1 + '-' + $2;
726  }).toLowerCase();
727};
728
729var console = window.console;
730/**
731 * allow user to initialize classes via [data-namespace] or .js-namespace class
732 * htmlInit( Widget, 'widgetName' )
733 * options are parsed from data-namespace-options
734 */
735utils.htmlInit = function( WidgetClass, namespace ) {
736  utils.docReady( function() {
737    var dashedNamespace = utils.toDashed( namespace );
738    var dataAttr = 'data-' + dashedNamespace;
739    var dataAttrElems = document.querySelectorAll( '[' + dataAttr + ']' );
740    var jsDashElems = document.querySelectorAll( '.js-' + dashedNamespace );
741    var elems = utils.makeArray( dataAttrElems )
742      .concat( utils.makeArray( jsDashElems ) );
743    var dataOptionsAttr = dataAttr + '-options';
744    var jQuery = window.jQuery;
745
746    elems.forEach( function( elem ) {
747      var attr = elem.getAttribute( dataAttr ) ||
748        elem.getAttribute( dataOptionsAttr );
749      var options;
750      try {
751        options = attr && JSON.parse( attr );
752      } catch ( error ) {
753        // log error, do not initialize
754        if ( console ) {
755          console.error( 'Error parsing ' + dataAttr + ' on ' + elem.className +
756          ': ' + error );
757        }
758        return;
759      }
760      // initialize
761      var instance = new WidgetClass( elem, options );
762      // make available via $().data('namespace')
763      if ( jQuery ) {
764        jQuery.data( elem, namespace, instance );
765      }
766    });
767
768  });
769};
770
771// -----  ----- //
772
773return utils;
774
775}));
776
777// Flickity.Cell
778( function( window, factory ) {
779  // universal module definition
780  /* jshint strict: false */
781  if ( typeof define == 'function' && define.amd ) {
782    // AMD
783    define( 'flickity/js/cell',[
784      'get-size/get-size'
785    ], function( getSize ) {
786      return factory( window, getSize );
787    });
788  } else if ( typeof module == 'object' && module.exports ) {
789    // CommonJS
790    module.exports = factory(
791      window,
792      require('get-size')
793    );
794  } else {
795    // browser global
796    window.Flickity = window.Flickity || {};
797    window.Flickity.Cell = factory(
798      window,
799      window.getSize
800    );
801  }
802
803}( window, function factory( window, getSize ) {
804
805
806
807function Cell( elem, parent ) {
808  this.element = elem;
809  this.parent = parent;
810
811  this.create();
812}
813
814var proto = Cell.prototype;
815
816proto.create = function() {
817  this.element.style.position = 'absolute';
818  this.element.setAttribute( 'aria-selected', 'false' );
819  this.x = 0;
820  this.shift = 0;
821};
822
823proto.destroy = function() {
824  // reset style
825  this.element.style.position = '';
826  var side = this.parent.originSide;
827  this.element.removeAttribute('aria-selected');
828  this.element.style[ side ] = '';
829};
830
831proto.getSize = function() {
832  this.size = getSize( this.element );
833};
834
835proto.setPosition = function( x ) {
836  this.x = x;
837  this.updateTarget();
838  this.renderPosition( x );
839};
840
841// setDefaultTarget v1 method, backwards compatibility, remove in v3
842proto.updateTarget = proto.setDefaultTarget = function() {
843  var marginProperty = this.parent.originSide == 'left' ? 'marginLeft' : 'marginRight';
844  this.target = this.x + this.size[ marginProperty ] +
845    this.size.width * this.parent.cellAlign;
846};
847
848proto.renderPosition = function( x ) {
849  // render position of cell with in slider
850  var side = this.parent.originSide;
851  this.element.style[ side ] = this.parent.getPositionValue( x );
852};
853
854/**
855 * @param {Integer} factor - 0, 1, or -1
856**/
857proto.wrapShift = function( shift ) {
858  this.shift = shift;
859  this.renderPosition( this.x + this.parent.slideableWidth * shift );
860};
861
862proto.remove = function() {
863  this.element.parentNode.removeChild( this.element );
864};
865
866return Cell;
867
868}));
869
870// slide
871( function( window, factory ) {
872  // universal module definition
873  /* jshint strict: false */
874  if ( typeof define == 'function' && define.amd ) {
875    // AMD
876    define( 'flickity/js/slide',factory );
877  } else if ( typeof module == 'object' && module.exports ) {
878    // CommonJS
879    module.exports = factory();
880  } else {
881    // browser global
882    window.Flickity = window.Flickity || {};
883    window.Flickity.Slide = factory();
884  }
885
886}( window, function factory() {
887'use strict';
888
889function Slide( parent ) {
890  this.parent = parent;
891  this.isOriginLeft = parent.originSide == 'left';
892  this.cells = [];
893  this.outerWidth = 0;
894  this.height = 0;
895}
896
897var proto = Slide.prototype;
898
899proto.addCell = function( cell ) {
900  this.cells.push( cell );
901  this.outerWidth += cell.size.outerWidth;
902  this.height = Math.max( cell.size.outerHeight, this.height );
903  // first cell stuff
904  if ( this.cells.length == 1 ) {
905    this.x = cell.x; // x comes from first cell
906    var beginMargin = this.isOriginLeft ? 'marginLeft' : 'marginRight';
907    this.firstMargin = cell.size[ beginMargin ];
908  }
909};
910
911proto.updateTarget = function() {
912  var endMargin = this.isOriginLeft ? 'marginRight' : 'marginLeft';
913  var lastCell = this.getLastCell();
914  var lastMargin = lastCell ? lastCell.size[ endMargin ] : 0;
915  var slideWidth = this.outerWidth - ( this.firstMargin + lastMargin );
916  this.target = this.x + this.firstMargin + slideWidth * this.parent.cellAlign;
917};
918
919proto.getLastCell = function() {
920  return this.cells[ this.cells.length - 1 ];
921};
922
923proto.select = function() {
924  this.changeSelected( true );
925};
926
927proto.unselect = function() {
928  this.changeSelected( false );
929};
930
931proto.changeSelected = function( isSelected ) {
932  var classMethod = isSelected ? 'add' : 'remove';
933  this.cells.forEach( function( cell ) {
934    cell.element.classList[ classMethod ]('is-selected');
935    cell.element.setAttribute( 'aria-selected', isSelected.toString() );
936  });
937};
938
939proto.getCellElements = function() {
940  return this.cells.map( function( cell ) {
941    return cell.element;
942  });
943};
944
945return Slide;
946
947}));
948
949// animate
950( function( window, factory ) {
951  // universal module definition
952  /* jshint strict: false */
953  if ( typeof define == 'function' && define.amd ) {
954    // AMD
955    define( 'flickity/js/animate',[
956      'fizzy-ui-utils/utils'
957    ], function( utils ) {
958      return factory( window, utils );
959    });
960  } else if ( typeof module == 'object' && module.exports ) {
961    // CommonJS
962    module.exports = factory(
963      window,
964      require('fizzy-ui-utils')
965    );
966  } else {
967    // browser global
968    window.Flickity = window.Flickity || {};
969    window.Flickity.animatePrototype = factory(
970      window,
971      window.fizzyUIUtils
972    );
973  }
974
975}( window, function factory( window, utils ) {
976
977
978
979// -------------------------- animate -------------------------- //
980
981var proto = {};
982
983proto.startAnimation = function() {
984  if ( this.isAnimating ) {
985    return;
986  }
987
988  this.isAnimating = true;
989  this.restingFrames = 0;
990  this.animate();
991};
992
993proto.animate = function() {
994  this.applyDragForce();
995  this.applySelectedAttraction();
996
997  var previousX = this.x;
998
999  this.integratePhysics();
1000  this.positionSlider();
1001  this.settle( previousX );
1002  // animate next frame
1003  if ( this.isAnimating ) {
1004    var _this = this;
1005    requestAnimationFrame( function animateFrame() {
1006      _this.animate();
1007    });
1008  }
1009};
1010
1011proto.positionSlider = function() {
1012  var x = this.x;
1013  // wrap position around
1014  if ( this.options.wrapAround && this.cells.length > 1 ) {
1015    x = utils.modulo( x, this.slideableWidth );
1016    x = x - this.slideableWidth;
1017    this.shiftWrapCells( x );
1018  }
1019
1020  x = x + this.cursorPosition;
1021  // reverse if right-to-left and using transform
1022  x = this.options.rightToLeft ? -x : x;
1023  var value = this.getPositionValue( x );
1024  // use 3D tranforms for hardware acceleration on iOS
1025  // but use 2D when settled, for better font-rendering
1026  this.slider.style.transform = this.isAnimating ?
1027    'translate3d(' + value + ',0,0)' : 'translateX(' + value + ')';
1028
1029  // scroll event
1030  var firstSlide = this.slides[0];
1031  if ( firstSlide ) {
1032    var positionX = -this.x - firstSlide.target;
1033    var progress = positionX / this.slidesWidth;
1034    this.dispatchEvent( 'scroll', null, [ progress, positionX ] );
1035  }
1036};
1037
1038proto.positionSliderAtSelected = function() {
1039  if ( !this.cells.length ) {
1040    return;
1041  }
1042  this.x = -this.selectedSlide.target;
1043  this.velocity = 0; // stop wobble
1044  this.positionSlider();
1045};
1046
1047proto.getPositionValue = function( position ) {
1048  if ( this.options.percentPosition ) {
1049    // percent position, round to 2 digits, like 12.34%
1050    return ( Math.round( ( position / this.size.innerWidth ) * 10000 ) * 0.01 )+ '%';
1051  } else {
1052    // pixel positioning
1053    return Math.round( position ) + 'px';
1054  }
1055};
1056
1057proto.settle = function( previousX ) {
1058  // keep track of frames where x hasn't moved
1059  if ( !this.isPointerDown && Math.round( this.x * 100 ) == Math.round( previousX * 100 ) ) {
1060    this.restingFrames++;
1061  }
1062  // stop animating if resting for 3 or more frames
1063  if ( this.restingFrames > 2 ) {
1064    this.isAnimating = false;
1065    delete this.isFreeScrolling;
1066    // render position with translateX when settled
1067    this.positionSlider();
1068    this.dispatchEvent( 'settle', null, [ this.selectedIndex ] );
1069  }
1070};
1071
1072proto.shiftWrapCells = function( x ) {
1073  // shift before cells
1074  var beforeGap = this.cursorPosition + x;
1075  this._shiftCells( this.beforeShiftCells, beforeGap, -1 );
1076  // shift after cells
1077  var afterGap = this.size.innerWidth - ( x + this.slideableWidth + this.cursorPosition );
1078  this._shiftCells( this.afterShiftCells, afterGap, 1 );
1079};
1080
1081proto._shiftCells = function( cells, gap, shift ) {
1082  for ( var i=0; i < cells.length; i++ ) {
1083    var cell = cells[i];
1084    var cellShift = gap > 0 ? shift : 0;
1085    cell.wrapShift( cellShift );
1086    gap -= cell.size.outerWidth;
1087  }
1088};
1089
1090proto._unshiftCells = function( cells ) {
1091  if ( !cells || !cells.length ) {
1092    return;
1093  }
1094  for ( var i=0; i < cells.length; i++ ) {
1095    cells[i].wrapShift( 0 );
1096  }
1097};
1098
1099// -------------------------- physics -------------------------- //
1100
1101proto.integratePhysics = function() {
1102  this.x += this.velocity;
1103  this.velocity *= this.getFrictionFactor();
1104};
1105
1106proto.applyForce = function( force ) {
1107  this.velocity += force;
1108};
1109
1110proto.getFrictionFactor = function() {
1111  return 1 - this.options[ this.isFreeScrolling ? 'freeScrollFriction' : 'friction' ];
1112};
1113
1114proto.getRestingPosition = function() {
1115  // my thanks to Steven Wittens, who simplified this math greatly
1116  return this.x + this.velocity / ( 1 - this.getFrictionFactor() );
1117};
1118
1119proto.applyDragForce = function() {
1120  if ( !this.isDraggable || !this.isPointerDown ) {
1121    return;
1122  }
1123  // change the position to drag position by applying force
1124  var dragVelocity = this.dragX - this.x;
1125  var dragForce = dragVelocity - this.velocity;
1126  this.applyForce( dragForce );
1127};
1128
1129proto.applySelectedAttraction = function() {
1130  // do not attract if pointer down or no slides
1131  var dragDown = this.isDraggable && this.isPointerDown;
1132  if ( dragDown || this.isFreeScrolling || !this.slides.length ) {
1133    return;
1134  }
1135  var distance = this.selectedSlide.target * -1 - this.x;
1136  var force = distance * this.options.selectedAttraction;
1137  this.applyForce( force );
1138};
1139
1140return proto;
1141
1142}));
1143
1144// Flickity main
1145( function( window, factory ) {
1146  // universal module definition
1147  /* jshint strict: false */
1148  if ( typeof define == 'function' && define.amd ) {
1149    // AMD
1150    define( 'flickity/js/flickity',[
1151      'ev-emitter/ev-emitter',
1152      'get-size/get-size',
1153      'fizzy-ui-utils/utils',
1154      './cell',
1155      './slide',
1156      './animate'
1157    ], function( EvEmitter, getSize, utils, Cell, Slide, animatePrototype ) {
1158      return factory( window, EvEmitter, getSize, utils, Cell, Slide, animatePrototype );
1159    });
1160  } else if ( typeof module == 'object' && module.exports ) {
1161    // CommonJS
1162    module.exports = factory(
1163      window,
1164      require('ev-emitter'),
1165      require('get-size'),
1166      require('fizzy-ui-utils'),
1167      require('./cell'),
1168      require('./slide'),
1169      require('./animate')
1170    );
1171  } else {
1172    // browser global
1173    var _Flickity = window.Flickity;
1174
1175    window.Flickity = factory(
1176      window,
1177      window.EvEmitter,
1178      window.getSize,
1179      window.fizzyUIUtils,
1180      _Flickity.Cell,
1181      _Flickity.Slide,
1182      _Flickity.animatePrototype
1183    );
1184  }
1185
1186}( window, function factory( window, EvEmitter, getSize,
1187  utils, Cell, Slide, animatePrototype ) {
1188
1189
1190
1191// vars
1192var jQuery = window.jQuery;
1193var getComputedStyle = window.getComputedStyle;
1194var console = window.console;
1195
1196function moveElements( elems, toElem ) {
1197  elems = utils.makeArray( elems );
1198  while ( elems.length ) {
1199    toElem.appendChild( elems.shift() );
1200  }
1201}
1202
1203// -------------------------- Flickity -------------------------- //
1204
1205// globally unique identifiers
1206var GUID = 0;
1207// internal store of all Flickity intances
1208var instances = {};
1209
1210function Flickity( element, options ) {
1211  var queryElement = utils.getQueryElement( element );
1212  if ( !queryElement ) {
1213    if ( console ) {
1214      console.error( 'Bad element for Flickity: ' + ( queryElement || element ) );
1215    }
1216    return;
1217  }
1218  this.element = queryElement;
1219  // do not initialize twice on same element
1220  if ( this.element.flickityGUID ) {
1221    var instance = instances[ this.element.flickityGUID ];
1222    instance.option( options );
1223    return instance;
1224  }
1225
1226  // add jQuery
1227  if ( jQuery ) {
1228    this.$element = jQuery( this.element );
1229  }
1230  // options
1231  this.options = utils.extend( {}, this.constructor.defaults );
1232  this.option( options );
1233
1234  // kick things off
1235  this._create();
1236}
1237
1238Flickity.defaults = {
1239  accessibility: true,
1240  // adaptiveHeight: false,
1241  cellAlign: 'center',
1242  // cellSelector: undefined,
1243  // contain: false,
1244  freeScrollFriction: 0.075, // friction when free-scrolling
1245  friction: 0.28, // friction when selecting
1246  namespaceJQueryEvents: true,
1247  // initialIndex: 0,
1248  percentPosition: true,
1249  resize: true,
1250  selectedAttraction: 0.025,
1251  setGallerySize: true
1252  // watchCSS: false,
1253  // wrapAround: false
1254};
1255
1256// hash of methods triggered on _create()
1257Flickity.createMethods = [];
1258
1259var proto = Flickity.prototype;
1260// inherit EventEmitter
1261utils.extend( proto, EvEmitter.prototype );
1262
1263proto._create = function() {
1264  // add id for Flickity.data
1265  var id = this.guid = ++GUID;
1266  this.element.flickityGUID = id; // expando
1267  instances[ id ] = this; // associate via id
1268  // initial properties
1269  this.selectedIndex = 0;
1270  // how many frames slider has been in same position
1271  this.restingFrames = 0;
1272  // initial physics properties
1273  this.x = 0;
1274  this.velocity = 0;
1275  this.originSide = this.options.rightToLeft ? 'right' : 'left';
1276  // create viewport & slider
1277  /*nectar addition*/
1278  
1279  if(this.$element.hasClass('generate-markup')) {
1280    this.viewport = document.createElement('div'); 
1281    this.viewport.className = 'flickity-viewport'; 
1282  } else {
1283    this.viewport = this.$element.find('.flickity-viewport')[0];
1284    this.slider = this.$element.find('.flickity-slider')[0];
1285    this.viewport.className = 'flickity-viewport';
1286  }
1287
1288  this._createSlider();
1289
1290  
1291  /*nectar addition end*/
1292
1293  if ( this.options.resize || this.options.watchCSS ) {
1294    window.addEventListener( 'resize', this );
1295  }
1296
1297  // add listeners from on option
1298  for ( var eventName in this.options.on ) {
1299    var listener = this.options.on[ eventName ];
1300    this.on( eventName, listener );
1301  }
1302
1303  Flickity.createMethods.forEach( function( method ) {
1304    this[ method ]();
1305  }, this );
1306
1307  if ( this.options.watchCSS ) {
1308    this.watchCSS();
1309  } else {
1310    this.activate();
1311  }
1312
1313};
1314
1315/**
1316 * set options
1317 * @param {Object} opts
1318 */
1319proto.option = function( opts ) {
1320  utils.extend( this.options, opts );
1321};
1322
1323proto.activate = function() {
1324  if ( this.isActive ) {
1325    return;
1326  }
1327  this.isActive = true;
1328  this.element.classList.add('flickity-enabled');
1329  if ( this.options.rightToLeft ) {
1330    this.element.classList.add('flickity-rtl');
1331  }
1332
1333  this.getSize();
1334  // move initial cell elements so they can be loaded as cells
1335  var cellElems = this._filterFindCellElements( this.element.children );
1336  
1337  /* nectar addition */
1338  if(this.$element.hasClass('generate-markup')) {
1339    moveElements( cellElems, this.slider );
1340    this.viewport.appendChild( this.slider );
1341    this.element.appendChild( this.viewport );
1342  } else {
1343    //do nothing
1344  }
1345  /* nectar addition  end */
1346  
1347  // get cells from children
1348  this.reloadCells();
1349
1350  if ( this.options.accessibility ) {
1351    // allow element to focusable
1352    this.element.tabIndex = 0;
1353    // listen for key presses
1354    this.element.addEventListener( 'keydown', this );
1355  }
1356
1357  this.emitEvent('activate');
1358
1359  var index;
1360  var initialIndex = this.options.initialIndex;
1361  if ( this.isInitActivated ) {
1362    index = this.selectedIndex;
1363  } else if ( initialIndex !== undefined ) {
1364    index = this.cells[ initialIndex ] ? initialIndex : 0;
1365  } else {
1366    index = 0;
1367  }
1368  // select instantly
1369  this.select( index, false, true );
1370  // flag for initial activation, for using initialIndex
1371  this.isInitActivated = true;
1372  // ready event. #493
1373  this.dispatchEvent('ready');
1374};
1375
1376// slider positions the cells
1377/* nectar addition */
1378proto._createSlider = function() {
1379  if(this.$element.hasClass('generate-markup')) {
1380    var slider = document.createElement('div');
1381    slider.className = 'flickity-slider';
1382    slider.style[ this.originSide ] = 0;
1383    this.slider = slider;
1384  } else {
1385    // slider element does all the positioning
1386    //var slider = document.createElement('div');
1387    //slider.className = 'flickity-slider';
1388    this.slider.style[ this.originSide ] = 0;
1389  //  this.slider = slider;
1390  }
1391  
1392};
1393/* nectar addition end */
1394
1395proto._filterFindCellElements = function( elems ) {
1396  return utils.filterFindElements( elems, this.options.cellSelector );
1397};
1398
1399// goes through all children
1400proto.reloadCells = function() {
1401  /* nectar addition */
1402  
1403  if(jQuery(this.slider).parent().parent().find('.flickity-page-dots').length > 0) {
1404    var $that = this;
1405    setTimeout(function(){
1406      $that.pageDots.setDots();
1407    },100);
1408  }
1409  var slidesArr = [];
1410  jQuery(this.slider).find('> *').each(function(i){
1411    slidesArr[i] = jQuery(this)[0];
1412  });
1413    
1414    
1415  // collection of item elements
1416    this.cells = this._makeCells(slidesArr);
1417    /* nectar addition end */
1418  this.positionCells();
1419  this._getWrapShiftCells();
1420  this.setGallerySize();
1421};
1422
1423/**
1424 * turn elements into Flickity.Cells
1425 * @param {Array or NodeList or HTMLElement} elems
1426 * @returns {Array} items - collection of new Flickity Cells
1427 */
1428proto._makeCells = function( elems ) {
1429  var cellElems = this._filterFindCellElements( elems );
1430
1431  // create new Flickity for collection
1432  var cells = cellElems.map( function( cellElem ) {
1433    return new Cell( cellElem, this );
1434  }, this );
1435
1436  return cells;
1437};
1438
1439proto.getLastCell = function() {
1440  return this.cells[ this.cells.length - 1 ];
1441};
1442
1443proto.getLastSlide = function() {
1444  return this.slides[ this.slides.length - 1 ];
1445};
1446
1447// positions all cells
1448proto.positionCells = function() {
1449  // size all cells
1450  this._sizeCells( this.cells );
1451  // position all cells
1452  this._positionCells( 0 );
1453};
1454
1455/**
1456 * position certain cells
1457 * @param {Integer} index - which cell to start with
1458 */
1459proto._positionCells = function( index ) {
1460  index = index || 0;
1461  // also measure maxCellHeight
1462  // start 0 if positioning all cells
1463  this.maxCellHeight = index ? this.maxCellHeight || 0 : 0;
1464  var cellX = 0;
1465  // get cellX
1466  if ( index > 0 ) {
1467    var startCell = this.cells[ index - 1 ];
1468    cellX = startCell.x + startCell.size.outerWidth;
1469  }
1470  var len = this.cells.length;
1471  for ( var i=index; i < len; i++ ) {
1472    var cell = this.cells[i];
1473    cell.setPosition( cellX );
1474    cellX += cell.size.outerWidth;
1475    this.maxCellHeight = Math.max( cell.size.outerHeight, this.maxCellHeight );
1476  }
1477  // keep track of cellX for wrap-around
1478  this.slideableWidth = cellX;
1479  // slides
1480  this.updateSlides();
1481  // contain slides target
1482  this._containSlides();
1483  // update slidesWidth
1484  this.slidesWidth = len ? this.getLastSlide().target - this.slides[0].target : 0;
1485};
1486
1487/**
1488 * cell.getSize() on multiple cells
1489 * @param {Array} cells
1490 */
1491proto._sizeCells = function( cells ) {
1492  cells.forEach( function( cell ) {
1493    cell.getSize();
1494  });
1495};
1496
1497// --------------------------  -------------------------- //
1498
1499proto.updateSlides = function() {
1500  this.slides = [];
1501  if ( !this.cells.length ) {
1502    return;
1503  }
1504
1505  var slide = new Slide( this );
1506  this.slides.push( slide );
1507  var isOriginLeft = this.originSide == 'left';
1508  var nextMargin = isOriginLeft ? 'marginRight' : 'marginLeft';
1509
1510  var canCellFit = this._getCanCellFit();
1511
1512  this.cells.forEach( function( cell, i ) {
1513    // just add cell if first cell in slide
1514    if ( !slide.cells.length ) {
1515      slide.addCell( cell );
1516      return;
1517    }
1518
1519    var slideWidth = ( slide.outerWidth - slide.firstMargin ) +
1520      ( cell.size.outerWidth - cell.size[ nextMargin ] );
1521
1522    if ( canCellFit.call( this, i, slideWidth ) ) {
1523      slide.addCell( cell );
1524    } else {
1525      // doesn't fit, new slide
1526      slide.updateTarget();
1527
1528      slide = new Slide( this );
1529      this.slides.push( slide );
1530      slide.addCell( cell );
1531    }
1532  }, this );
1533  // last slide
1534  slide.updateTarget();
1535  // update .selectedSlide
1536  this.updateSelectedSlide();
1537};
1538
1539proto._getCanCellFit = function() {
1540  var groupCells = this.options.groupCells;
1541  if ( !groupCells ) {
1542    return function() {
1543      return false;
1544    };
1545  } else if ( typeof groupCells == 'number' ) {
1546    // group by number. 3 -> [0,1,2], [3,4,5], ...
1547    var number = parseInt( groupCells, 10 );
1548    return function( i ) {
1549      return ( i % number ) !== 0;
1550    };
1551  }
1552  // default, group by width of slide
1553  // parse '75%
1554  var percentMatch = typeof groupCells == 'string' &&
1555    groupCells.match(/^(\d+)%$/);
1556  var percent = percentMatch ? parseInt( percentMatch[1], 10 ) / 100 : 1;
1557  return function( i, slideWidth ) {
1558    return slideWidth <= ( this.size.innerWidth + 1 ) * percent;
1559  };
1560};
1561
1562// alias _init for jQuery plugin .flickity()
1563proto._init =
1564proto.reposition = function() {
1565  this.positionCells();
1566  this.positionSliderAtSelected();
1567};
1568
1569proto.getSize = function() {
1570  this.size = getSize( this.element );
1571  this.setCellAlign();
1572  this.cursorPosition = this.size.innerWidth * this.cellAlign;
1573};
1574
1575var cellAlignShorthands = {
1576  // cell align, then based on origin side
1577  center: {
1578    left: 0.5,
1579    right: 0.5
1580  },
1581  left: {
1582    left: 0,
1583    right: 1
1584  },
1585  right: {
1586    right: 0,
1587    left: 1
1588  }
1589};
1590
1591proto.setCellAlign = function() {
1592  var shorthand = cellAlignShorthands[ this.options.cellAlign ];
1593  this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign;
1594};
1595
1596proto.setGallerySize = function() {
1597  if ( this.options.setGallerySize ) {
1598    var height = this.options.adaptiveHeight && this.selectedSlide ?
1599      this.selectedSlide.height : this.maxCellHeight;
1600    this.viewport.style.height = height + 'px';
1601  }
1602};
1603
1604proto._getWrapShiftCells = function() {
1605  // only for wrap-around
1606  if ( !this.options.wrapAround ) {
1607    return;
1608  }
1609  // unshift previous cells
1610  this._unshiftCells( this.beforeShiftCells );
1611  this._unshiftCells( this.afterShiftCells );
1612  // get before cells
1613  // initial gap
1614  var gapX = this.cursorPosition;
1615  var cellIndex = this.cells.length - 1;
1616  this.beforeShiftCells = this._getGapCells( gapX, cellIndex, -1 );
1617  // get after cells
1618  // ending gap between last cell and end of gallery viewport
1619  gapX = this.size.innerWidth - this.cursorPosition;
1620  // start cloning at first cell, working forwards
1621  this.afterShiftCells = this._getGapCells( gapX, 0, 1 );
1622};
1623
1624proto._getGapCells = function( gapX, cellIndex, increment ) {
1625  // keep adding cells until the cover the initial gap
1626  var cells = [];
1627  while ( gapX > 0 ) {
1628    var cell = this.cells[ cellIndex ];
1629    if ( !cell ) {
1630      break;
1631    }
1632    cells.push( cell );
1633    cellIndex += increment;
1634    gapX -= cell.size.outerWidth;
1635  }
1636  return cells;
1637};
1638
1639// ----- contain ----- //
1640
1641// contain cell targets so no excess sliding
1642proto._containSlides = function() {
1643  if ( !this.options.contain || this.options.wrapAround || !this.cells.length ) {
1644    return;
1645  }
1646  var isRightToLeft = this.options.rightToLeft;
1647  var beginMargin = isRightToLeft ? 'marginRight' : 'marginLeft';
1648  var endMargin = isRightToLeft ? 'marginLeft' : 'marginRight';
1649  var contentWidth = this.slideableWidth - this.getLastCell().size[ endMargin ];
1650  // content is less than gallery size
1651  var isContentSmaller = contentWidth < this.size.innerWidth;
1652  // bounds
1653  var beginBound = this.cursorPosition + this.cells[0].size[ beginMargin ];
1654  var endBound = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign );
1655  // contain each cell target
1656  this.slides.forEach( function( slide ) {
1657    if ( isContentSmaller ) {
1658      // all cells fit inside gallery
1659      slide.target = contentWidth * this.cellAlign;
1660    } else {
1661      // contain to bounds
1662      slide.target = Math.max( slide.target, beginBound );
1663      slide.target = Math.min( slide.target, endBound );
1664    }
1665  }, this );
1666};
1667
1668// -----  ----- //
1669
1670/**
1671 * emits events via eventEmitter and jQuery events
1672 * @param {String} type - name of event
1673 * @param {Event} event - original event
1674 * @param {Array} args - extra arguments
1675 */
1676proto.dispatchEvent = function( type, event, args ) {
1677  var emitArgs = event ? [ event ].concat( args ) : args;
1678  this.emitEvent( type, emitArgs );
1679
1680  if ( jQuery && this.$element ) {
1681    // default trigger with type if no event
1682    type += this.options.namespaceJQueryEvents ? '.flickity' : '';
1683    var $event = type;
1684    if ( event ) {
1685      // create jQuery event
1686      var jQEvent = jQuery.Event( event );
1687      jQEvent.type = type;
1688      $event = jQEvent;
1689    }
1690    this.$element.trigger( $event, args );
1691  }
1692};
1693
1694// -------------------------- select -------------------------- //
1695
1696/**
1697 * @param {Integer} index - index of the slide
1698 * @param {Boolean} isWrap - will wrap-around to last/first if at the end
1699 * @param {Boolean} isInstant - will immediately set position at selected cell
1700 */
1701proto.select = function( index, isWrap, isInstant ) {
1702  if ( !this.isActive ) {
1703    return;
1704  }
1705  index = parseInt( index, 10 );
1706  this._wrapSelect( index );
1707
1708  if ( this.options.wrapAround || isWrap ) {
1709    index = utils.modulo( index, this.slides.length );
1710  }
1711  // bail if invalid index
1712  if ( !this.slides[ index ] ) {
1713    return;
1714  }
1715  var prevIndex = this.selectedIndex;
1716  this.selectedIndex = index;
1717  this.updateSelectedSlide();
1718  if ( isInstant ) {
1719    this.positionSliderAtSelected();
1720  } else {
1721    this.startAnimation();
1722  }
1723  if ( this.options.adaptiveHeight ) {
1724    this.setGallerySize();
1725  }
1726  // events
1727  this.dispatchEvent( 'select', null, [ index ] );
1728  // change event if new index
1729  if ( index != prevIndex ) {
1730    this.dispatchEvent( 'change', null, [ index ] );
1731  }
1732  // old v1 event name, remove in v3
1733  this.dispatchEvent('cellSelect');
1734};
1735
1736// wraps position for wrapAround, to move to closest slide. #113
1737proto._wrapSelect = function( index ) {
1738  var len = this.slides.length;
1739  var isWrapping = this.options.wrapAround && len > 1;
1740  if ( !isWrapping ) {
1741    return index;
1742  }
1743  var wrapIndex = utils.modulo( index, len );
1744  // go to shortest
1745  var delta = Math.abs( wrapIndex - this.selectedIndex );
1746  var backWrapDelta = Math.abs( ( wrapIndex + len ) - this.selectedIndex );
1747  var forewardWrapDelta = Math.abs( ( wrapIndex - len ) - this.selectedIndex );
1748  if ( !this.isDragSelect && backWrapDelta < delta ) {
1749    index += len;
1750  } else if ( !this.isDragSelect && forewardWrapDelta < delta ) {
1751    index -= len;
1752  }
1753  // wrap position so slider is within normal area
1754  if ( index < 0 ) {
1755    this.x -= this.slideableWidth;
1756  } else if ( index >= len ) {
1757    this.x += this.slideableWidth;
1758  }
1759};
1760
1761proto.previous = function( isWrap, isInstant ) {
1762  this.select( this.selectedIndex - 1, isWrap, isInstant );
1763};
1764
1765proto.next = function( isWrap, isInstant ) {
1766  this.select( this.selectedIndex + 1, isWrap, isInstant );
1767};
1768
1769proto.updateSelectedSlide = function() {
1770  var slide = this.slides[ this.selectedIndex ];
1771  // selectedIndex could be outside of slides, if triggered before resize()
1772  if ( !slide ) {
1773    return;
1774  }
1775  // unselect previous selected slide
1776  this.unselectSelectedSlide();
1777  // update new selected slide
1778  this.selectedSlide = slide;
1779  slide.select();
1780  this.selectedCells = slide.cells;
1781  this.selectedElements = slide.getCellElements();
1782  // HACK: selectedCell & selectedElement is first cell in slide, backwards compatibility
1783  // Remove in v3?
1784  this.selectedCell = slide.cells[0];
1785  this.selectedElement = this.selectedElements[0];
1786};
1787
1788proto.unselectSelectedSlide = function() {
1789  if ( this.selectedSlide ) {
1790    this.selectedSlide.unselect();
1791  }
1792};
1793
1794/**
1795 * select slide from number or cell element
1796 * @param {Element or Number} elem
1797 */
1798proto.selectCell = function( value, isWrap, isInstant ) {
1799  // get cell
1800  var cell = this.queryCell( value );
1801  if ( !cell ) {
1802    return;
1803  }
1804
1805  var index = this.getCellSlideIndex( cell );
1806  this.select( index, isWrap, isInstant );
1807};
1808
1809proto.getCellSlideIndex = function( cell ) {
1810  // get index of slides that has cell
1811  for ( var i=0; i < this.slides.length; i++ ) {
1812    var slide = this.slides[i];
1813    var index = slide.cells.indexOf( cell );
1814    if ( index != -1 ) {
1815      return i;
1816    }
1817  }
1818};
1819
1820// -------------------------- get cells -------------------------- //
1821
1822/**
1823 * get Flickity.Cell, given an Element
1824 * @param {Element} elem
1825 * @returns {Flickity.Cell} item
1826 */
1827proto.getCell = function( elem ) {
1828  // loop through cells to get the one that matches
1829  for ( var i=0; i < this.cells.length; i++ ) {
1830    var cell = this.cells[i];
1831    if ( cell.element == elem ) {
1832      return cell;
1833    }
1834  }
1835};
1836
1837/**
1838 * get collection of Flickity.Cells, given Elements
1839 * @param {Element, Array, NodeList} elems
1840 * @returns {Array} cells - Flickity.Cells
1841 */
1842proto.getCells = function( elems ) {
1843  elems = utils.makeArray( elems );
1844  var cells = [];
1845  elems.forEach( function( elem ) {
1846    var cell = this.getCell( elem );
1847    if ( cell ) {
1848      cells.push( cell );
1849    }
1850  }, this );
1851  return cells;
1852};
1853
1854/**
1855 * get cell elements
1856 * @returns {Array} cellElems
1857 */
1858proto.getCellElements = function() {
1859  return this.cells.map( function( cell ) {
1860    return cell.element;
1861  });
1862};
1863
1864/**
1865 * get parent cell from an element
1866 * @param {Element} elem
1867 * @returns {Flickit.Cell} cell
1868 */
1869proto.getParentCell = function( elem ) {
1870  // first check if elem is cell
1871  var cell = this.getCell( elem );
1872  if ( cell ) {
1873    return cell;
1874  }
1875  // try to get parent cell elem
1876  elem = utils.getParent( elem, '.flickity-slider > *' );
1877  return this.getCell( elem );
1878};
1879
1880/**
1881 * get cells adjacent to a slide
1882 * @param {Integer} adjCount - number of adjacent slides
1883 * @param {Integer} index - index of slide to start
1884 * @returns {Array} cells - array of Flickity.Cells
1885 */
1886proto.getAdjacentCellElements = function( adjCount, index ) {
1887  if ( !adjCount ) {
1888    return this.selectedSlide.getCellElements();
1889  }
1890  index = index === undefined ? this.selectedIndex : index;
1891
1892  var len = this.slides.length;
1893  if ( 1 + ( adjCount * 2 ) >= len ) {
1894    return this.getCellElements();
1895  }
1896
1897  var cellElems = [];
1898  for ( var i = index - adjCount; i <= index + adjCount ; i++ ) {
1899    var slideIndex = this.options.wrapAround ? utils.modulo( i, len ) : i;
1900    var slide = this.slides[ slideIndex ];
1901    if ( slide ) {
1902      cellElems = cellElems.concat( slide.getCellElements() );
1903    }
1904  }
1905  return cellElems;
1906};
1907
1908/**
1909 * select slide from number or cell element
1910 * @param {Element, Selector String, or Number} selector
1911 */
1912proto.queryCell = function( selector ) {
1913  if ( typeof selector == 'number' ) {
1914    // use number as index
1915    return this.cells[ selector ];
1916  }
1917  if ( typeof selector == 'string' ) {
1918    // use string as selector, get element
1919    selector = this.element.querySelector( selector );
1920  }
1921  // get cell from element
1922  return this.getCell( selector );
1923};
1924
1925// -------------------------- events -------------------------- //
1926
1927proto.uiChange = function() {
1928  this.emitEvent('uiChange');
1929};
1930
1931proto.childUIPointerDown = function( event ) {
1932  this.emitEvent( 'childUIPointerDown', [ event ] );
1933};
1934
1935// ----- resize ----- //
1936
1937proto.onresize = function() {
1938  this.watchCSS();
1939  this.resize();
1940};
1941
1942utils.debounceMethod( Flickity, 'onresize', 150 );
1943
1944proto.resize = function() {
1945  if ( !this.isActive ) {
1946    return;
1947  }
1948  this.getSize();
1949  // wrap values
1950  if ( this.options.wrapAround ) {
1951    this.x = utils.modulo( this.x, this.slideableWidth );
1952  }
1953  this.positionCells();
1954  this._getWrapShiftCells();
1955  this.setGallerySize();
1956  this.emitEvent('resize');
1957  // update selected index for group slides, instant
1958  // TODO: position can be lost between groups of various numbers
1959  var selectedElement = this.selectedElements && this.selectedElements[0];
1960  this.selectCell( selectedElement, false, true );
1961};
1962
1963// watches the :after property, activates/deactivates
1964proto.watchCSS = function() {
1965  var watchOption = this.options.watchCSS;
1966  if ( !watchOption ) {
1967    return;
1968  }
1969
1970  var afterContent = getComputedStyle( this.element, ':after' ).content;
1971  // activate if :after { content: 'flickity' }
1972  if ( afterContent.indexOf('flickity') != -1 ) {
1973    this.activate();
1974  } else {
1975    this.deactivate();
1976  }
1977};
1978
1979// ----- keydown ----- //
1980
1981// go previous/next if left/right keys pressed
1982proto.onkeydown = function( event ) {
1983  // only work if element is in focus
1984  var isNotFocused = document.activeElement && document.activeElement != this.element;
1985  if ( !this.options.accessibility ||isNotFocused ) {
1986    return;
1987  }
1988
1989  var handler = Flickity.keyboardHandlers[ event.keyCode ];
1990  if ( handler ) {
1991    handler.call( this );
1992  }
1993};
1994
1995Flickity.keyboardHandlers = {
1996  // left arrow
1997  37: function() {
1998    var leftMethod = this.options.rightToLeft ? 'next' : 'previous';
1999    this.uiChange();
2000    this[ leftMethod ]();
2001  },
2002  // right arrow
2003  39: function() {
2004    var rightMethod = this.options.rightToLeft ? 'previous' : 'next';
2005    this.uiChange();
2006    this[ rightMethod ]();
2007  },
2008};
2009
2010// ----- focus ----- //
2011
2012proto.focus = function() {
2013  // TODO remove scrollTo once focus options gets more support
2014  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#Browser_compatibility
2015  var prevScrollY = window.pageYOffset;
2016  this.element.focus({ preventScroll: true });
2017  // hack to fix scroll jump after focus, #76
2018  if ( window.pageYOffset != prevScrollY ) {
2019    window.scrollTo( window.pageXOffset, prevScrollY );
2020  }
2021};
2022
2023// -------------------------- destroy -------------------------- //
2024
2025// deactivate all Flickity functionality, but keep stuff available
2026proto.deactivate = function() {
2027  if ( !this.isActive ) {
2028    return;
2029  }
2030  this.element.classList.remove('flickity-enabled');
2031  this.element.classList.remove('flickity-rtl');
2032  this.unselectSelectedSlide();
2033  // destroy cells
2034  this.cells.forEach( function( cell ) {
2035    cell.destroy();
2036  });
2037  this.element.removeChild( this.viewport );
2038  // move child elements back into element
2039  moveElements( this.slider.children, this.element );
2040  if ( this.options.accessibility ) {
2041    this.element.removeAttribute('tabIndex');
2042    this.element.removeEventListener( 'keydown', this );
2043  }
2044  // set flags
2045  this.isActive = false;
2046  this.emitEvent('deactivate');
2047};
2048
2049proto.destroy = function() {
2050  this.deactivate();
2051  window.removeEventListener( 'resize', this );
2052  this.emitEvent('destroy');
2053  if ( jQuery && this.$element ) {
2054    jQuery.removeData( this.element, 'flickity' );
2055  }
2056  delete this.element.flickityGUID;
2057  delete instances[ this.guid ];
2058};
2059
2060// -------------------------- prototype -------------------------- //
2061
2062utils.extend( proto, animatePrototype );
2063
2064// -------------------------- extras -------------------------- //
2065
2066/**
2067 * get Flickity instance from element
2068 * @param {Element} elem
2069 * @returns {Flickity}
2070 */
2071Flickity.data = function( elem ) {
2072  elem = utils.getQueryElement( elem );
2073  var id = elem && elem.flickityGUID;
2074  return id && instances[ id ];
2075};
2076
2077utils.htmlInit( Flickity, 'flickity' );
2078
2079if ( jQuery && jQuery.bridget ) {
2080  jQuery.bridget( 'flickity', Flickity );
2081}
2082
2083// set internal jQuery, for Webpack + jQuery v3, #478
2084Flickity.setJQuery = function( jq ) {
2085  jQuery = jq;
2086};
2087
2088Flickity.Cell = Cell;
2089
2090return Flickity;
2091
2092}));
2093
2094/*!
2095 * Unipointer v2.3.0
2096 * base class for doing one thing with pointer event
2097 * MIT license
2098 */
2099
2100/*jshint browser: true, undef: true, unused: true, strict: true */
2101
2102( function( window, factory ) {
2103  // universal module definition
2104  /* jshint strict: false */ /*global define, module, require */
2105  if ( typeof define == 'function' && define.amd ) {
2106    // AMD
2107    define( 'unipointer/unipointer',[
2108      'ev-emitter/ev-emitter'
2109    ], function( EvEmitter ) {
2110      return factory( window, EvEmitter );
2111    });
2112  } else if ( typeof module == 'object' && module.exports ) {
2113    // CommonJS
2114    module.exports = factory(
2115      window,
2116      require('ev-emitter')
2117    );
2118  } else {
2119    // browser global
2120    window.Unipointer = factory(
2121      window,
2122      window.EvEmitter
2123    );
2124  }
2125
2126}( window, function factory( window, EvEmitter ) {
2127
2128
2129
2130function noop() {}
2131
2132function Unipointer() {}
2133
2134// inherit EvEmitter
2135var proto = Unipointer.prototype = Object.create( EvEmitter.prototype );
2136
2137proto.bindStartEvent = function( elem ) {
2138  this._bindStartEvent( elem, true );
2139};
2140
2141proto.unbindStartEvent = function( elem ) {
2142  this._bindStartEvent( elem, false );
2143};
2144
2145/**
2146 * Add or remove start event
2147 * @param {Boolean} isAdd - remove if falsey
2148 */
2149proto._bindStartEvent = function( elem, isAdd ) {
2150  // munge isAdd, default to true
2151  isAdd = isAdd === undefined ? true : isAdd;
vendor: 7,271 bytes, lines 2152-2456
2152  var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';
2153
2154  // default to mouse events
2155  var startEvent = 'mousedown';
2156  if ( window.PointerEvent ) {
2157    // Pointer Events
2158    startEvent = 'pointerdown';
2159  } else if ( 'ontouchstart' in window ) {
2160    // Touch Events. iOS Safari
2161    startEvent = 'touchstart';
2162  }
2163  elem[ bindMethod ]( startEvent, this );
2164};
2165
2166// trigger handler methods for events
2167proto.handleEvent = function( event ) {
2168  var method = 'on' + event.type;
2169  if ( this[ method ] ) {
2170    this[ method ]( event );
2171  }
2172};
2173
2174// returns the touch that we're keeping track of
2175proto.getTouch = function( touches ) {
2176  for ( var i=0; i < touches.length; i++ ) {
2177    var touch = touches[i];
2178    if ( touch.identifier == this.pointerIdentifier ) {
2179      return touch;
2180    }
2181  }
2182};
2183
2184// ----- start event ----- //
2185
2186proto.onmousedown = function( event ) {
2187  // dismiss clicks from right or middle buttons
2188  var button = event.button;
2189  if ( button && ( button !== 0 && button !== 1 ) ) {
2190    return;
2191  }
2192  this._pointerDown( event, event );
2193};
2194
2195proto.ontouchstart = function( event ) {
2196  this._pointerDown( event, event.changedTouches[0] );
2197};
2198
2199proto.onpointerdown = function( event ) {
2200  this._pointerDown( event, event );
2201};
2202
2203/**
2204 * pointer start
2205 * @param {Event} event
2206 * @param {Event or Touch} pointer
2207 */
2208proto._pointerDown = function( event, pointer ) {
2209  // dismiss right click and other pointers
2210  // button = 0 is okay, 1-4 not
2211  if ( event.button || this.isPointerDown ) {
2212    return;
2213  }
2214
2215  this.isPointerDown = true;
2216  // save pointer identifier to match up touch events
2217  this.pointerIdentifier = pointer.pointerId !== undefined ?
2218    // pointerId for pointer events, touch.indentifier for touch events
2219    pointer.pointerId : pointer.identifier;
2220
2221  this.pointerDown( event, pointer );
2222};
2223
2224proto.pointerDown = function( event, pointer ) {
2225  this._bindPostStartEvents( event );
2226  this.emitEvent( 'pointerDown', [ event, pointer ] );
2227};
2228
2229// hash of events to be bound after start event
2230var postStartEvents = {
2231  mousedown: [ 'mousemove', 'mouseup' ],
2232  touchstart: [ 'touchmove', 'touchend', 'touchcancel' ],
2233  pointerdown: [ 'pointermove', 'pointerup', 'pointercancel' ],
2234};
2235
2236proto._bindPostStartEvents = function( event ) {
2237  if ( !event ) {
2238    return;
2239  }
2240  // get proper events to match start event
2241  var events = postStartEvents[ event.type ];
2242  // bind events to node
2243  events.forEach( function( eventName ) {
2244    window.addEventListener( eventName, this );
2245  }, this );
2246  // save these arguments
2247  this._boundPointerEvents = events;
2248};
2249
2250proto._unbindPostStartEvents = function() {
2251  // check for _boundEvents, in case dragEnd triggered twice (old IE8 bug)
2252  if ( !this._boundPointerEvents ) {
2253    return;
2254  }
2255  this._boundPointerEvents.forEach( function( eventName ) {
2256    window.removeEventListener( eventName, this );
2257  }, this );
2258
2259  delete this._boundPointerEvents;
2260};
2261
2262// ----- move event ----- //
2263
2264proto.onmousemove = function( event ) {
2265  this._pointerMove( event, event );
2266};
2267
2268proto.onpointermove = function( event ) {
2269  if ( event.pointerId == this.pointerIdentifier ) {
2270    this._pointerMove( event, event );
2271  }
2272};
2273
2274proto.ontouchmove = function( event ) {
2275  var touch = this.getTouch( event.changedTouches );
2276  if ( touch ) {
2277    this._pointerMove( event, touch );
2278  }
2279};
2280
2281/**
2282 * pointer move
2283 * @param {Event} event
2284 * @param {Event or Touch} pointer
2285 * @private
2286 */
2287proto._pointerMove = function( event, pointer ) {
2288  this.pointerMove( event, pointer );
2289};
2290
2291// public
2292proto.pointerMove = function( event, pointer ) {
2293  this.emitEvent( 'pointerMove', [ event, pointer ] );
2294};
2295
2296// ----- end event ----- //
2297
2298
2299proto.onmouseup = function( event ) {
2300  this._pointerUp( event, event );
2301};
2302
2303proto.onpointerup = function( event ) {
2304  if ( event.pointerId == this.pointerIdentifier ) {
2305    this._pointerUp( event, event );
2306  }
2307};
2308
2309proto.ontouchend = function( event ) {
2310  var touch = this.getTouch( event.changedTouches );
2311  if ( touch ) {
2312    this._pointerUp( event, touch );
2313  }
2314};
2315
2316/**
2317 * pointer up
2318 * @param {Event} event
2319 * @param {Event or Touch} pointer
2320 * @private
2321 */
2322proto._pointerUp = function( event, pointer ) {
2323  this._pointerDone();
2324  this.pointerUp( event, pointer );
2325};
2326
2327// public
2328proto.pointerUp = function( event, pointer ) {
2329  this.emitEvent( 'pointerUp', [ event, pointer ] );
2330};
2331
2332// ----- pointer done ----- //
2333
2334// triggered on pointer up & pointer cancel
2335proto._pointerDone = function() {
2336  this._pointerReset();
2337  this._unbindPostStartEvents();
2338  this.pointerDone();
2339};
2340
2341proto._pointerReset = function() {
2342  // reset properties
2343  this.isPointerDown = false;
2344  delete this.pointerIdentifier;
2345};
2346
2347proto.pointerDone = noop;
2348
2349// ----- pointer cancel ----- //
2350
2351proto.onpointercancel = function( event ) {
2352  if ( event.pointerId == this.pointerIdentifier ) {
2353    this._pointerCancel( event, event );
2354  }
2355};
2356
2357proto.ontouchcancel = function( event ) {
2358  var touch = this.getTouch( event.changedTouches );
2359  if ( touch ) {
2360    this._pointerCancel( event, touch );
2361  }
2362};
2363
2364/**
2365 * pointer cancel
2366 * @param {Event} event
2367 * @param {Event or Touch} pointer
2368 * @private
2369 */
2370proto._pointerCancel = function( event, pointer ) {
2371  this._pointerDone();
2372  this.pointerCancel( event, pointer );
2373};
2374
2375// public
2376proto.pointerCancel = function( event, pointer ) {
2377  this.emitEvent( 'pointerCancel', [ event, pointer ] );
2378};
2379
2380// -----  ----- //
2381
2382// utility function for getting x/y coords from event
2383Unipointer.getPointerPoint = function( pointer ) {
2384  return {
2385    x: pointer.pageX,
2386    y: pointer.pageY
2387  };
2388};
2389
2390// -----  ----- //
2391
2392return Unipointer;
2393
2394}));
2395
2396/*!
2397 * Unidragger v2.3.0
2398 * Draggable base class
2399 * MIT license
2400 */
2401
2402/*jshint browser: true, unused: true, undef: true, strict: true */
2403
2404( function( window, factory ) {
2405  // universal module definition
2406  /*jshint strict: false */ /*globals define, module, require */
2407
2408  if ( typeof define == 'function' && define.amd ) {
2409    // AMD
2410    define( 'unidragger/unidragger',[
2411      'unipointer/unipointer'
2412    ], function( Unipointer ) {
2413      return factory( window, Unipointer );
2414    });
2415  } else if ( typeof module == 'object' && module.exports ) {
2416    // CommonJS
2417    module.exports = factory(
2418      window,
2419      require('unipointer')
2420    );
2421  } else {
2422    // browser global
2423    window.Unidragger = factory(
2424      window,
2425      window.Unipointer
2426    );
2427  }
2428
2429}( window, function factory( window, Unipointer ) {
2430
2431
2432
2433// -------------------------- Unidragger -------------------------- //
2434
2435function Unidragger() {}
2436
2437// inherit Unipointer & EvEmitter
2438var proto = Unidragger.prototype = Object.create( Unipointer.prototype );
2439
2440// ----- bind start ----- //
2441
2442proto.bindHandles = function() {
2443  this._bindHandles( true );
2444};
2445
2446proto.unbindHandles = function() {
2447  this._bindHandles( false );
2448};
2449
2450/**
2451 * Add or remove start event
2452 * @param {Boolean} isAdd
2453 */
2454proto._bindHandles = function( isAdd ) {
2455  // munge isAdd, default to true
2456  isAdd = isAdd === undefined ? true : isAdd;
vendor: 3,706 bytes, lines 2457-2592
2457  // bind each handle
2458  var bindMethod = isAdd ? 'addEventListener' : 'removeEventListener';
2459  var touchAction = isAdd ? this._touchActionValue : '';
2460  for ( var i=0; i < this.handles.length; i++ ) {
2461    var handle = this.handles[i];
2462    this._bindStartEvent( handle, isAdd );
2463    handle[ bindMethod ]( 'click', this );
2464    // touch-action: none to override browser touch gestures. metafizzy/flickity#540
2465    if ( window.PointerEvent ) {
2466      handle.style.touchAction = touchAction;
2467    }
2468  }
2469};
2470
2471// prototype so it can be overwriteable by Flickity
2472proto._touchActionValue = 'none';
2473
2474// ----- start event ----- //
2475
2476/**
2477 * pointer start
2478 * @param {Event} event
2479 * @param {Event or Touch} pointer
2480 */
2481proto.pointerDown = function( event, pointer ) {
2482  var isOkay = this.okayPointerDown( event );
2483  if ( !isOkay ) {
2484    return;
2485  }
2486  // track start event position
2487  this.pointerDownPointer = pointer;
2488
2489  event.preventDefault();
2490  this.pointerDownBlur();
2491  // bind move and end events
2492  this._bindPostStartEvents( event );
2493  this.emitEvent( 'pointerDown', [ event, pointer ] );
2494};
2495
2496// nodes that have text fields
2497var cursorNodes = {
2498  TEXTAREA: true,
2499  INPUT: true,
2500  SELECT: true,
2501  OPTION: true,
2502};
2503
2504// input types that do not have text fields
2505var clickTypes = {
2506  radio: true,
2507  checkbox: true,
2508  button: true,
2509  submit: true,
2510  image: true,
2511  file: true,
2512};
2513
2514// dismiss inputs with text fields. flickity#403, flickity#404
2515proto.okayPointerDown = function( event ) {
2516  var isCursorNode = cursorNodes[ event.target.nodeName ];
2517  var isClickType = clickTypes[ event.target.type ];
2518  var isOkay = !isCursorNode || isClickType;
2519  if ( !isOkay ) {
2520    this._pointerReset();
2521  }
2522  return isOkay;
2523};
2524
2525// kludge to blur previously focused input
2526proto.pointerDownBlur = function() {
2527  var focused = document.activeElement;
2528  // do not blur body for IE10, metafizzy/flickity#117
2529  var canBlur = focused && focused.blur && focused != document.body;
2530  if ( canBlur ) {
2531    focused.blur();
2532  }
2533};
2534
2535// ----- move event ----- //
2536
2537/**
2538 * drag move
2539 * @param {Event} event
2540 * @param {Event or Touch} pointer
2541 */
2542proto.pointerMove = function( event, pointer ) {
2543  var moveVector = this._dragPointerMove( event, pointer );
2544  this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] );
2545  this._dragMove( event, pointer, moveVector );
2546};
2547
2548// base pointer move logic
2549proto._dragPointerMove = function( event, pointer ) {
2550  var moveVector = {
2551    x: pointer.pageX - this.pointerDownPointer.pageX,
2552    y: pointer.pageY - this.pointerDownPointer.pageY
2553  };
2554  // start drag if pointer has moved far enough to start drag
2555  if ( !this.isDragging && this.hasDragStarted( moveVector ) ) {
2556    this._dragStart( event, pointer );
2557  }
2558  return moveVector;
2559};
2560
2561// condition if pointer has moved far enough to start drag
2562proto.hasDragStarted = function( moveVector ) {
2563  return Math.abs( moveVector.x ) > 3 || Math.abs( moveVector.y ) > 3;
2564};
2565
2566// ----- end event ----- //
2567
2568/**
2569 * pointer up
2570 * @param {Event} event
2571 * @param {Event or Touch} pointer
2572 */
2573proto.pointerUp = function( event, pointer ) {
2574  this.emitEvent( 'pointerUp', [ event, pointer ] );
2575  this._dragPointerUp( event, pointer );
2576};
2577
2578proto._dragPointerUp = function( event, pointer ) {
2579  if ( this.isDragging ) {
2580    this._dragEnd( event, pointer );
2581  } else {
2582    // pointer didn't move enough for drag to start
2583    this._staticClick( event, pointer );
2584  }
2585};
2586
2587// -------------------------- drag -------------------------- //
2588
2589// dragStart
2590proto._dragStart = function( event, pointer ) {
2591  this.isDragging = true;
2592  // prevent clicks
2593  this.isPreventingClicks = true;
2594  this.dragStart( event, pointer );
2595};
2596
2597proto.dragStart = function( event, pointer ) {
2598  this.emitEvent( 'dragStart', [ event, pointer ] );
2599};
2600
2601// dragMove
2602proto._dragMove = function( event, pointer, moveVector ) {
2603  // do not drag if not dragging yet
2604  if ( !this.isDragging ) {
2605    return;
2606  }
2607
2608  this.dragMove( event, pointer, moveVector );
2609};
2610
2611proto.dragMove = function( event, pointer, moveVector ) {
2612  event.preventDefault();
2613  this.emitEvent( 'dragMove', [ event, pointer, moveVector ] );
2614};
2615
2616// dragEnd
2617proto._dragEnd = function( event, pointer ) {
2618  // set flags
2619  this.isDragging = false;
2620  // re-enable clicking async
2621  setTimeout( function() {
2622    delete this.isPreventingClicks;
2623  }.bind( this ) );
2624
2625  this.dragEnd( event, pointer );
2626};
2627
2628proto.dragEnd = function( event, pointer ) {
2629  this.emitEvent( 'dragEnd', [ event, pointer ] );
2630};
2631
2632// ----- onclick ----- //
2633
2634// handle all clicks and prevent clicks when dragging
2635proto.onclick = function( event ) {
2636  if ( this.isPreventingClicks ) {
2637    event.preventDefault();
2638  }
2639};
2640
2641// ----- staticClick ----- //
2642
2643// triggered after pointer down & up with no/tiny movement
2644proto._staticClick = function( event, pointer ) {
2645  // ignore emulated mouse up clicks
2646  if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {
2647    return;
2648  }
2649
2650  this.staticClick( event, pointer );
2651
2652  // set flag for emulated clicks 300ms after touchend
2653  if ( event.type != 'mouseup' ) {
2654    this.isIgnoringMouseUp = true;
2655    // reset flag after 300ms
2656    setTimeout( function() {
2657      delete this.isIgnoringMouseUp;
2658    }.bind( this ), 400 );
2659  }
2660};
2661
2662proto.staticClick = function( event, pointer ) {
2663  this.emitEvent( 'staticClick', [ event, pointer ] );
2664};
2665
2666// ----- utils ----- //
2667
2668Unidragger.getPointerPoint = Unipointer.getPointerPoint;
2669
2670// -----  ----- //
2671
2672return Unidragger;
2673
2674}));
2675
2676// drag
2677( function( window, factory ) {
2678  // universal module definition
2679  /* jshint strict: false */
2680  if ( typeof define == 'function' && define.amd ) {
2681    // AMD
2682    define( 'flickity/js/drag',[
2683      './flickity',
2684      'unidragger/unidragger',
2685      'fizzy-ui-utils/utils'
2686    ], function( Flickity, Unidragger, utils ) {
2687      return factory( window, Flickity, Unidragger, utils );
2688    });
2689  } else if ( typeof module == 'object' && module.exports ) {
2690    // CommonJS
2691    module.exports = factory(
2692      window,
2693      require('./flickity'),
2694      require('unidragger'),
2695      require('fizzy-ui-utils')
2696    );
2697  } else {
2698    // browser global
2699    window.Flickity = factory(
2700      window,
2701      window.Flickity,
2702      window.Unidragger,
2703      window.fizzyUIUtils
2704    );
2705  }
2706
2707}( window, function factory( window, Flickity, Unidragger, utils ) {
2708
2709
2710
2711// ----- defaults ----- //
2712
2713utils.extend( Flickity.defaults, {
2714  draggable: '>1',
2715  dragThreshold: 3,
2716});
2717
2718// ----- create ----- //
2719
2720Flickity.createMethods.push('_createDrag');
2721
2722// -------------------------- drag prototype -------------------------- //
2723
2724var proto = Flickity.prototype;
2725utils.extend( proto, Unidragger.prototype );
2726proto._touchActionValue = 'pan-y';
2727
2728// --------------------------  -------------------------- //
2729
2730var isTouch = 'createTouch' in document;
2731var isTouchmoveScrollCanceled = false;
2732
2733proto._createDrag = function() {
2734  this.on( 'activate', this.onActivateDrag );
2735  this.on( 'uiChange', this._uiChangeDrag );
2736  this.on( 'childUIPointerDown', this._childUIPointerDownDrag );
2737  this.on( 'deactivate', this.onDeactivateDrag );
2738  this.on( 'cellChange', this.updateDraggable );
2739  // TODO updateDraggable on resize? if groupCells & slides change
2740  // HACK - add seemingly innocuous handler to fix iOS 10 scroll behavior
2741  // #457, RubaXa/Sortable#973
2742  if ( isTouch && !isTouchmoveScrollCanceled ) {
2743    window.addEventListener( 'touchmove', function() {});
2744    isTouchmoveScrollCanceled = true;
2745  }
2746};
2747
2748proto.onActivateDrag = function() {
2749  this.handles = [ this.viewport ];
2750  this.bindHandles();
2751  this.updateDraggable();
2752};
2753
2754proto.onDeactivateDrag = function() {
2755  this.unbindHandles();
2756  this.element.classList.remove('is-draggable');
2757};
vendor: 4,709 bytes, lines 2758-2921
2758
2759proto.updateDraggable = function() {
2760  // disable dragging if less than 2 slides. #278
2761  if ( this.options.draggable == '>1' ) {
2762    this.isDraggable = this.slides.length > 1;
2763  } else {
2764    this.isDraggable = this.options.draggable;
2765  }
2766  if ( this.isDraggable ) {
2767    this.element.classList.add('is-draggable');
2768  } else {
2769    this.element.classList.remove('is-draggable');
2770  }
2771};
2772
2773// backwards compatibility
2774proto.bindDrag = function() {
2775  this.options.draggable = true;
2776  this.updateDraggable();
2777};
2778
2779proto.unbindDrag = function() {
2780  this.options.draggable = false;
2781  this.updateDraggable();
2782};
2783
2784proto._uiChangeDrag = function() {
2785  delete this.isFreeScrolling;
2786};
2787
2788proto._childUIPointerDownDrag = function( event ) {
2789  // allow focus & preventDefault even when not draggable
2790  // so child UI elements keep focus on carousel. #721
2791  event.preventDefault();
2792  this.pointerDownFocus( event );
2793};
2794
2795// -------------------------- pointer events -------------------------- //
2796
2797proto.pointerDown = function( event, pointer ) {
2798  if ( !this.isDraggable ) {
2799    this._pointerDownDefault( event, pointer );
2800    return;
2801  }
2802  var isOkay = this.okayPointerDown( event );
2803  if ( !isOkay ) {
2804    return;
2805  }
2806
2807  this._pointerDownPreventDefault( event );
2808  this.pointerDownFocus( event );
2809  // blur
2810  if ( document.activeElement != this.element ) {
2811    // do not blur if already focused
2812    this.pointerDownBlur();
2813  }
2814
2815  // stop if it was moving
2816  this.dragX = this.x;
2817  this.viewport.classList.add('is-pointer-down');
2818  // track scrolling
2819  this.pointerDownScroll = getScrollPosition();
2820  window.addEventListener( 'scroll', this );
2821
2822  this._pointerDownDefault( event, pointer );
2823};
2824
2825// default pointerDown logic, used for staticClick
2826proto._pointerDownDefault = function( event, pointer ) {
2827  // track start event position
2828  this.pointerDownPointer = pointer;
2829  // bind move and end events
2830  this._bindPostStartEvents( event );
2831  this.dispatchEvent( 'pointerDown', event, [ pointer ] );
2832};
2833
2834var focusNodes = {
2835  INPUT: true,
2836  TEXTAREA: true,
2837  SELECT: true,
2838};
2839
2840proto.pointerDownFocus = function( event ) {
2841  var isFocusNode = focusNodes[ event.target.nodeName ];
2842  if ( !isFocusNode ) {
2843    this.focus();
2844  }
2845};
2846
2847proto._pointerDownPreventDefault = function( event ) {
2848  var isTouchStart = event.type == 'touchstart';
2849  var isTouchPointer = event.pointerType == 'touch';
2850  var isFocusNode = focusNodes[ event.target.nodeName ];
2851  if ( !isTouchStart && !isTouchPointer && !isFocusNode ) {
2852    event.preventDefault();
2853  }
2854};
2855
2856// ----- move ----- //
2857
2858proto.hasDragStarted = function( moveVector ) {
2859  return Math.abs( moveVector.x ) > this.options.dragThreshold;
2860};
2861
2862// ----- up ----- //
2863
2864proto.pointerUp = function( event, pointer ) {
2865  delete this.isTouchScrolling;
2866  this.viewport.classList.remove('is-pointer-down');
2867  this.dispatchEvent( 'pointerUp', event, [ pointer ] );
2868  this._dragPointerUp( event, pointer );
2869};
2870
2871proto.pointerDone = function() {
2872  window.removeEventListener( 'scroll', this );
2873  delete this.pointerDownScroll;
2874};
2875
2876// -------------------------- dragging -------------------------- //
2877
2878proto.dragStart = function( event, pointer ) {
2879  if ( !this.isDraggable ) {
2880    return;
2881  }
2882  this.dragStartPosition = this.x;
2883  this.startAnimation();
2884  window.removeEventListener( 'scroll', this );
2885  this.dispatchEvent( 'dragStart', event, [ pointer ] );
2886};
2887
2888proto.pointerMove = function( event, pointer ) {
2889  var moveVector = this._dragPointerMove( event, pointer );
2890  this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] );
2891  this._dragMove( event, pointer, moveVector );
2892};
2893
2894proto.dragMove = function( event, pointer, moveVector ) {
2895  if ( !this.isDraggable ) {
2896    return;
2897  }
2898  event.preventDefault();
2899
2900  this.previousDragX = this.dragX;
2901  // reverse if right-to-left
2902  var direction = this.options.rightToLeft ? -1 : 1;
2903  if ( this.options.wrapAround ) {
2904    // wrap around move. #589
2905    moveVector.x = moveVector.x % this.slideableWidth;
2906  }
2907  var dragX = this.dragStartPosition + moveVector.x * direction;
2908
2909  if ( !this.options.wrapAround && this.slides.length ) {
2910    // slow drag
2911    var originBound = Math.max( -this.slides[0].target, this.dragStartPosition );
2912    dragX = dragX > originBound ? ( dragX + originBound ) * 0.5 : dragX;
2913    var endBound = Math.min( -this.getLastSlide().target, this.dragStartPosition );
2914    dragX = dragX < endBound ? ( dragX + endBound ) * 0.5 : dragX;
2915  }
2916
2917  this.dragX = dragX;
2918
2919  this.dragMoveTime = new Date();
2920  this.dispatchEvent( 'dragMove', event, [ pointer, moveVector ] );
2921};
2922
2923proto.dragEnd = function( event, pointer ) {
2924  if ( !this.isDraggable ) {
2925    return;
2926  }
2927  if ( this.options.freeScroll ) {
2928    this.isFreeScrolling = true;
2929  }
2930  // set selectedIndex based on where flick will end up
2931  var index = this.dragEndRestingSelect();
2932
2933  if ( this.options.freeScroll && !this.options.wrapAround ) {
2934    // if free-scroll & not wrap around
2935    // do not free-scroll if going outside of bounding slides
2936    // so bounding slides can attract slider, and keep it in bounds
2937    var restingX = this.getRestingPosition();
2938    this.isFreeScrolling = -restingX > this.slides[0].target &&
2939      -restingX < this.getLastSlide().target;
2940  } else if ( !this.options.freeScroll && index == this.selectedIndex ) {
2941    // boost selection if selected index has not changed
2942    index += this.dragEndBoostSelect();
2943  }
2944  delete this.previousDragX;
2945  // apply selection
2946  // TODO refactor this, selecting here feels weird
2947  // HACK, set flag so dragging stays in correct direction
2948  this.isDragSelect = this.options.wrapAround;
2949  this.select( index );
2950  delete this.isDragSelect;
2951  this.dispatchEvent( 'dragEnd', event, [ pointer ] );
2952};
2953
2954proto.dragEndRestingSelect = function() {
2955  var restingX = this.getRestingPosition();
2956  // how far away from selected slide
2957  var distance = Math.abs( this.getSlideDistance( -restingX, this.selectedIndex ) );
2958  // get closet resting going up and going down
2959  var positiveResting = this._getClosestResting( restingX, distance, 1 );
2960  var negativeResting = this._getClosestResting( restingX, distance, -1 );
2961  // use closer resting for wrap-around
2962  var index = positiveResting.distance < negativeResting.distance ?
2963    positiveResting.index : negativeResting.index;
2964  return index;
2965};
2966
2967/**
2968 * given resting X and distance to selected cell
2969 * get the distance and index of the closest cell
2970 * @param {Number} restingX - estimated post-flick resting position
2971 * @param {Number} distance - distance to selected cell
2972 * @param {Integer} increment - +1 or -1, going up or down
2973 * @returns {Object} - { distance: {Number}, index: {Integer} }
2974 */
2975proto._getClosestResting = function( restingX, distance, increment ) {
2976  var index = this.selectedIndex;
2977  var minDistance = Infinity;
2978  var condition = this.options.contain && !this.options.wrapAround ?
2979    // if contain, keep going if distance is equal to minDistance
2980    function( d, md ) { return d <= md; } : function( d, md ) { return d < md; };
2981  while ( condition( distance, minDistance ) ) {
2982    // measure distance to next cell
2983    index += increment;
2984    minDistance = distance;
2985    distance = this.getSlideDistance( -restingX, index );
2986    if ( distance === null ) {
2987      break;
2988    }
2989    distance = Math.abs( distance );
2990  }
2991  return {
2992    distance: minDistance,
2993    // selected was previous index
2994    index: index - increment
2995  };
2996};
2997
2998/**
2999 * measure distance between x and a slide target
3000 * @param {Number} x
3001 * @param {Integer} index - slide index
3002 */
3003proto.getSlideDistance = function( x, index ) {
3004  var len = this.slides.length;
3005  // wrap around if at least 2 slides
3006  var isWrapAround = this.options.wrapAround && len > 1;
3007  var slideIndex = isWrapAround ? utils.modulo( index, len ) : index;
3008  var slide = this.slides[ slideIndex ];
3009  if ( !slide ) {
3010    return null;
3011  }
3012  // add distance for wrap-around slides
3013  var wrap = isWrapAround ? this.slideableWidth * Math.floor( index / len ) : 0;
3014  return x - ( slide.target + wrap );
3015};
3016
3017proto.dragEndBoostSelect = function() {
3018  // do not boost if no previousDragX or dragMoveTime
3019  if ( this.previousDragX === undefined || !this.dragMoveTime ||
3020    // or if drag was held for 100 ms
3021    new Date() - this.dragMoveTime > 100 ) {
3022    return 0;
3023  }
3024
3025  var distance = this.getSlideDistance( -this.dragX, this.selectedIndex );
3026  var delta = this.previousDragX - this.dragX;
3027  if ( distance > 0 && delta > 0 ) {
3028    // boost to next if moving towards the right, and positive velocity
3029    return 1;
3030  } else if ( distance < 0 && delta < 0 ) {
3031    // boost to previous if moving towards the left, and negative velocity
3032    return -1;
3033  }
3034  return 0;
3035};
3036
3037// ----- staticClick ----- //
3038
3039proto.staticClick = function( event, pointer ) {
3040  // get clickedCell, if cell was clicked
3041  var clickedCell = this.getParentCell( event.target );
3042  var cellElem = clickedCell && clickedCell.element;
3043  var cellIndex = clickedCell && this.cells.indexOf( clickedCell );
3044  this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] );
3045};
3046
3047// ----- scroll ----- //
3048
3049proto.onscroll = function() {
3050  var scroll = getScrollPosition();
3051  var scrollMoveX = this.pointerDownScroll.x - scroll.x;
3052  var scrollMoveY = this.pointerDownScroll.y - scroll.y;
3053  // cancel click/tap if scroll is too much
3054  if ( Math.abs( scrollMoveX ) > 3 || Math.abs( scrollMoveY ) > 3 ) {
3055    this._pointerDone();
3056  }
3057};
3058
3059// ----- utils ----- //
3060
3061function getScrollPosition() {
3062  return {
3063    x: window.pageXOffset,
3064    y: window.pageYOffset
3065  };
3066}
3067
3068// -----  ----- //
3069
3070return Flickity;
3071
3072}));
3073
3074/*!
3075 * Tap listener v2.0.0
3076 * listens to taps
3077 * MIT license
3078 */
3079
3080/*jshint browser: true, unused: true, undef: true, strict: true */
3081
3082( function( window, factory ) {
3083  // universal module definition
3084  /*jshint strict: false*/ /*globals define, module, require */
3085
3086  if ( typeof define == 'function' && define.amd ) {
3087    // AMD
3088    define( 'tap-listener/tap-listener',[
3089      'unipointer/unipointer'
3090    ], function( Unipointer ) {
3091      return factory( window, Unipointer );
3092    });
3093  } else if ( typeof module == 'object' && module.exports ) {
3094    // CommonJS
3095    module.exports = factory(
3096      window,
3097      require('unipointer')
3098    );
3099  } else {
3100    // browser global
3101    window.TapListener = factory(
3102      window,
3103      window.Unipointer
3104    );
3105  }
3106
3107}( window, function factory( window, Unipointer ) {
3108
3109
3110
3111// --------------------------  TapListener -------------------------- //
3112
3113function TapListener( elem ) {
3114  this.bindTap( elem );
3115}
3116
3117// inherit Unipointer & EventEmitter
3118var proto = TapListener.prototype = Object.create( Unipointer.prototype );
3119
3120/**
3121 * bind tap event to element
3122 * @param {Element} elem
3123 */
3124proto.bindTap = function( elem ) {
3125  if ( !elem ) {
3126    return;
3127  }
3128  this.unbindTap();
3129  this.tapElement = elem;
3130  this._bindStartEvent( elem, true );
3131};
3132
3133proto.unbindTap = function() {
3134  if ( !this.tapElement ) {
3135    return;
3136  }
3137  this._bindStartEvent( this.tapElement, true );
3138  delete this.tapElement;
3139};
3140
3141/**
3142 * pointer up
3143 * @param {Event} event
3144 * @param {Event or Touch} pointer
3145 */
3146proto.pointerUp = function( event, pointer ) {
3147  // ignore emulated mouse up clicks
3148  if ( this.isIgnoringMouseUp && event.type == 'mouseup' ) {
3149    return;
3150  }
3151
3152  var pointerPoint = Unipointer.getPointerPoint( pointer );
3153  var boundingRect = this.tapElement.getBoundingClientRect();
3154  var scrollX = window.pageXOffset;
3155  var scrollY = window.pageYOffset;
3156  // calculate if pointer is inside tapElement
3157  var isInside = pointerPoint.x >
3157= boundingRect.left + scrollX &&
3158    pointerPoint.x <= boundingRect.right + scrollX &&
3159    pointerPoint.y >= boundingRect.top + scrollY &&
3160    pointerPoint.y <= boundingRect.bottom + scrollY;
3161  // trigger callback if pointer is inside element
3162  if ( isInside ) {
3163    this.emitEvent( 'tap', [ event, pointer ] );
3164  }
3165
3166  // set flag for emulated clicks 300ms after touchend
3167  if ( event.type != 'mouseup' ) {
3168    this.isIgnoringMouseUp = true;
3169    // reset flag after 300ms
3170    var _this = this;
3171    setTimeout( function() {
3172      delete _this.isIgnoringMouseUp;
3173    }, 400 );
3174  }
3175};
3176
3177proto.destroy = function() {
3178  this.pointerDone();
3179  this.unbindTap();
3180};
3181
3182// -----  ----- //
3183
3184return TapListener;
3185
3186}));
3187
3188// prev/next buttons
3189( function( window, factory ) {
3190  // universal module definition
3191  /* jshint strict: false */
3192  if ( typeof define == 'function' && define.amd ) {
3193    // AMD
3194    define( 'flickity/js/prev-next-button',[
3195      './flickity',
3196      'tap-listener/tap-listener',
3197      'fizzy-ui-utils/utils'
3198    ], function( Flickity, TapListener, utils ) {
3199      return factory( window, Flickity, TapListener, utils );
3200    });
3201  } else if ( typeof module == 'object' && module.exports ) {
3202    // CommonJS
3203    module.exports = factory(
3204      window,
3205      require('./flickity'),
3206      require('tap-listener'),
3207      require('fizzy-ui-utils')
3208    );
3209  } else {
3210    // browser global
3211    factory(
3212      window,
3213      window.Flickity,
3214      window.TapListener,
3215      window.fizzyUIUtils
3216    );
3217  }
3218
3219}( window, function factory( window, Flickity, TapListener, utils ) {
3220'use strict';
3221
3222var svgURI = 'http://www.w3.org/2000/svg';
3223
3224// -------------------------- PrevNextButton -------------------------- //
3225
3226function PrevNextButton( direction, parent ) {
3227  this.direction = direction;
3228  this.parent = parent;
3229  this._create();
3230}
3231
3232PrevNextButton.prototype = Object.create( TapListener.prototype );
3233
3234PrevNextButton.prototype._create = function() {
3235  // properties
3236  this.isEnabled = true;
3237  this.isPrevious = this.direction == -1;
3238  var leftDirection = this.parent.options.rightToLeft ? 1 : -1;
3239  this.isLeft = this.direction == leftDirection;
3240
3241  var element = this.element = document.createElement('button');
3242  element.className = 'flickity-button flickity-prev-next-button';
3243  element.className += this.isPrevious ? ' previous' : ' next';
3244  // prevent button from submitting form http://stackoverflow.com/a/10836076/182183
3245  element.setAttribute( 'type', 'button' );
3246  // init as disabled
3247  this.disable();
3248
3249  element.setAttribute( 'aria-label', this.isPrevious ? 'Previous' : 'Next' );
3250
3251  // create arrow
3252  var svg = this.createSVG();
3253  element.appendChild( svg );
3254  // events
3255  this.on( 'tap', this.onTap );
3256  this.parent.on( 'select', this.update.bind( this ) );
3257  this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );
3258};
3259
3260PrevNextButton.prototype.activate = function() {
3261  this.bindTap( this.element );
3262  // click events from keyboard
3263  this.element.addEventListener( 'click', this );
3264  // add to DOM
3265  this.parent.element.appendChild( this.element );
3266};
3267
3268PrevNextButton.prototype.deactivate = function() {
3269  // remove from DOM
3270  this.parent.element.removeChild( this.element );
3271  // do regular TapListener destroy
3272  TapListener.prototype.destroy.call( this );
3273  // click events from keyboard
3274  this.element.removeEventListener( 'click', this );
3275};
3276
3277PrevNextButton.prototype.createSVG = function() {
3278  var svg = document.createElementNS( svgURI, 'svg');
3279  svg.setAttribute( 'class', 'flickity-button-icon' );
3280  svg.setAttribute( 'viewBox', '0 0 100 100' );
3281  var path = document.createElementNS( svgURI, 'path');
3282  var pathMovements = getArrowMovements( this.parent.options.arrowShape );
3283  path.setAttribute( 'd', pathMovements );
3284  path.setAttribute( 'class', 'arrow' );
3285  // rotate arrow
3286  if ( !this.isLeft ) {
3287    path.setAttribute( 'transform', 'translate(100, 100) rotate(180) ' );
3288  }
3289  svg.appendChild( path );
3290  return svg;
3291};
3292
3293// get SVG path movmement
3294function getArrowMovements( shape ) {
3295  // use shape as movement if string
3296  if ( typeof shape == 'string' ) {
3297    return shape;
3298  }
3299  // create movement string
3300  return 'M ' + shape.x0 + ',50' +
3301    ' L ' + shape.x1 + ',' + ( shape.y1 + 50 ) +
3302    ' L ' + shape.x2 + ',' + ( shape.y2 + 50 ) +
3303    ' L ' + shape.x3 + ',50 ' +
3304    ' L ' + shape.x2 + ',' + ( 50 - shape.y2 ) +
3305    ' L ' + shape.x1 + ',' + ( 50 - shape.y1 ) +
3306    ' Z';
3307}
3308
3309PrevNextButton.prototype.onTap = function() {
3310  if ( !this.isEnabled ) {
3311    return;
3312  }
3313  this.parent.uiChange();
3314  var method = this.isPrevious ? 'previous' : 'next';
3315  this.parent[ method ]();
3316};
3317
3318PrevNextButton.prototype.handleEvent = utils.handleEvent;
3319
3320PrevNextButton.prototype.onclick = function( event ) {
3321  // only allow clicks from keyboard
3322  var focused = document.activeElement;
3323  if ( focused && focused == this.element ) {
3324    this.onTap( event, event );
3325  }
3326};
3327
3328// -----  ----- //
3329
3330PrevNextButton.prototype.enable = function() {
3331  if ( this.isEnabled ) {
3332    return;
3333  }
3334  this.element.disabled = false;
3335  this.isEnabled = true;
3336};
3337
3338PrevNextButton.prototype.disable = function() {
3339  if ( !this.isEnabled ) {
3340    return;
3341  }
3342  this.element.disabled = true;
3343  this.isEnabled = false;
3344};
3345
3346PrevNextButton.prototype.update = function() {
3347  // index of first or last slide, if previous or next
3348  var slides = this.parent.slides;
3349  // enable is wrapAround and at least 2 slides
3350  if ( this.parent.options.wrapAround && slides.length > 1 ) {
3351    this.enable();
3352    return;
3353  }
3354  var lastIndex = slides.length ? slides.length - 1 : 0;
3355  var boundIndex = this.isPrevious ? 0 : lastIndex;
3356  var method = this.parent.selectedIndex == boundIndex ? 'disable' : 'enable';
3357  this[ method ]();
3358};
3359
3360PrevNextButton.prototype.destroy = function() {
3361  this.deactivate();
3362};
3363
3364// -------------------------- Flickity prototype -------------------------- //
3365
3366utils.extend( Flickity.defaults, {
3367  prevNextButtons: true,
3368  arrowShape: {
3369    x0: 10,
3370    x1: 60, y1: 50,
3371    x2: 70, y2: 40,
3372    x3: 30
3373  }
3374});
3375
3376Flickity.createMethods.push('_createPrevNextButtons');
3377var proto = Flickity.prototype;
3378
3379proto._createPrevNextButtons = function() {
3380  if ( !this.options.prevNextButtons ) {
3381    return;
3382  }
3383
3384  this.prevButton = new PrevNextButton( -1, this );
3385  this.nextButton = new PrevNextButton( 1, this );
3386
3387  this.on( 'activate', this.activatePrevNextButtons );
3388};
3389
3390proto.activatePrevNextButtons = function() {
3391  this.prevButton.activate();
3392  this.nextButton.activate();
3393  this.on( 'deactivate', this.deactivatePrevNextButtons );
3394};
3395
3396proto.deactivatePrevNextButtons = function() {
3397  this.prevButton.deactivate();
3398  this.nextButton.deactivate();
3399  this.off( 'deactivate', this.deactivatePrevNextButtons );
3400};
3401
3402// --------------------------  -------------------------- //
3403
3404Flickity.PrevNextButton = PrevNextButton;
3405
3406return Flickity;
3407
3408}));
3409
3410// page dots
3411( function( window, factory ) {
3412  // universal module definition
3413  /* jshint strict: false */
3414  if ( typeof define == 'function' && define.amd ) {
3415    // AMD
3416    define( 'flickity/js/page-dots',[
3417      './flickity',
3418      'tap-listener/tap-listener',
3419      'fizzy-ui-utils/utils'
3420    ], function( Flickity, TapListener, utils ) {
3421      return factory( window, Flickity, TapListener, utils );
3422    });
3423  } else if ( typeof module == 'object' && module.exports ) {
3424    // CommonJS
3425    module.exports = factory(
3426      window,
3427      require('./flickity'),
3428      require('tap-listener'),
3429      require('fizzy-ui-utils')
3430    );
3431  } else {
3432    // browser global
3433    factory(
3434      window,
3435      window.Flickity,
3436      window.TapListener,
3437      window.fizzyUIUtils
3438    );
3439  }
3440
3441}( window, function factory( window, Flickity, TapListener, utils ) {
3442
3443// -------------------------- PageDots -------------------------- //
3444
3445
3446
3447function PageDots( parent ) {
3448  this.parent = parent;
3449  this._create();
3450}
3451
3452PageDots.prototype = new TapListener();
3453
3454PageDots.prototype._create = function() {
3455  // create holder element
3456  this.holder = document.createElement('ol');
3457  this.holder.className = 'flickity-page-dots';
3458  // create dots, array of elements
3459  this.dots = [];
3460  // events
3461  this.on( 'tap', this.onTap );
3462  this.on( 'pointerDown', this.parent.childUIPointerDown.bind( this.parent ) );
3463};
3464
3465PageDots.prototype.activate = function() {
3466  this.setDots();
3467  this.bindTap( this.holder );
3468  // add to DOM
3469  this.parent.element.appendChild( this.holder );
3470};
3471
3472PageDots.prototype.deactivate = function() {
3473  // remove from DOM
3474  this.parent.element.removeChild( this.holder );
3475  TapListener.prototype.destroy.call( this );
3476};
3477
3478PageDots.prototype.setDots = function() {
3479  // get difference between number of slides and number of dots
3480  var delta = this.parent.slides.length - this.dots.length;
3481  if ( delta > 0 ) {
3482    this.addDots( delta );
3483  } else if ( delta < 0 ) {
3484    this.removeDots( -delta );
3485  }
3486};
3487
3488PageDots.prototype.addDots = function( count ) {
3489  var fragment = document.createDocumentFragment();
3490  var newDots = [];
3491  var length = this.dots.length;
3492  var max = length + count;
3493
3494  for ( var i = length; i < max; i++ ) {
3495    var dot = document.createElement('li');
3496    dot.className = 'dot';
3497    dot.setAttribute( 'aria-label', 'Page dot ' + ( i + 1 ) );
3498    fragment.appendChild( dot );
3499    newDots.push( dot );
3500  }
3501
3502  this.holder.appendChild( fragment );
3503  this.dots = this.dots.concat( newDots );
3504};
3505
3506PageDots.prototype.removeDots = function( count ) {
3507  // remove from this.dots collection
3508  var removeDots = this.dots.splice( this.dots.length - count, count );
3509  // remove from DOM
3510  removeDots.forEach( function( dot ) {
3511    this.holder.removeChild( dot );
3512  }, this );
3513};
3514
3515PageDots.prototype.updateSelected = function() {
3516  // remove selected class on previous
3517  if ( this.selectedDot ) {
3518    this.selectedDot.className = 'dot';
3519    this.selectedDot.removeAttribute('aria-current');
3520  }
3521  // don't proceed if no dots
3522  if ( !this.dots.length ) {
3523    return;
3524  }
3525  this.selectedDot = this.dots[ this.parent.selectedIndex ];
3526  this.selectedDot.className = 'dot is-selected';
3527  this.selectedDot.setAttribute( 'aria-current', 'step' );
3528};
3529
3530PageDots.prototype.onTap = function( event ) {
3531  var target = event.target;
3532  // only care about dot clicks
3533  if ( target.nodeName != 'LI' ) {
3534    return;
3535  }
3536
3537  this.parent.uiChange();
3538  var index = this.dots.indexOf( target );
3539  this.parent.select( index );
3540};
3541
3542PageDots.prototype.destroy = function() {
3543  this.deactivate();
3544};
3545
3546Flickity.PageDots = PageDots;
3547
3548// -------------------------- Flickity -------------------------- //
3549
3550utils.extend( Flickity.defaults, {
3551  pageDots: true
3552});
3553
3554Flickity.createMethods.push('_createPageDots');
3555
3556var proto = Flickity.prototype;
3557
3558proto._createPageDots = function() {
3559  if ( !this.options.pageDots ) {
3560    return;
3561  }
3562  this.pageDots = new PageDots( this );
3563  // events
3564  this.on( 'activate', this.activatePageDots );
3565  this.on( 'select', this.updateSelectedPageDots );
3566  this.on( 'cellChange', this.updatePageDots );
3567  this.on( 'resize', this.updatePageDots );
3568  this.on( 'deactivate', this.deactivatePageDots );
3569};
3570
3571proto.activatePageDots = function() {
3572  this.pageDots.activate();
3573};
3574
3575proto.updateSelectedPageDots = function() {
3576  this.pageDots.updateSelected();
3577};
3578
3579proto.updatePageDots = function() {
3580  this.pageDots.setDots();
3581};
3582
3583proto.deactivatePageDots = function() {
3584  this.pageDots.deactivate();
3585};
3586
3587// -----  ----- //
3588
3589Flickity.PageDots = PageDots;
3590
3591return Flickity;
3592
3593}));
3594
3595// player & autoPlay
3596( function( window, factory ) {
3597  // universal module definition
3598  /* jshint strict: false */
3599  if ( typeof define == 'function' && define.amd ) {
3600    // AMD
3601    define( 'flickity/js/player',[
3602      'ev-emitter/ev-emitter',
3603      'fizzy-ui-utils/utils',
3604      './flickity'
3605    ], function( EvEmitter, utils, Flickity ) {
3606      return factory( EvEmitter, utils, Flickity );
3607    });
3608  } else if ( typeof module == 'object' && module.exports ) {
3609    // CommonJS
3610    module.exports = factory(
3611      require('ev-emitter'),
3612      require('fizzy-ui-utils'),
3613      require('./flickity')
3614    );
3615  } else {
3616    // browser global
3617    factory(
3618      window.EvEmitter,
3619      window.fizzyUIUtils,
3620      window.Flickity
3621    );
3622  }
3623
3624}( window, function factory( EvEmitter, utils, Flickity ) {
3625
3626
3627
3628// -------------------------- Player -------------------------- //
3629
3630function Player( parent ) {
3631  this.parent = parent;
3632  this.state = 'stopped';
3633  // visibility change event handler
3634  this.onVisibilityChange = this.visibilityChange.bind( this );
3635  this.onVisibilityPlay = this.visibilityPlay.bind( this );
3636}
3637
3638Player.prototype = Object.create( EvEmitter.prototype );
3639
3640// start play
3641Player.prototype.play = function() {
3642  if ( this.state == 'playing' ) {
3643    return;
3644  }
3645  // do not play if page is hidden, start playing when page is visible
3646  var isPageHidden = document.hidden;
3647  if ( isPageHidden ) {
3648    document.addEventListener( 'visibilitychange', this.onVisibilityPlay );
3649    return;
3650  }
3651
3652  this.state = 'playing';
3653  // listen to visibility change
3654  document.addEventListener( 'visibilitychange', this.onVisibilityChange );
3655  // start ticking
3656  this.tick();
3657};
3658
3659Player.prototype.tick = function() {
3660  // do not tick if not playing
3661  if ( this.state != 'playing' ) {
3662    return;
3663  }
3664
3665  var time = this.parent.options.autoPlay;
3666  // default to 3 seconds
3667  time = typeof time == 'number' ? time : 3000;
3668  var _this = this;
3669  // HACK: reset ticks if stopped and started within interval
3670  this.clear();
3671  this.timeout = setTimeout( function() {
3672    _this.parent.next( true );
3673    _this.tick();
3674  }, time );
3675};
3676
3677Player.prototype.stop = function() {
3678  this.state = 'stopped';
3679  this.clear();
3680  // remove visibility change event
3681  document.removeEventListener( 'visibilitychange', this.onVisibilityChange );
3682};
3683
3684Player.prototype.clear = function() {
3685  clearTimeout( this.timeout );
3686};
3687
3688Player.prototype.pause = function() {
3689  if ( this.state == 'playing' ) {
3690    this.state = 'paused';
3691    this.clear();
3692  }
3693};
3694
3695Player.prototype.unpause = function() {
3696  // re-start play if paused
3697  if ( this.state == 'paused' ) {
3698    this.play();
3699  }
3700};
3701
3702// pause if page visibility is hidden, unpause if visible
3703Player.prototype.visibilityChange = function() {
3704  var isPageHidden = document.hidden;
3705  this[ isPageHidden ? 'pause' : 'unpause' ]();
3706};
3707
3708Player.prototype.visibilityPlay = function() {
3709  this.play();
3710  document.removeEventListener( 'visibilitychange', this.onVisibilityPlay );
3711};
3712
3713// -------------------------- Flickity -------------------------- //
3714
3715utils.extend( Flickity.defaults, {
3716  pauseAutoPlayOnHover: true
3717});
3718
3719Flickity.createMethods.push('_createPlayer');
3720var proto = Flickity.prototype;
3721
3722proto._createPlayer = function() {
3723  this.player = new Player( this );
3724
3725  this.on( 'activate', this.activatePlayer );
3726  this.on( 'uiChange', this.stopPlayer );
3727  this.on( 'pointerDown', this.stopPlayer );
3728  this.on( 'deactivate', this.deactivatePlayer );
3729};
3730
3731proto.activatePlayer = function() {
3732  if ( !this.options.autoPlay ) {
3733    return;
3734  }
3735  this.player.play();
3736  this.element.addEventListener( 'mouseenter', this );
3737};
3738
3739// Player API, don't hate the ... thanks I know where the door is
3740
3741proto.playPlayer = function() {
3742  this.player.play();
3743};
3744
3745proto.stopPlayer = function() {
3746  this.player.stop();
3747};
3748
3749proto.pausePlayer = function() {
3750  this.player.pause();
3751};
3752
3753proto.unpausePlayer = function() {
3754  this.player.unpause();
3755};
3756
3757proto.deactivatePlayer = function() {
3758  this.player.stop();
3759  this.element.removeEventListener( 'mouseenter', this );
3760};
3761
3762// ----- mouseenter/leave ----- //
3763
3764// pause auto-play on hover
3765proto.onmouseenter = function() {
3766  if ( !this.options.pauseAutoPlayOnHover ) {
3767    return;
3768  }
3769  this.player.pause();
3770  this.element.addEventListener( 'mouseleave', this );
3771};
3772
3773// resume auto-play on hover off
3774proto.onmouseleave = function() {
3775  this.player.unpause();
3776  this.element.removeEventListener( 'mouseleave', this );
3777};
3778
3779// -----  ----- //
3780
3781Flickity.Player = Player;
3782
3783return Flickity;
3784
3785}));
3786
3787// add, remove cell
3788( function( window, factory ) {
3789  // universal module definition
3790  /* jshint strict: false */
3791  if ( typeof define == 'function' && define.amd ) {
3792    // AMD
3793    define( 'flickity/js/add-remove-cell',[
3794      './flickity',
3795      'fizzy-ui-utils/utils'
3796    ], function( Flickity, utils ) {
3797      return factory( window, Flickity, utils );
3798    });
3799  } else if ( typeof module == 'object' && module.exports ) {
3800    // CommonJS
3801    module.exports = factory(
3802      window,
3803      require('./flickity'),
3804      require('fizzy-ui-utils')
3805    );
3806  } else {
3807    // browser global
3808    factory(
3809      window,
3810      window.Flickity,
3811      window.fizzyUIUtils
3812    );
3813  }
3814
3815}( window, function factory( window, Flickity, utils ) {
3816
3817
3818
3819// append cells to a document fragment
3820function getCellsFragment( cells ) {
3821  var fragment = document.createDocumentFragment();
3822  cells.forEach( function( cell ) {
3823    fragment.appendChild( cell.element );
3824  });
3825  return fragment;
3826}
3827
3828// -------------------------- add/remove cell prototype -------------------------- //
3829
3830var proto = Flickity.prototype;
3831
3832/**
3833 * Insert, prepend, or append cells
3834 * @param {Element, Array, NodeList} elems
3835 * @param {Integer} index
3836 */
3837proto.insert = function( elems, index ) {
3838  var cells = this._makeCells( elems );
3839  if ( !cells || !cells.length ) {
3840    return;
3841  }
3842  var len = this.cells.length;
3843  // default to append
3844  index = index === undefined ? len : index;
3845  // add cells with document fragment
3846  var fragment = getCellsFragment( cells );
3847  // append to slider
3848  var isAppend = index == len;
3849  if ( isAppend ) {
3850    this.slider.appendChild( fragment );
3851  } else {
3852    var insertCellElement = this.cells[ index ].element;
3853    this.slider.insertBefore( fragment, insertCellElement );
3854  }
3855  // add to this.cells
3856  if ( index === 0 ) {
3857    // prepend, add to start
3858    this.cells = cells.concat( this.cells );
3859  } else if ( isAppend ) {
3860    // append, add to end
3861    this.cells = this.cells.concat( cells );
3862  } else {
3863    // insert in this.cells
3864    var endCells = this.cells.splice( index, len - index );
3865    this.cells = this.cells.concat( cells ).concat( endCells );
3866  }
3867
3868  this._sizeCells( cells );
3869  this.cellChange( index, true );
3870};
3871
3872proto.append = function( elems ) {
3873  this.insert( elems, this.cells.length );
3874};
3875
3876proto.prepend = function( elems ) {
3877  this.insert( elems, 0 );
3878};
3879
3880/**
3881 * Remove cells
3882 * @param {Element, Array, NodeList} elems
3883 */
3884proto.remove = function( elems ) {
3885  var cells = this.getCells( elems );
3886  if ( !cells || !cells.length ) {
3887    return;
3888  }
3889
3890  var minCellIndex = this.cells.length - 1;
3891  // remove cells from collection & DOM
3892  cells.forEach( function( cell ) {
3893    cell.remove();
3894    var index = this.cells.indexOf( cell );
3895    minCellIndex = Math.min( index, minCellIndex );
3896    utils.removeFrom( this.cells, cell );
3897  }, this );
3898
3899  this.cellChange( minCellIndex, true );
3900};
3901
3902/**
3903 * logic to be run after a cell's size changes
3904 * @param {Element} elem - cell's element
3905 */
3906proto.cellSizeChange = function( elem ) {
3907  var cell = this.getCell( elem );
3908  if ( !cell ) {
3909    return;
3910  }
3911  cell.getSize();
3912
3913  var index = this.cells.indexOf( cell );
3914  this.cellChange( index );
3915};
3916
3917/**
3918 * logic any time a cell is changed: added, removed, or size changed
3919 * @param {Integer} changedCellIndex - index of the changed cell, optional
3920 */
3921proto.cellChange = function( changedCellIndex, isPositioningSlider ) {
3922  var prevSelectedElem = this.selectedElement;
3923  this._positionCells( changedCellIndex );
3924  this._getWrapShiftCells();
3925  this.setGallerySize();
3926  // update selectedIndex
3927  // try to maintain position & select previous selected element
3928  var cell = this.getCell( prevSelectedElem );
3929  if ( cell ) {
3930    this.selectedIndex = this.getCellSlideIndex( cell );
3931  }
3932  this.selectedIndex = Math.min( this.slides.length - 1, this.selectedIndex );
3933
3934  this.emitEvent( 'cellChange', [ changedCellIndex ] );
3935  // position slider
3936  this.select( this.selectedIndex );
3937  // do not position slider after lazy load
3938  if ( isPositioningSlider ) {
3939    this.positionSliderAtSelected();
3940  }
3941};
3942
3943// -----  ----- //
3944
3945return Flickity;
3946
3947}));
3948
3949// lazyload
3950( function( window, factory ) {
3951  // universal module definition
3952  /* jshint strict: false */
3953  if ( typeof define == 'function' && define.amd ) {
3954    // AMD
3955    define( 'flickity/js/lazyload',[
3956      './flickity',
3957      'fizzy-ui-utils/utils'
3958    ], function( Flickity, utils ) {
3959      return factory( window, Flickity, utils );
3960    });
3961  } else if ( typeof module == 'object' && module.exports ) {
3962    // CommonJS
3963    module.exports = factory(
3964      window,
3965      require('./flickity'),
3966      require('fizzy-ui-utils')
3967    );
3968  } else {
3969    // browser global
3970    factory(
3971      window,
3972      window.Flickity,
3973      window.fizzyUIUtils
3974    );
3975  }
3976
3977}( window, function factory( window, Flickity, utils ) {
3978'use strict';
3979
3980Flickity.createMethods.push('_createLazyload');
3981var proto = Flickity.prototype;
3982
3983proto._createLazyload = function() {
3984  this.on( 'select', this.lazyLoad );
3985};
3986
3987proto.lazyLoad = function() {
3988  var lazyLoad = this.options.lazyLoad;
3989  if ( !lazyLoad ) {
3990    return;
3991  }
3992  // get adjacent cells, use lazyLoad option for adjacent count
3993  var adjCount = typeof lazyLoad == 'number' ? lazyLoad : 0;
3994  var cellElems = this.getAdjacentCellElements( adjCount );
3995  // get lazy images in those cells
3996  var lazyImages = [];
3997  cellElems.forEach( function( cellElem ) {
3998    var lazyCellImages = getCellLazyImages( cellElem );
3999    lazyImages = lazyImages.concat( lazyCellImages );
4000  });
4001  // load lazy images
4002  lazyImages.forEach( function( img ) {
4003    new LazyLoader( img, this );
4004  }, this );
4005};
4006
4007function getCellLazyImages( cellElem ) {
4008  // check if cell element is lazy image
4009  if ( cellElem.nodeName == 'IMG' ) {
4010    var lazyloadAttr = cellElem.getAttribute('data-flickity-lazyload');
4011    var srcAttr = cellElem.getAttribute('data-flickity-lazyload-src');
4012    var srcsetAttr = cellElem.getAttribute('data-flickity-lazyload-srcset');
4013    if ( lazyloadAttr || srcAttr || srcsetAttr ) {
4014      return [ cellElem ];
4015    }
4016  }
4017  // select lazy images in cell
4018  var lazySelector = 'img[data-flickity-lazyload], ' +
4019    'img[data-flickity-lazyload-src], img[data-flickity-lazyload-srcset]';
4020  var imgs = cellElem.querySelectorAll( lazySelector );
4021  return utils.makeArray( imgs );
4022}
4023
4024// -------------------------- LazyLoader -------------------------- //
4025
4026/**
4027 * class to handle loading images
4028 */
4029function LazyLoader( img, flickity ) {
4030  this.img = img;
4031  this.flickity = flickity;
4032  this.load();
4033}
4034
4035LazyLoader.prototype.handleEvent = utils.handleEvent;
4036
4037LazyLoader.prototype.load = function() {
4038  this.img.addEventListener( 'load', this );
4039  this.img.addEventListener( 'error', this );
4040  // get src & srcset
4041  var src = this.img.getAttribute('data-flickity-lazyload') ||
4042    this.img.getAttribute('data-flickity-lazyload-src');
4043  var srcset = this.img.getAttribute('data-flickity-lazyload-srcset');
4044  // set src & serset
4045  this.img.src = src;
4046  if ( srcset ) {
4047    this.img.setAttribute( 'srcset', srcset );
4048  }
4049  // remove attr
4050  this.img.removeAttribute('data-flickity-lazyload');
4051  this.img.removeAttribute('data-flickity-lazyload-src');
4052  this.img.removeAttribute('data-flickity-lazyload-srcset');
4053};
4054
4055LazyLoader.prototype.onload = function( event ) {
4056  this.complete( event, 'flickity-lazyloaded' );
4057};
4058
4059LazyLoader.prototype.onerror = function( event ) {
4060  this.complete( event, 'flickity-lazyerror' );
4061};
4062
4063LazyLoader.prototype.complete = function( event, className ) {
4064  // unbind events
4065  this.img.removeEventListener( 'load', this );
4066  this.img.removeEventListener( 'error', this );
4067
4068  var cell = this.flickity.getParentCell( this.img );
4069  var cellElem = cell && cell.element;
4070  this.flickity.cellSizeChange( cellElem );
4071
4072  this.img.classList.add( className );
4073  this.flickity.dispatchEvent( 'lazyLoad', event, cellElem );
4074};
4075
4076// -----  ----- //
4077
4078Flickity.LazyLoader = LazyLoader;
4079
4080return Flickity;
4081
4082}));
4083
4084/*!
4085 * Flickity v2.1.2
4086 * Touch, responsive, flickable carousels
4087 *
4088 * Licensed GPLv3 for open source use
4089 * or Flickity Commercial License for commercial use
4090 *
4091 * https://flickity.metafizzy.co
4092 * Copyright 2015-2018 Metafizzy
4093 */
4094
4095( function( window, factory ) {
4096  // universal module definition
4097  /* jshint strict: false */
4098  if ( typeof define == 'function' && define.amd ) {
4099    // AMD
4100    define( 'flickity/js/index',[
4101      './flickity',
4102      './drag',
4103      './prev-next-button',
4104      './page-dots',
4105      './player',
4106      './add-remove-cell',
4107      './lazyload'
4108    ], factory );
4109  } else if ( typeof module == 'object' && module.exports ) {
4110    // CommonJS
4111    module.exports = factory(
4112      require('./flickity'),
4113      require('./drag'),
4114      require('./prev-next-button'),
4115      require('./page-dots'),
4116      require('./player'),
4117      require('./add-remove-cell'),
4118      require('./lazyload')
4119    );
4120  }
4121
4122})( window, function factory( Flickity ) {
4123  /*jshint strict: false*/
4124  return Flickity;
4125});
4126
4127/*!
4128 * Flickity asNavFor v2.0.1
4129 * enable asNavFor for Flickity
4130 */
4131
4132/*jshint browser: true, undef: true, unused: true, strict: true*/
4133
4134( function( window, factory ) {
4135  // universal module definition
4136  /*jshint strict: false */ /*globals define, module, require */
4137  if ( typeof define == 'function' && define.amd ) {
4138    // AMD
4139    define( 'flickity-as-nav-for/as-nav-for',[
4140      'flickity/js/index',
4141      'fizzy-ui-utils/utils'
4142    ], factory );
4143  } else if ( typeof module == 'object' && module.exports ) {
4144    // CommonJS
4145    module.exports = factory(
4146      require('flickity'),
4147      require('fizzy-ui-utils')
4148    );
4149  } else {
4150    // browser global
4151    window.Flickity = factory(
4152      window.Flickity,
4153      window.fizzyUIUtils
4154    );
4155  }
4156
4157}( window, function factory( Flickity, utils ) {
4158
4159
4160
4161// -------------------------- asNavFor prototype -------------------------- //
4162
4163// Flickity.defaults.asNavFor = null;
4164
4165Flickity.createMethods.push('_createAsNavFor');
4166
4167var proto = Flickity.prototype;
4168
4169proto._createAsNavFor = function() {
4170  this.on( 'activate', this.activateAsNavFor );
4171  this.on( 'deactivate', this.deactivateAsNavFor );
4172  this.on( 'destroy', this.destroyAsNavFor );
4173
4174  var asNavForOption = this.options.asNavFor;
4175  if ( !asNavForOption ) {
4176    return;
4177  }
4178  // HACK do async, give time for other flickity to be initalized
4179  var _this = this;
4180  setTimeout( function initNavCompanion() {
4181    _this.setNavCompanion( asNavForOption );
4182  });
4183};
4184
4185proto.setNavCompanion = function( elem ) {
4186  elem = utils.getQueryElement( elem );
4187  var companion = Flickity.data( elem );
4188  // stop if no companion or companion is self
4189  if ( !companion || companion == this ) {
4190    return;
4191  }
4192
4193  this.navCompanion = companion;
4194  // companion select
4195  var _this = this;
4196  this.onNavCompanionSelect = function() {
4197    _this.navCompanionSelect();
4198  };
4199  companion.on( 'select', this.onNavCompanionSelect );
4200  // click
4201  this.on( 'staticClick', this.onNavStaticClick );
4202
4203  this.navCompanionSelect( true );
4204};
4205
4206proto.navCompanionSelect = function( isInstant ) {
4207  if ( !this.navCompanion ) {
4208    return;
4209  }
4210  // select slide that matches first cell of slide
4211  var selectedCell = this.navCompanion.selectedCells[0];
4212  var firstIndex = this.navCompanion.cells.indexOf( selectedCell );
4213  var lastIndex = firstIndex + this.navCompanion.selectedCells.length - 1;
4214  var selectIndex = Math.floor( lerp( firstIndex, lastIndex,
4215    this.navCompanion.cellAlign ) );
4216  this.selectCell( selectIndex, false, isInstant );
4217  // set nav selected class
4218  this.removeNavSelectedElements();
vendor: 4,590 bytes, lines 4219-4404
4219  // stop if companion has more cells than this one
4220  if ( selectIndex >= this.cells.length ) {
4221    return;
4222  }
4223
4224  var selectedCells = this.cells.slice( firstIndex, lastIndex + 1 );
4225  this.navSelectedElements = selectedCells.map( function( cell ) {
4226    return cell.element;
4227  });
4228  this.changeNavSelectedClass('add');
4229};
4230
4231function lerp( a, b, t ) {
4232  return ( b - a ) * t + a;
4233}
4234
4235proto.changeNavSelectedClass = function( method ) {
4236  this.navSelectedElements.forEach( function( navElem ) {
4237    navElem.classList[ method ]('is-nav-selected');
4238  });
4239};
4240
4241proto.activateAsNavFor = function() {
4242  this.navCompanionSelect( true );
4243};
4244
4245proto.removeNavSelectedElements = function() {
4246  if ( !this.navSelectedElements ) {
4247    return;
4248  }
4249  this.changeNavSelectedClass('remove');
4250  delete this.navSelectedElements;
4251};
4252
4253proto.onNavStaticClick = function( event, pointer, cellElement, cellIndex ) {
4254  if ( typeof cellIndex == 'number' ) {
4255    this.navCompanion.selectCell( cellIndex );
4256  }
4257};
4258
4259proto.deactivateAsNavFor = function() {
4260  this.removeNavSelectedElements();
4261};
4262
4263proto.destroyAsNavFor = function() {
4264  if ( !this.navCompanion ) {
4265    return;
4266  }
4267  this.navCompanion.off( 'select', this.onNavCompanionSelect );
4268  this.off( 'staticClick', this.onNavStaticClick );
4269  delete this.navCompanion;
4270};
4271
4272// -----  ----- //
4273
4274return Flickity;
4275
4276}));
4277
4278/*!
4279 * imagesLoaded v4.1.4
4280 * JavaScript is all like "You images are done yet or what?"
4281 * MIT License
4282 */
4283
4284( function( window, factory ) { 'use strict';
4285  // universal module definition
4286
4287  /*global define: false, module: false, require: false */
4288
4289  if ( typeof define == 'function' && define.amd ) {
4290    // AMD
4291    define( 'imagesloaded/imagesloaded',[
4292      'ev-emitter/ev-emitter'
4293    ], function( EvEmitter ) {
4294      return factory( window, EvEmitter );
4295    });
4296  } else if ( typeof module == 'object' && module.exports ) {
4297    // CommonJS
4298    module.exports = factory(
4299      window,
4300      require('ev-emitter')
4301    );
4302  } else {
4303    // browser global
4304    window.imagesLoaded = factory(
4305      window,
4306      window.EvEmitter
4307    );
4308  }
4309
4310})( typeof window !== 'undefined' ? window : this,
4311
4312// --------------------------  factory -------------------------- //
4313
4314function factory( window, EvEmitter ) {
4315
4316
4317
4318var $ = window.jQuery;
4319var console = window.console;
4320
4321// -------------------------- helpers -------------------------- //
4322
4323// extend objects
4324function extend( a, b ) {
4325  for ( var prop in b ) {
4326    a[ prop ] = b[ prop ];
4327  }
4328  return a;
4329}
4330
4331var arraySlice = Array.prototype.slice;
4332
4333// turn element or nodeList into an array
4334function makeArray( obj ) {
4335  if ( Array.isArray( obj ) ) {
4336    // use object if already an array
4337    return obj;
4338  }
4339
4340  var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
4341  if ( isArrayLike ) {
4342    // convert nodeList to array
4343    return arraySlice.call( obj );
4344  }
4345
4346  // array of single index
4347  return [ obj ];
4348}
4349
4350// -------------------------- imagesLoaded -------------------------- //
4351
4352/**
4353 * @param {Array, Element, NodeList, String} elem
4354 * @param {Object or Function} options - if function, use as callback
4355 * @param {Function} onAlways - callback function
4356 */
4357function ImagesLoaded( elem, options, onAlways ) {
4358  // coerce ImagesLoaded() without new, to be new ImagesLoaded()
4359  if ( !( this instanceof ImagesLoaded ) ) {
4360    return new ImagesLoaded( elem, options, onAlways );
4361  }
4362  // use elem as selector string
4363  var queryElem = elem;
4364  if ( typeof elem == 'string' ) {
4365    queryElem = document.querySelectorAll( elem );
4366  }
4367  // bail if bad element
4368  if ( !queryElem ) {
4369    console.error( 'Bad element for imagesLoaded ' + ( queryElem || elem ) );
4370    return;
4371  }
4372
4373  this.elements = makeArray( queryElem );
4374  this.options = extend( {}, this.options );
4375  // shift arguments if no options set
4376  if ( typeof options == 'function' ) {
4377    onAlways = options;
4378  } else {
4379    extend( this.options, options );
4380  }
4381
4382  if ( onAlways ) {
4383    this.on( 'always', onAlways );
4384  }
4385
4386  this.getImages();
4387
4388  if ( $ ) {
4389    // add jQuery Deferred object
4390    this.jqDeferred = new $.Deferred();
4391  }
4392
4393  // HACK check async to allow time to bind listeners
4394  setTimeout( this.check.bind( this ) );
4395}
4396
4397ImagesLoaded.prototype = Object.create( EvEmitter.prototype );
4398
4399ImagesLoaded.prototype.options = {};
4400
4401ImagesLoaded.prototype.getImages = function() {
4402  this.images = [];
4403
4404  // filter & find items if we have an item selector
vendor: 4,504 bytes, lines 4405-4561
4405  this.elements.forEach( this.addElementImages, this );
4406};
4407
4408/**
4409 * @param {Node} element
4410 */
4411ImagesLoaded.prototype.addElementImages = function( elem ) {
4412  // filter siblings
4413  if ( elem.nodeName == 'IMG' ) {
4414    this.addImage( elem );
4415  }
4416  // get background image on element
4417  if ( this.options.background === true ) {
4418    this.addElementBackgroundImages( elem );
4419  }
4420
4421  // find children
4422  // no non-element nodes, #143
4423  var nodeType = elem.nodeType;
4424  if ( !nodeType || !elementNodeTypes[ nodeType ] ) {
4425    return;
4426  }
4427  var childImgs = elem.querySelectorAll('img');
4428  // concat childElems to filterFound array
4429  for ( var i=0; i < childImgs.length; i++ ) {
4430    var img = childImgs[i];
4431    this.addImage( img );
4432  }
4433
4434  // get child background images
4435  if ( typeof this.options.background == 'string' ) {
4436    var children = elem.querySelectorAll( this.options.background );
4437    for ( i=0; i < children.length; i++ ) {
4438      var child = children[i];
4439      this.addElementBackgroundImages( child );
4440    }
4441  }
4442};
4443
4444var elementNodeTypes = {
4445  1: true,
4446  9: true,
4447  11: true
4448};
4449
4450ImagesLoaded.prototype.addElementBackgroundImages = function( elem ) {
4451  var style = getComputedStyle( elem );
4452  if ( !style ) {
4453    // Firefox returns null if in a hidden iframe https://bugzil.la/548397
4454    return;
4455  }
4456  // get url inside url("...")
4457  var reURL = /url\((['"])?(.*?)\1\)/gi;
4458  var matches = reURL.exec( style.backgroundImage );
4459  while ( matches !== null ) {
4460    var url = matches && matches[2];
4461    if ( url ) {
4462      this.addBackground( url, elem );
4463    }
4464    matches = reURL.exec( style.backgroundImage );
4465  }
4466};
4467
4468/**
4469 * @param {Image} img
4470 */
4471ImagesLoaded.prototype.addImage = function( img ) {
4472  var loadingImage = new LoadingImage( img );
4473  this.images.push( loadingImage );
4474};
4475
4476ImagesLoaded.prototype.addBackground = function( url, elem ) {
4477  var background = new Background( url, elem );
4478  this.images.push( background );
4479};
4480
4481ImagesLoaded.prototype.check = function() {
4482  var _this = this;
4483  this.progressedCount = 0;
4484  this.hasAnyBroken = false;
4485  // complete if no images
4486  if ( !this.images.length ) {
4487    this.complete();
4488    return;
4489  }
4490
4491  function onProgress( image, elem, message ) {
4492    // HACK - Chrome triggers event before object properties have changed. #83
4493    setTimeout( function() {
4494      _this.progress( image, elem, message );
4495    });
4496  }
4497
4498  this.images.forEach( function( loadingImage ) {
4499    loadingImage.once( 'progress', onProgress );
4500    loadingImage.check();
4501  });
4502};
4503
4504ImagesLoaded.prototype.progress = function( image, elem, message ) {
4505  this.progressedCount++;
4506  this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
4507  // progress event
4508  this.emitEvent( 'progress', [ this, image, elem ] );
4509  if ( this.jqDeferred && this.jqDeferred.notify ) {
4510    this.jqDeferred.notify( this, image );
4511  }
4512  // check if completed
4513  if ( this.progressedCount == this.images.length ) {
4514    this.complete();
4515  }
4516
4517  if ( this.options.debug && console ) {
4518    console.log( 'progress: ' + message, image, elem );
4519  }
4520};
4521
4522ImagesLoaded.prototype.complete = function() {
4523  var eventName = this.hasAnyBroken ? 'fail' : 'done';
4524  this.isComplete = true;
4525  this.emitEvent( eventName, [ this ] );
4526  this.emitEvent( 'always', [ this ] );
4527  if ( this.jqDeferred ) {
4528    var jqMethod = this.hasAnyBroken ? 'reject' : 'resolve';
4529    this.jqDeferred[ jqMethod ]( this );
4530  }
4531};
4532
4533// --------------------------  -------------------------- //
4534
4535function LoadingImage( img ) {
4536  this.img = img;
4537}
4538
4539LoadingImage.prototype = Object.create( EvEmitter.prototype );
4540
4541LoadingImage.prototype.check = function() {
4542  // If complete is true and browser supports natural sizes,
4543  // try to check for image status manually.
4544  var isComplete = this.getIsImageComplete();
4545  if ( isComplete ) {
4546    // report based on naturalWidth
4547    this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
4548    return;
4549  }
4550
4551  // If none of the checks above matched, simulate loading on detached element.
4552  this.proxyImage = new Image();
4553  this.proxyImage.addEventListener( 'load', this );
4554  this.proxyImage.addEventListener( 'error', this );
4555  // bind to image as well for Firefox. #191
4556  this.img.addEventListener( 'load', this );
4557  this.img.addEventListener( 'error', this );
4558  this.proxyImage.src = this.img.src;
4559};
4560
4561LoadingImage.prototype.getIsImageComplete = function() {
vendor: 4,255 bytes, lines 4562-4714
4562  // check for non-zero, non-undefined naturalWidth
4563  // fixes Safari+InfiniteScroll+Masonry bug infinite-scroll#671
4564  return this.img.complete && this.img.naturalWidth;
4565};
4566
4567LoadingImage.prototype.confirm = function( isLoaded, message ) {
4568  this.isLoaded = isLoaded;
4569  this.emitEvent( 'progress', [ this, this.img, message ] );
4570};
4571
4572// ----- events ----- //
4573
4574// trigger specified handler for event type
4575LoadingImage.prototype.handleEvent = function( event ) {
4576  var method = 'on' + event.type;
4577  if ( this[ method ] ) {
4578    this[ method ]( event );
4579  }
4580};
4581
4582LoadingImage.prototype.onload = function() {
4583  this.confirm( true, 'onload' );
4584  this.unbindEvents();
4585};
4586
4587LoadingImage.prototype.onerror = function() {
4588  this.confirm( false, 'onerror' );
4589  this.unbindEvents();
4590};
4591
4592LoadingImage.prototype.unbindEvents = function() {
4593  this.proxyImage.removeEventListener( 'load', this );
4594  this.proxyImage.removeEventListener( 'error', this );
4595  this.img.removeEventListener( 'load', this );
4596  this.img.removeEventListener( 'error', this );
4597};
4598
4599// -------------------------- Background -------------------------- //
4600
4601function Background( url, element ) {
4602  this.url = url;
4603  this.element = element;
4604  this.img = new Image();
4605}
4606
4607// inherit LoadingImage prototype
4608Background.prototype = Object.create( LoadingImage.prototype );
4609
4610Background.prototype.check = function() {
4611  this.img.addEventListener( 'load', this );
4612  this.img.addEventListener( 'error', this );
4613  this.img.src = this.url;
4614  // check if image is already complete
4615  var isComplete = this.getIsImageComplete();
4616  if ( isComplete ) {
4617    this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
4618    this.unbindEvents();
4619  }
4620};
4621
4622Background.prototype.unbindEvents = function() {
4623  this.img.removeEventListener( 'load', this );
4624  this.img.removeEventListener( 'error', this );
4625};
4626
4627Background.prototype.confirm = function( isLoaded, message ) {
4628  this.isLoaded = isLoaded;
4629  this.emitEvent( 'progress', [ this, this.element, message ] );
4630};
4631
4632// -------------------------- jQuery -------------------------- //
4633
4634ImagesLoaded.makeJQueryPlugin = function( jQuery ) {
4635  jQuery = jQuery || window.jQuery;
4636  if ( !jQuery ) {
4637    return;
4638  }
4639  // set local variable
4640  $ = jQuery;
4641  // $().imagesLoaded()
4642  $.fn.imagesLoaded = function( options, callback ) {
4643    var instance = new ImagesLoaded( this, options, callback );
4644    return instance.jqDeferred.promise( $(this) );
4645  };
4646};
4647// try making plugin
4648ImagesLoaded.makeJQueryPlugin();
4649
4650// --------------------------  -------------------------- //
4651
4652return ImagesLoaded;
4653
4654});
4655
4656/*!
4657 * Flickity imagesLoaded v2.0.0
4658 * enables imagesLoaded option for Flickity
4659 */
4660
4661/*jshint browser: true, strict: true, undef: true, unused: true */
4662
4663( function( window, factory ) {
4664  // universal module definition
4665  /*jshint strict: false */ /*globals define, module, require */
4666  if ( typeof define == 'function' && define.amd ) {
4667    // AMD
4668    define( [
4669      'flickity/js/index',
4670      'imagesloaded/imagesloaded'
4671    ], function( Flickity, imagesLoaded ) {
4672      return factory( window, Flickity, imagesLoaded );
4673    });
4674  } else if ( typeof module == 'object' && module.exports ) {
4675    // CommonJS
4676    module.exports = factory(
4677      window,
4678      require('flickity'),
4679      require('imagesloaded')
4680    );
4681  } else {
4682    // browser global
4683    window.Flickity = factory(
4684      window,
4685      window.Flickity,
4686      window.imagesLoaded
4687    );
4688  }
4689
4690}( window, function factory( window, Flickity, imagesLoaded ) {
4691'use strict';
4692
4693Flickity.createMethods.push('_createImagesLoaded');
4694
4695var proto = Flickity.prototype;
4696
4697proto._createImagesLoaded = function() {
4698  this.on( 'activate', this.imagesLoaded );
4699};
4700
4701proto.imagesLoaded = function() {
4702  if ( !this.options.imagesLoaded ) {
4703    return;
4704  }
4705  var _this = this;
4706  function onImagesLoadedProgress( instance, image ) {
4707    var cell = _this.getParentCell( image.img );
4708    _this.cellSizeChange( cell && cell.element );
4709    if ( !_this.options.freeScroll ) {
4710      _this.positionSliderAtSelected();
4711    }
4712  }
4713  imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress );
4714};
4715
4716return Flickity;
4717
4718}));

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.