Addons for WPBakery Page Builder - Version 1.4

Version Description

  • Added - Left, right and center alignment option to the heading element
  • Added - Styling for services when font icons are chosen instead of image icons
  • Fixed - The testimonials slider content not aligned to the center
  • Fixed - The tab title width was fixed with no wrapping
  • Updated - The isotope and imagesloaded JS libraries.
Download this release

Release Info

Developer livemesh
Plugin Icon 128x128 Addons for WPBakery Page Builder
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

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