Make WordPress Core

Ticket #32802: masonry.patch

File masonry.patch, 181.5 KB (added by Ninos Ego, 10 years ago)
  • wp-includes/js/imagesloaded.js

     
     1/*!
     2 * imagesLoaded PACKAGED v3.1.8
     3 * JavaScript is all like "You images are done yet or what?"
     4 * MIT License
     5 */
     6
     7
     8/*!
     9 * EventEmitter v4.2.6 - git.io/ee
     10 * Oliver Caldwell
     11 * MIT license
     12 * @preserve
     13 */
     14
     15(function () {
     16       
     17
     18        /**
     19         * Class for managing events.
     20         * Can be extended to provide event functionality in other classes.
     21         *
     22         * @class EventEmitter Manages event registering and emitting.
     23         */
     24        function EventEmitter() {}
     25
     26        // Shortcuts to improve speed and size
     27        var proto = EventEmitter.prototype;
     28        var exports = this;
     29        var originalGlobalValue = exports.EventEmitter;
     30
     31        /**
     32         * Finds the index of the listener for the event in it's storage array.
     33         *
     34         * @param {Function[]} listeners Array of listeners to search through.
     35         * @param {Function} listener Method to look for.
     36         * @return {Number} Index of the specified listener, -1 if not found
     37         * @api private
     38         */
     39        function indexOfListener(listeners, listener) {
     40                var i = listeners.length;
     41                while (i--) {
     42                        if (listeners[i].listener === listener) {
     43                                return i;
     44                        }
     45                }
     46
     47                return -1;
     48        }
     49
     50        /**
     51         * Alias a method while keeping the context correct, to allow for overwriting of target method.
     52         *
     53         * @param {String} name The name of the target method.
     54         * @return {Function} The aliased method
     55         * @api private
     56         */
     57        function alias(name) {
     58                return function aliasClosure() {
     59                        return this[name].apply(this, arguments);
     60                };
     61        }
     62
     63        /**
     64         * Returns the listener array for the specified event.
     65         * Will initialise the event object and listener arrays if required.
     66         * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
     67         * Each property in the object response is an array of listener functions.
     68         *
     69         * @param {String|RegExp} evt Name of the event to return the listeners from.
     70         * @return {Function[]|Object} All listener functions for the event.
     71         */
     72        proto.getListeners = function getListeners(evt) {
     73                var events = this._getEvents();
     74                var response;
     75                var key;
     76
     77                // Return a concatenated array of all matching events if
     78                // the selector is a regular expression.
     79                if (typeof evt === 'object') {
     80                        response = {};
     81                        for (key in events) {
     82                                if (events.hasOwnProperty(key) && evt.test(key)) {
     83                                        response[key] = events[key];
     84                                }
     85                        }
     86                }
     87                else {
     88                        response = events[evt] || (events[evt] = []);
     89                }
     90
     91                return response;
     92        };
     93
     94        /**
     95         * Takes a list of listener objects and flattens it into a list of listener functions.
     96         *
     97         * @param {Object[]} listeners Raw listener objects.
     98         * @return {Function[]} Just the listener functions.
     99         */
     100        proto.flattenListeners = function flattenListeners(listeners) {
     101                var flatListeners = [];
     102                var i;
     103
     104                for (i = 0; i < listeners.length; i += 1) {
     105                        flatListeners.push(listeners[i].listener);
     106                }
     107
     108                return flatListeners;
     109        };
     110
     111        /**
     112         * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
     113         *
     114         * @param {String|RegExp} evt Name of the event to return the listeners from.
     115         * @return {Object} All listener functions for an event in an object.
     116         */
     117        proto.getListenersAsObject = function getListenersAsObject(evt) {
     118                var listeners = this.getListeners(evt);
     119                var response;
     120
     121                if (listeners instanceof Array) {
     122                        response = {};
     123                        response[evt] = listeners;
     124                }
     125
     126                return response || listeners;
     127        };
     128
     129        /**
     130         * Adds a listener function to the specified event.
     131         * The listener will not be added if it is a duplicate.
     132         * If the listener returns true then it will be removed after it is called.
     133         * If you pass a regular expression as the event name then the listener will be added to all events that match it.
     134         *
     135         * @param {String|RegExp} evt Name of the event to attach the listener to.
     136         * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
     137         * @return {Object} Current instance of EventEmitter for chaining.
     138         */
     139        proto.addListener = function addListener(evt, listener) {
     140                var listeners = this.getListenersAsObject(evt);
     141                var listenerIsWrapped = typeof listener === 'object';
     142                var key;
     143
     144                for (key in listeners) {
     145                        if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
     146                                listeners[key].push(listenerIsWrapped ? listener : {
     147                                        listener: listener,
     148                                        once: false
     149                                });
     150                        }
     151                }
     152
     153                return this;
     154        };
     155
     156        /**
     157         * Alias of addListener
     158         */
     159        proto.on = alias('addListener');
     160
     161        /**
     162         * Semi-alias of addListener. It will add a listener that will be
     163         * automatically removed after it's first execution.
     164         *
     165         * @param {String|RegExp} evt Name of the event to attach the listener to.
     166         * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
     167         * @return {Object} Current instance of EventEmitter for chaining.
     168         */
     169        proto.addOnceListener = function addOnceListener(evt, listener) {
     170                return this.addListener(evt, {
     171                        listener: listener,
     172                        once: true
     173                });
     174        };
     175
     176        /**
     177         * Alias of addOnceListener.
     178         */
     179        proto.once = alias('addOnceListener');
     180
     181        /**
     182         * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
     183         * You need to tell it what event names should be matched by a regex.
     184         *
     185         * @param {String} evt Name of the event to create.
     186         * @return {Object} Current instance of EventEmitter for chaining.
     187         */
     188        proto.defineEvent = function defineEvent(evt) {
     189                this.getListeners(evt);
     190                return this;
     191        };
     192
     193        /**
     194         * Uses defineEvent to define multiple events.
     195         *
     196         * @param {String[]} evts An array of event names to define.
     197         * @return {Object} Current instance of EventEmitter for chaining.
     198         */
     199        proto.defineEvents = function defineEvents(evts) {
     200                for (var i = 0; i < evts.length; i += 1) {
     201                        this.defineEvent(evts[i]);
     202                }
     203                return this;
     204        };
     205
     206        /**
     207         * Removes a listener function from the specified event.
     208         * When passed a regular expression as the event name, it will remove the listener from all events that match it.
     209         *
     210         * @param {String|RegExp} evt Name of the event to remove the listener from.
     211         * @param {Function} listener Method to remove from the event.
     212         * @return {Object} Current instance of EventEmitter for chaining.
     213         */
     214        proto.removeListener = function removeListener(evt, listener) {
     215                var listeners = this.getListenersAsObject(evt);
     216                var index;
     217                var key;
     218
     219                for (key in listeners) {
     220                        if (listeners.hasOwnProperty(key)) {
     221                                index = indexOfListener(listeners[key], listener);
     222
     223                                if (index !== -1) {
     224                                        listeners[key].splice(index, 1);
     225                                }
     226                        }
     227                }
     228
     229                return this;
     230        };
     231
     232        /**
     233         * Alias of removeListener
     234         */
     235        proto.off = alias('removeListener');
     236
     237        /**
     238         * Adds listeners in bulk using the manipulateListeners method.
     239         * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
     240         * You can also pass it a regular expression to add the array of listeners to all events that match it.
     241         * Yeah, this function does quite a bit. That's probably a bad thing.
     242         *
     243         * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
     244         * @param {Function[]} [listeners] An optional array of listener functions to add.
     245         * @return {Object} Current instance of EventEmitter for chaining.
     246         */
     247        proto.addListeners = function addListeners(evt, listeners) {
     248                // Pass through to manipulateListeners
     249                return this.manipulateListeners(false, evt, listeners);
     250        };
     251
     252        /**
     253         * Removes listeners in bulk using the manipulateListeners method.
     254         * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
     255         * You can also pass it an event name and an array of listeners to be removed.
     256         * You can also pass it a regular expression to remove the listeners from all events that match it.
     257         *
     258         * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
     259         * @param {Function[]} [listeners] An optional array of listener functions to remove.
     260         * @return {Object} Current instance of EventEmitter for chaining.
     261         */
     262        proto.removeListeners = function removeListeners(evt, listeners) {
     263                // Pass through to manipulateListeners
     264                return this.manipulateListeners(true, evt, listeners);
     265        };
     266
     267        /**
     268         * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
     269         * The first argument will determine if the listeners are removed (true) or added (false).
     270         * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
     271         * You can also pass it an event name and an array of listeners to be added/removed.
     272         * You can also pass it a regular expression to manipulate the listeners of all events that match it.
     273         *
     274         * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
     275         * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
     276         * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
     277         * @return {Object} Current instance of EventEmitter for chaining.
     278         */
     279        proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
     280                var i;
     281                var value;
     282                var single = remove ? this.removeListener : this.addListener;
     283                var multiple = remove ? this.removeListeners : this.addListeners;
     284
     285                // If evt is an object then pass each of it's properties to this method
     286                if (typeof evt === 'object' && !(evt instanceof RegExp)) {
     287                        for (i in evt) {
     288                                if (evt.hasOwnProperty(i) && (value = evt[i])) {
     289                                        // Pass the single listener straight through to the singular method
     290                                        if (typeof value === 'function') {
     291                                                single.call(this, i, value);
     292                                        }
     293                                        else {
     294                                                // Otherwise pass back to the multiple function
     295                                                multiple.call(this, i, value);
     296                                        }
     297                                }
     298                        }
     299                }
     300                else {
     301                        // So evt must be a string
     302                        // And listeners must be an array of listeners
     303                        // Loop over it and pass each one to the multiple method
     304                        i = listeners.length;
     305                        while (i--) {
     306                                single.call(this, evt, listeners[i]);
     307                        }
     308                }
     309
     310                return this;
     311        };
     312
     313        /**
     314         * Removes all listeners from a specified event.
     315         * If you do not specify an event then all listeners will be removed.
     316         * That means every event will be emptied.
     317         * You can also pass a regex to remove all events that match it.
     318         *
     319         * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
     320         * @return {Object} Current instance of EventEmitter for chaining.
     321         */
     322        proto.removeEvent = function removeEvent(evt) {
     323                var type = typeof evt;
     324                var events = this._getEvents();
     325                var key;
     326
     327                // Remove different things depending on the state of evt
     328                if (type === 'string') {
     329                        // Remove all listeners for the specified event
     330                        delete events[evt];
     331                }
     332                else if (type === 'object') {
     333                        // Remove all events matching the regex.
     334                        for (key in events) {
     335                                if (events.hasOwnProperty(key) && evt.test(key)) {
     336                                        delete events[key];
     337                                }
     338                        }
     339                }
     340                else {
     341                        // Remove all listeners in all events
     342                        delete this._events;
     343                }
     344
     345                return this;
     346        };
     347
     348        /**
     349         * Alias of removeEvent.
     350         *
     351         * Added to mirror the node API.
     352         */
     353        proto.removeAllListeners = alias('removeEvent');
     354
     355        /**
     356         * Emits an event of your choice.
     357         * When emitted, every listener attached to that event will be executed.
     358         * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
     359         * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
     360         * So they will not arrive within the array on the other side, they will be separate.
     361         * You can also pass a regular expression to emit to all events that match it.
     362         *
     363         * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
     364         * @param {Array} [args] Optional array of arguments to be passed to each listener.
     365         * @return {Object} Current instance of EventEmitter for chaining.
     366         */
     367        proto.emitEvent = function emitEvent(evt, args) {
     368                var listeners = this.getListenersAsObject(evt);
     369                var listener;
     370                var i;
     371                var key;
     372                var response;
     373
     374                for (key in listeners) {
     375                        if (listeners.hasOwnProperty(key)) {
     376                                i = listeners[key].length;
     377
     378                                while (i--) {
     379                                        // If the listener returns true then it shall be removed from the event
     380                                        // The function is executed either with a basic call or an apply if there is an args array
     381                                        listener = listeners[key][i];
     382
     383                                        if (listener.once === true) {
     384                                                this.removeListener(evt, listener.listener);
     385                                        }
     386
     387                                        response = listener.listener.apply(this, args || []);
     388
     389                                        if (response === this._getOnceReturnValue()) {
     390                                                this.removeListener(evt, listener.listener);
     391                                        }
     392                                }
     393                        }
     394                }
     395
     396                return this;
     397        };
     398
     399        /**
     400         * Alias of emitEvent
     401         */
     402        proto.trigger = alias('emitEvent');
     403
     404        /**
     405         * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
     406         * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
     407         *
     408         * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
     409         * @param {...*} Optional additional arguments to be passed to each listener.
     410         * @return {Object} Current instance of EventEmitter for chaining.
     411         */
     412        proto.emit = function emit(evt) {
     413                var args = Array.prototype.slice.call(arguments, 1);
     414                return this.emitEvent(evt, args);
     415        };
     416
     417        /**
     418         * Sets the current value to check against when executing listeners. If a
     419         * listeners return value matches the one set here then it will be removed
     420         * after execution. This value defaults to true.
     421         *
     422         * @param {*} value The new value to check for when executing listeners.
     423         * @return {Object} Current instance of EventEmitter for chaining.
     424         */
     425        proto.setOnceReturnValue = function setOnceReturnValue(value) {
     426                this._onceReturnValue = value;
     427                return this;
     428        };
     429
     430        /**
     431         * Fetches the current value to check against when executing listeners. If
     432         * the listeners return value matches this one then it should be removed
     433         * automatically. It will return true by default.
     434         *
     435         * @return {*|Boolean} The current value to check for or the default, true.
     436         * @api private
     437         */
     438        proto._getOnceReturnValue = function _getOnceReturnValue() {
     439                if (this.hasOwnProperty('_onceReturnValue')) {
     440                        return this._onceReturnValue;
     441                }
     442                else {
     443                        return true;
     444                }
     445        };
     446
     447        /**
     448         * Fetches the events object and creates one if required.
     449         *
     450         * @return {Object} The events storage object.
     451         * @api private
     452         */
     453        proto._getEvents = function _getEvents() {
     454                return this._events || (this._events = {});
     455        };
     456
     457        /**
     458         * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
     459         *
     460         * @return {Function} Non conflicting EventEmitter class.
     461         */
     462        EventEmitter.noConflict = function noConflict() {
     463                exports.EventEmitter = originalGlobalValue;
     464                return EventEmitter;
     465        };
     466
     467        // Expose the class either via AMD, CommonJS or the global object
     468        if (typeof define === 'function' && define.amd) {
     469                define('eventEmitter/EventEmitter',[],function () {
     470                        return EventEmitter;
     471                });
     472        }
     473        else if (typeof module === 'object' && module.exports){
     474                module.exports = EventEmitter;
     475        }
     476        else {
     477                this.EventEmitter = EventEmitter;
     478        }
     479}.call(this));
     480
     481/*!
     482 * eventie v1.0.4
     483 * event binding helper
     484 *   eventie.bind( elem, 'click', myFn )
     485 *   eventie.unbind( elem, 'click', myFn )
     486 */
     487
     488/*jshint browser: true, undef: true, unused: true */
     489/*global define: false */
     490
     491( function( window ) {
     492
     493
     494
     495var docElem = document.documentElement;
     496
     497var bind = function() {};
     498
     499function getIEEvent( obj ) {
     500  var event = window.event;
     501  // add event.target
     502  event.target = event.target || event.srcElement || obj;
     503  return event;
     504}
     505
     506if ( docElem.addEventListener ) {
     507  bind = function( obj, type, fn ) {
     508    obj.addEventListener( type, fn, false );
     509  };
     510} else if ( docElem.attachEvent ) {
     511  bind = function( obj, type, fn ) {
     512    obj[ type + fn ] = fn.handleEvent ?
     513      function() {
     514        var event = getIEEvent( obj );
     515        fn.handleEvent.call( fn, event );
     516      } :
     517      function() {
     518        var event = getIEEvent( obj );
     519        fn.call( obj, event );
     520      };
     521    obj.attachEvent( "on" + type, obj[ type + fn ] );
     522  };
     523}
     524
     525var unbind = function() {};
     526
     527if ( docElem.removeEventListener ) {
     528  unbind = function( obj, type, fn ) {
     529    obj.removeEventListener( type, fn, false );
     530  };
     531} else if ( docElem.detachEvent ) {
     532  unbind = function( obj, type, fn ) {
     533    obj.detachEvent( "on" + type, obj[ type + fn ] );
     534    try {
     535      delete obj[ type + fn ];
     536    } catch ( err ) {
     537      // can't delete window object properties
     538      obj[ type + fn ] = undefined;
     539    }
     540  };
     541}
     542
     543var eventie = {
     544  bind: bind,
     545  unbind: unbind
     546};
     547
     548// transport
     549if ( typeof define === 'function' && define.amd ) {
     550  // AMD
     551  define( 'eventie/eventie',eventie );
     552} else {
     553  // browser global
     554  window.eventie = eventie;
     555}
     556
     557})( this );
     558
     559/*!
     560 * imagesLoaded v3.1.8
     561 * JavaScript is all like "You images are done yet or what?"
     562 * MIT License
     563 */
     564
     565( function( window, factory ) {
     566  // universal module definition
     567
     568  /*global define: false, module: false, require: false */
     569
     570  if ( typeof define === 'function' && define.amd ) {
     571    // AMD
     572    define( [
     573      'eventEmitter/EventEmitter',
     574      'eventie/eventie'
     575    ], function( EventEmitter, eventie ) {
     576      return factory( window, EventEmitter, eventie );
     577    });
     578  } else if ( typeof exports === 'object' ) {
     579    // CommonJS
     580    module.exports = factory(
     581      window,
     582      require('wolfy87-eventemitter'),
     583      require('eventie')
     584    );
     585  } else {
     586    // browser global
     587    window.imagesLoaded = factory(
     588      window,
     589      window.EventEmitter,
     590      window.eventie
     591    );
     592  }
     593
     594})( window,
     595
     596// --------------------------  factory -------------------------- //
     597
     598function factory( window, EventEmitter, eventie ) {
     599
     600
     601
     602var $ = window.jQuery;
     603var console = window.console;
     604var hasConsole = typeof console !== 'undefined';
     605
     606// -------------------------- helpers -------------------------- //
     607
     608// extend objects
     609function extend( a, b ) {
     610  for ( var prop in b ) {
     611    a[ prop ] = b[ prop ];
     612  }
     613  return a;
     614}
     615
     616var objToString = Object.prototype.toString;
     617function isArray( obj ) {
     618  return objToString.call( obj ) === '[object Array]';
     619}
     620
     621// turn element or nodeList into an array
     622function makeArray( obj ) {
     623  var ary = [];
     624  if ( isArray( obj ) ) {
     625    // use object if already an array
     626    ary = obj;
     627  } else if ( typeof obj.length === 'number' ) {
     628    // convert nodeList to array
     629    for ( var i=0, len = obj.length; i < len; i++ ) {
     630      ary.push( obj[i] );
     631    }
     632  } else {
     633    // array of single index
     634    ary.push( obj );
     635  }
     636  return ary;
     637}
     638
     639  // -------------------------- imagesLoaded -------------------------- //
     640
     641  /**
     642   * @param {Array, Element, NodeList, String} elem
     643   * @param {Object or Function} options - if function, use as callback
     644   * @param {Function} onAlways - callback function
     645   */
     646  function ImagesLoaded( elem, options, onAlways ) {
     647    // coerce ImagesLoaded() without new, to be new ImagesLoaded()
     648    if ( !( this instanceof ImagesLoaded ) ) {
     649      return new ImagesLoaded( elem, options );
     650    }
     651    // use elem as selector string
     652    if ( typeof elem === 'string' ) {
     653      elem = document.querySelectorAll( elem );
     654    }
     655
     656    this.elements = makeArray( elem );
     657    this.options = extend( {}, this.options );
     658
     659    if ( typeof options === 'function' ) {
     660      onAlways = options;
     661    } else {
     662      extend( this.options, options );
     663    }
     664
     665    if ( onAlways ) {
     666      this.on( 'always', onAlways );
     667    }
     668
     669    this.getImages();
     670
     671    if ( $ ) {
     672      // add jQuery Deferred object
     673      this.jqDeferred = new $.Deferred();
     674    }
     675
     676    // HACK check async to allow time to bind listeners
     677    var _this = this;
     678    setTimeout( function() {
     679      _this.check();
     680    });
     681  }
     682
     683  ImagesLoaded.prototype = new EventEmitter();
     684
     685  ImagesLoaded.prototype.options = {};
     686
     687  ImagesLoaded.prototype.getImages = function() {
     688    this.images = [];
     689
     690    // filter & find items if we have an item selector
     691    for ( var i=0, len = this.elements.length; i < len; i++ ) {
     692      var elem = this.elements[i];
     693      // filter siblings
     694      if ( elem.nodeName === 'IMG' ) {
     695        this.addImage( elem );
     696      }
     697      // find children
     698      // no non-element nodes, #143
     699      var nodeType = elem.nodeType;
     700      if ( !nodeType || !( nodeType === 1 || nodeType === 9 || nodeType === 11 ) ) {
     701        continue;
     702      }
     703      var childElems = elem.querySelectorAll('img');
     704      // concat childElems to filterFound array
     705      for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
     706        var img = childElems[j];
     707        this.addImage( img );
     708      }
     709    }
     710  };
     711
     712  /**
     713   * @param {Image} img
     714   */
     715  ImagesLoaded.prototype.addImage = function( img ) {
     716    var loadingImage = new LoadingImage( img );
     717    this.images.push( loadingImage );
     718  };
     719
     720  ImagesLoaded.prototype.check = function() {
     721    var _this = this;
     722    var checkedCount = 0;
     723    var length = this.images.length;
     724    this.hasAnyBroken = false;
     725    // complete if no images
     726    if ( !length ) {
     727      this.complete();
     728      return;
     729    }
     730
     731    function onConfirm( image, message ) {
     732      if ( _this.options.debug && hasConsole ) {
     733        console.log( 'confirm', image, message );
     734      }
     735
     736      _this.progress( image );
     737      checkedCount++;
     738      if ( checkedCount === length ) {
     739        _this.complete();
     740      }
     741      return true; // bind once
     742    }
     743
     744    for ( var i=0; i < length; i++ ) {
     745      var loadingImage = this.images[i];
     746      loadingImage.on( 'confirm', onConfirm );
     747      loadingImage.check();
     748    }
     749  };
     750
     751  ImagesLoaded.prototype.progress = function( image ) {
     752    this.hasAnyBroken = this.hasAnyBroken || !image.isLoaded;
     753    // HACK - Chrome triggers event before object properties have changed. #83
     754    var _this = this;
     755    setTimeout( function() {
     756      _this.emit( 'progress', _this, image );
     757      if ( _this.jqDeferred && _this.jqDeferred.notify ) {
     758        _this.jqDeferred.notify( _this, image );
     759      }
     760    });
     761  };
     762
     763  ImagesLoaded.prototype.complete = function() {
     764    var eventName = this.hasAnyBroken ? 'fail' : 'done';
     765    this.isComplete = true;
     766    var _this = this;
     767    // HACK - another setTimeout so that confirm happens after progress
     768    setTimeout( function() {
     769      _this.emit( eventName, _this );
     770      _this.emit( 'always', _this );
     771      if ( _this.jqDeferred ) {
     772        var jqMethod = _this.hasAnyBroken ? 'reject' : 'resolve';
     773        _this.jqDeferred[ jqMethod ]( _this );
     774      }
     775    });
     776  };
     777
     778  // -------------------------- jquery -------------------------- //
     779
     780  if ( $ ) {
     781    $.fn.imagesLoaded = function( options, callback ) {
     782      var instance = new ImagesLoaded( this, options, callback );
     783      return instance.jqDeferred.promise( $(this) );
     784    };
     785  }
     786
     787
     788  // --------------------------  -------------------------- //
     789
     790  function LoadingImage( img ) {
     791    this.img = img;
     792  }
     793
     794  LoadingImage.prototype = new EventEmitter();
     795
     796  LoadingImage.prototype.check = function() {
     797    // first check cached any previous images that have same src
     798    var resource = cache[ this.img.src ] || new Resource( this.img.src );
     799    if ( resource.isConfirmed ) {
     800      this.confirm( resource.isLoaded, 'cached was confirmed' );
     801      return;
     802    }
     803
     804    // If complete is true and browser supports natural sizes,
     805    // try to check for image status manually.
     806    if ( this.img.complete && this.img.naturalWidth !== undefined ) {
     807      // report based on naturalWidth
     808      this.confirm( this.img.naturalWidth !== 0, 'naturalWidth' );
     809      return;
     810    }
     811
     812    // If none of the checks above matched, simulate loading on detached element.
     813    var _this = this;
     814    resource.on( 'confirm', function( resrc, message ) {
     815      _this.confirm( resrc.isLoaded, message );
     816      return true;
     817    });
     818
     819    resource.check();
     820  };
     821
     822  LoadingImage.prototype.confirm = function( isLoaded, message ) {
     823    this.isLoaded = isLoaded;
     824    this.emit( 'confirm', this, message );
     825  };
     826
     827  // -------------------------- Resource -------------------------- //
     828
     829  // Resource checks each src, only once
     830  // separate class from LoadingImage to prevent memory leaks. See #115
     831
     832  var cache = {};
     833
     834  function Resource( src ) {
     835    this.src = src;
     836    // add to cache
     837    cache[ src ] = this;
     838  }
     839
     840  Resource.prototype = new EventEmitter();
     841
     842  Resource.prototype.check = function() {
     843    // only trigger checking once
     844    if ( this.isChecked ) {
     845      return;
     846    }
     847    // simulate loading on detached element
     848    var proxyImage = new Image();
     849    eventie.bind( proxyImage, 'load', this );
     850    eventie.bind( proxyImage, 'error', this );
     851    proxyImage.src = this.src;
     852    // set flag
     853    this.isChecked = true;
     854  };
     855
     856  // ----- events ----- //
     857
     858  // trigger specified handler for event type
     859  Resource.prototype.handleEvent = function( event ) {
     860    var method = 'on' + event.type;
     861    if ( this[ method ] ) {
     862      this[ method ]( event );
     863    }
     864  };
     865
     866  Resource.prototype.onload = function( event ) {
     867    this.confirm( true, 'onload' );
     868    this.unbindProxyEvents( event );
     869  };
     870
     871  Resource.prototype.onerror = function( event ) {
     872    this.confirm( false, 'onerror' );
     873    this.unbindProxyEvents( event );
     874  };
     875
     876  // ----- confirm ----- //
     877
     878  Resource.prototype.confirm = function( isLoaded, message ) {
     879    this.isConfirmed = true;
     880    this.isLoaded = isLoaded;
     881    this.emit( 'confirm', this, message );
     882  };
     883
     884  Resource.prototype.unbindProxyEvents = function( event ) {
     885    eventie.unbind( event.target, 'load', this );
     886    eventie.unbind( event.target, 'error', this );
     887  };
     888
     889  // -----  ----- //
     890
     891  return ImagesLoaded;
     892
     893});
  • wp-includes/js/imagesloaded.min.js

     
     1/*!
     2 * imagesLoaded PACKAGED v3.1.8
     3 * JavaScript is all like "You images are done yet or what?"
     4 * MIT License
     5 */
     6
     7(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
     8 No newline at end of file
  • wp-includes/js/masonry.js

     
     1/*!
     2 * Masonry PACKAGED v3.3.0
     3 * Cascading grid layout library
     4 * http://masonry.desandro.com
     5 * MIT License
     6 * by David DeSandro
     7 */
     8
     9/**
     10 * Bridget makes jQuery widgets
     11 * v1.1.0
     12 * MIT license
     13 */
     14
     15( function( window ) {
     16
     17
     18
     19// -------------------------- utils -------------------------- //
     20
     21var slice = Array.prototype.slice;
     22
     23function noop() {}
     24
     25// -------------------------- definition -------------------------- //
     26
     27function defineBridget( $ ) {
     28
     29// bail if no jQuery
     30if ( !$ ) {
     31  return;
     32}
     33
     34// -------------------------- addOptionMethod -------------------------- //
     35
     36/**
     37 * adds option method -> $().plugin('option', {...})
     38 * @param {Function} PluginClass - constructor class
     39 */
     40function addOptionMethod( PluginClass ) {
     41  // don't overwrite original option method
     42  if ( PluginClass.prototype.option ) {
     43    return;
     44  }
     45
     46  // option setter
     47  PluginClass.prototype.option = function( opts ) {
     48    // bail out if not an object
     49    if ( !$.isPlainObject( opts ) ){
     50      return;
     51    }
     52    this.options = $.extend( true, this.options, opts );
     53  };
     54}
     55
     56// -------------------------- plugin bridge -------------------------- //
     57
     58// helper function for logging errors
     59// $.error breaks jQuery chaining
     60var logError = typeof console === 'undefined' ? noop :
     61  function( message ) {
     62    console.error( message );
     63  };
     64
     65/**
     66 * jQuery plugin bridge, access methods like $elem.plugin('method')
     67 * @param {String} namespace - plugin name
     68 * @param {Function} PluginClass - constructor class
     69 */
     70function bridge( namespace, PluginClass ) {
     71  // add to jQuery fn namespace
     72  $.fn[ namespace ] = function( options ) {
     73    if ( typeof options === 'string' ) {
     74      // call plugin method when first argument is a string
     75      // get arguments for method
     76      var args = slice.call( arguments, 1 );
     77
     78      for ( var i=0, len = this.length; i < len; i++ ) {
     79        var elem = this[i];
     80        var instance = $.data( elem, namespace );
     81        if ( !instance ) {
     82          logError( "cannot call methods on " + namespace + " prior to initialization; " +
     83            "attempted to call '" + options + "'" );
     84          continue;
     85        }
     86        if ( !$.isFunction( instance[options] ) || options.charAt(0) === '_' ) {
     87          logError( "no such method '" + options + "' for " + namespace + " instance" );
     88          continue;
     89        }
     90
     91        // trigger method with arguments
     92        var returnValue = instance[ options ].apply( instance, args );
     93
     94        // break look and return first value if provided
     95        if ( returnValue !== undefined ) {
     96          return returnValue;
     97        }
     98      }
     99      // return this if no return value
     100      return this;
     101    } else {
     102      return this.each( function() {
     103        var instance = $.data( this, namespace );
     104        if ( instance ) {
     105          // apply options & init
     106          instance.option( options );
     107          instance._init();
     108        } else {
     109          // initialize new instance
     110          instance = new PluginClass( this, options );
     111          $.data( this, namespace, instance );
     112        }
     113      });
     114    }
     115  };
     116
     117}
     118
     119// -------------------------- bridget -------------------------- //
     120
     121/**
     122 * converts a Prototypical class into a proper jQuery plugin
     123 *   the class must have a ._init method
     124 * @param {String} namespace - plugin name, used in $().pluginName
     125 * @param {Function} PluginClass - constructor class
     126 */
     127$.bridget = function( namespace, PluginClass ) {
     128  addOptionMethod( PluginClass );
     129  bridge( namespace, PluginClass );
     130};
     131
     132return $.bridget;
     133
     134}
     135
     136// transport
     137if ( typeof define === 'function' && define.amd ) {
     138  // AMD
     139  define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget );
     140} else if ( typeof exports === 'object' ) {
     141  defineBridget( require('jquery') );
     142} else {
     143  // get jquery from browser global
     144  defineBridget( window.jQuery );
     145}
     146
     147})( window );
     148
     149/*!
     150 * eventie v1.0.6
     151 * event binding helper
     152 *   eventie.bind( elem, 'click', myFn )
     153 *   eventie.unbind( elem, 'click', myFn )
     154 * MIT license
     155 */
     156
     157/*jshint browser: true, undef: true, unused: true */
     158/*global define: false, module: false */
     159
     160( function( window ) {
     161
     162
     163
     164var docElem = document.documentElement;
     165
     166var bind = function() {};
     167
     168function getIEEvent( obj ) {
     169  var event = window.event;
     170  // add event.target
     171  event.target = event.target || event.srcElement || obj;
     172  return event;
     173}
     174
     175if ( docElem.addEventListener ) {
     176  bind = function( obj, type, fn ) {
     177    obj.addEventListener( type, fn, false );
     178  };
     179} else if ( docElem.attachEvent ) {
     180  bind = function( obj, type, fn ) {
     181    obj[ type + fn ] = fn.handleEvent ?
     182      function() {
     183        var event = getIEEvent( obj );
     184        fn.handleEvent.call( fn, event );
     185      } :
     186      function() {
     187        var event = getIEEvent( obj );
     188        fn.call( obj, event );
     189      };
     190    obj.attachEvent( "on" + type, obj[ type + fn ] );
     191  };
     192}
     193
     194var unbind = function() {};
     195
     196if ( docElem.removeEventListener ) {
     197  unbind = function( obj, type, fn ) {
     198    obj.removeEventListener( type, fn, false );
     199  };
     200} else if ( docElem.detachEvent ) {
     201  unbind = function( obj, type, fn ) {
     202    obj.detachEvent( "on" + type, obj[ type + fn ] );
     203    try {
     204      delete obj[ type + fn ];
     205    } catch ( err ) {
     206      // can't delete window object properties
     207      obj[ type + fn ] = undefined;
     208    }
     209  };
     210}
     211
     212var eventie = {
     213  bind: bind,
     214  unbind: unbind
     215};
     216
     217// ----- module definition ----- //
     218
     219if ( typeof define === 'function' && define.amd ) {
     220  // AMD
     221  define( 'eventie/eventie',eventie );
     222} else if ( typeof exports === 'object' ) {
     223  // CommonJS
     224  module.exports = eventie;
     225} else {
     226  // browser global
     227  window.eventie = eventie;
     228}
     229
     230})( window );
     231
     232/*!
     233 * EventEmitter v4.2.11 - git.io/ee
     234 * Unlicense - http://unlicense.org/
     235 * Oliver Caldwell - http://oli.me.uk/
     236 * @preserve
     237 */
     238
     239;(function () {
     240   
     241
     242    /**
     243     * Class for managing events.
     244     * Can be extended to provide event functionality in other classes.
     245     *
     246     * @class EventEmitter Manages event registering and emitting.
     247     */
     248    function EventEmitter() {}
     249
     250    // Shortcuts to improve speed and size
     251    var proto = EventEmitter.prototype;
     252    var exports = this;
     253    var originalGlobalValue = exports.EventEmitter;
     254
     255    /**
     256     * Finds the index of the listener for the event in its storage array.
     257     *
     258     * @param {Function[]} listeners Array of listeners to search through.
     259     * @param {Function} listener Method to look for.
     260     * @return {Number} Index of the specified listener, -1 if not found
     261     * @api private
     262     */
     263    function indexOfListener(listeners, listener) {
     264        var i = listeners.length;
     265        while (i--) {
     266            if (listeners[i].listener === listener) {
     267                return i;
     268            }
     269        }
     270
     271        return -1;
     272    }
     273
     274    /**
     275     * Alias a method while keeping the context correct, to allow for overwriting of target method.
     276     *
     277     * @param {String} name The name of the target method.
     278     * @return {Function} The aliased method
     279     * @api private
     280     */
     281    function alias(name) {
     282        return function aliasClosure() {
     283            return this[name].apply(this, arguments);
     284        };
     285    }
     286
     287    /**
     288     * Returns the listener array for the specified event.
     289     * Will initialise the event object and listener arrays if required.
     290     * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
     291     * Each property in the object response is an array of listener functions.
     292     *
     293     * @param {String|RegExp} evt Name of the event to return the listeners from.
     294     * @return {Function[]|Object} All listener functions for the event.
     295     */
     296    proto.getListeners = function getListeners(evt) {
     297        var events = this._getEvents();
     298        var response;
     299        var key;
     300
     301        // Return a concatenated array of all matching events if
     302        // the selector is a regular expression.
     303        if (evt instanceof RegExp) {
     304            response = {};
     305            for (key in events) {
     306                if (events.hasOwnProperty(key) && evt.test(key)) {
     307                    response[key] = events[key];
     308                }
     309            }
     310        }
     311        else {
     312            response = events[evt] || (events[evt] = []);
     313        }
     314
     315        return response;
     316    };
     317
     318    /**
     319     * Takes a list of listener objects and flattens it into a list of listener functions.
     320     *
     321     * @param {Object[]} listeners Raw listener objects.
     322     * @return {Function[]} Just the listener functions.
     323     */
     324    proto.flattenListeners = function flattenListeners(listeners) {
     325        var flatListeners = [];
     326        var i;
     327
     328        for (i = 0; i < listeners.length; i += 1) {
     329            flatListeners.push(listeners[i].listener);
     330        }
     331
     332        return flatListeners;
     333    };
     334
     335    /**
     336     * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
     337     *
     338     * @param {String|RegExp} evt Name of the event to return the listeners from.
     339     * @return {Object} All listener functions for an event in an object.
     340     */
     341    proto.getListenersAsObject = function getListenersAsObject(evt) {
     342        var listeners = this.getListeners(evt);
     343        var response;
     344
     345        if (listeners instanceof Array) {
     346            response = {};
     347            response[evt] = listeners;
     348        }
     349
     350        return response || listeners;
     351    };
     352
     353    /**
     354     * Adds a listener function to the specified event.
     355     * The listener will not be added if it is a duplicate.
     356     * If the listener returns true then it will be removed after it is called.
     357     * If you pass a regular expression as the event name then the listener will be added to all events that match it.
     358     *
     359     * @param {String|RegExp} evt Name of the event to attach the listener to.
     360     * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
     361     * @return {Object} Current instance of EventEmitter for chaining.
     362     */
     363    proto.addListener = function addListener(evt, listener) {
     364        var listeners = this.getListenersAsObject(evt);
     365        var listenerIsWrapped = typeof listener === 'object';
     366        var key;
     367
     368        for (key in listeners) {
     369            if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
     370                listeners[key].push(listenerIsWrapped ? listener : {
     371                    listener: listener,
     372                    once: false
     373                });
     374            }
     375        }
     376
     377        return this;
     378    };
     379
     380    /**
     381     * Alias of addListener
     382     */
     383    proto.on = alias('addListener');
     384
     385    /**
     386     * Semi-alias of addListener. It will add a listener that will be
     387     * automatically removed after its first execution.
     388     *
     389     * @param {String|RegExp} evt Name of the event to attach the listener to.
     390     * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
     391     * @return {Object} Current instance of EventEmitter for chaining.
     392     */
     393    proto.addOnceListener = function addOnceListener(evt, listener) {
     394        return this.addListener(evt, {
     395            listener: listener,
     396            once: true
     397        });
     398    };
     399
     400    /**
     401     * Alias of addOnceListener.
     402     */
     403    proto.once = alias('addOnceListener');
     404
     405    /**
     406     * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
     407     * You need to tell it what event names should be matched by a regex.
     408     *
     409     * @param {String} evt Name of the event to create.
     410     * @return {Object} Current instance of EventEmitter for chaining.
     411     */
     412    proto.defineEvent = function defineEvent(evt) {
     413        this.getListeners(evt);
     414        return this;
     415    };
     416
     417    /**
     418     * Uses defineEvent to define multiple events.
     419     *
     420     * @param {String[]} evts An array of event names to define.
     421     * @return {Object} Current instance of EventEmitter for chaining.
     422     */
     423    proto.defineEvents = function defineEvents(evts) {
     424        for (var i = 0; i < evts.length; i += 1) {
     425            this.defineEvent(evts[i]);
     426        }
     427        return this;
     428    };
     429
     430    /**
     431     * Removes a listener function from the specified event.
     432     * When passed a regular expression as the event name, it will remove the listener from all events that match it.
     433     *
     434     * @param {String|RegExp} evt Name of the event to remove the listener from.
     435     * @param {Function} listener Method to remove from the event.
     436     * @return {Object} Current instance of EventEmitter for chaining.
     437     */
     438    proto.removeListener = function removeListener(evt, listener) {
     439        var listeners = this.getListenersAsObject(evt);
     440        var index;
     441        var key;
     442
     443        for (key in listeners) {
     444            if (listeners.hasOwnProperty(key)) {
     445                index = indexOfListener(listeners[key], listener);
     446
     447                if (index !== -1) {
     448                    listeners[key].splice(index, 1);
     449                }
     450            }
     451        }
     452
     453        return this;
     454    };
     455
     456    /**
     457     * Alias of removeListener
     458     */
     459    proto.off = alias('removeListener');
     460
     461    /**
     462     * Adds listeners in bulk using the manipulateListeners method.
     463     * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
     464     * You can also pass it a regular expression to add the array of listeners to all events that match it.
     465     * Yeah, this function does quite a bit. That's probably a bad thing.
     466     *
     467     * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
     468     * @param {Function[]} [listeners] An optional array of listener functions to add.
     469     * @return {Object} Current instance of EventEmitter for chaining.
     470     */
     471    proto.addListeners = function addListeners(evt, listeners) {
     472        // Pass through to manipulateListeners
     473        return this.manipulateListeners(false, evt, listeners);
     474    };
     475
     476    /**
     477     * Removes listeners in bulk using the manipulateListeners method.
     478     * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
     479     * You can also pass it an event name and an array of listeners to be removed.
     480     * You can also pass it a regular expression to remove the listeners from all events that match it.
     481     *
     482     * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
     483     * @param {Function[]} [listeners] An optional array of listener functions to remove.
     484     * @return {Object} Current instance of EventEmitter for chaining.
     485     */
     486    proto.removeListeners = function removeListeners(evt, listeners) {
     487        // Pass through to manipulateListeners
     488        return this.manipulateListeners(true, evt, listeners);
     489    };
     490
     491    /**
     492     * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
     493     * The first argument will determine if the listeners are removed (true) or added (false).
     494     * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
     495     * You can also pass it an event name and an array of listeners to be added/removed.
     496     * You can also pass it a regular expression to manipulate the listeners of all events that match it.
     497     *
     498     * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
     499     * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
     500     * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
     501     * @return {Object} Current instance of EventEmitter for chaining.
     502     */
     503    proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
     504        var i;
     505        var value;
     506        var single = remove ? this.removeListener : this.addListener;
     507        var multiple = remove ? this.removeListeners : this.addListeners;
     508
     509        // If evt is an object then pass each of its properties to this method
     510        if (typeof evt === 'object' && !(evt instanceof RegExp)) {
     511            for (i in evt) {
     512                if (evt.hasOwnProperty(i) && (value = evt[i])) {
     513                    // Pass the single listener straight through to the singular method
     514                    if (typeof value === 'function') {
     515                        single.call(this, i, value);
     516                    }
     517                    else {
     518                        // Otherwise pass back to the multiple function
     519                        multiple.call(this, i, value);
     520                    }
     521                }
     522            }
     523        }
     524        else {
     525            // So evt must be a string
     526            // And listeners must be an array of listeners
     527            // Loop over it and pass each one to the multiple method
     528            i = listeners.length;
     529            while (i--) {
     530                single.call(this, evt, listeners[i]);
     531            }
     532        }
     533
     534        return this;
     535    };
     536
     537    /**
     538     * Removes all listeners from a specified event.
     539     * If you do not specify an event then all listeners will be removed.
     540     * That means every event will be emptied.
     541     * You can also pass a regex to remove all events that match it.
     542     *
     543     * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
     544     * @return {Object} Current instance of EventEmitter for chaining.
     545     */
     546    proto.removeEvent = function removeEvent(evt) {
     547        var type = typeof evt;
     548        var events = this._getEvents();
     549        var key;
     550
     551        // Remove different things depending on the state of evt
     552        if (type === 'string') {
     553            // Remove all listeners for the specified event
     554            delete events[evt];
     555        }
     556        else if (evt instanceof RegExp) {
     557            // Remove all events matching the regex.
     558            for (key in events) {
     559                if (events.hasOwnProperty(key) && evt.test(key)) {
     560                    delete events[key];
     561                }
     562            }
     563        }
     564        else {
     565            // Remove all listeners in all events
     566            delete this._events;
     567        }
     568
     569        return this;
     570    };
     571
     572    /**
     573     * Alias of removeEvent.
     574     *
     575     * Added to mirror the node API.
     576     */
     577    proto.removeAllListeners = alias('removeEvent');
     578
     579    /**
     580     * Emits an event of your choice.
     581     * When emitted, every listener attached to that event will be executed.
     582     * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
     583     * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
     584     * So they will not arrive within the array on the other side, they will be separate.
     585     * You can also pass a regular expression to emit to all events that match it.
     586     *
     587     * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
     588     * @param {Array} [args] Optional array of arguments to be passed to each listener.
     589     * @return {Object} Current instance of EventEmitter for chaining.
     590     */
     591    proto.emitEvent = function emitEvent(evt, args) {
     592        var listeners = this.getListenersAsObject(evt);
     593        var listener;
     594        var i;
     595        var key;
     596        var response;
     597
     598        for (key in listeners) {
     599            if (listeners.hasOwnProperty(key)) {
     600                i = listeners[key].length;
     601
     602                while (i--) {
     603                    // If the listener returns true then it shall be removed from the event
     604                    // The function is executed either with a basic call or an apply if there is an args array
     605                    listener = listeners[key][i];
     606
     607                    if (listener.once === true) {
     608                        this.removeListener(evt, listener.listener);
     609                    }
     610
     611                    response = listener.listener.apply(this, args || []);
     612
     613                    if (response === this._getOnceReturnValue()) {
     614                        this.removeListener(evt, listener.listener);
     615                    }
     616                }
     617            }
     618        }
     619
     620        return this;
     621    };
     622
     623    /**
     624     * Alias of emitEvent
     625     */
     626    proto.trigger = alias('emitEvent');
     627
     628    /**
     629     * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
     630     * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
     631     *
     632     * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
     633     * @param {...*} Optional additional arguments to be passed to each listener.
     634     * @return {Object} Current instance of EventEmitter for chaining.
     635     */
     636    proto.emit = function emit(evt) {
     637        var args = Array.prototype.slice.call(arguments, 1);
     638        return this.emitEvent(evt, args);
     639    };
     640
     641    /**
     642     * Sets the current value to check against when executing listeners. If a
     643     * listeners return value matches the one set here then it will be removed
     644     * after execution. This value defaults to true.
     645     *
     646     * @param {*} value The new value to check for when executing listeners.
     647     * @return {Object} Current instance of EventEmitter for chaining.
     648     */
     649    proto.setOnceReturnValue = function setOnceReturnValue(value) {
     650        this._onceReturnValue = value;
     651        return this;
     652    };
     653
     654    /**
     655     * Fetches the current value to check against when executing listeners. If
     656     * the listeners return value matches this one then it should be removed
     657     * automatically. It will return true by default.
     658     *
     659     * @return {*|Boolean} The current value to check for or the default, true.
     660     * @api private
     661     */
     662    proto._getOnceReturnValue = function _getOnceReturnValue() {
     663        if (this.hasOwnProperty('_onceReturnValue')) {
     664            return this._onceReturnValue;
     665        }
     666        else {
     667            return true;
     668        }
     669    };
     670
     671    /**
     672     * Fetches the events object and creates one if required.
     673     *
     674     * @return {Object} The events storage object.
     675     * @api private
     676     */
     677    proto._getEvents = function _getEvents() {
     678        return this._events || (this._events = {});
     679    };
     680
     681    /**
     682     * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
     683     *
     684     * @return {Function} Non conflicting EventEmitter class.
     685     */
     686    EventEmitter.noConflict = function noConflict() {
     687        exports.EventEmitter = originalGlobalValue;
     688        return EventEmitter;
     689    };
     690
     691    // Expose the class either via AMD, CommonJS or the global object
     692    if (typeof define === 'function' && define.amd) {
     693        define('eventEmitter/EventEmitter',[],function () {
     694            return EventEmitter;
     695        });
     696    }
     697    else if (typeof module === 'object' && module.exports){
     698        module.exports = EventEmitter;
     699    }
     700    else {
     701        exports.EventEmitter = EventEmitter;
     702    }
     703}.call(this));
     704
     705/*!
     706 * getStyleProperty v1.0.4
     707 * original by kangax
     708 * http://perfectionkills.com/feature-testing-css-properties/
     709 * MIT license
     710 */
     711
     712/*jshint browser: true, strict: true, undef: true */
     713/*global define: false, exports: false, module: false */
     714
     715( function( window ) {
     716
     717
     718
     719var prefixes = 'Webkit Moz ms Ms O'.split(' ');
     720var docElemStyle = document.documentElement.style;
     721
     722function getStyleProperty( propName ) {
     723  if ( !propName ) {
     724    return;
     725  }
     726
     727  // test standard property first
     728  if ( typeof docElemStyle[ propName ] === 'string' ) {
     729    return propName;
     730  }
     731
     732  // capitalize
     733  propName = propName.charAt(0).toUpperCase() + propName.slice(1);
     734
     735  // test vendor specific properties
     736  var prefixed;
     737  for ( var i=0, len = prefixes.length; i < len; i++ ) {
     738    prefixed = prefixes[i] + propName;
     739    if ( typeof docElemStyle[ prefixed ] === 'string' ) {
     740      return prefixed;
     741    }
     742  }
     743}
     744
     745// transport
     746if ( typeof define === 'function' && define.amd ) {
     747  // AMD
     748  define( 'get-style-property/get-style-property',[],function() {
     749    return getStyleProperty;
     750  });
     751} else if ( typeof exports === 'object' ) {
     752  // CommonJS for Component
     753  module.exports = getStyleProperty;
     754} else {
     755  // browser global
     756  window.getStyleProperty = getStyleProperty;
     757}
     758
     759})( window );
     760
     761/*!
     762 * getSize v1.2.2
     763 * measure size of elements
     764 * MIT license
     765 */
     766
     767/*jshint browser: true, strict: true, undef: true, unused: true */
     768/*global define: false, exports: false, require: false, module: false, console: false */
     769
     770( function( window, undefined ) {
     771
     772
     773
     774// -------------------------- helpers -------------------------- //
     775
     776// get a number from a string, not a percentage
     777function getStyleSize( value ) {
     778  var num = parseFloat( value );
     779  // not a percent like '100%', and a number
     780  var isValid = value.indexOf('%') === -1 && !isNaN( num );
     781  return isValid && num;
     782}
     783
     784function noop() {}
     785
     786var logError = typeof console === 'undefined' ? noop :
     787  function( message ) {
     788    console.error( message );
     789  };
     790
     791// -------------------------- measurements -------------------------- //
     792
     793var measurements = [
     794  'paddingLeft',
     795  'paddingRight',
     796  'paddingTop',
     797  'paddingBottom',
     798  'marginLeft',
     799  'marginRight',
     800  'marginTop',
     801  'marginBottom',
     802  'borderLeftWidth',
     803  'borderRightWidth',
     804  'borderTopWidth',
     805  'borderBottomWidth'
     806];
     807
     808function getZeroSize() {
     809  var size = {
     810    width: 0,
     811    height: 0,
     812    innerWidth: 0,
     813    innerHeight: 0,
     814    outerWidth: 0,
     815    outerHeight: 0
     816  };
     817  for ( var i=0, len = measurements.length; i < len; i++ ) {
     818    var measurement = measurements[i];
     819    size[ measurement ] = 0;
     820  }
     821  return size;
     822}
     823
     824
     825
     826function defineGetSize( getStyleProperty ) {
     827
     828// -------------------------- setup -------------------------- //
     829
     830var isSetup = false;
     831
     832var getStyle, boxSizingProp, isBoxSizeOuter;
     833
     834/**
     835 * setup vars and functions
     836 * do it on initial getSize(), rather than on script load
     837 * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
     838 */
     839function setup() {
     840  // setup once
     841  if ( isSetup ) {
     842    return;
     843  }
     844  isSetup = true;
     845
     846  var getComputedStyle = window.getComputedStyle;
     847  getStyle = ( function() {
     848    var getStyleFn = getComputedStyle ?
     849      function( elem ) {
     850        return getComputedStyle( elem, null );
     851      } :
     852      function( elem ) {
     853        return elem.currentStyle;
     854      };
     855
     856      return function getStyle( elem ) {
     857        var style = getStyleFn( elem );
     858        if ( !style ) {
     859          logError( 'Style returned ' + style +
     860            '. Are you running this code in a hidden iframe on Firefox? ' +
     861            'See http://bit.ly/getsizebug1' );
     862        }
     863        return style;
     864      };
     865  })();
     866
     867  // -------------------------- box sizing -------------------------- //
     868
     869  boxSizingProp = getStyleProperty('boxSizing');
     870
     871  /**
     872   * WebKit measures the outer-width on style.width on border-box elems
     873   * IE & Firefox measures the inner-width
     874   */
     875  if ( boxSizingProp ) {
     876    var div = document.createElement('div');
     877    div.style.width = '200px';
     878    div.style.padding = '1px 2px 3px 4px';
     879    div.style.borderStyle = 'solid';
     880    div.style.borderWidth = '1px 2px 3px 4px';
     881    div.style[ boxSizingProp ] = 'border-box';
     882
     883    var body = document.body || document.documentElement;
     884    body.appendChild( div );
     885    var style = getStyle( div );
     886
     887    isBoxSizeOuter = getStyleSize( style.width ) === 200;
     888    body.removeChild( div );
     889  }
     890
     891}
     892
     893// -------------------------- getSize -------------------------- //
     894
     895function getSize( elem ) {
     896  setup();
     897
     898  // use querySeletor if elem is string
     899  if ( typeof elem === 'string' ) {
     900    elem = document.querySelector( elem );
     901  }
     902
     903  // do not proceed on non-objects
     904  if ( !elem || typeof elem !== 'object' || !elem.nodeType ) {
     905    return;
     906  }
     907
     908  var style = getStyle( elem );
     909
     910  // if hidden, everything is 0
     911  if ( style.display === 'none' ) {
     912    return getZeroSize();
     913  }
     914
     915  var size = {};
     916  size.width = elem.offsetWidth;
     917  size.height = elem.offsetHeight;
     918
     919  var isBorderBox = size.isBorderBox = !!( boxSizingProp &&
     920    style[ boxSizingProp ] && style[ boxSizingProp ] === 'border-box' );
     921
     922  // get all measurements
     923  for ( var i=0, len = measurements.length; i < len; i++ ) {
     924    var measurement = measurements[i];
     925    var value = style[ measurement ];
     926    value = mungeNonPixel( elem, value );
     927    var num = parseFloat( value );
     928    // any 'auto', 'medium' value will be 0
     929    size[ measurement ] = !isNaN( num ) ? num : 0;
     930  }
     931
     932  var paddingWidth = size.paddingLeft + size.paddingRight;
     933  var paddingHeight = size.paddingTop + size.paddingBottom;
     934  var marginWidth = size.marginLeft + size.marginRight;
     935  var marginHeight = size.marginTop + size.marginBottom;
     936  var borderWidth = size.borderLeftWidth + size.borderRightWidth;
     937  var borderHeight = size.borderTopWidth + size.borderBottomWidth;
     938
     939  var isBorderBoxSizeOuter = isBorderBox && isBoxSizeOuter;
     940
     941  // overwrite width and height if we can get it from style
     942  var styleWidth = getStyleSize( style.width );
     943  if ( styleWidth !== false ) {
     944    size.width = styleWidth +
     945      // add padding and border unless it's already including it
     946      ( isBorderBoxSizeOuter ? 0 : paddingWidth + borderWidth );
     947  }
     948
     949  var styleHeight = getStyleSize( style.height );
     950  if ( styleHeight !== false ) {
     951    size.height = styleHeight +
     952      // add padding and border unless it's already including it
     953      ( isBorderBoxSizeOuter ? 0 : paddingHeight + borderHeight );
     954  }
     955
     956  size.innerWidth = size.width - ( paddingWidth + borderWidth );
     957  size.innerHeight = size.height - ( paddingHeight + borderHeight );
     958
     959  size.outerWidth = size.width + marginWidth;
     960  size.outerHeight = size.height + marginHeight;
     961
     962  return size;
     963}
     964
     965// IE8 returns percent values, not pixels
     966// taken from jQuery's curCSS
     967function mungeNonPixel( elem, value ) {
     968  // IE8 and has percent value
     969  if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
     970    return value;
     971  }
     972  var style = elem.style;
     973  // Remember the original values
     974  var left = style.left;
     975  var rs = elem.runtimeStyle;
     976  var rsLeft = rs && rs.left;
     977
     978  // Put in the new values to get a computed value out
     979  if ( rsLeft ) {
     980    rs.left = elem.currentStyle.left;
     981  }
     982  style.left = value;
     983  value = style.pixelLeft;
     984
     985  // Revert the changed values
     986  style.left = left;
     987  if ( rsLeft ) {
     988    rs.left = rsLeft;
     989  }
     990
     991  return value;
     992}
     993
     994return getSize;
     995
     996}
     997
     998// transport
     999if ( typeof define === 'function' && define.amd ) {
     1000  // AMD for RequireJS
     1001  define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize );
     1002} else if ( typeof exports === 'object' ) {
     1003  // CommonJS for Component
     1004  module.exports = defineGetSize( require('desandro-get-style-property') );
     1005} else {
     1006  // browser global
     1007  window.getSize = defineGetSize( window.getStyleProperty );
     1008}
     1009
     1010})( window );
     1011
     1012/*!
     1013 * docReady v1.0.4
     1014 * Cross browser DOMContentLoaded event emitter
     1015 * MIT license
     1016 */
     1017
     1018/*jshint browser: true, strict: true, undef: true, unused: true*/
     1019/*global define: false, require: false, module: false */
     1020
     1021( function( window ) {
     1022
     1023
     1024
     1025var document = window.document;
     1026// collection of functions to be triggered on ready
     1027var queue = [];
     1028
     1029function docReady( fn ) {
     1030  // throw out non-functions
     1031  if ( typeof fn !== 'function' ) {
     1032    return;
     1033  }
     1034
     1035  if ( docReady.isReady ) {
     1036    // ready now, hit it
     1037    fn();
     1038  } else {
     1039    // queue function when ready
     1040    queue.push( fn );
     1041  }
     1042}
     1043
     1044docReady.isReady = false;
     1045
     1046// triggered on various doc ready events
     1047function onReady( event ) {
     1048  // bail if already triggered or IE8 document is not ready just yet
     1049  var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
     1050  if ( docReady.isReady || isIE8NotReady ) {
     1051    return;
     1052  }
     1053
     1054  trigger();
     1055}
     1056
     1057function trigger() {
     1058  docReady.isReady = true;
     1059  // process queue
     1060  for ( var i=0, len = queue.length; i < len; i++ ) {
     1061    var fn = queue[i];
     1062    fn();
     1063  }
     1064}
     1065
     1066function defineDocReady( eventie ) {
     1067  // trigger ready if page is ready
     1068  if ( document.readyState === 'complete' ) {
     1069    trigger();
     1070  } else {
     1071    // listen for events
     1072    eventie.bind( document, 'DOMContentLoaded', onReady );
     1073    eventie.bind( document, 'readystatechange', onReady );
     1074    eventie.bind( window, 'load', onReady );
     1075  }
     1076
     1077  return docReady;
     1078}
     1079
     1080// transport
     1081if ( typeof define === 'function' && define.amd ) {
     1082  // AMD
     1083  define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady );
     1084} else if ( typeof exports === 'object' ) {
     1085  module.exports = defineDocReady( require('eventie') );
     1086} else {
     1087  // browser global
     1088  window.docReady = defineDocReady( window.eventie );
     1089}
     1090
     1091})( window );
     1092
     1093/**
     1094 * matchesSelector v1.0.3
     1095 * matchesSelector( element, '.selector' )
     1096 * MIT license
     1097 */
     1098
     1099/*jshint browser: true, strict: true, undef: true, unused: true */
     1100/*global define: false, module: false */
     1101
     1102( function( ElemProto ) {
     1103
     1104 
     1105
     1106  var matchesMethod = ( function() {
     1107    // check for the standard method name first
     1108    if ( ElemProto.matches ) {
     1109      return 'matches';
     1110    }
     1111    // check un-prefixed
     1112    if ( ElemProto.matchesSelector ) {
     1113      return 'matchesSelector';
     1114    }
     1115    // check vendor prefixes
     1116    var prefixes = [ 'webkit', 'moz', 'ms', 'o' ];
     1117
     1118    for ( var i=0, len = prefixes.length; i < len; i++ ) {
     1119      var prefix = prefixes[i];
     1120      var method = prefix + 'MatchesSelector';
     1121      if ( ElemProto[ method ] ) {
     1122        return method;
     1123      }
     1124    }
     1125  })();
     1126
     1127  // ----- match ----- //
     1128
     1129  function match( elem, selector ) {
     1130    return elem[ matchesMethod ]( selector );
     1131  }
     1132
     1133  // ----- appendToFragment ----- //
     1134
     1135  function checkParent( elem ) {
     1136    // not needed if already has parent
     1137    if ( elem.parentNode ) {
     1138      return;
     1139    }
     1140    var fragment = document.createDocumentFragment();
     1141    fragment.appendChild( elem );
     1142  }
     1143
     1144  // ----- query ----- //
     1145
     1146  // fall back to using QSA
     1147  // thx @jonathantneal https://gist.github.com/3062955
     1148  function query( elem, selector ) {
     1149    // append to fragment if no parent
     1150    checkParent( elem );
     1151
     1152    // match elem with all selected elems of parent
     1153    var elems = elem.parentNode.querySelectorAll( selector );
     1154    for ( var i=0, len = elems.length; i < len; i++ ) {
     1155      // return true if match
     1156      if ( elems[i] === elem ) {
     1157        return true;
     1158      }
     1159    }
     1160    // otherwise return false
     1161    return false;
     1162  }
     1163
     1164  // ----- matchChild ----- //
     1165
     1166  function matchChild( elem, selector ) {
     1167    checkParent( elem );
     1168    return match( elem, selector );
     1169  }
     1170
     1171  // ----- matchesSelector ----- //
     1172
     1173  var matchesSelector;
     1174
     1175  if ( matchesMethod ) {
     1176    // IE9 supports matchesSelector, but doesn't work on orphaned elems
     1177    // check for that
     1178    var div = document.createElement('div');
     1179    var supportsOrphans = match( div, 'div' );
     1180    matchesSelector = supportsOrphans ? match : matchChild;
     1181  } else {
     1182    matchesSelector = query;
     1183  }
     1184
     1185  // transport
     1186  if ( typeof define === 'function' && define.amd ) {
     1187    // AMD
     1188    define( 'matches-selector/matches-selector',[],function() {
     1189      return matchesSelector;
     1190    });
     1191  } else if ( typeof exports === 'object' ) {
     1192    module.exports = matchesSelector;
     1193  }
     1194  else {
     1195    // browser global
     1196    window.matchesSelector = matchesSelector;
     1197  }
     1198
     1199})( Element.prototype );
     1200
     1201/**
     1202 * Fizzy UI utils v1.0.1
     1203 * MIT license
     1204 */
     1205
     1206/*jshint browser: true, undef: true, unused: true, strict: true */
     1207
     1208( function( window, factory ) {
     1209  /*global define: false, module: false, require: false */
     1210 
     1211  // universal module definition
     1212
     1213  if ( typeof define == 'function' && define.amd ) {
     1214    // AMD
     1215    define( 'fizzy-ui-utils/utils',[
     1216      'doc-ready/doc-ready',
     1217      'matches-selector/matches-selector'
     1218    ], function( docReady, matchesSelector ) {
     1219      return factory( window, docReady, matchesSelector );
     1220    });
     1221  } else if ( typeof exports == 'object' ) {
     1222    // CommonJS
     1223    module.exports = factory(
     1224      window,
     1225      require('doc-ready'),
     1226      require('desandro-matches-selector')
     1227    );
     1228  } else {
     1229    // browser global
     1230    window.fizzyUIUtils = factory(
     1231      window,
     1232      window.docReady,
     1233      window.matchesSelector
     1234    );
     1235  }
     1236
     1237}( window, function factory( window, docReady, matchesSelector ) {
     1238
     1239
     1240
     1241var utils = {};
     1242
     1243// ----- extend ----- //
     1244
     1245// extends objects
     1246utils.extend = function( a, b ) {
     1247  for ( var prop in b ) {
     1248    a[ prop ] = b[ prop ];
     1249  }
     1250  return a;
     1251};
     1252
     1253// ----- modulo ----- //
     1254
     1255utils.modulo = function( num, div ) {
     1256  return ( ( num % div ) + div ) % div;
     1257};
     1258
     1259// ----- isArray ----- //
     1260 
     1261var objToString = Object.prototype.toString;
     1262utils.isArray = function( obj ) {
     1263  return objToString.call( obj ) == '[object Array]';
     1264};
     1265
     1266// ----- makeArray ----- //
     1267
     1268// turn element or nodeList into an array
     1269utils.makeArray = function( obj ) {
     1270  var ary = [];
     1271  if ( utils.isArray( obj ) ) {
     1272    // use object if already an array
     1273    ary = obj;
     1274  } else if ( obj && typeof obj.length == 'number' ) {
     1275    // convert nodeList to array
     1276    for ( var i=0, len = obj.length; i < len; i++ ) {
     1277      ary.push( obj[i] );
     1278    }
     1279  } else {
     1280    // array of single index
     1281    ary.push( obj );
     1282  }
     1283  return ary;
     1284};
     1285
     1286// ----- indexOf ----- //
     1287
     1288// index of helper cause IE8
     1289utils.indexOf = Array.prototype.indexOf ? function( ary, obj ) {
     1290    return ary.indexOf( obj );
     1291  } : function( ary, obj ) {
     1292    for ( var i=0, len = ary.length; i < len; i++ ) {
     1293      if ( ary[i] === obj ) {
     1294        return i;
     1295      }
     1296    }
     1297    return -1;
     1298  };
     1299
     1300// ----- removeFrom ----- //
     1301
     1302utils.removeFrom = function( ary, obj ) {
     1303  var index = utils.indexOf( ary, obj );
     1304  if ( index != -1 ) {
     1305    ary.splice( index, 1 );
     1306  }
     1307};
     1308
     1309// ----- isElement ----- //
     1310
     1311// http://stackoverflow.com/a/384380/182183
     1312utils.isElement = ( typeof HTMLElement == 'function' || typeof HTMLElement == 'object' ) ?
     1313  function isElementDOM2( obj ) {
     1314    return obj instanceof HTMLElement;
     1315  } :
     1316  function isElementQuirky( obj ) {
     1317    return obj && typeof obj == 'object' &&
     1318      obj.nodeType == 1 && typeof obj.nodeName == 'string';
     1319  };
     1320
     1321// ----- setText ----- //
     1322
     1323utils.setText = ( function() {
     1324  var setTextProperty;
     1325  function setText( elem, text ) {
     1326    // only check setTextProperty once
     1327    setTextProperty = setTextProperty || ( document.documentElement.textContent !== undefined ? 'textContent' : 'innerText' );
     1328    elem[ setTextProperty ] = text;
     1329  }
     1330  return setText;
     1331})();
     1332
     1333// ----- getParent ----- //
     1334
     1335utils.getParent = function( elem, selector ) {
     1336  while ( elem != document.body ) {
     1337    elem = elem.parentNode;
     1338    if ( matchesSelector( elem, selector ) ) {
     1339      return elem;
     1340    }
     1341  }
     1342};
     1343
     1344// ----- getQueryElement ----- //
     1345
     1346// use element as selector string
     1347utils.getQueryElement = function( elem ) {
     1348  if ( typeof elem == 'string' ) {
     1349    return document.querySelector( elem );
     1350  }
     1351  return elem;
     1352};
     1353
     1354// ----- handleEvent ----- //
     1355
     1356// enable .ontype to trigger from .addEventListener( elem, 'type' )
     1357utils.handleEvent = function( event ) {
     1358  var method = 'on' + event.type;
     1359  if ( this[ method ] ) {
     1360    this[ method ]( event );
     1361  }
     1362};
     1363
     1364// ----- filterFindElements ----- //
     1365
     1366utils.filterFindElements = function( elems, selector ) {
     1367  // make array of elems
     1368  elems = utils.makeArray( elems );
     1369  var ffElems = [];
     1370
     1371  for ( var i=0, len = elems.length; i < len; i++ ) {
     1372    var elem = elems[i];
     1373    // check that elem is an actual element
     1374    if ( !utils.isElement( elem ) ) {
     1375      continue;
     1376    }
     1377    // filter & find items if we have a selector
     1378    if ( selector ) {
     1379      // filter siblings
     1380      if ( matchesSelector( elem, selector ) ) {
     1381        ffElems.push( elem );
     1382      }
     1383      // find children
     1384      var childElems = elem.querySelectorAll( selector );
     1385      // concat childElems to filterFound array
     1386      for ( var j=0, jLen = childElems.length; j < jLen; j++ ) {
     1387        ffElems.push( childElems[j] );
     1388      }
     1389    } else {
     1390      ffElems.push( elem );
     1391    }
     1392  }
     1393
     1394  return ffElems;
     1395};
     1396
     1397// ----- debounceMethod ----- //
     1398
     1399utils.debounceMethod = function( _class, methodName, threshold ) {
     1400  // original method
     1401  var method = _class.prototype[ methodName ];
     1402  var timeoutName = methodName + 'Timeout';
     1403
     1404  _class.prototype[ methodName ] = function() {
     1405    var timeout = this[ timeoutName ];
     1406    if ( timeout ) {
     1407      clearTimeout( timeout );
     1408    }
     1409    var args = arguments;
     1410
     1411    var _this = this;
     1412    this[ timeoutName ] = setTimeout( function() {
     1413      method.apply( _this, args );
     1414      delete _this[ timeoutName ];
     1415    }, threshold || 100 );
     1416  };
     1417};
     1418
     1419// ----- htmlInit ----- //
     1420
     1421// http://jamesroberts.name/blog/2010/02/22/string-functions-for-javascript-trim-to-camel-case-to-dashed-and-to-underscore/
     1422utils.toDashed = function( str ) {
     1423  return str.replace( /(.)([A-Z])/g, function( match, $1, $2 ) {
     1424    return $1 + '-' + $2;
     1425  }).toLowerCase();
     1426};
     1427
     1428var console = window.console;
     1429/**
     1430 * allow user to initialize classes via .js-namespace class
     1431 * htmlInit( Widget, 'widgetName' )
     1432 * options are parsed from data-namespace-option attribute
     1433 */
     1434utils.htmlInit = function( WidgetClass, namespace ) {
     1435  docReady( function() {
     1436    var dashedNamespace = utils.toDashed( namespace );
     1437    var elems = document.querySelectorAll( '.js-' + dashedNamespace );
     1438    var dataAttr = 'data-' + dashedNamespace + '-options';
     1439
     1440    for ( var i=0, len = elems.length; i < len; i++ ) {
     1441      var elem = elems[i];
     1442      var attr = elem.getAttribute( dataAttr );
     1443      var options;
     1444      try {
     1445        options = attr && JSON.parse( attr );
     1446      } catch ( error ) {
     1447        // log error, do not initialize
     1448        if ( console ) {
     1449          console.error( 'Error parsing ' + dataAttr + ' on ' +
     1450            elem.nodeName.toLowerCase() + ( elem.id ? '#' + elem.id : '' ) + ': ' +
     1451            error );
     1452        }
     1453        continue;
     1454      }
     1455      // initialize
     1456      var instance = new WidgetClass( elem, options );
     1457      // make available via $().data('layoutname')
     1458      var jQuery = window.jQuery;
     1459      if ( jQuery ) {
     1460        jQuery.data( elem, namespace, instance );
     1461      }
     1462    }
     1463  });
     1464};
     1465
     1466// -----  ----- //
     1467
     1468return utils;
     1469
     1470}));
     1471
     1472/**
     1473 * Outlayer Item
     1474 */
     1475
     1476( function( window, factory ) {
     1477 
     1478  // universal module definition
     1479  if ( typeof define === 'function' && define.amd ) {
     1480    // AMD
     1481    define( 'outlayer/item',[
     1482        'eventEmitter/EventEmitter',
     1483        'get-size/get-size',
     1484        'get-style-property/get-style-property',
     1485        'fizzy-ui-utils/utils'
     1486      ],
     1487      function( EventEmitter, getSize, getStyleProperty, utils ) {
     1488        return factory( window, EventEmitter, getSize, getStyleProperty, utils );
     1489      }
     1490    );
     1491  } else if (typeof exports === 'object') {
     1492    // CommonJS
     1493    module.exports = factory(
     1494      window,
     1495      require('wolfy87-eventemitter'),
     1496      require('get-size'),
     1497      require('desandro-get-style-property'),
     1498      require('fizzy-ui-utils')
     1499    );
     1500  } else {
     1501    // browser global
     1502    window.Outlayer = {};
     1503    window.Outlayer.Item = factory(
     1504      window,
     1505      window.EventEmitter,
     1506      window.getSize,
     1507      window.getStyleProperty,
     1508      window.fizzyUIUtils
     1509    );
     1510  }
     1511
     1512}( window, function factory( window, EventEmitter, getSize, getStyleProperty, utils ) {
     1513
     1514
     1515// ----- helpers ----- //
     1516
     1517var getComputedStyle = window.getComputedStyle;
     1518var getStyle = getComputedStyle ?
     1519  function( elem ) {
     1520    return getComputedStyle( elem, null );
     1521  } :
     1522  function( elem ) {
     1523    return elem.currentStyle;
     1524  };
     1525
     1526
     1527function isEmptyObj( obj ) {
     1528  for ( var prop in obj ) {
     1529    return false;
     1530  }
     1531  prop = null;
     1532  return true;
     1533}
     1534
     1535// -------------------------- CSS3 support -------------------------- //
     1536
     1537var transitionProperty = getStyleProperty('transition');
     1538var transformProperty = getStyleProperty('transform');
     1539var supportsCSS3 = transitionProperty && transformProperty;
     1540var is3d = !!getStyleProperty('perspective');
     1541
     1542var transitionEndEvent = {
     1543  WebkitTransition: 'webkitTransitionEnd',
     1544  MozTransition: 'transitionend',
     1545  OTransition: 'otransitionend',
     1546  transition: 'transitionend'
     1547}[ transitionProperty ];
     1548
     1549// properties that could have vendor prefix
     1550var prefixableProperties = [
     1551  'transform',
     1552  'transition',
     1553  'transitionDuration',
     1554  'transitionProperty'
     1555];
     1556
     1557// cache all vendor properties
     1558var vendorProperties = ( function() {
     1559  var cache = {};
     1560  for ( var i=0, len = prefixableProperties.length; i < len; i++ ) {
     1561    var prop = prefixableProperties[i];
     1562    var supportedProp = getStyleProperty( prop );
     1563    if ( supportedProp && supportedProp !== prop ) {
     1564      cache[ prop ] = supportedProp;
     1565    }
     1566  }
     1567  return cache;
     1568})();
     1569
     1570// -------------------------- Item -------------------------- //
     1571
     1572function Item( element, layout ) {
     1573  if ( !element ) {
     1574    return;
     1575  }
     1576
     1577  this.element = element;
     1578  // parent layout class, i.e. Masonry, Isotope, or Packery
     1579  this.layout = layout;
     1580  this.position = {
     1581    x: 0,
     1582    y: 0
     1583  };
     1584
     1585  this._create();
     1586}
     1587
     1588// inherit EventEmitter
     1589utils.extend( Item.prototype, EventEmitter.prototype );
     1590
     1591Item.prototype._create = function() {
     1592  // transition objects
     1593  this._transn = {
     1594    ingProperties: {},
     1595    clean: {},
     1596    onEnd: {}
     1597  };
     1598
     1599  this.css({
     1600    position: 'absolute'
     1601  });
     1602};
     1603
     1604// trigger specified handler for event type
     1605Item.prototype.handleEvent = function( event ) {
     1606  var method = 'on' + event.type;
     1607  if ( this[ method ] ) {
     1608    this[ method ]( event );
     1609  }
     1610};
     1611
     1612Item.prototype.getSize = function() {
     1613  this.size = getSize( this.element );
     1614};
     1615
     1616/**
     1617 * apply CSS styles to element
     1618 * @param {Object} style
     1619 */
     1620Item.prototype.css = function( style ) {
     1621  var elemStyle = this.element.style;
     1622
     1623  for ( var prop in style ) {
     1624    // use vendor property if available
     1625    var supportedProp = vendorProperties[ prop ] || prop;
     1626    elemStyle[ supportedProp ] = style[ prop ];
     1627  }
     1628};
     1629
     1630 // measure position, and sets it
     1631Item.prototype.getPosition = function() {
     1632  var style = getStyle( this.element );
     1633  var layoutOptions = this.layout.options;
     1634  var isOriginLeft = layoutOptions.isOriginLeft;
     1635  var isOriginTop = layoutOptions.isOriginTop;
     1636  var x = parseInt( style[ isOriginLeft ? 'left' : 'right' ], 10 );
     1637  var y = parseInt( style[ isOriginTop ? 'top' : 'bottom' ], 10 );
     1638
     1639  // clean up 'auto' or other non-integer values
     1640  x = isNaN( x ) ? 0 : x;
     1641  y = isNaN( y ) ? 0 : y;
     1642  // remove padding from measurement
     1643  var layoutSize = this.layout.size;
     1644  x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
     1645  y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
     1646
     1647  this.position.x = x;
     1648  this.position.y = y;
     1649};
     1650
     1651// set settled position, apply padding
     1652Item.prototype.layoutPosition = function() {
     1653  var layoutSize = this.layout.size;
     1654  var layoutOptions = this.layout.options;
     1655  var style = {};
     1656
     1657  // x
     1658  var xPadding = layoutOptions.isOriginLeft ? 'paddingLeft' : 'paddingRight';
     1659  var xProperty = layoutOptions.isOriginLeft ? 'left' : 'right';
     1660  var xResetProperty = layoutOptions.isOriginLeft ? 'right' : 'left';
     1661
     1662  var x = this.position.x + layoutSize[ xPadding ];
     1663  // set in percentage
     1664  x = layoutOptions.percentPosition && !layoutOptions.isHorizontal ?
     1665    ( ( x / layoutSize.width ) * 100 ) + '%' : x + 'px';
     1666  style[ xProperty ] = x;
     1667  // reset other property
     1668  style[ xResetProperty ] = '';
     1669
     1670  // y
     1671  var yPadding = layoutOptions.isOriginTop ? 'paddingTop' : 'paddingBottom';
     1672  var yProperty = layoutOptions.isOriginTop ? 'top' : 'bottom';
     1673  var yResetProperty = layoutOptions.isOriginTop ? 'bottom' : 'top';
     1674
     1675  var y = this.position.y + layoutSize[ yPadding ];
     1676  // set in percentage
     1677  y = layoutOptions.percentPosition && layoutOptions.isHorizontal ?
     1678    ( ( y / layoutSize.height ) * 100 ) + '%' : y + 'px';
     1679  style[ yProperty ] = y;
     1680  // reset other property
     1681  style[ yResetProperty ] = '';
     1682
     1683  this.css( style );
     1684  this.emitEvent( 'layout', [ this ] );
     1685};
     1686
     1687
     1688// transform translate function
     1689var translate = is3d ?
     1690  function( x, y ) {
     1691    return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
     1692  } :
     1693  function( x, y ) {
     1694    return 'translate(' + x + 'px, ' + y + 'px)';
     1695  };
     1696
     1697
     1698Item.prototype._transitionTo = function( x, y ) {
     1699  this.getPosition();
     1700  // get current x & y from top/left
     1701  var curX = this.position.x;
     1702  var curY = this.position.y;
     1703
     1704  var compareX = parseInt( x, 10 );
     1705  var compareY = parseInt( y, 10 );
     1706  var didNotMove = compareX === this.position.x && compareY === this.position.y;
     1707
     1708  // save end position
     1709  this.setPosition( x, y );
     1710
     1711  // if did not move and not transitioning, just go to layout
     1712  if ( didNotMove && !this.isTransitioning ) {
     1713    this.layoutPosition();
     1714    return;
     1715  }
     1716
     1717  var transX = x - curX;
     1718  var transY = y - curY;
     1719  var transitionStyle = {};
     1720  // flip cooridinates if origin on right or bottom
     1721  var layoutOptions = this.layout.options;
     1722  transX = layoutOptions.isOriginLeft ? transX : -transX;
     1723  transY = layoutOptions.isOriginTop ? transY : -transY;
     1724  transitionStyle.transform = translate( transX, transY );
     1725
     1726  this.transition({
     1727    to: transitionStyle,
     1728    onTransitionEnd: {
     1729      transform: this.layoutPosition
     1730    },
     1731    isCleaning: true
     1732  });
     1733};
     1734
     1735// non transition + transform support
     1736Item.prototype.goTo = function( x, y ) {
     1737  this.setPosition( x, y );
     1738  this.layoutPosition();
     1739};
     1740
     1741// use transition and transforms if supported
     1742Item.prototype.moveTo = supportsCSS3 ?
     1743  Item.prototype._transitionTo : Item.prototype.goTo;
     1744
     1745Item.prototype.setPosition = function( x, y ) {
     1746  this.position.x = parseInt( x, 10 );
     1747  this.position.y = parseInt( y, 10 );
     1748};
     1749
     1750// ----- transition ----- //
     1751
     1752/**
     1753 * @param {Object} style - CSS
     1754 * @param {Function} onTransitionEnd
     1755 */
     1756
     1757// non transition, just trigger callback
     1758Item.prototype._nonTransition = function( args ) {
     1759  this.css( args.to );
     1760  if ( args.isCleaning ) {
     1761    this._removeStyles( args.to );
     1762  }
     1763  for ( var prop in args.onTransitionEnd ) {
     1764    args.onTransitionEnd[ prop ].call( this );
     1765  }
     1766};
     1767
     1768/**
     1769 * proper transition
     1770 * @param {Object} args - arguments
     1771 *   @param {Object} to - style to transition to
     1772 *   @param {Object} from - style to start transition from
     1773 *   @param {Boolean} isCleaning - removes transition styles after transition
     1774 *   @param {Function} onTransitionEnd - callback
     1775 */
     1776Item.prototype._transition = function( args ) {
     1777  // redirect to nonTransition if no transition duration
     1778  if ( !parseFloat( this.layout.options.transitionDuration ) ) {
     1779    this._nonTransition( args );
     1780    return;
     1781  }
     1782
     1783  var _transition = this._transn;
     1784  // keep track of onTransitionEnd callback by css property
     1785  for ( var prop in args.onTransitionEnd ) {
     1786    _transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
     1787  }
     1788  // keep track of properties that are transitioning
     1789  for ( prop in args.to ) {
     1790    _transition.ingProperties[ prop ] = true;
     1791    // keep track of properties to clean up when transition is done
     1792    if ( args.isCleaning ) {
     1793      _transition.clean[ prop ] = true;
     1794    }
     1795  }
     1796
     1797  // set from styles
     1798  if ( args.from ) {
     1799    this.css( args.from );
     1800    // force redraw. http://blog.alexmaccaw.com/css-transitions
     1801    var h = this.element.offsetHeight;
     1802    // hack for JSHint to hush about unused var
     1803    h = null;
     1804  }
     1805  // enable transition
     1806  this.enableTransition( args.to );
     1807  // set styles that are transitioning
     1808  this.css( args.to );
     1809
     1810  this.isTransitioning = true;
     1811
     1812};
     1813
     1814var itemTransitionProperties = transformProperty && ( utils.toDashed( transformProperty ) +
     1815  ',opacity' );
     1816
     1817Item.prototype.enableTransition = function(/* style */) {
     1818  // only enable if not already transitioning
     1819  // bug in IE10 were re-setting transition style will prevent
     1820  // transitionend event from triggering
     1821  if ( this.isTransitioning ) {
     1822    return;
     1823  }
     1824
     1825  // make transition: foo, bar, baz from style object
     1826  // TODO uncomment this bit when IE10 bug is resolved
     1827  // var transitionValue = [];
     1828  // for ( var prop in style ) {
     1829  //   // dash-ify camelCased properties like WebkitTransition
     1830  //   transitionValue.push( toDash( prop ) );
     1831  // }
     1832  // enable transition styles
     1833  // HACK always enable transform,opacity for IE10
     1834  this.css({
     1835    transitionProperty: itemTransitionProperties,
     1836    transitionDuration: this.layout.options.transitionDuration
     1837  });
     1838  // listen for transition end event
     1839  this.element.addEventListener( transitionEndEvent, this, false );
     1840};
     1841
     1842Item.prototype.transition = Item.prototype[ transitionProperty ? '_transition' : '_nonTransition' ];
     1843
     1844// ----- events ----- //
     1845
     1846Item.prototype.onwebkitTransitionEnd = function( event ) {
     1847  this.ontransitionend( event );
     1848};
     1849
     1850Item.prototype.onotransitionend = function( event ) {
     1851  this.ontransitionend( event );
     1852};
     1853
     1854// properties that I munge to make my life easier
     1855var dashedVendorProperties = {
     1856  '-webkit-transform': 'transform',
     1857  '-moz-transform': 'transform',
     1858  '-o-transform': 'transform'
     1859};
     1860
     1861Item.prototype.ontransitionend = function( event ) {
     1862  // disregard bubbled events from children
     1863  if ( event.target !== this.element ) {
     1864    return;
     1865  }
     1866  var _transition = this._transn;
     1867  // get property name of transitioned property, convert to prefix-free
     1868  var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
     1869
     1870  // remove property that has completed transitioning
     1871  delete _transition.ingProperties[ propertyName ];
     1872  // check if any properties are still transitioning
     1873  if ( isEmptyObj( _transition.ingProperties ) ) {
     1874    // all properties have completed transitioning
     1875    this.disableTransition();
     1876  }
     1877  // clean style
     1878  if ( propertyName in _transition.clean ) {
     1879    // clean up style
     1880    this.element.style[ event.propertyName ] = '';
     1881    delete _transition.clean[ propertyName ];
     1882  }
     1883  // trigger onTransitionEnd callback
     1884  if ( propertyName in _transition.onEnd ) {
     1885    var onTransitionEnd = _transition.onEnd[ propertyName ];
     1886    onTransitionEnd.call( this );
     1887    delete _transition.onEnd[ propertyName ];
     1888  }
     1889
     1890  this.emitEvent( 'transitionEnd', [ this ] );
     1891};
     1892
     1893Item.prototype.disableTransition = function() {
     1894  this.removeTransitionStyles();
     1895  this.element.removeEventListener( transitionEndEvent, this, false );
     1896  this.isTransitioning = false;
     1897};
     1898
     1899/**
     1900 * removes style property from element
     1901 * @param {Object} style
     1902**/
     1903Item.prototype._removeStyles = function( style ) {
     1904  // clean up transition styles
     1905  var cleanStyle = {};
     1906  for ( var prop in style ) {
     1907    cleanStyle[ prop ] = '';
     1908  }
     1909  this.css( cleanStyle );
     1910};
     1911
     1912var cleanTransitionStyle = {
     1913  transitionProperty: '',
     1914  transitionDuration: ''
     1915};
     1916
     1917Item.prototype.removeTransitionStyles = function() {
     1918  // remove transition
     1919  this.css( cleanTransitionStyle );
     1920};
     1921
     1922// ----- show/hide/remove ----- //
     1923
     1924// remove element from DOM
     1925Item.prototype.removeElem = function() {
     1926  this.element.parentNode.removeChild( this.element );
     1927  // remove display: none
     1928  this.css({ display: '' });
     1929  this.emitEvent( 'remove', [ this ] );
     1930};
     1931
     1932Item.prototype.remove = function() {
     1933  // just remove element if no transition support or no transition
     1934  if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
     1935    this.removeElem();
     1936    return;
     1937  }
     1938
     1939  // start transition
     1940  var _this = this;
     1941  this.once( 'transitionEnd', function() {
     1942    _this.removeElem();
     1943  });
     1944  this.hide();
     1945};
     1946
     1947Item.prototype.reveal = function() {
     1948  delete this.isHidden;
     1949  // remove display: none
     1950  this.css({ display: '' });
     1951
     1952  var options = this.layout.options;
     1953
     1954  var onTransitionEnd = {};
     1955  var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
     1956  onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
     1957
     1958  this.transition({
     1959    from: options.hiddenStyle,
     1960    to: options.visibleStyle,
     1961    isCleaning: true,
     1962    onTransitionEnd: onTransitionEnd
     1963  });
     1964};
     1965
     1966Item.prototype.onRevealTransitionEnd = function() {
     1967  // check if still visible
     1968  // during transition, item may have been hidden
     1969  if ( !this.isHidden ) {
     1970    this.emitEvent('reveal');
     1971  }
     1972};
     1973
     1974/**
     1975 * get style property use for hide/reveal transition end
     1976 * @param {String} styleProperty - hiddenStyle/visibleStyle
     1977 * @returns {String}
     1978 */
     1979Item.prototype.getHideRevealTransitionEndProperty = function( styleProperty ) {
     1980  var optionStyle = this.layout.options[ styleProperty ];
     1981  // use opacity
     1982  if ( optionStyle.opacity ) {
     1983    return 'opacity';
     1984  }
     1985  // get first property
     1986  for ( var prop in optionStyle ) {
     1987    return prop;
     1988  }
     1989};
     1990
     1991Item.prototype.hide = function() {
     1992  // set flag
     1993  this.isHidden = true;
     1994  // remove display: none
     1995  this.css({ display: '' });
     1996
     1997  var options = this.layout.options;
     1998
     1999  var onTransitionEnd = {};
     2000  var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
     2001  onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
     2002
     2003  this.transition({
     2004    from: options.visibleStyle,
     2005    to: options.hiddenStyle,
     2006    // keep hidden stuff hidden
     2007    isCleaning: true,
     2008    onTransitionEnd: onTransitionEnd
     2009  });
     2010};
     2011
     2012Item.prototype.onHideTransitionEnd = function() {
     2013  // check if still hidden
     2014  // during transition, item may have been un-hidden
     2015  if ( this.isHidden ) {
     2016    this.css({ display: 'none' });
     2017    this.emitEvent('hide');
     2018  }
     2019};
     2020
     2021Item.prototype.destroy = function() {
     2022  this.css({
     2023    position: '',
     2024    left: '',
     2025    right: '',
     2026    top: '',
     2027    bottom: '',
     2028    transition: '',
     2029    transform: ''
     2030  });
     2031};
     2032
     2033return Item;
     2034
     2035}));
     2036
     2037/*!
     2038 * Outlayer v1.4.0
     2039 * the brains and guts of a layout library
     2040 * MIT license
     2041 */
     2042
     2043( function( window, factory ) {
     2044 
     2045  // universal module definition
     2046
     2047  if ( typeof define == 'function' && define.amd ) {
     2048    // AMD
     2049    define( 'outlayer/outlayer',[
     2050        'eventie/eventie',
     2051        'eventEmitter/EventEmitter',
     2052        'get-size/get-size',
     2053        'fizzy-ui-utils/utils',
     2054        './item'
     2055      ],
     2056      function( eventie, EventEmitter, getSize, utils, Item ) {
     2057        return factory( window, eventie, EventEmitter, getSize, utils, Item);
     2058      }
     2059    );
     2060  } else if ( typeof exports == 'object' ) {
     2061    // CommonJS
     2062    module.exports = factory(
     2063      window,
     2064      require('eventie'),
     2065      require('wolfy87-eventemitter'),
     2066      require('get-size'),
     2067      require('fizzy-ui-utils'),
     2068      require('./item')
     2069    );
     2070  } else {
     2071    // browser global
     2072    window.Outlayer = factory(
     2073      window,
     2074      window.eventie,
     2075      window.EventEmitter,
     2076      window.getSize,
     2077      window.fizzyUIUtils,
     2078      window.Outlayer.Item
     2079    );
     2080  }
     2081
     2082}( window, function factory( window, eventie, EventEmitter, getSize, utils, Item ) {
     2083
     2084
     2085// ----- vars ----- //
     2086
     2087var console = window.console;
     2088var jQuery = window.jQuery;
     2089var noop = function() {};
     2090
     2091// -------------------------- Outlayer -------------------------- //
     2092
     2093// globally unique identifiers
     2094var GUID = 0;
     2095// internal store of all Outlayer intances
     2096var instances = {};
     2097
     2098
     2099/**
     2100 * @param {Element, String} element
     2101 * @param {Object} options
     2102 * @constructor
     2103 */
     2104function Outlayer( element, options ) {
     2105  var queryElement = utils.getQueryElement( element );
     2106  if ( !queryElement ) {
     2107    if ( console ) {
     2108      console.error( 'Bad element for ' + this.constructor.namespace +
     2109        ': ' + ( queryElement || element ) );
     2110    }
     2111    return;
     2112  }
     2113  this.element = queryElement;
     2114  // add jQuery
     2115  if ( jQuery ) {
     2116    this.$element = jQuery( this.element );
     2117  }
     2118
     2119  // options
     2120  this.options = utils.extend( {}, this.constructor.defaults );
     2121  this.option( options );
     2122
     2123  // add id for Outlayer.getFromElement
     2124  var id = ++GUID;
     2125  this.element.outlayerGUID = id; // expando
     2126  instances[ id ] = this; // associate via id
     2127
     2128  // kick it off
     2129  this._create();
     2130
     2131  if ( this.options.isInitLayout ) {
     2132    this.layout();
     2133  }
     2134}
     2135
     2136// settings are for internal use only
     2137Outlayer.namespace = 'outlayer';
     2138Outlayer.Item = Item;
     2139
     2140// default options
     2141Outlayer.defaults = {
     2142  containerStyle: {
     2143    position: 'relative'
     2144  },
     2145  isInitLayout: true,
     2146  isOriginLeft: true,
     2147  isOriginTop: true,
     2148  isResizeBound: true,
     2149  isResizingContainer: true,
     2150  // item options
     2151  transitionDuration: '0.4s',
     2152  hiddenStyle: {
     2153    opacity: 0,
     2154    transform: 'scale(0.001)'
     2155  },
     2156  visibleStyle: {
     2157    opacity: 1,
     2158    transform: 'scale(1)'
     2159  }
     2160};
     2161
     2162// inherit EventEmitter
     2163utils.extend( Outlayer.prototype, EventEmitter.prototype );
     2164
     2165/**
     2166 * set options
     2167 * @param {Object} opts
     2168 */
     2169Outlayer.prototype.option = function( opts ) {
     2170  utils.extend( this.options, opts );
     2171};
     2172
     2173Outlayer.prototype._create = function() {
     2174  // get items from children
     2175  this.reloadItems();
     2176  // elements that affect layout, but are not laid out
     2177  this.stamps = [];
     2178  this.stamp( this.options.stamp );
     2179  // set container style
     2180  utils.extend( this.element.style, this.options.containerStyle );
     2181
     2182  // bind resize method
     2183  if ( this.options.isResizeBound ) {
     2184    this.bindResize();
     2185  }
     2186};
     2187
     2188// goes through all children again and gets bricks in proper order
     2189Outlayer.prototype.reloadItems = function() {
     2190  // collection of item elements
     2191  this.items = this._itemize( this.element.children );
     2192};
     2193
     2194
     2195/**
     2196 * turn elements into Outlayer.Items to be used in layout
     2197 * @param {Array or NodeList or HTMLElement} elems
     2198 * @returns {Array} items - collection of new Outlayer Items
     2199 */
     2200Outlayer.prototype._itemize = function( elems ) {
     2201
     2202  var itemElems = this._filterFindItemElements( elems );
     2203  var Item = this.constructor.Item;
     2204
     2205  // create new Outlayer Items for collection
     2206  var items = [];
     2207  for ( var i=0, len = itemElems.length; i < len; i++ ) {
     2208    var elem = itemElems[i];
     2209    var item = new Item( elem, this );
     2210    items.push( item );
     2211  }
     2212
     2213  return items;
     2214};
     2215
     2216/**
     2217 * get item elements to be used in layout
     2218 * @param {Array or NodeList or HTMLElement} elems
     2219 * @returns {Array} items - item elements
     2220 */
     2221Outlayer.prototype._filterFindItemElements = function( elems ) {
     2222  return utils.filterFindElements( elems, this.options.itemSelector );
     2223};
     2224
     2225/**
     2226 * getter method for getting item elements
     2227 * @returns {Array} elems - collection of item elements
     2228 */
     2229Outlayer.prototype.getItemElements = function() {
     2230  var elems = [];
     2231  for ( var i=0, len = this.items.length; i < len; i++ ) {
     2232    elems.push( this.items[i].element );
     2233  }
     2234  return elems;
     2235};
     2236
     2237// ----- init & layout ----- //
     2238
     2239/**
     2240 * lays out all items
     2241 */
     2242Outlayer.prototype.layout = function() {
     2243  this._resetLayout();
     2244  this._manageStamps();
     2245
     2246  // don't animate first layout
     2247  var isInstant = this.options.isLayoutInstant !== undefined ?
     2248    this.options.isLayoutInstant : !this._isLayoutInited;
     2249  this.layoutItems( this.items, isInstant );
     2250
     2251  // flag for initalized
     2252  this._isLayoutInited = true;
     2253};
     2254
     2255// _init is alias for layout
     2256Outlayer.prototype._init = Outlayer.prototype.layout;
     2257
     2258/**
     2259 * logic before any new layout
     2260 */
     2261Outlayer.prototype._resetLayout = function() {
     2262  this.getSize();
     2263};
     2264
     2265
     2266Outlayer.prototype.getSize = function() {
     2267  this.size = getSize( this.element );
     2268};
     2269
     2270/**
     2271 * get measurement from option, for columnWidth, rowHeight, gutter
     2272 * if option is String -> get element from selector string, & get size of element
     2273 * if option is Element -> get size of element
     2274 * else use option as a number
     2275 *
     2276 * @param {String} measurement
     2277 * @param {String} size - width or height
     2278 * @private
     2279 */
     2280Outlayer.prototype._getMeasurement = function( measurement, size ) {
     2281  var option = this.options[ measurement ];
     2282  var elem;
     2283  if ( !option ) {
     2284    // default to 0
     2285    this[ measurement ] = 0;
     2286  } else {
     2287    // use option as an element
     2288    if ( typeof option === 'string' ) {
     2289      elem = this.element.querySelector( option );
     2290    } else if ( utils.isElement( option ) ) {
     2291      elem = option;
     2292    }
     2293    // use size of element, if element
     2294    this[ measurement ] = elem ? getSize( elem )[ size ] : option;
     2295  }
     2296};
     2297
     2298/**
     2299 * layout a collection of item elements
     2300 * @api public
     2301 */
     2302Outlayer.prototype.layoutItems = function( items, isInstant ) {
     2303  items = this._getItemsForLayout( items );
     2304
     2305  this._layoutItems( items, isInstant );
     2306
     2307  this._postLayout();
     2308};
     2309
     2310/**
     2311 * get the items to be laid out
     2312 * you may want to skip over some items
     2313 * @param {Array} items
     2314 * @returns {Array} items
     2315 */
     2316Outlayer.prototype._getItemsForLayout = function( items ) {
     2317  var layoutItems = [];
     2318  for ( var i=0, len = items.length; i < len; i++ ) {
     2319    var item = items[i];
     2320    if ( !item.isIgnored ) {
     2321      layoutItems.push( item );
     2322    }
     2323  }
     2324  return layoutItems;
     2325};
     2326
     2327/**
     2328 * layout items
     2329 * @param {Array} items
     2330 * @param {Boolean} isInstant
     2331 */
     2332Outlayer.prototype._layoutItems = function( items, isInstant ) {
     2333  this._emitCompleteOnItems( 'layout', items );
     2334
     2335  if ( !items || !items.length ) {
     2336    // no items, emit event with empty array
     2337    return;
     2338  }
     2339
     2340  var queue = [];
     2341
     2342  for ( var i=0, len = items.length; i < len; i++ ) {
     2343    var item = items[i];
     2344    // get x/y object from method
     2345    var position = this._getItemLayoutPosition( item );
     2346    // enqueue
     2347    position.item = item;
     2348    position.isInstant = isInstant || item.isLayoutInstant;
     2349    queue.push( position );
     2350  }
     2351
     2352  this._processLayoutQueue( queue );
     2353};
     2354
     2355/**
     2356 * get item layout position
     2357 * @param {Outlayer.Item} item
     2358 * @returns {Object} x and y position
     2359 */
     2360Outlayer.prototype._getItemLayoutPosition = function( /* item */ ) {
     2361  return {
     2362    x: 0,
     2363    y: 0
     2364  };
     2365};
     2366
     2367/**
     2368 * iterate over array and position each item
     2369 * Reason being - separating this logic prevents 'layout invalidation'
     2370 * thx @paul_irish
     2371 * @param {Array} queue
     2372 */
     2373Outlayer.prototype._processLayoutQueue = function( queue ) {
     2374  for ( var i=0, len = queue.length; i < len; i++ ) {
     2375    var obj = queue[i];
     2376    this._positionItem( obj.item, obj.x, obj.y, obj.isInstant );
     2377  }
     2378};
     2379
     2380/**
     2381 * Sets position of item in DOM
     2382 * @param {Outlayer.Item} item
     2383 * @param {Number} x - horizontal position
     2384 * @param {Number} y - vertical position
     2385 * @param {Boolean} isInstant - disables transitions
     2386 */
     2387Outlayer.prototype._positionItem = function( item, x, y, isInstant ) {
     2388  if ( isInstant ) {
     2389    // if not transition, just set CSS
     2390    item.goTo( x, y );
     2391  } else {
     2392    item.moveTo( x, y );
     2393  }
     2394};
     2395
     2396/**
     2397 * Any logic you want to do after each layout,
     2398 * i.e. size the container
     2399 */
     2400Outlayer.prototype._postLayout = function() {
     2401  this.resizeContainer();
     2402};
     2403
     2404Outlayer.prototype.resizeContainer = function() {
     2405  if ( !this.options.isResizingContainer ) {
     2406    return;
     2407  }
     2408  var size = this._getContainerSize();
     2409  if ( size ) {
     2410    this._setContainerMeasure( size.width, true );
     2411    this._setContainerMeasure( size.height, false );
     2412  }
     2413};
     2414
     2415/**
     2416 * Sets width or height of container if returned
     2417 * @returns {Object} size
     2418 *   @param {Number} width
     2419 *   @param {Number} height
     2420 */
     2421Outlayer.prototype._getContainerSize = noop;
     2422
     2423/**
     2424 * @param {Number} measure - size of width or height
     2425 * @param {Boolean} isWidth
     2426 */
     2427Outlayer.prototype._setContainerMeasure = function( measure, isWidth ) {
     2428  if ( measure === undefined ) {
     2429    return;
     2430  }
     2431
     2432  var elemSize = this.size;
     2433  // add padding and border width if border box
     2434  if ( elemSize.isBorderBox ) {
     2435    measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
     2436      elemSize.borderLeftWidth + elemSize.borderRightWidth :
     2437      elemSize.paddingBottom + elemSize.paddingTop +
     2438      elemSize.borderTopWidth + elemSize.borderBottomWidth;
     2439  }
     2440
     2441  measure = Math.max( measure, 0 );
     2442  this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
     2443};
     2444
     2445/**
     2446 * emit eventComplete on a collection of items events
     2447 * @param {String} eventName
     2448 * @param {Array} items - Outlayer.Items
     2449 */
     2450Outlayer.prototype._emitCompleteOnItems = function( eventName, items ) {
     2451  var _this = this;
     2452  function onComplete() {
     2453    _this.emitEvent( eventName + 'Complete', [ items ] );
     2454  }
     2455
     2456  var count = items.length;
     2457  if ( !items || !count ) {
     2458    onComplete();
     2459    return;
     2460  }
     2461
     2462  var doneCount = 0;
     2463  function tick() {
     2464    doneCount++;
     2465    if ( doneCount === count ) {
     2466      onComplete();
     2467    }
     2468  }
     2469
     2470  // bind callback
     2471  for ( var i=0, len = items.length; i < len; i++ ) {
     2472    var item = items[i];
     2473    item.once( eventName, tick );
     2474  }
     2475};
     2476
     2477// -------------------------- ignore & stamps -------------------------- //
     2478
     2479
     2480/**
     2481 * keep item in collection, but do not lay it out
     2482 * ignored items do not get skipped in layout
     2483 * @param {Element} elem
     2484 */
     2485Outlayer.prototype.ignore = function( elem ) {
     2486  var item = this.getItem( elem );
     2487  if ( item ) {
     2488    item.isIgnored = true;
     2489  }
     2490};
     2491
     2492/**
     2493 * return item to layout collection
     2494 * @param {Element} elem
     2495 */
     2496Outlayer.prototype.unignore = function( elem ) {
     2497  var item = this.getItem( elem );
     2498  if ( item ) {
     2499    delete item.isIgnored;
     2500  }
     2501};
     2502
     2503/**
     2504 * adds elements to stamps
     2505 * @param {NodeList, Array, Element, or String} elems
     2506 */
     2507Outlayer.prototype.stamp = function( elems ) {
     2508  elems = this._find( elems );
     2509  if ( !elems ) {
     2510    return;
     2511  }
     2512
     2513  this.stamps = this.stamps.concat( elems );
     2514  // ignore
     2515  for ( var i=0, len = elems.length; i < len; i++ ) {
     2516    var elem = elems[i];
     2517    this.ignore( elem );
     2518  }
     2519};
     2520
     2521/**
     2522 * removes elements to stamps
     2523 * @param {NodeList, Array, or Element} elems
     2524 */
     2525Outlayer.prototype.unstamp = function( elems ) {
     2526  elems = this._find( elems );
     2527  if ( !elems ){
     2528    return;
     2529  }
     2530
     2531  for ( var i=0, len = elems.length; i < len; i++ ) {
     2532    var elem = elems[i];
     2533    // filter out removed stamp elements
     2534    utils.removeFrom( this.stamps, elem );
     2535    this.unignore( elem );
     2536  }
     2537
     2538};
     2539
     2540/**
     2541 * finds child elements
     2542 * @param {NodeList, Array, Element, or String} elems
     2543 * @returns {Array} elems
     2544 */
     2545Outlayer.prototype._find = function( elems ) {
     2546  if ( !elems ) {
     2547    return;
     2548  }
     2549  // if string, use argument as selector string
     2550  if ( typeof elems === 'string' ) {
     2551    elems = this.element.querySelectorAll( elems );
     2552  }
     2553  elems = utils.makeArray( elems );
     2554  return elems;
     2555};
     2556
     2557Outlayer.prototype._manageStamps = function() {
     2558  if ( !this.stamps || !this.stamps.length ) {
     2559    return;
     2560  }
     2561
     2562  this._getBoundingRect();
     2563
     2564  for ( var i=0, len = this.stamps.length; i < len; i++ ) {
     2565    var stamp = this.stamps[i];
     2566    this._manageStamp( stamp );
     2567  }
     2568};
     2569
     2570// update boundingLeft / Top
     2571Outlayer.prototype._getBoundingRect = function() {
     2572  // get bounding rect for container element
     2573  var boundingRect = this.element.getBoundingClientRect();
     2574  var size = this.size;
     2575  this._boundingRect = {
     2576    left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
     2577    top: boundingRect.top + size.paddingTop + size.borderTopWidth,
     2578    right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
     2579    bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
     2580  };
     2581};
     2582
     2583/**
     2584 * @param {Element} stamp
     2585**/
     2586Outlayer.prototype._manageStamp = noop;
     2587
     2588/**
     2589 * get x/y position of element relative to container element
     2590 * @param {Element} elem
     2591 * @returns {Object} offset - has left, top, right, bottom
     2592 */
     2593Outlayer.prototype._getElementOffset = function( elem ) {
     2594  var boundingRect = elem.getBoundingClientRect();
     2595  var thisRect = this._boundingRect;
     2596  var size = getSize( elem );
     2597  var offset = {
     2598    left: boundingRect.left - thisRect.left - size.marginLeft,
     2599    top: boundingRect.top - thisRect.top - size.marginTop,
     2600    right: thisRect.right - boundingRect.right - size.marginRight,
     2601    bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
     2602  };
     2603  return offset;
     2604};
     2605
     2606// -------------------------- resize -------------------------- //
     2607
     2608// enable event handlers for listeners
     2609// i.e. resize -> onresize
     2610Outlayer.prototype.handleEvent = function( event ) {
     2611  var method = 'on' + event.type;
     2612  if ( this[ method ] ) {
     2613    this[ method ]( event );
     2614  }
     2615};
     2616
     2617/**
     2618 * Bind layout to window resizing
     2619 */
     2620Outlayer.prototype.bindResize = function() {
     2621  // bind just one listener
     2622  if ( this.isResizeBound ) {
     2623    return;
     2624  }
     2625  eventie.bind( window, 'resize', this );
     2626  this.isResizeBound = true;
     2627};
     2628
     2629/**
     2630 * Unbind layout to window resizing
     2631 */
     2632Outlayer.prototype.unbindResize = function() {
     2633  if ( this.isResizeBound ) {
     2634    eventie.unbind( window, 'resize', this );
     2635  }
     2636  this.isResizeBound = false;
     2637};
     2638
     2639// original debounce by John Hann
     2640// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
     2641
     2642// this fires every resize
     2643Outlayer.prototype.onresize = function() {
     2644  if ( this.resizeTimeout ) {
     2645    clearTimeout( this.resizeTimeout );
     2646  }
     2647
     2648  var _this = this;
     2649  function delayed() {
     2650    _this.resize();
     2651    delete _this.resizeTimeout;
     2652  }
     2653
     2654  this.resizeTimeout = setTimeout( delayed, 100 );
     2655};
     2656
     2657// debounced, layout on resize
     2658Outlayer.prototype.resize = function() {
     2659  // don't trigger if size did not change
     2660  // or if resize was unbound. See #9
     2661  if ( !this.isResizeBound || !this.needsResizeLayout() ) {
     2662    return;
     2663  }
     2664
     2665  this.layout();
     2666};
     2667
     2668/**
     2669 * check if layout is needed post layout
     2670 * @returns Boolean
     2671 */
     2672Outlayer.prototype.needsResizeLayout = function() {
     2673  var size = getSize( this.element );
     2674  // check that this.size and size are there
     2675  // IE8 triggers resize on body size change, so they might not be
     2676  var hasSizes = this.size && size;
     2677  return hasSizes && size.innerWidth !== this.size.innerWidth;
     2678};
     2679
     2680// -------------------------- methods -------------------------- //
     2681
     2682/**
     2683 * add items to Outlayer instance
     2684 * @param {Array or NodeList or Element} elems
     2685 * @returns {Array} items - Outlayer.Items
     2686**/
     2687Outlayer.prototype.addItems = function( elems ) {
     2688  var items = this._itemize( elems );
     2689  // add items to collection
     2690  if ( items.length ) {
     2691    this.items = this.items.concat( items );
     2692  }
     2693  return items;
     2694};
     2695
     2696/**
     2697 * Layout newly-appended item elements
     2698 * @param {Array or NodeList or Element} elems
     2699 */
     2700Outlayer.prototype.appended = function( elems ) {
     2701  var items = this.addItems( elems );
     2702  if ( !items.length ) {
     2703    return;
     2704  }
     2705  // layout and reveal just the new items
     2706  this.layoutItems( items, true );
     2707  this.reveal( items );
     2708};
     2709
     2710/**
     2711 * Layout prepended elements
     2712 * @param {Array or NodeList or Element} elems
     2713 */
     2714Outlayer.prototype.prepended = function( elems ) {
     2715  var items = this._itemize( elems );
     2716  if ( !items.length ) {
     2717    return;
     2718  }
     2719  // add items to beginning of collection
     2720  var previousItems = this.items.slice(0);
     2721  this.items = items.concat( previousItems );
     2722  // start new layout
     2723  this._resetLayout();
     2724  this._manageStamps();
     2725  // layout new stuff without transition
     2726  this.layoutItems( items, true );
     2727  this.reveal( items );
     2728  // layout previous items
     2729  this.layoutItems( previousItems );
     2730};
     2731
     2732/**
     2733 * reveal a collection of items
     2734 * @param {Array of Outlayer.Items} items
     2735 */
     2736Outlayer.prototype.reveal = function( items ) {
     2737  this._emitCompleteOnItems( 'reveal', items );
     2738
     2739  var len = items && items.length;
     2740  for ( var i=0; len && i < len; i++ ) {
     2741    var item = items[i];
     2742    item.reveal();
     2743  }
     2744};
     2745
     2746/**
     2747 * hide a collection of items
     2748 * @param {Array of Outlayer.Items} items
     2749 */
     2750Outlayer.prototype.hide = function( items ) {
     2751  this._emitCompleteOnItems( 'hide', items );
     2752
     2753  var len = items && items.length;
     2754  for ( var i=0; len && i < len; i++ ) {
     2755    var item = items[i];
     2756    item.hide();
     2757  }
     2758};
     2759
     2760/**
     2761 * reveal item elements
     2762 * @param {Array}, {Element}, {NodeList} items
     2763 */
     2764Outlayer.prototype.revealItemElements = function( elems ) {
     2765  var items = this.getItems( elems );
     2766  this.reveal( items );
     2767};
     2768
     2769/**
     2770 * hide item elements
     2771 * @param {Array}, {Element}, {NodeList} items
     2772 */
     2773Outlayer.prototype.hideItemElements = function( elems ) {
     2774  var items = this.getItems( elems );
     2775  this.hide( items );
     2776};
     2777
     2778/**
     2779 * get Outlayer.Item, given an Element
     2780 * @param {Element} elem
     2781 * @param {Function} callback
     2782 * @returns {Outlayer.Item} item
     2783 */
     2784Outlayer.prototype.getItem = function( elem ) {
     2785  // loop through items to get the one that matches
     2786  for ( var i=0, len = this.items.length; i < len; i++ ) {
     2787    var item = this.items[i];
     2788    if ( item.element === elem ) {
     2789      // return item
     2790      return item;
     2791    }
     2792  }
     2793};
     2794
     2795/**
     2796 * get collection of Outlayer.Items, given Elements
     2797 * @param {Array} elems
     2798 * @returns {Array} items - Outlayer.Items
     2799 */
     2800Outlayer.prototype.getItems = function( elems ) {
     2801  elems = utils.makeArray( elems );
     2802  var items = [];
     2803  for ( var i=0, len = elems.length; i < len; i++ ) {
     2804    var elem = elems[i];
     2805    var item = this.getItem( elem );
     2806    if ( item ) {
     2807      items.push( item );
     2808    }
     2809  }
     2810
     2811  return items;
     2812};
     2813
     2814/**
     2815 * remove element(s) from instance and DOM
     2816 * @param {Array or NodeList or Element} elems
     2817 */
     2818Outlayer.prototype.remove = function( elems ) {
     2819  var removeItems = this.getItems( elems );
     2820
     2821  this._emitCompleteOnItems( 'remove', removeItems );
     2822
     2823  // bail if no items to remove
     2824  if ( !removeItems || !removeItems.length ) {
     2825    return;
     2826  }
     2827
     2828  for ( var i=0, len = removeItems.length; i < len; i++ ) {
     2829    var item = removeItems[i];
     2830    item.remove();
     2831    // remove item from collection
     2832    utils.removeFrom( this.items, item );
     2833  }
     2834};
     2835
     2836// ----- destroy ----- //
     2837
     2838// remove and disable Outlayer instance
     2839Outlayer.prototype.destroy = function() {
     2840  // clean up dynamic styles
     2841  var style = this.element.style;
     2842  style.height = '';
     2843  style.position = '';
     2844  style.width = '';
     2845  // destroy items
     2846  for ( var i=0, len = this.items.length; i < len; i++ ) {
     2847    var item = this.items[i];
     2848    item.destroy();
     2849  }
     2850
     2851  this.unbindResize();
     2852
     2853  var id = this.element.outlayerGUID;
     2854  delete instances[ id ]; // remove reference to instance by id
     2855  delete this.element.outlayerGUID;
     2856  // remove data for jQuery
     2857  if ( jQuery ) {
     2858    jQuery.removeData( this.element, this.constructor.namespace );
     2859  }
     2860
     2861};
     2862
     2863// -------------------------- data -------------------------- //
     2864
     2865/**
     2866 * get Outlayer instance from element
     2867 * @param {Element} elem
     2868 * @returns {Outlayer}
     2869 */
     2870Outlayer.data = function( elem ) {
     2871  elem = utils.getQueryElement( elem );
     2872  var id = elem && elem.outlayerGUID;
     2873  return id && instances[ id ];
     2874};
     2875
     2876
     2877// -------------------------- create Outlayer class -------------------------- //
     2878
     2879/**
     2880 * create a layout class
     2881 * @param {String} namespace
     2882 */
     2883Outlayer.create = function( namespace, options ) {
     2884  // sub-class Outlayer
     2885  function Layout() {
     2886    Outlayer.apply( this, arguments );
     2887  }
     2888  // inherit Outlayer prototype, use Object.create if there
     2889  if ( Object.create ) {
     2890    Layout.prototype = Object.create( Outlayer.prototype );
     2891  } else {
     2892    utils.extend( Layout.prototype, Outlayer.prototype );
     2893  }
     2894  // set contructor, used for namespace and Item
     2895  Layout.prototype.constructor = Layout;
     2896
     2897  Layout.defaults = utils.extend( {}, Outlayer.defaults );
     2898  // apply new options
     2899  utils.extend( Layout.defaults, options );
     2900  // keep prototype.settings for backwards compatibility (Packery v1.2.0)
     2901  Layout.prototype.settings = {};
     2902
     2903  Layout.namespace = namespace;
     2904
     2905  Layout.data = Outlayer.data;
     2906
     2907  // sub-class Item
     2908  Layout.Item = function LayoutItem() {
     2909    Item.apply( this, arguments );
     2910  };
     2911
     2912  Layout.Item.prototype = new Item();
     2913
     2914  // -------------------------- declarative -------------------------- //
     2915
     2916  utils.htmlInit( Layout, namespace );
     2917
     2918  // -------------------------- jQuery bridge -------------------------- //
     2919
     2920  // make into jQuery plugin
     2921  if ( jQuery && jQuery.bridget ) {
     2922    jQuery.bridget( namespace, Layout );
     2923  }
     2924
     2925  return Layout;
     2926};
     2927
     2928// ----- fin ----- //
     2929
     2930// back in global
     2931Outlayer.Item = Item;
     2932
     2933return Outlayer;
     2934
     2935}));
     2936
     2937
     2938/*!
     2939 * Masonry v3.3.0
     2940 * Cascading grid layout library
     2941 * http://masonry.desandro.com
     2942 * MIT License
     2943 * by David DeSandro
     2944 */
     2945
     2946( function( window, factory ) {
     2947 
     2948  // universal module definition
     2949  if ( typeof define === 'function' && define.amd ) {
     2950    // AMD
     2951    define( [
     2952        'outlayer/outlayer',
     2953        'get-size/get-size',
     2954        'fizzy-ui-utils/utils'
     2955      ],
     2956      factory );
     2957  } else if ( typeof exports === 'object' ) {
     2958    // CommonJS
     2959    module.exports = factory(
     2960      require('outlayer'),
     2961      require('get-size'),
     2962      require('fizzy-ui-utils')
     2963    );
     2964  } else {
     2965    // browser global
     2966    window.Masonry = factory(
     2967      window.Outlayer,
     2968      window.getSize,
     2969      window.fizzyUIUtils
     2970    );
     2971  }
     2972
     2973}( window, function factory( Outlayer, getSize, utils ) {
     2974
     2975
     2976
     2977// -------------------------- masonryDefinition -------------------------- //
     2978
     2979  // create an Outlayer layout class
     2980  var Masonry = Outlayer.create('masonry');
     2981
     2982  Masonry.prototype._resetLayout = function() {
     2983    this.getSize();
     2984    this._getMeasurement( 'columnWidth', 'outerWidth' );
     2985    this._getMeasurement( 'gutter', 'outerWidth' );
     2986    this.measureColumns();
     2987
     2988    // reset column Y
     2989    var i = this.cols;
     2990    this.colYs = [];
     2991    while (i--) {
     2992      this.colYs.push( 0 );
     2993    }
     2994
     2995    this.maxY = 0;
     2996  };
     2997
     2998  Masonry.prototype.measureColumns = function() {
     2999    this.getContainerWidth();
     3000    // if columnWidth is 0, default to outerWidth of first item
     3001    if ( !this.columnWidth ) {
     3002      var firstItem = this.items[0];
     3003      var firstItemElem = firstItem && firstItem.element;
     3004      // columnWidth fall back to item of first element
     3005      this.columnWidth = firstItemElem && getSize( firstItemElem ).outerWidth ||
     3006        // if first elem has no width, default to size of container
     3007        this.containerWidth;
     3008    }
     3009
     3010    var columnWidth = this.columnWidth += this.gutter;
     3011
     3012    // calculate columns
     3013    var containerWidth = this.containerWidth + this.gutter;
     3014    var cols = containerWidth / columnWidth;
     3015    // fix rounding errors, typically with gutters
     3016    var excess = columnWidth - containerWidth % columnWidth;
     3017    // if overshoot is less than a pixel, round up, otherwise floor it
     3018    var mathMethod = excess && excess < 1 ? 'round' : 'floor';
     3019    cols = Math[ mathMethod ]( cols );
     3020    this.cols = Math.max( cols, 1 );
     3021  };
     3022
     3023  Masonry.prototype.getContainerWidth = function() {
     3024    // container is parent if fit width
     3025    var container = this.options.isFitWidth ? this.element.parentNode : this.element;
     3026    // check that this.size and size are there
     3027    // IE8 triggers resize on body size change, so they might not be
     3028    var size = getSize( container );
     3029    this.containerWidth = size && size.innerWidth;
     3030  };
     3031
     3032  Masonry.prototype._getItemLayoutPosition = function( item ) {
     3033    item.getSize();
     3034    // how many columns does this brick span
     3035    var remainder = item.size.outerWidth % this.columnWidth;
     3036    var mathMethod = remainder && remainder < 1 ? 'round' : 'ceil';
     3037    // round if off by 1 pixel, otherwise use ceil
     3038    var colSpan = Math[ mathMethod ]( item.size.outerWidth / this.columnWidth );
     3039    colSpan = Math.min( colSpan, this.cols );
     3040
     3041    var colGroup = this._getColGroup( colSpan );
     3042    // get the minimum Y value from the columns
     3043    var minimumY = Math.min.apply( Math, colGroup );
     3044    var shortColIndex = utils.indexOf( colGroup, minimumY );
     3045
     3046    // position the brick
     3047    var position = {
     3048      x: this.columnWidth * shortColIndex,
     3049      y: minimumY
     3050    };
     3051
     3052    // apply setHeight to necessary columns
     3053    var setHeight = minimumY + item.size.outerHeight;
     3054    var setSpan = this.cols + 1 - colGroup.length;
     3055    for ( var i = 0; i < setSpan; i++ ) {
     3056      this.colYs[ shortColIndex + i ] = setHeight;
     3057    }
     3058
     3059    return position;
     3060  };
     3061
     3062  /**
     3063   * @param {Number} colSpan - number of columns the element spans
     3064   * @returns {Array} colGroup
     3065   */
     3066  Masonry.prototype._getColGroup = function( colSpan ) {
     3067    if ( colSpan < 2 ) {
     3068      // if brick spans only one column, use all the column Ys
     3069      return this.colYs;
     3070    }
     3071
     3072    var colGroup = [];
     3073    // how many different places could this brick fit horizontally
     3074    var groupCount = this.cols + 1 - colSpan;
     3075    // for each group potential horizontal position
     3076    for ( var i = 0; i < groupCount; i++ ) {
     3077      // make an array of colY values for that one group
     3078      var groupColYs = this.colYs.slice( i, i + colSpan );
     3079      // and get the max value of the array
     3080      colGroup[i] = Math.max.apply( Math, groupColYs );
     3081    }
     3082    return colGroup;
     3083  };
     3084
     3085  Masonry.prototype._manageStamp = function( stamp ) {
     3086    var stampSize = getSize( stamp );
     3087    var offset = this._getElementOffset( stamp );
     3088    // get the columns that this stamp affects
     3089    var firstX = this.options.isOriginLeft ? offset.left : offset.right;
     3090    var lastX = firstX + stampSize.outerWidth;
     3091    var firstCol = Math.floor( firstX / this.columnWidth );
     3092    firstCol = Math.max( 0, firstCol );
     3093    var lastCol = Math.floor( lastX / this.columnWidth );
     3094    // lastCol should not go over if multiple of columnWidth #425
     3095    lastCol -= lastX % this.columnWidth ? 0 : 1;
     3096    lastCol = Math.min( this.cols - 1, lastCol );
     3097    // set colYs to bottom of the stamp
     3098    var stampMaxY = ( this.options.isOriginTop ? offset.top : offset.bottom ) +
     3099      stampSize.outerHeight;
     3100    for ( var i = firstCol; i <= lastCol; i++ ) {
     3101      this.colYs[i] = Math.max( stampMaxY, this.colYs[i] );
     3102    }
     3103  };
     3104
     3105  Masonry.prototype._getContainerSize = function() {
     3106    this.maxY = Math.max.apply( Math, this.colYs );
     3107    var size = {
     3108      height: this.maxY
     3109    };
     3110
     3111    if ( this.options.isFitWidth ) {
     3112      size.width = this._getContainerFitWidth();
     3113    }
     3114
     3115    return size;
     3116  };
     3117
     3118  Masonry.prototype._getContainerFitWidth = function() {
     3119    var unusedCols = 0;
     3120    // count unused columns
     3121    var i = this.cols;
     3122    while ( --i ) {
     3123      if ( this.colYs[i] !== 0 ) {
     3124        break;
     3125      }
     3126      unusedCols++;
     3127    }
     3128    // fit container to columns that have been used
     3129    return ( this.cols - unusedCols ) * this.columnWidth - this.gutter;
     3130  };
     3131
     3132  Masonry.prototype.needsResizeLayout = function() {
     3133    var previousWidth = this.containerWidth;
     3134    this.getContainerWidth();
     3135    return previousWidth !== this.containerWidth;
     3136  };
     3137
     3138  return Masonry;
     3139
     3140}));
     3141
  • wp-includes/js/masonry.min.js

     
    11/*!
    2  * Masonry PACKAGED v3.1.4
     2 * Masonry PACKAGED v3.3.0
    33 * Cascading grid layout library
    44 * http://masonry.desandro.com
    55 * MIT License
     
    66 * by David DeSandro
    77 */
    88
    9 (function(t){function e(){}function i(t){function i(e){e.prototype.option||(e.prototype.option=function(e){t.isPlainObject(e)&&(this.options=t.extend(!0,this.options,e))})}function o(e,i){t.fn[e]=function(o){if("string"==typeof o){for(var s=n.call(arguments,1),a=0,h=this.length;h>a;a++){var p=this[a],u=t.data(p,e);if(u)if(t.isFunction(u[o])&&"_"!==o.charAt(0)){var f=u[o].apply(u,s);if(void 0!==f)return f}else r("no such method '"+o+"' for "+e+" instance");else r("cannot call methods on "+e+" prior to initialization; "+"attempted to call '"+o+"'")}return this}return this.each(function(){var n=t.data(this,e);n?(n.option(o),n._init()):(n=new i(this,o),t.data(this,e,n))})}}if(t){var r="undefined"==typeof console?e:function(t){console.error(t)};return t.bridget=function(t,e){i(e),o(t,e)},t.bridget}}var n=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],i):i(t.jQuery)})(window),function(t){function e(e){var i=t.event;return i.target=i.target||i.srcElement||e,i}var i=document.documentElement,n=function(){};i.addEventListener?n=function(t,e,i){t.addEventListener(e,i,!1)}:i.attachEvent&&(n=function(t,i,n){t[i+n]=n.handleEvent?function(){var i=e(t);n.handleEvent.call(n,i)}:function(){var i=e(t);n.call(t,i)},t.attachEvent("on"+i,t[i+n])});var o=function(){};i.removeEventListener?o=function(t,e,i){t.removeEventListener(e,i,!1)}:i.detachEvent&&(o=function(t,e,i){t.detachEvent("on"+e,t[e+i]);try{delete t[e+i]}catch(n){t[e+i]=void 0}});var r={bind:n,unbind:o};"function"==typeof define&&define.amd?define("eventie/eventie",r):"object"==typeof exports?module.exports=r:t.eventie=r}(this),function(t){function e(t){"function"==typeof t&&(e.isReady?t():r.push(t))}function i(t){var i="readystatechange"===t.type&&"complete"!==o.readyState;if(!e.isReady&&!i){e.isReady=!0;for(var n=0,s=r.length;s>n;n++){var a=r[n];a()}}}function n(n){return n.bind(o,"DOMContentLoaded",i),n.bind(o,"readystatechange",i),n.bind(t,"load",i),e}var o=t.document,r=[];e.isReady=!1,"function"==typeof define&&define.amd?(e.isReady="function"==typeof requirejs,define("doc-ready/doc-ready",["eventie/eventie"],n)):t.docReady=n(t.eventie)}(this),function(){function t(){}function e(t,e){for(var i=t.length;i--;)if(t[i].listener===e)return i;return-1}function i(t){return function(){return this[t].apply(this,arguments)}}var n=t.prototype,o=this,r=o.EventEmitter;n.getListeners=function(t){var e,i,n=this._getEvents();if(t instanceof RegExp){e={};for(i in n)n.hasOwnProperty(i)&&t.test(i)&&(e[i]=n[i])}else e=n[t]||(n[t]=[]);return e},n.flattenListeners=function(t){var e,i=[];for(e=0;t.length>e;e+=1)i.push(t[e].listener);return i},n.getListenersAsObject=function(t){var e,i=this.getListeners(t);return i instanceof Array&&(e={},e[t]=i),e||i},n.addListener=function(t,i){var n,o=this.getListenersAsObject(t),r="object"==typeof i;for(n in o)o.hasOwnProperty(n)&&-1===e(o[n],i)&&o[n].push(r?i:{listener:i,once:!1});return this},n.on=i("addListener"),n.addOnceListener=function(t,e){return this.addListener(t,{listener:e,once:!0})},n.once=i("addOnceListener"),n.defineEvent=function(t){return this.getListeners(t),this},n.defineEvents=function(t){for(var e=0;t.length>e;e+=1)this.defineEvent(t[e]);return this},n.removeListener=function(t,i){var n,o,r=this.getListenersAsObject(t);for(o in r)r.hasOwnProperty(o)&&(n=e(r[o],i),-1!==n&&r[o].splice(n,1));return this},n.off=i("removeListener"),n.addListeners=function(t,e){return this.manipulateListeners(!1,t,e)},n.removeListeners=function(t,e){return this.manipulateListeners(!0,t,e)},n.manipulateListeners=function(t,e,i){var n,o,r=t?this.removeListener:this.addListener,s=t?this.removeListeners:this.addListeners;if("object"!=typeof e||e instanceof RegExp)for(n=i.length;n--;)r.call(this,e,i[n]);else for(n in e)e.hasOwnProperty(n)&&(o=e[n])&&("function"==typeof o?r.call(this,n,o):s.call(this,n,o));return this},n.removeEvent=function(t){var e,i=typeof t,n=this._getEvents();if("string"===i)delete n[t];else if(t instanceof RegExp)for(e in n)n.hasOwnProperty(e)&&t.test(e)&&delete n[e];else delete this._events;return this},n.removeAllListeners=i("removeEvent"),n.emitEvent=function(t,e){var i,n,o,r,s=this.getListenersAsObject(t);for(o in s)if(s.hasOwnProperty(o))for(n=s[o].length;n--;)i=s[o][n],i.once===!0&&this.removeListener(t,i.listener),r=i.listener.apply(this,e||[]),r===this._getOnceReturnValue()&&this.removeListener(t,i.listener);return this},n.trigger=i("emitEvent"),n.emit=function(t){var e=Array.prototype.slice.call(arguments,1);return this.emitEvent(t,e)},n.setOnceReturnValue=function(t){return this._onceReturnValue=t,this},n._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},n._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return o.EventEmitter=r,t},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return t}):"object"==typeof module&&module.exports?module.exports=t:this.EventEmitter=t}.call(this),function(t){function e(t){if(t){if("string"==typeof n[t])return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e,o=0,r=i.length;r>o;o++)if(e=i[o]+t,"string"==typeof n[e])return e}}var i="Webkit Moz ms Ms O".split(" "),n=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return e}):"object"==typeof exports?module.exports=e:t.getStyleProperty=e}(window),function(t){function e(t){var e=parseFloat(t),i=-1===t.indexOf("%")&&!isNaN(e);return i&&e}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0,i=s.length;i>e;e++){var n=s[e];t[n]=0}return t}function n(t){function n(t){if("string"==typeof t&&(t=document.querySelector(t)),t&&"object"==typeof t&&t.nodeType){var n=r(t);if("none"===n.display)return i();var o={};o.width=t.offsetWidth,o.height=t.offsetHeight;for(var u=o.isBorderBox=!(!p||!n[p]||"border-box"!==n[p]),f=0,c=s.length;c>f;f++){var d=s[f],l=n[d];l=a(t,l);var m=parseFloat(l);o[d]=isNaN(m)?0:m}var y=o.paddingLeft+o.paddingRight,g=o.paddingTop+o.paddingBottom,v=o.marginLeft+o.marginRight,b=o.marginTop+o.marginBottom,_=o.borderLeftWidth+o.borderRightWidth,E=o.borderTopWidth+o.borderBottomWidth,L=u&&h,x=e(n.width);x!==!1&&(o.width=x+(L?0:y+_));var z=e(n.height);return z!==!1&&(o.height=z+(L?0:g+E)),o.innerWidth=o.width-(y+_),o.innerHeight=o.height-(g+E),o.outerWidth=o.width+v,o.outerHeight=o.height+b,o}}function a(t,e){if(o||-1===e.indexOf("%"))return e;var i=t.style,n=i.left,r=t.runtimeStyle,s=r&&r.left;return s&&(r.left=t.currentStyle.left),i.left=e,e=i.pixelLeft,i.left=n,s&&(r.left=s),e}var h,p=t("boxSizing");return function(){if(p){var t=document.createElement("div");t.style.width="200px",t.style.padding="1px 2px 3px 4px",t.style.borderStyle="solid",t.style.borderWidth="1px 2px 3px 4px",t.style[p]="border-box";var i=document.body||document.documentElement;i.appendChild(t);var n=r(t);h=200===e(n.width),i.removeChild(t)}}(),n}var o=t.getComputedStyle,r=o?function(t){return o(t,null)}:function(t){return t.currentStyle},s=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],n):"object"==typeof exports?module.exports=n(require("get-style-property")):t.getSize=n(t.getStyleProperty)}(window),function(t,e){function i(t,e){return t[a](e)}function n(t){if(!t.parentNode){var e=document.createDocumentFragment();e.appendChild(t)}}function o(t,e){n(t);for(var i=t.parentNode.querySelectorAll(e),o=0,r=i.length;r>o;o++)if(i[o]===t)return!0;return!1}function r(t,e){return n(t),i(t,e)}var s,a=function(){if(e.matchesSelector)return"matchesSelector";for(var t=["webkit","moz","ms","o"],i=0,n=t.length;n>i;i++){var o=t[i],r=o+"MatchesSelector";if(e[r])return r}}();if(a){var h=document.createElement("div"),p=i(h,"div");s=p?i:r}else s=o;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return s}):window.matchesSelector=s}(this,Element.prototype),function(t){function e(t,e){for(var i in e)t[i]=e[i];return t}function i(t){for(var e in t)return!1;return e=null,!0}function n(t){return t.replace(/([A-Z])/g,function(t){return"-"+t.toLowerCase()})}function o(t,o,r){function a(t,e){t&&(this.element=t,this.layout=e,this.position={x:0,y:0},this._create())}var h=r("transition"),p=r("transform"),u=h&&p,f=!!r("perspective"),c={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[h],d=["transform","transition","transitionDuration","transitionProperty"],l=function(){for(var t={},e=0,i=d.length;i>e;e++){var n=d[e],o=r(n);o&&o!==n&&(t[n]=o)}return t}();e(a.prototype,t.prototype),a.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},a.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},a.prototype.getSize=function(){this.size=o(this.element)},a.prototype.css=function(t){var e=this.element.style;for(var i in t){var n=l[i]||i;e[n]=t[i]}},a.prototype.getPosition=function(){var t=s(this.element),e=this.layout.options,i=e.isOriginLeft,n=e.isOriginTop,o=parseInt(t[i?"left":"right"],10),r=parseInt(t[n?"top":"bottom"],10);o=isNaN(o)?0:o,r=isNaN(r)?0:r;var a=this.layout.size;o-=i?a.paddingLeft:a.paddingRight,r-=n?a.paddingTop:a.paddingBottom,this.position.x=o,this.position.y=r},a.prototype.layoutPosition=function(){var t=this.layout.size,e=this.layout.options,i={};e.isOriginLeft?(i.left=this.position.x+t.paddingLeft+"px",i.right=""):(i.right=this.position.x+t.paddingRight+"px",i.left=""),e.isOriginTop?(i.top=this.position.y+t.paddingTop+"px",i.bottom=""):(i.bottom=this.position.y+t.paddingBottom+"px",i.top=""),this.css(i),this.emitEvent("layout",[this])};var m=f?function(t,e){return"translate3d("+t+"px, "+e+"px, 0)"}:function(t,e){return"translate("+t+"px, "+e+"px)"};a.prototype._transitionTo=function(t,e){this.getPosition();var i=this.position.x,n=this.position.y,o=parseInt(t,10),r=parseInt(e,10),s=o===this.position.x&&r===this.position.y;if(this.setPosition(t,e),s&&!this.isTransitioning)return this.layoutPosition(),void 0;var a=t-i,h=e-n,p={},u=this.layout.options;a=u.isOriginLeft?a:-a,h=u.isOriginTop?h:-h,p.transform=m(a,h),this.transition({to:p,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},a.prototype.goTo=function(t,e){this.setPosition(t,e),this.layoutPosition()},a.prototype.moveTo=u?a.prototype._transitionTo:a.prototype.goTo,a.prototype.setPosition=function(t,e){this.position.x=parseInt(t,10),this.position.y=parseInt(e,10)},a.prototype._nonTransition=function(t){this.css(t.to),t.isCleaning&&this._removeStyles(t.to);for(var e in t.onTransitionEnd)t.onTransitionEnd[e].call(this)},a.prototype._transition=function(t){if(!parseFloat(this.layout.options.transitionDuration))return this._nonTransition(t),void 0;var e=this._transn;for(var i in t.onTransitionEnd)e.onEnd[i]=t.onTransitionEnd[i];for(i in t.to)e.ingProperties[i]=!0,t.isCleaning&&(e.clean[i]=!0);if(t.from){this.css(t.from);var n=this.element.offsetHeight;n=null}this.enableTransition(t.to),this.css(t.to),this.isTransitioning=!0};var y=p&&n(p)+",opacity";a.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:y,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(c,this,!1))},a.prototype.transition=a.prototype[h?"_transition":"_nonTransition"],a.prototype.onwebkitTransitionEnd=function(t){this.ontransitionend(t)},a.prototype.onotransitionend=function(t){this.ontransitionend(t)};var g={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};a.prototype.ontransitionend=function(t){if(t.target===this.element){var e=this._transn,n=g[t.propertyName]||t.propertyName;if(delete e.ingProperties[n],i(e.ingProperties)&&this.disableTransition(),n in e.clean&&(this.element.style[t.propertyName]="",delete e.clean[n]),n in e.onEnd){var o=e.onEnd[n];o.call(this),delete e.onEnd[n]}this.emitEvent("transitionEnd",[this])}},a.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(c,this,!1),this.isTransitioning=!1},a.prototype._removeStyles=function(t){var e={};for(var i in t)e[i]="";this.css(e)};var v={transitionProperty:"",transitionDuration:""};return a.prototype.removeTransitionStyles=function(){this.css(v)},a.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.emitEvent("remove",[this])},a.prototype.remove=function(){if(!h||!parseFloat(this.layout.options.transitionDuration))return this.removeElem(),void 0;var t=this;this.on("transitionEnd",function(){return t.removeElem(),!0}),this.hide()},a.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var t=this.layout.options;this.transition({from:t.hiddenStyle,to:t.visibleStyle,isCleaning:!0})},a.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var t=this.layout.options;this.transition({from:t.visibleStyle,to:t.hiddenStyle,isCleaning:!0,onTransitionEnd:{opacity:function(){this.isHidden&&this.css({display:"none"})}}})},a.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},a}var r=document.defaultView,s=r&&r.getComputedStyle?function(t){return r.getComputedStyle(t,null)}:function(t){return t.currentStyle};"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property"],o):(t.Outlayer={},t.Outlayer.Item=o(t.EventEmitter,t.getSize,t.getStyleProperty))}(window),function(t){function e(t,e){for(var i in e)t[i]=e[i];return t}function i(t){return"[object Array]"===f.call(t)}function n(t){var e=[];if(i(t))e=t;else if(t&&"number"==typeof t.length)for(var n=0,o=t.length;o>n;n++)e.push(t[n]);else e.push(t);return e}function o(t,e){var i=d(e,t);-1!==i&&e.splice(i,1)}function r(t){return t.replace(/(.)([A-Z])/g,function(t,e,i){return e+"-"+i}).toLowerCase()}function s(i,s,f,d,l,m){function y(t,i){if("string"==typeof t&&(t=a.querySelector(t)),!t||!c(t))return h&&h.error("Bad "+this.constructor.namespace+" element: "+t),void 0;this.element=t,this.options=e({},this.options),this.option(i);var n=++v;this.element.outlayerGUID=n,b[n]=this,this._create(),this.options.isInitLayout&&this.layout()}function g(t,i){t.prototype[i]=e({},y.prototype[i])}var v=0,b={};return y.namespace="outlayer",y.Item=m,y.prototype.options={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},e(y.prototype,f.prototype),y.prototype.option=function(t){e(this.options,t)},y.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),e(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},y.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},y.prototype._itemize=function(t){for(var e=this._filterFindItemElements(t),i=this.constructor.Item,n=[],o=0,r=e.length;r>o;o++){var s=e[o],a=new i(s,this);n.push(a)}return n},y.prototype._filterFindItemElements=function(t){t=n(t);for(var e=this.options.itemSelector,i=[],o=0,r=t.length;r>o;o++){var s=t[o];if(c(s))if(e){l(s,e)&&i.push(s);for(var a=s.querySelectorAll(e),h=0,p=a.length;p>h;h++)i.push(a[h])}else i.push(s)}return i},y.prototype.getItemElements=function(){for(var t=[],e=0,i=this.items.length;i>e;e++)t.push(this.items[e].element);return t},y.prototype.layout=function(){this._resetLayout(),this._manageStamps();var t=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,t),this._isLayoutInited=!0},y.prototype._init=y.prototype.layout,y.prototype._resetLayout=function(){this.getSize()},y.prototype.getSize=function(){this.size=d(this.element)},y.prototype._getMeasurement=function(t,e){var i,n=this.options[t];n?("string"==typeof n?i=this.element.querySelector(n):c(n)&&(i=n),this[t]=i?d(i)[e]:n):this[t]=0},y.prototype.layoutItems=function(t,e){t=this._getItemsForLayout(t),this._layoutItems(t,e),this._postLayout()},y.prototype._getItemsForLayout=function(t){for(var e=[],i=0,n=t.length;n>i;i++){var o=t[i];o.isIgnored||e.push(o)}return e},y.prototype._layoutItems=function(t,e){function i(){n.emitEvent("layoutComplete",[n,t])}var n=this;if(!t||!t.length)return i(),void 0;this._itemsOn(t,"layout",i);for(var o=[],r=0,s=t.length;s>r;r++){var a=t[r],h=this._getItemLayoutPosition(a);h.item=a,h.isInstant=e||a.isLayoutInstant,o.push(h)}this._processLayoutQueue(o)},y.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},y.prototype._processLayoutQueue=function(t){for(var e=0,i=t.length;i>e;e++){var n=t[e];this._positionItem(n.item,n.x,n.y,n.isInstant)}},y.prototype._positionItem=function(t,e,i,n){n?t.goTo(e,i):t.moveTo(e,i)},y.prototype._postLayout=function(){var t=this._getContainerSize();t&&(this._setContainerMeasure(t.width,!0),this._setContainerMeasure(t.height,!1))},y.prototype._getContainerSize=u,y.prototype._setContainerMeasure=function(t,e){if(void 0!==t){var i=this.size;i.isBorderBox&&(t+=e?i.paddingLeft+i.paddingRight+i.borderLeftWidth+i.borderRightWidth:i.paddingBottom+i.paddingTop+i.borderTopWidth+i.borderBottomWidth),t=Math.max(t,0),this.element.style[e?"width":"height"]=t+"px"}},y.prototype._itemsOn=function(t,e,i){function n(){return o++,o===r&&i.call(s),!0}for(var o=0,r=t.length,s=this,a=0,h=t.length;h>a;a++){var p=t[a];p.on(e,n)}},y.prototype.ignore=function(t){var e=this.getItem(t);e&&(e.isIgnored=!0)},y.prototype.unignore=function(t){var e=this.getItem(t);e&&delete e.isIgnored},y.prototype.stamp=function(t){if(t=this._find(t)){this.stamps=this.stamps.concat(t);for(var e=0,i=t.length;i>e;e++){var n=t[e];this.ignore(n)}}},y.prototype.unstamp=function(t){if(t=this._find(t))for(var e=0,i=t.length;i>e;e++){var n=t[e];o(n,this.stamps),this.unignore(n)}},y.prototype._find=function(t){return t?("string"==typeof t&&(t=this.element.querySelectorAll(t)),t=n(t)):void 0},y.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var t=0,e=this.stamps.length;e>t;t++){var i=this.stamps[t];this._manageStamp(i)}}},y.prototype._getBoundingRect=function(){var t=this.element.getBoundingClientRect(),e=this.size;this._boundingRect={left:t.left+e.paddingLeft+e.borderLeftWidth,top:t.top+e.paddingTop+e.borderTopWidth,right:t.right-(e.paddingRight+e.borderRightWidth),bottom:t.bottom-(e.paddingBottom+e.borderBottomWidth)}},y.prototype._manageStamp=u,y.prototype._getElementOffset=function(t){var e=t.getBoundingClientRect(),i=this._boundingRect,n=d(t),o={left:e.left-i.left-n.marginLeft,top:e.top-i.top-n.marginTop,right:i.right-e.right-n.marginRight,bottom:i.bottom-e.bottom-n.marginBottom};return o},y.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},y.prototype.bindResize=function(){this.isResizeBound||(i.bind(t,"resize",this),this.isResizeBound=!0)},y.prototype.unbindResize=function(){i.unbind(t,"resize",this),this.isResizeBound=!1},y.prototype.onresize=function(){function t(){e.resize(),delete e.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var e=this;this.resizeTimeout=setTimeout(t,100)},y.prototype.resize=function(){var t=d(this.element),e=this.size&&t;e&&t.innerWidth===this.size.innerWidth||this.layout()},y.prototype.addItems=function(t){var e=this._itemize(t);return e.length&&(this.items=this.items.concat(e)),e},y.prototype.appended=function(t){var e=this.addItems(t);e.length&&(this.layoutItems(e,!0),this.reveal(e))},y.prototype.prepended=function(t){var e=this._itemize(t);if(e.length){var i=this.items.slice(0);this.items=e.concat(i),this._resetLayout(),this._manageStamps(),this.layoutItems(e,!0),this.reveal(e),this.layoutItems(i)}},y.prototype.reveal=function(t){var e=t&&t.length;if(e)for(var i=0;e>i;i++){var n=t[i];n.reveal()}},y.prototype.hide=function(t){var e=t&&t.length;if(e)for(var i=0;e>i;i++){var n=t[i];n.hide()}},y.prototype.getItem=function(t){for(var e=0,i=this.items.length;i>e;e++){var n=this.items[e];if(n.element===t)return n}},y.prototype.getItems=function(t){if(t&&t.length){for(var e=[],i=0,n=t.length;n>i;i++){var o=t[i],r=this.getItem(o);r&&e.push(r)}return e}},y.prototype.remove=function(t){t=n(t);var e=this.getItems(t);if(e&&e.length){this._itemsOn(e,"remove",function(){this.emitEvent("removeComplete",[this,e])});for(var i=0,r=e.length;r>i;i++){var s=e[i];s.remove(),o(s,this.items)}}},y.prototype.destroy=function(){var t=this.element.style;t.height="",t.position="",t.width="";for(var e=0,i=this.items.length;i>e;e++){var n=this.items[e];n.destroy()}this.unbindResize(),delete this.element.outlayerGUID,p&&p.removeData(this.element,this.constructor.namespace)},y.data=function(t){var e=t&&t.outlayerGUID;return e&&b[e]},y.create=function(t,i){function n(){y.apply(this,arguments)}return Object.create?n.prototype=Object.create(y.prototype):e(n.prototype,y.prototype),n.prototype.constructor=n,g(n,"options"),e(n.prototype.options,i),n.namespace=t,n.data=y.data,n.Item=function(){m.apply(this,arguments)},n.Item.prototype=new m,s(function(){for(var e=r(t),i=a.querySelectorAll(".js-"+e),o="data-"+e+"-options",s=0,u=i.length;u>s;s++){var f,c=i[s],d=c.getAttribute(o);try{f=d&&JSON.parse(d)}catch(l){h&&h.error("Error parsing "+o+" on "+c.nodeName.toLowerCase()+(c.id?"#"+c.id:"")+": "+l);continue}var m=new n(c,f);p&&p.data(c,t,m)}}),p&&p.bridget&&p.bridget(t,n),n},y.Item=m,y}var a=t.document,h=t.console,p=t.jQuery,u=function(){},f=Object.prototype.toString,c="object"==typeof HTMLElement?function(t){return t instanceof HTMLElement}:function(t){return t&&"object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName},d=Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var i=0,n=t.length;n>i;i++)if(t[i]===e)return i;return-1};"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","doc-ready/doc-ready","eventEmitter/EventEmitter","get-size/get-size","matches-selector/matches-selector","./item"],s):t.Outlayer=s(t.eventie,t.docReady,t.EventEmitter,t.getSize,t.matchesSelector,t.Outlayer.Item)}(window),function(t){function e(t,e){var n=t.create("masonry");return n.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var t=this.cols;for(this.colYs=[];t--;)this.colYs.push(0);this.maxY=0},n.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var t=this.items[0],i=t&&t.element;this.columnWidth=i&&e(i).outerWidth||this.containerWidth}this.columnWidth+=this.gutter,this.cols=Math.floor((this.containerWidth+this.gutter)/this.columnWidth),this.cols=Math.max(this.cols,1)},n.prototype.getContainerWidth=function(){var t=this.options.isFitWidth?this.element.parentNode:this.element,i=e(t);this.containerWidth=i&&i.innerWidth},n.prototype._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth%this.columnWidth,n=e&&1>e?"round":"ceil",o=Math[n](t.size.outerWidth/this.columnWidth);o=Math.min(o,this.cols);for(var r=this._getColGroup(o),s=Math.min.apply(Math,r),a=i(r,s),h={x:this.columnWidth*a,y:s},p=s+t.size.outerHeight,u=this.cols+1-r.length,f=0;u>f;f++)this.colYs[a+f]=p;return h},n.prototype._getColGroup=function(t){if(2>t)return this.colYs;for(var e=[],i=this.cols+1-t,n=0;i>n;n++){var o=this.colYs.slice(n,n+t);e[n]=Math.max.apply(Math,o)}return e},n.prototype._manageStamp=function(t){var i=e(t),n=this._getElementOffset(t),o=this.options.isOriginLeft?n.left:n.right,r=o+i.outerWidth,s=Math.floor(o/this.columnWidth);s=Math.max(0,s);var a=Math.floor(r/this.columnWidth);a-=r%this.columnWidth?0:1,a=Math.min(this.cols-1,a);for(var h=(this.options.isOriginTop?n.top:n.bottom)+i.outerHeight,p=s;a>=p;p++)this.colYs[p]=Math.max(h,this.colYs[p])},n.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this.options.isFitWidth&&(t.width=this._getContainerFitWidth()),t},n.prototype._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},n.prototype.resize=function(){var t=this.containerWidth;this.getContainerWidth(),t!==this.containerWidth&&this.layout()},n}var i=Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var i=0,n=t.length;n>i;i++){var o=t[i];if(o===e)return i}return-1};"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size"],e):t.Masonry=e(t.Outlayer,t.getSize)}(window);
    10 
    11 /*!
    12  * imagesLoaded PACKAGED v3.1.4
    13  * JavaScript is all like "You images are done yet or what?"
    14  * MIT License
    15  */
    16 
    17 (function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("eventEmitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(this,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function c(e){this.img=e}function f(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
    18  No newline at end of file
     9!function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}return this.each(function(){var d=a.data(this,b);d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d))})}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],c):c("object"==typeof exports?require("jquery"):a.jQuery)}(window),function(a){function b(b){var c=a.event;return c.target=c.target||c.srcElement||b,c}var c=document.documentElement,d=function(){};c.addEventListener?d=function(a,b,c){a.addEventListener(b,c,!1)}:c.attachEvent&&(d=function(a,c,d){a[c+d]=d.handleEvent?function(){var c=b(a);d.handleEvent.call(d,c)}:function(){var c=b(a);d.call(a,c)},a.attachEvent("on"+c,a[c+d])});var e=function(){};c.removeEventListener?e=function(a,b,c){a.removeEventListener(b,c,!1)}:c.detachEvent&&(e=function(a,b,c){a.detachEvent("on"+b,a[b+c]);try{delete a[b+c]}catch(d){a[b+c]=void 0}});var f={bind:d,unbind:e};"function"==typeof define&&define.amd?define("eventie/eventie",f):"object"==typeof exports?module.exports=f:a.eventie=f}(window),function(){function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this),function(a){function b(a){if(a){if("string"==typeof d[a])return a;a=a.charAt(0).toUpperCase()+a.slice(1);for(var b,e=0,f=c.length;f>e;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):"object"==typeof exports?module.exports=b:a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function c(){}function d(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}return a}function e(c){function e(){if(!m){m=!0;var d=a.getComputedStyle;if(j=function(){var a=d?function(a){return d(a,null)}:function(a){return a.currentStyle};return function(b){var c=a(b);return c||f("Style returned "+c+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),c}}(),k=c("boxSizing")){var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style[k]="border-box";var g=document.body||document.documentElement;g.appendChild(e);var h=j(e);l=200===b(h.width),g.removeChild(e)}}}function h(a){if(e(),"string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var c=j(a);if("none"===c.display)return d();var f={};f.width=a.offsetWidth,f.height=a.offsetHeight;for(var h=f.isBorderBox=!(!k||!c[k]||"border-box"!==c[k]),m=0,n=g.length;n>m;m++){var o=g[m],p=c[o];p=i(a,p);var q=parseFloat(p);f[o]=isNaN(q)?0:q}var r=f.paddingLeft+f.paddingRight,s=f.paddingTop+f.paddingBottom,t=f.marginLeft+f.marginRight,u=f.marginTop+f.marginBottom,v=f.borderLeftWidth+f.borderRightWidth,w=f.borderTopWidth+f.borderBottomWidth,x=h&&l,y=b(c.width);y!==!1&&(f.width=y+(x?0:r+v));var z=b(c.height);return z!==!1&&(f.height=z+(x?0:s+w)),f.innerWidth=f.width-(r+v),f.innerHeight=f.height-(s+w),f.outerWidth=f.width+t,f.outerHeight=f.height+u,f}}function i(b,c){if(a.getComputedStyle||-1===c.indexOf("%"))return c;var d=b.style,e=d.left,f=b.runtimeStyle,g=f&&f.left;return g&&(f.left=b.currentStyle.left),d.left=c,c=d.pixelLeft,d.left=e,g&&(f.left=g),c}var j,k,l,m=!1;return h}var f="undefined"==typeof console?c:function(a){console.error(a)},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],e):"object"==typeof exports?module.exports=e(require("desandro-get-style-property")):a.getSize=e(a.getStyleProperty)}(window),function(a){function b(a){"function"==typeof a&&(b.isReady?a():g.push(a))}function c(a){var c="readystatechange"===a.type&&"complete"!==f.readyState;b.isReady||c||d()}function d(){b.isReady=!0;for(var a=0,c=g.length;c>a;a++){var d=g[a];d()}}function e(e){return"complete"===f.readyState?d():(e.bind(f,"DOMContentLoaded",c),e.bind(f,"readystatechange",c),e.bind(a,"load",c)),b}var f=a.document,g=[];b.isReady=!1,"function"==typeof define&&define.amd?define("doc-ready/doc-ready",["eventie/eventie"],e):"object"==typeof exports?module.exports=e(require("eventie")):a.docReady=e(a.eventie)}(window),function(a){function b(a,b){return a[g](b)}function c(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}function d(a,b){c(a);for(var d=a.parentNode.querySelectorAll(b),e=0,f=d.length;f>e;e++)if(d[e]===a)return!0;return!1}function e(a,d){return c(a),b(a,d)}var f,g=function(){if(a.matches)return"matches";if(a.matchesSelector)return"matchesSelector";for(var b=["webkit","moz","ms","o"],c=0,d=b.length;d>c;c++){var e=b[c],f=e+"MatchesSelector";if(a[f])return f}}();if(g){var h=document.createElement("div"),i=b(h,"div");f=i?b:e}else f=d;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return f}):"object"==typeof exports?module.exports=f:window.matchesSelector=f}(Element.prototype),function(a,b){"function"==typeof define&&define.amd?define("fizzy-ui-utils/utils",["doc-ready/doc-ready","matches-selector/matches-selector"],function(c,d){return b(a,c,d)}):"object"==typeof exports?module.exports=b(a,require("doc-ready"),require("desandro-matches-selector")):a.fizzyUIUtils=b(a,a.docReady,a.matchesSelector)}(window,function(a,b,c){var d={};d.extend=function(a,b){for(var c in b)a[c]=b[c];return a},d.modulo=function(a,b){return(a%b+b)%b};var e=Object.prototype.toString;d.isArray=function(a){return"[object Array]"==e.call(a)},d.makeArray=function(a){var b=[];if(d.isArray(a))b=a;else if(a&&"number"==typeof a.length)for(var c=0,e=a.length;e>c;c++)b.push(a[c]);else b.push(a);return b},d.indexOf=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},d.removeFrom=function(a,b){var c=d.indexOf(a,b);-1!=c&&a.splice(c,1)},d.isElement="function"==typeof HTMLElement||"object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1==a.nodeType&&"string"==typeof a.nodeName},d.setText=function(){function a(a,c){b=b||(void 0!==document.documentElement.textContent?"textContent":"innerText"),a[b]=c}var b;return a}(),d.getParent=function(a,b){for(;a!=document.body;)if(a=a.parentNode,c(a,b))return a},d.getQueryElement=function(a){return"string"==typeof a?document.querySelector(a):a},d.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},d.filterFindElements=function(a,b){a=d.makeArray(a);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f];if(d.isElement(h))if(b){c(h,b)&&e.push(h);for(var i=h.querySelectorAll(b),j=0,k=i.length;k>j;j++)e.push(i[j])}else e.push(h)}return e},d.debounceMethod=function(a,b,c){var d=a.prototype[b],e=b+"Timeout";a.prototype[b]=function(){var a=this[e];a&&clearTimeout(a);var b=arguments,f=this;this[e]=setTimeout(function(){d.apply(f,b),delete f[e]},c||100)}},d.toDashed=function(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()};var f=a.console;return d.htmlInit=function(c,e){b(function(){for(var b=d.toDashed(e),g=document.querySelectorAll(".js-"+b),h="data-"+b+"-options",i=0,j=g.length;j>i;i++){var k,l=g[i],m=l.getAttribute(h);try{k=m&&JSON.parse(m)}catch(n){f&&f.error("Error parsing "+h+" on "+l.nodeName.toLowerCase()+(l.id?"#"+l.id:"")+": "+n);continue}var o=new c(l,k),p=a.jQuery;p&&p.data(l,e,o)}})},d}),function(a,b){"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property","fizzy-ui-utils/utils"],function(c,d,e,f){return b(a,c,d,e,f)}):"object"==typeof exports?module.exports=b(a,require("wolfy87-eventemitter"),require("get-size"),require("desandro-get-style-property"),require("fizzy-ui-utils")):(a.Outlayer={},a.Outlayer.Item=b(a,a.EventEmitter,a.getSize,a.getStyleProperty,a.fizzyUIUtils))}(window,function(a,b,c,d,e){function f(a){for(var b in a)return!1;return b=null,!0}function g(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}var h=a.getComputedStyle,i=h?function(a){return h(a,null)}:function(a){return a.currentStyle},j=d("transition"),k=d("transform"),l=j&&k,m=!!d("perspective"),n={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[j],o=["transform","transition","transitionDuration","transitionProperty"],p=function(){for(var a={},b=0,c=o.length;c>b;b++){var e=o[b],f=d(e);f&&f!==e&&(a[e]=f)}return a}();e.extend(g.prototype,b.prototype),g.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.getSize=function(){this.size=c(this.element)},g.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=p[c]||c;b[d]=a[c]}},g.prototype.getPosition=function(){var a=i(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=parseInt(a[c?"left":"right"],10),f=parseInt(a[d?"top":"bottom"],10);e=isNaN(e)?0:e,f=isNaN(f)?0:f;var g=this.layout.size;e-=c?g.paddingLeft:g.paddingRight,f-=d?g.paddingTop:g.paddingBottom,this.position.x=e,this.position.y=f},g.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={},d=b.isOriginLeft?"paddingLeft":"paddingRight",e=b.isOriginLeft?"left":"right",f=b.isOriginLeft?"right":"left",g=this.position.x+a[d];g=b.percentPosition&&!b.isHorizontal?g/a.width*100+"%":g+"px",c[e]=g,c[f]="";var h=b.isOriginTop?"paddingTop":"paddingBottom",i=b.isOriginTop?"top":"bottom",j=b.isOriginTop?"bottom":"top",k=this.position.y+a[h];k=b.percentPosition&&b.isHorizontal?k/a.height*100+"%":k+"px",c[i]=k,c[j]="",this.css(c),this.emitEvent("layout",[this])};var q=m?function(a,b){return"translate3d("+a+"px, "+b+"px, 0)"}:function(a,b){return"translate("+a+"px, "+b+"px)"};g.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),f=parseInt(b,10),g=e===this.position.x&&f===this.position.y;if(this.setPosition(a,b),g&&!this.isTransitioning)return void this.layoutPosition();var h=a-c,i=b-d,j={},k=this.layout.options;h=k.isOriginLeft?h:-h,i=k.isOriginTop?i:-i,j.transform=q(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},g.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},g.prototype.moveTo=l?g.prototype._transitionTo:g.prototype.goTo,g.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},g.prototype._nonTransition=function(a){this.css(a.to),a.isCleaning&&this._removeStyles(a.to);for(var b in a.onTransitionEnd)a.onTransitionEnd[b].call(this)},g.prototype._transition=function(a){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(a);var b=this._transn;for(var c in a.onTransitionEnd)b.onEnd[c]=a.onTransitionEnd[c];for(c in a.to)b.ingProperties[c]=!0,a.isCleaning&&(b.clean[c]=!0);if(a.from){this.css(a.from);var d=this.element.offsetHeight;d=null}this.enableTransition(a.to),this.css(a.to),this.isTransitioning=!0};var r=k&&e.toDashed(k)+",opacity";g.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:r,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(n,this,!1))},g.prototype.transition=g.prototype[j?"_transition":"_nonTransition"],g.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},g.prototype.onotransitionend=function(a){this.ontransitionend(a)};var s={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};g.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,c=s[a.propertyName]||a.propertyName;if(delete b.ingProperties[c],f(b.ingProperties)&&this.disableTransition(),c in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[c]),c in b.onEnd){var d=b.onEnd[c];d.call(this),delete b.onEnd[c]}this.emitEvent("transitionEnd",[this])}},g.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(n,this,!1),this.isTransitioning=!1},g.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var t={transitionProperty:"",transitionDuration:""};return g.prototype.removeTransitionStyles=function(){this.css(t)},g.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.css({display:""}),this.emitEvent("remove",[this])},g.prototype.remove=function(){if(!j||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.once("transitionEnd",function(){a.removeElem()}),this.hide()},g.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options,b={},c=this.getHideRevealTransitionEndProperty("visibleStyle");b[c]=this.onRevealTransitionEnd,this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onRevealTransitionEnd=function(){this.isHidden||this.emitEvent("reveal")},g.prototype.getHideRevealTransitionEndProperty=function(a){var b=this.layout.options[a];if(b.opacity)return"opacity";for(var c in b)return c},g.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options,b={},c=this.getHideRevealTransitionEndProperty("hiddenStyle");b[c]=this.onHideTransitionEnd,this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onHideTransitionEnd=function(){this.isHidden&&(this.css({display:"none"}),this.emitEvent("hide"))},g.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},g}),function(a,b){"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","eventEmitter/EventEmitter","get-size/get-size","fizzy-ui-utils/utils","./item"],function(c,d,e,f,g){return b(a,c,d,e,f,g)}):"object"==typeof exports?module.exports=b(a,require("eventie"),require("wolfy87-eventemitter"),require("get-size"),require("fizzy-ui-utils"),require("./item")):a.Outlayer=b(a,a.eventie,a.EventEmitter,a.getSize,a.fizzyUIUtils,a.Outlayer.Item)}(window,function(a,b,c,d,e,f){function g(a,b){var c=e.getQueryElement(a);if(!c)return void(h&&h.error("Bad element for "+this.constructor.namespace+": "+(c||a)));this.element=c,i&&(this.$element=i(this.element)),this.options=e.extend({},this.constructor.defaults),this.option(b);var d=++k;this.element.outlayerGUID=d,l[d]=this,this._create(),this.options.isInitLayout&&this.layout()}var h=a.console,i=a.jQuery,j=function(){},k=0,l={};return g.namespace="outlayer",g.Item=f,g.defaults={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,isResizingContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},e.extend(g.prototype,c.prototype),g.prototype.option=function(a){e.extend(this.options,a)},g.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),e.extend(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},g.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},g.prototype._itemize=function(a){for(var b=this._filterFindItemElements(a),c=this.constructor.Item,d=[],e=0,f=b.length;f>e;e++){var g=b[e],h=new c(g,this);d.push(h)}return d},g.prototype._filterFindItemElements=function(a){return e.filterFindElements(a,this.options.itemSelector)},g.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},g.prototype.layout=function(){this._resetLayout(),this._manageStamps();var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,a),this._isLayoutInited=!0},g.prototype._init=g.prototype.layout,g.prototype._resetLayout=function(){this.getSize()},g.prototype.getSize=function(){this.size=d(this.element)},g.prototype._getMeasurement=function(a,b){var c,f=this.options[a];f?("string"==typeof f?c=this.element.querySelector(f):e.isElement(f)&&(c=f),this[a]=c?d(c)[b]:f):this[a]=0},g.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},g.prototype._getItemsForLayout=function(a){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];e.isIgnored||b.push(e)}return b},g.prototype._layoutItems=function(a,b){if(this._emitCompleteOnItems("layout",a),a&&a.length){for(var c=[],d=0,e=a.length;e>d;d++){var f=a[d],g=this._getItemLayoutPosition(f);g.item=f,g.isInstant=b||f.isLayoutInstant,c.push(g)}this._processLayoutQueue(c)}},g.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},g.prototype._processLayoutQueue=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];this._positionItem(d.item,d.x,d.y,d.isInstant)}},g.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},g.prototype._postLayout=function(){this.resizeContainer()},g.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},g.prototype._getContainerSize=j,g.prototype._setContainerMeasure=function(a,b){if(void 0!==a){var c=this.size;c.isBorderBox&&(a+=b?c.paddingLeft+c.paddingRight+c.borderLeftWidth+c.borderRightWidth:c.paddingBottom+c.paddingTop+c.borderTopWidth+c.borderBottomWidth),a=Math.max(a,0),this.element.style[b?"width":"height"]=a+"px"}},g.prototype._emitCompleteOnItems=function(a,b){function c(){e.emitEvent(a+"Complete",[b])}function d(){g++,g===f&&c()}var e=this,f=b.length;if(!b||!f)return void c();for(var g=0,h=0,i=b.length;i>h;h++){var j=b[h];j.once(a,d)}},g.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},g.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored},g.prototype.stamp=function(a){if(a=this._find(a)){this.stamps=this.stamps.concat(a);for(var b=0,c=a.length;c>b;b++){var d=a[b];this.ignore(d)}}},g.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e.removeFrom(this.stamps,d),this.unignore(d)}},g.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=e.makeArray(a)):void 0},g.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var a=0,b=this.stamps.length;b>a;a++){var c=this.stamps[a];this._manageStamp(c)}}},g.prototype._getBoundingRect=function(){var a=this.element.getBoundingClientRect(),b=this.size;this._boundingRect={left:a.left+b.paddingLeft+b.borderLeftWidth,top:a.top+b.paddingTop+b.borderTopWidth,right:a.right-(b.paddingRight+b.borderRightWidth),bottom:a.bottom-(b.paddingBottom+b.borderBottomWidth)}},g.prototype._manageStamp=j,g.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,e=d(a),f={left:b.left-c.left-e.marginLeft,top:b.top-c.top-e.marginTop,right:c.right-b.right-e.marginRight,bottom:c.bottom-b.bottom-e.marginBottom};return f},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.bindResize=function(){this.isResizeBound||(b.bind(a,"resize",this),this.isResizeBound=!0)},g.prototype.unbindResize=function(){this.isResizeBound&&b.unbind(a,"resize",this),this.isResizeBound=!1},g.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},g.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},g.prototype.needsResizeLayout=function(){var a=d(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},g.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},g.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},g.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){var c=this.items.slice(0);this.items=b.concat(c),this._resetLayout(),this._manageStamps(),this.layoutItems(b,!0),this.reveal(b),this.layoutItems(c)}},g.prototype.reveal=function(a){this._emitCompleteOnItems("reveal",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.reveal()}},g.prototype.hide=function(a){this._emitCompleteOnItems("hide",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.hide()}},g.prototype.revealItemElements=function(a){var b=this.getItems(a);this.reveal(b)},g.prototype.hideItemElements=function(a){var b=this.getItems(a);this.hide(b)},g.prototype.getItem=function(a){for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];if(d.element===a)return d}},g.prototype.getItems=function(a){a=e.makeArray(a);for(var b=[],c=0,d=a.length;d>c;c++){var f=a[c],g=this.getItem(f);g&&b.push(g)}return b},g.prototype.remove=function(a){var b=this.getItems(a);if(this._emitCompleteOnItems("remove",b),b&&b.length)for(var c=0,d=b.length;d>c;c++){var f=b[c];f.remove(),e.removeFrom(this.items,f)}},g.prototype.destroy=function(){var a=this.element.style;a.height="",a.position="",a.width="";for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];d.destroy()}this.unbindResize();var e=this.element.outlayerGUID;delete l[e],delete this.element.outlayerGUID,i&&i.removeData(this.element,this.constructor.namespace)},g.data=function(a){a=e.getQueryElement(a);var b=a&&a.outlayerGUID;return b&&l[b]},g.create=function(a,b){function c(){g.apply(this,arguments)}return Object.create?c.prototype=Object.create(g.prototype):e.extend(c.prototype,g.prototype),c.prototype.constructor=c,c.defaults=e.extend({},g.defaults),e.extend(c.defaults,b),c.prototype.settings={},c.namespace=a,c.data=g.data,c.Item=function(){f.apply(this,arguments)},c.Item.prototype=new f,e.htmlInit(c,a),i&&i.bridget&&i.bridget(a,c),c},g.Item=f,g}),function(a,b){"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size","fizzy-ui-utils/utils"],b):"object"==typeof exports?module.exports=b(require("outlayer"),require("get-size"),require("fizzy-ui-utils")):a.Masonry=b(a.Outlayer,a.getSize,a.fizzyUIUtils)}(window,function(a,b,c){var d=a.create("masonry");return d.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0);this.maxY=0},d.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var a=this.items[0],c=a&&a.element;this.columnWidth=c&&b(c).outerWidth||this.containerWidth}var d=this.columnWidth+=this.gutter,e=this.containerWidth+this.gutter,f=e/d,g=d-e%d,h=g&&1>g?"round":"floor";f=Math[h](f),this.cols=Math.max(f,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);this.containerWidth=c&&c.innerWidth},d.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth%this.columnWidth,d=b&&1>b?"round":"ceil",e=Math[d](a.size.outerWidth/this.columnWidth);e=Math.min(e,this.cols);for(var f=this._getColGroup(e),g=Math.min.apply(Math,f),h=c.indexOf(f,g),i={x:this.columnWidth*h,y:g},j=g+a.size.outerHeight,k=this.cols+1-f.length,l=0;k>l;l++)this.colYs[h+l]=j;return i},d.prototype._getColGroup=function(a){if(2>a)return this.colYs;for(var b=[],c=this.cols+1-a,d=0;c>d;d++){var e=this.colYs.slice(d,d+a);b[d]=Math.max.apply(Math,e)}return b},d.prototype._manageStamp=function(a){var c=b(a),d=this._getElementOffset(a),e=this.options.isOriginLeft?d.left:d.right,f=e+c.outerWidth,g=Math.floor(e/this.columnWidth);g=Math.max(0,g);var h=Math.floor(f/this.columnWidth);h-=f%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var i=(this.options.isOriginTop?d.top:d.bottom)+c.outerHeight,j=g;h>=j;j++)this.colYs[j]=Math.max(i,this.colYs[j])},d.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var a={height:this.maxY};return this.options.isFitWidth&&(a.width=this._getContainerFitWidth()),a},d.prototype._getContainerFitWidth=function(){for(var a=0,b=this.cols;--b&&0===this.colYs[b];)a++;return(this.cols-a)*this.columnWidth-this.gutter},d.prototype.needsResizeLayout=function(){var a=this.containerWidth;return this.getContainerWidth(),a!==this.containerWidth},d});
     10 No newline at end of file
  • wp-includes/script-loader.php

     
    242242        $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 );
    243243        $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 );
    244244
    245         // Masonry v2 depended on jQuery. v3 does not. The older jquery-masonry handle is a shiv.
    246         // It sets jQuery as a dependency, as the theme may have been implicitly loading it this way.
    247         $scripts->add( 'masonry', "/wp-includes/js/masonry.min.js", array(), '3.1.2', 1 );
    248         $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry$dev_suffix.js", array( 'jquery', 'masonry' ), '3.1.2', 1 );
     245        $scripts->add( 'imagesLoaded', "/wp-includes/js/imagesloaded$suffix.js", array(), '3.1.8', 1 );
     246        $scripts->add( 'masonry', "/wp-includes/js/masonry$suffix.js", array(), '3.3.0', 1 );
    249247
    250248        $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20121105', 1 );
    251249        did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array(