diff options
Diffstat (limited to 'site/public/assets/javascripts/vendor/flickity.pkgd.js')
| -rw-r--r-- | site/public/assets/javascripts/vendor/flickity.pkgd.js | 215 |
1 files changed, 115 insertions, 100 deletions
diff --git a/site/public/assets/javascripts/vendor/flickity.pkgd.js b/site/public/assets/javascripts/vendor/flickity.pkgd.js index 6389014..0471fa5 100644 --- a/site/public/assets/javascripts/vendor/flickity.pkgd.js +++ b/site/public/assets/javascripts/vendor/flickity.pkgd.js @@ -1,6 +1,10 @@ /*! - * Flickity PACKAGED v0.2.3 + * Flickity PACKAGED v1.0.1 * Touch, responsive, flickable galleries + * + * Licensed GPLv3 for open source use + * or Flickity Commercial License for commercial use + * * http://flickity.metafizzy.co * Copyright 2015 Metafizzy */ @@ -1176,7 +1180,7 @@ if ( typeof define === 'function' && define.amd ) { })( window ); /** - * matchesSelector v1.0.2 + * matchesSelector v1.0.3 * matchesSelector( element, '.selector' ) * MIT license */ @@ -1189,6 +1193,10 @@ if ( typeof define === 'function' && define.amd ) { var matchesMethod = ( function() { + // check for the standard method name first + if ( ElemProto.matches ) { + return 'matches'; + } // check un-prefixed if ( ElemProto.matchesSelector ) { return 'matchesSelector'; @@ -1280,7 +1288,7 @@ if ( typeof define === 'function' && define.amd ) { })( Element.prototype ); /** - * Fizzy UI utils v0.1.1 + * Fizzy UI utils v1.0.1 * MIT license */ @@ -1380,7 +1388,7 @@ utils.indexOf = Array.prototype.indexOf ? function( ary, obj ) { // ----- removeFrom ----- // -utils.removeFrom = function( obj, ary ) { +utils.removeFrom = function( ary, obj ) { var index = utils.indexOf( ary, obj ); if ( index != -1 ) { ary.splice( index, 1 ); @@ -1499,14 +1507,12 @@ utils.debounceMethod = function( _class, methodName, threshold ) { // ----- htmlInit ----- // -var jQuery = window.jQuery; - // http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/ -function toDashed( str ) { +utils.toDashed = function( str ) { return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) { return $1 + '-' + $2; }).toLowerCase(); -} +}; var console = window.console; /** @@ -1516,7 +1522,7 @@ var console = window.console; */ utils.htmlInit = function( WidgetClass, namespace ) { docReady( function() { - var dashedNamespace = toDashed( namespace ); + var dashedNamespace = utils.toDashed( namespace ); var elems = document.querySelectorAll( '.js-' + dashedNamespace ); var dataAttr = 'data-' + dashedNamespace + '-options'; @@ -1538,6 +1544,7 @@ utils.htmlInit = function( WidgetClass, namespace ) { // initialize var instance = new WidgetClass( elem, options ); // make available via $().data('layoutname') + var jQuery = window.jQuery; if ( jQuery ) { jQuery.data( elem, namespace, instance ); } @@ -1893,8 +1900,12 @@ return proto; })); /*! - * Flickity v0.2.3 + * Flickity v1.0.1 * Touch, responsive, flickable galleries + * + * Licensed GPLv3 for open source use + * or Flickity Commercial License for commercial use + * * http://flickity.metafizzy.co * Copyright 2015 Metafizzy */ @@ -1999,7 +2010,8 @@ Flickity.defaults = { // initialIndex: 0, percentPosition: true, resize: true, - selectedAttraction: 0.025 + selectedAttraction: 0.025, + setGallerySize: true // watchCSS: false, // wrapAround: false }; @@ -2075,7 +2087,6 @@ Flickity.prototype.activate = function() { this.getSize(); // get cells from children this.reloadCells(); - this.setContainerSize(); if ( this.options.accessibility ) { // allow element to focusable @@ -2109,7 +2120,7 @@ Flickity.prototype.reloadCells = function() { this.cells = this._makeCells( this.slider.children ); this.positionCells(); this._getWrapShiftCells(); - this.setContainerSize(); + this.setGallerySize(); }; /** @@ -2215,8 +2226,10 @@ Flickity.prototype.setCellAlign = function() { this.cellAlign = shorthand ? shorthand[ this.originSide ] : this.options.cellAlign; }; -Flickity.prototype.setContainerSize = function() { - this.viewport.style.height = this.maxCellHeight + 'px'; +Flickity.prototype.setGallerySize = function() { + if ( this.options.setGallerySize ) { + this.viewport.style.height = this.maxCellHeight + 'px'; + } }; Flickity.prototype._getWrapShiftCells = function() { @@ -2267,13 +2280,21 @@ Flickity.prototype._containCells = function() { var lastCell = this.getLastCell(); var contentWidth = this.slideableWidth - lastCell.size[ endMargin ]; var endLimit = contentWidth - this.size.innerWidth * ( 1 - this.cellAlign ); + // content is less than gallery size + var isContentSmaller = contentWidth < this.size.innerWidth; // contain each cell target for ( var i=0, len = this.cells.length; i < len; i++ ) { var cell = this.cells[i]; // reset default target cell.setDefaultTarget(); - cell.target = Math.max( cell.target, this.cursorPosition + firstCellStartMargin ); - cell.target = Math.min( cell.target, endLimit ); + if ( isContentSmaller ) { + // all cells fit inside gallery + cell.target = contentWidth * this.cellAlign; + } else { + // contain to bounds + cell.target = Math.max( cell.target, this.cursorPosition + firstCellStartMargin ); + cell.target = Math.min( cell.target, endLimit ); + } } }; @@ -2293,7 +2314,7 @@ Flickity.prototype.dispatchEvent = function( type, event, args ) { if ( event ) { // create jQuery event var $event = jQuery.Event( event ); - $event.type = type + '.flickity'; + $event.type = type; this.$element.trigger( $event, args ); } else { // just trigger with type if no event available @@ -2330,7 +2351,7 @@ Flickity.prototype.select = function( index, isWrap ) { this.selectedIndex = index; this.setSelectedCell(); this.startAnimation(); - this.dispatchEvent('select'); + this.dispatchEvent('cellSelect'); } }; @@ -2448,7 +2469,7 @@ Flickity.prototype.resize = function() { } this.positionCells(); this._getWrapShiftCells(); - this.setContainerSize(); + this.setGallerySize(); this.positionSliderAtSelected(); }; @@ -2554,6 +2575,9 @@ Flickity.prototype.destroy = function() { eventie.unbind( window, 'resize', this ); } this.emit('destroy'); + if ( jQuery && this.$element ) { + jQuery.removeData( this.element, 'flickity' ); + } delete this.element.flickityGUID; delete instances[ this.guid ]; }; @@ -2599,7 +2623,7 @@ return Flickity; })); /*! - * Unipointer v0.1.0 + * Unipointer v1.1.0 * base class for doing one thing with pointer event * MIT license */ @@ -2736,7 +2760,7 @@ Unipointer.prototype._pointerDown = function( event, pointer ) { Unipointer.prototype.pointerDown = function( event, pointer ) { this._bindPostStartEvents( event ); - this.emitEvent( 'pointerDown', [ this, event, pointer ] ); + this.emitEvent( 'pointerDown', [ event, pointer ] ); }; // hash of events to be bound after start event @@ -2813,7 +2837,7 @@ Unipointer.prototype._pointerMove = function( event, pointer ) { // public Unipointer.prototype.pointerMove = function( event, pointer ) { - this.emitEvent( 'pointerMove', [ this, event, pointer ] ); + this.emitEvent( 'pointerMove', [ event, pointer ] ); }; // ----- end event ----- // @@ -2850,7 +2874,7 @@ Unipointer.prototype._pointerUp = function( event, pointer ) { // public Unipointer.prototype.pointerUp = function( event, pointer ) { - this.emitEvent( 'pointerUp', [ this, event, pointer ] ); + this.emitEvent( 'pointerUp', [ event, pointer ] ); }; // ----- pointer done ----- // @@ -2896,7 +2920,7 @@ Unipointer.prototype._pointerCancel = function( event, pointer ) { // public Unipointer.prototype.pointerCancel = function( event, pointer ) { - this.emitEvent( 'pointerCancel', [ this, event, pointer ] ); + this.emitEvent( 'pointerCancel', [ event, pointer ] ); }; // ----- ----- // @@ -2916,7 +2940,7 @@ return Unipointer; })); /*! - * Unidragger v0.2.0 + * Unidragger v1.1.3 * Draggable base class * MIT license */ @@ -3050,13 +3074,6 @@ var disableImgOndragstart = !isIE8 ? noop : function( handle ) { // ----- start event ----- // -var allowTouchstartNodes = Unidragger.allowTouchstartNodes = { - INPUT: true, - A: true, - BUTTON: true, - SELECT: true -}; - /** * pointer start * @param {Event} event @@ -3071,7 +3088,7 @@ Unidragger.prototype.pointerDown = function( event, pointer ) { } // bind move and end events this._bindPostStartEvents( event ); - this.emitEvent( 'pointerDown', [ this, event, pointer ] ); + this.emitEvent( 'pointerDown', [ event, pointer ] ); }; // base pointer down logic @@ -3079,11 +3096,10 @@ Unidragger.prototype._dragPointerDown = function( event, pointer ) { // track to see when dragging starts this.pointerDownPoint = Unipointer.getPointerPoint( pointer ); + // prevent default, unless touchstart or <select> + var isTouchstart = event.type == 'touchstart'; var targetNodeName = event.target.nodeName; - // HACK iOS, allow clicks on buttons, inputs, and links - var isTouchstartNode = event.type == 'touchstart' && allowTouchstartNodes[ targetNodeName ]; - // do not prevent default on touchstart nodes or <select> - if ( !isTouchstartNode && targetNodeName != 'SELECT' ) { + if ( !isTouchstart && targetNodeName != 'SELECT' ) { preventDefaultEvent( event ); } }; @@ -3097,7 +3113,7 @@ Unidragger.prototype._dragPointerDown = function( event, pointer ) { */ Unidragger.prototype.pointerMove = function( event, pointer ) { var moveVector = this._dragPointerMove( event, pointer ); - this.emitEvent( 'pointerMove', [ this, event, pointer, moveVector ] ); + this.emitEvent( 'pointerMove', [ event, pointer, moveVector ] ); this._dragMove( event, pointer, moveVector ); }; @@ -3129,7 +3145,7 @@ Unidragger.prototype.hasDragStarted = function( moveVector ) { * @param {Event or Touch} pointer */ Unidragger.prototype.pointerUp = function( event, pointer ) { - this.emitEvent( 'pointerUp', [ this, event, pointer ] ); + this.emitEvent( 'pointerUp', [ event, pointer ] ); this._dragPointerUp( event, pointer ); }; @@ -3155,7 +3171,7 @@ Unidragger.prototype._dragStart = function( event, pointer ) { }; Unidragger.prototype.dragStart = function( event, pointer ) { - this.emitEvent( 'dragStart', [ this, event, pointer ] ); + this.emitEvent( 'dragStart', [ event, pointer ] ); }; // dragMove @@ -3169,7 +3185,8 @@ Unidragger.prototype._dragMove = function( event, pointer, moveVector ) { }; Unidragger.prototype.dragMove = function( event, pointer, moveVector ) { - this.emitEvent( 'dragMove', [ this, event, pointer, moveVector ] ); + preventDefaultEvent( event ); + this.emitEvent( 'dragMove', [ event, pointer, moveVector ] ); }; // dragEnd @@ -3186,7 +3203,7 @@ Unidragger.prototype._dragEnd = function( event, pointer ) { }; Unidragger.prototype.dragEnd = function( event, pointer ) { - this.emitEvent( 'dragEnd', [ this, event, pointer ] ); + this.emitEvent( 'dragEnd', [ event, pointer ] ); }; // ----- onclick ----- // @@ -3202,15 +3219,16 @@ Unidragger.prototype.onclick = function( event ) { // triggered after pointer down & up with no/tiny movement Unidragger.prototype._staticClick = function( event, pointer ) { - // allow click in text input - if ( event.target.nodeName == 'INPUT' && event.target.type == 'text' ) { + // allow click in <input>s and <textarea>s + var nodeName = event.target.nodeName; + if ( nodeName == 'INPUT' || nodeName == 'TEXTAREA' ) { event.target.focus(); } this.staticClick( event, pointer ); }; Unidragger.prototype.staticClick = function( event, pointer ) { - this.emitEvent( 'staticClick', [ this, event, pointer ] ); + this.emitEvent( 'staticClick', [ event, pointer ] ); }; // ----- ----- // @@ -3325,10 +3343,6 @@ proto.unbindDrag = function() { delete this.isDragBound; }; -proto.hasDragStarted = function( moveVector ) { - return Math.abs( moveVector.x ) > 3; -}; - proto._uiChangeDrag = function() { delete this.isFreeScrolling; }; @@ -3345,7 +3359,9 @@ proto.pointerDown = function( event, pointer ) { // kludge to blur focused inputs in dragger var focused = document.activeElement; - if ( focused && focused.blur && focused != this.element ) { + if ( focused && focused.blur && focused != this.element && + // do not blur body for IE9 & 10, #117 + focused != document.body ) { focused.blur(); } this.pointerDownFocus( event ); @@ -3375,6 +3391,8 @@ proto.pointerDownFocus = function( event ) { } }; +// ----- move ----- // + proto.pointerMove = function( event, pointer ) { var moveVector = this._dragPointerMove( event, pointer ); this.touchVerticalScrollMove( event, pointer, moveVector ); @@ -3382,6 +3400,12 @@ proto.pointerMove = function( event, pointer ) { this.dispatchEvent( 'pointerMove', event, [ pointer, moveVector ] ); }; +proto.hasDragStarted = function( moveVector ) { + return !this.isTouchScrolling && Math.abs( moveVector.x ) > 3; +}; + +// ----- up ----- // + proto.pointerUp = function( event, pointer ) { delete this.isTouchScrolling; classie.remove( this.viewport, 'is-pointer-down' ); @@ -3405,11 +3429,16 @@ function getPointerWindowY( pointer ) { } proto.touchVerticalScrollMove = function( event, pointer, moveVector ) { - if ( !this.options.touchVerticalScroll || !touchScrollEvents[ event.type ] ) { + // do not scroll if already dragging, if disabled + var touchVerticalScroll = this.options.touchVerticalScroll; + // if touchVerticalScroll is 'withDrag', allow scrolling and dragging + var canNotScroll = touchVerticalScroll == 'withDrag' ? !touchVerticalScroll : + this.isDragging || !touchVerticalScroll; + if ( canNotScroll || !touchScrollEvents[ event.type ] ) { return; } - // don't start vertical scrolling until pointer has moved 16 pixels in a direction - if ( !this.isTouchScrolling && Math.abs( moveVector.y ) > 16 ) { + // don't start vertical scrolling until pointer has moved 10 pixels in a direction + if ( !this.isTouchScrolling && Math.abs( moveVector.y ) > 10 ) { // start touch vertical scrolling // scroll & pointerY when started this.startScrollY = window.pageYOffset; @@ -3417,13 +3446,6 @@ proto.touchVerticalScrollMove = function( event, pointer, moveVector ) { // start scroll animation this.isTouchScrolling = true; } - if ( !this.isTouchScrolling ) { - return; - } - // scroll window - var scrollDelta = this.pointerWindowStartY - getPointerWindowY( pointer ); - var scrollY = this.startScrollY + scrollDelta; - window.scroll( window.pageXOffset, scrollY ); }; // -------------------------- dragging -------------------------- // @@ -3435,6 +3457,8 @@ proto.dragStart = function( event, pointer ) { }; proto.dragMove = function( event, pointer, moveVector ) { + preventDefaultEvent( event ); + this.previousDragX = this.x; var movedX = moveVector.x; @@ -3584,11 +3608,9 @@ proto.dragEndBoostSelect = function() { proto.staticClick = function( event, pointer ) { // get clickedCell, if cell was clicked var clickedCell = this.getParentCell( event.target ); - var clickedCellIndex = clickedCell && - utils.indexOf( this.cells, clickedCell ); - var clickedCellElem = clickedCell && clickedCell.element; - this.dispatchEvent( 'staticClick', event, - [ pointer, clickedCellIndex, clickedCellElem ] ); + var cellElem = clickedCell && clickedCell.element; + var cellIndex = clickedCell && utils.indexOf( this.cells, clickedCell ); + this.dispatchEvent( 'staticClick', event, [ pointer, cellElem, cellIndex ] ); }; // ----- ----- // @@ -3602,7 +3624,7 @@ return Flickity; })); /*! - * Tap listener v0.1.0 + * Tap listener v1.1.0 * listens to taps * MIT license */ @@ -3688,7 +3710,7 @@ TapListener.prototype.pointerUp = function( event, pointer ) { pointerPoint.y <= boundingRect.bottom + scrollY; // trigger callback if pointer is inside element if ( isInside ) { - this.emitEvent( 'tap', [ this, event, pointer ] ); + this.emitEvent( 'tap', [ event, pointer ] ); } }; @@ -3797,10 +3819,10 @@ PrevNextButton.prototype._create = function() { } // update on select var _this = this; - this.onselect = function() { + this.onCellSelect = function() { _this.update(); }; - this.parent.on( 'select', this.onselect ); + this.parent.on( 'cellSelect', this.onCellSelect ); // tap this.on( 'tap', this.onTap ); // pointerDown @@ -3906,8 +3928,8 @@ PrevNextButton.prototype.destroy = function() { utils.extend( Flickity.defaults, { prevNextButtons: true, - leftArrowText: '‹', - rightArrowText: '›' + leftArrowText: '‹', + rightArrowText: '›' }); Flickity.createMethods.push('_createPrevNextButtons'); @@ -4000,10 +4022,10 @@ PageDots.prototype._create = function() { this.dots = []; // update on select var _this = this; - this.onselect = function() { + this.onCellSelect = function() { _this.updateSelected(); }; - this.parent.on( 'select', this.onselect ); + this.parent.on( 'cellSelect', this.onCellSelect ); // tap this.on( 'tap', this.onTap ); // pointerDown @@ -4073,7 +4095,7 @@ PageDots.prototype.updateSelected = function() { this.selectedDot.className = 'dot is-selected'; }; -PageDots.prototype.onTap = function( instance, event ) { +PageDots.prototype.onTap = function( event ) { var target = event.target; // only care about dot clicks if ( target.nodeName != 'LI' ) { @@ -4430,7 +4452,7 @@ Flickity.prototype.remove = function( elems ) { cell = cells[i]; cell.remove(); // remove item from collection - utils.removeFrom( cell, this.cells ); + utils.removeFrom( this.cells, cell ); } if ( cells.length ) { @@ -4479,7 +4501,7 @@ Flickity.prototype.cellChange = function( changedCellIndex ) { this._positionCells( changedCellIndex ); this._getWrapShiftCells(); - this.setContainerSize(); + this.setGallerySize(); // position slider if ( this.options.freeScroll ) { this.positionSlider(); @@ -4532,7 +4554,7 @@ return Flickity; }); /*! - * Flickity asNavFor v0.1.1 + * Flickity asNavFor v1.0.1 * enable asNavFor for Flickity */ @@ -4556,7 +4578,7 @@ return Flickity; // CommonJS module.exports = factory( window, - require('dessandro-classie'), + require('desandro-classie'), require('flickity'), require('fizzy-ui-utils') ); @@ -4610,7 +4632,7 @@ Flickity.prototype.setNavCompanion = function( elem ) { this.onNavCompanionSelect = function() { _this.navCompanionSelect(); }; - companion.on( 'select', this.onNavCompanionSelect ); + companion.on( 'cellSelect', this.onNavCompanionSelect ); // click this.on( 'staticClick', this.onNavStaticClick ); @@ -4645,9 +4667,9 @@ Flickity.prototype.removeNavSelectedElement = function() { delete this.navSelectedElement; }; -Flickity.prototype.onNavStaticClick = function( event, pointer, clickedCellIndex ) { - if ( typeof clickedCellIndex == 'number' ) { - this.navCompanion.select( clickedCellIndex ); +Flickity.prototype.onNavStaticClick = function( event, pointer, cellElement, cellIndex ) { + if ( typeof cellIndex == 'number' ) { + this.navCompanion.select( cellIndex ); } }; @@ -4659,7 +4681,7 @@ Flickity.prototype.destroyAsNavFor = function() { if ( !this.navCompanion ) { return; } - this.navCompanion.off( 'select', this.onNavCompanionSelect ); + this.navCompanion.off( 'cellSelect', this.onNavCompanionSelect ); this.off( 'staticClick', this.onNavStaticClick ); delete this.navCompanion; }; @@ -5007,7 +5029,7 @@ function makeArray( obj ) { }); /*! - * Flickity imagesLoaded v0.1.2 + * Flickity imagesLoaded v1.0.0 * enables imagesLoaded option for Flickity */ @@ -5022,30 +5044,27 @@ function makeArray( obj ) { // AMD define( [ 'flickity/js/index', - 'imagesloaded/imagesloaded', - 'fizzy-ui-utils/utils' - ], function( Flickity, imagesLoaded, utils ) { - return factory( window, Flickity, imagesLoaded, utils ); + 'imagesloaded/imagesloaded' + ], function( Flickity, imagesLoaded ) { + return factory( window, Flickity, imagesLoaded ); }); } else if ( typeof exports == 'object' ) { // CommonJS module.exports = factory( window, require('flickity'), - require('imagesloaded'), - require('fizzy-ui-utils') + require('imagesloaded') ); } else { // browser global window.Flickity = factory( window, window.Flickity, - window.imagesLoaded, - window.fizzyUIUtils + window.imagesLoaded ); } -}( window, function factory( window, Flickity, imagesLoaded, utils ) { +}( window, function factory( window, Flickity, imagesLoaded ) { Flickity.createMethods.push('_createImagesLoaded'); @@ -5060,12 +5079,8 @@ Flickity.prototype.imagesLoaded = function() { } var _this = this; function onImagesLoadedProgress( instance, image ) { - // check if image is a cell - var cell = _this.getCell( image.img ); - // otherwise get its parents - var cellElem = cell && cell.element || - utils.getParent( image.img, '.flickity-slider > *' ); - _this.cellSizeChange( cellElem ); + var cell = _this.getParentCell( image.img ); + _this.cellSizeChange( cell && cell.element ); } this.loader = imagesLoaded( this.slider ).on( 'progress', onImagesLoadedProgress ); }; |
