vendor/assets/javascripts/packery.pkgd.js in packery-rails-1.2.4 vs vendor/assets/javascripts/packery.pkgd.js in packery-rails-1.3.0
- old
+ new
@@ -1,7 +1,7 @@
/*!
- * Packery PACKAGED v1.2.4
+ * Packery PACKAGED v1.3.0
* bin-packing layout library
* http://packery.metafizzy.co
*
* Commercial use requires one-time purchase of a commercial license
* http://packery.metafizzy.co/license.html
@@ -11,11 +11,12 @@
* Copyright 2014 Metafizzy
*/
/**
* Bridget makes jQuery widgets
- * v1.0.1
+ * v1.1.0
+ * MIT license
*/
( function( window ) {
@@ -55,11 +56,10 @@
}
this.options = $.extend( true, this.options, opts );
};
}
-
// -------------------------- plugin bridge -------------------------- //
// helper function for logging errors
// $.error breaks jQuery chaining
var logError = typeof console === 'undefined' ? noop :
@@ -140,10 +140,12 @@
// transport
if ( typeof define === 'function' && define.amd ) {
// AMD
define( 'jquery-bridget/jquery.bridget',[ 'jquery' ], defineBridget );
+} else if ( typeof exports === 'object' ) {
+ defineBridget( require('jquery') );
} else {
// get jquery from browser global
defineBridget( window.jQuery );
}
@@ -234,13 +236,14 @@
}
})( window );
/*!
- * getStyleProperty v1.0.3
+ * getStyleProperty v1.0.4
* original by kangax
* http://perfectionkills.com/feature-testing-css-properties/
+ * MIT license
*/
/*jshint browser: true, strict: true, undef: true */
/*global define: false, exports: false, module: false */
@@ -288,41 +291,40 @@
window.getStyleProperty = getStyleProperty;
}
})( window );
-/**
- * getSize v1.1.7
+/*!
+ * getSize v1.2.2
* measure size of elements
+ * MIT license
*/
/*jshint browser: true, strict: true, undef: true, unused: true */
-/*global define: false, exports: false, require: false, module: false */
+/*global define: false, exports: false, require: false, module: false, console: false */
( function( window, undefined ) {
// -------------------------- helpers -------------------------- //
-var getComputedStyle = window.getComputedStyle;
-var getStyle = getComputedStyle ?
- function( elem ) {
- return getComputedStyle( elem, null );
- } :
- function( elem ) {
- return elem.currentStyle;
- };
-
// get a number from a string, not a percentage
function getStyleSize( value ) {
var num = parseFloat( value );
// not a percent like '100%', and a number
var isValid = value.indexOf('%') === -1 && !isNaN( num );
return isValid && num;
}
+function noop() {}
+
+var logError = typeof console === 'undefined' ? noop :
+ function( message ) {
+ console.error( message );
+ };
+
// -------------------------- measurements -------------------------- //
var measurements = [
'paddingLeft',
'paddingRight',
@@ -356,43 +358,80 @@
function defineGetSize( getStyleProperty ) {
-// -------------------------- box sizing -------------------------- //
+// -------------------------- setup -------------------------- //
-var boxSizingProp = getStyleProperty('boxSizing');
-var isBoxSizeOuter;
+var isSetup = false;
+var getStyle, boxSizingProp, isBoxSizeOuter;
+
/**
- * WebKit measures the outer-width on style.width on border-box elems
- * IE & Firefox measures the inner-width
+ * setup vars and functions
+ * do it on initial getSize(), rather than on script load
+ * For Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=548397
*/
-( function() {
- if ( !boxSizingProp ) {
+function setup() {
+ // setup once
+ if ( isSetup ) {
return;
}
+ isSetup = true;
- var div = document.createElement('div');
- div.style.width = '200px';
- div.style.padding = '1px 2px 3px 4px';
- div.style.borderStyle = 'solid';
- div.style.borderWidth = '1px 2px 3px 4px';
- div.style[ boxSizingProp ] = 'border-box';
+ var getComputedStyle = window.getComputedStyle;
+ getStyle = ( function() {
+ var getStyleFn = getComputedStyle ?
+ function( elem ) {
+ return getComputedStyle( elem, null );
+ } :
+ function( elem ) {
+ return elem.currentStyle;
+ };
- var body = document.body || document.documentElement;
- body.appendChild( div );
- var style = getStyle( div );
+ return function getStyle( elem ) {
+ var style = getStyleFn( elem );
+ if ( !style ) {
+ logError( 'Style returned ' + style +
+ '. Are you running this code in a hidden iframe on Firefox? ' +
+ 'See http://bit.ly/getsizebug1' );
+ }
+ return style;
+ };
+ })();
- isBoxSizeOuter = getStyleSize( style.width ) === 200;
- body.removeChild( div );
-})();
+ // -------------------------- box sizing -------------------------- //
+ boxSizingProp = getStyleProperty('boxSizing');
+ /**
+ * WebKit measures the outer-width on style.width on border-box elems
+ * IE & Firefox measures the inner-width
+ */
+ if ( boxSizingProp ) {
+ var div = document.createElement('div');
+ div.style.width = '200px';
+ div.style.padding = '1px 2px 3px 4px';
+ div.style.borderStyle = 'solid';
+ div.style.borderWidth = '1px 2px 3px 4px';
+ div.style[ boxSizingProp ] = 'border-box';
+
+ var body = document.body || document.documentElement;
+ body.appendChild( div );
+ var style = getStyle( div );
+
+ isBoxSizeOuter = getStyleSize( style.width ) === 200;
+ body.removeChild( div );
+ }
+
+}
+
// -------------------------- getSize -------------------------- //
function getSize( elem ) {
+ setup();
+
// use querySeletor if elem is string
if ( typeof elem === 'string' ) {
elem = document.querySelector( elem );
}
@@ -460,11 +499,11 @@
// IE8 returns percent values, not pixels
// taken from jQuery's curCSS
function mungeNonPixel( elem, value ) {
// IE8 and has percent value
- if ( getComputedStyle || value.indexOf('%') === -1 ) {
+ if ( window.getComputedStyle || value.indexOf('%') === -1 ) {
return value;
}
var style = elem.style;
// Remember the original values
var left = style.left;
@@ -495,11 +534,11 @@
if ( typeof define === 'function' && define.amd ) {
// AMD for RequireJS
define( 'get-size/get-size',[ 'get-style-property/get-style-property' ], defineGetSize );
} else if ( typeof exports === 'object' ) {
// CommonJS for Component
- module.exports = defineGetSize( require('get-style-property') );
+ module.exports = defineGetSize( require('desandro-get-style-property') );
} else {
// browser global
window.getSize = defineGetSize( window.getStyleProperty );
}
@@ -587,17 +626,17 @@
}
})( this );
/*!
- * docReady v1.0.3
+ * docReady v1.0.4
* Cross browser DOMContentLoaded event emitter
* MIT license
*/
/*jshint browser: true, strict: true, undef: true, unused: true*/
-/*global define: false */
+/*global define: false, require: false, module: false */
( function( window ) {
@@ -621,38 +660,46 @@
}
docReady.isReady = false;
// triggered on various doc ready events
-function init( event ) {
- // bail if IE8 document is not ready just yet
+function onReady( event ) {
+ // bail if already triggered or IE8 document is not ready just yet
var isIE8NotReady = event.type === 'readystatechange' && document.readyState !== 'complete';
if ( docReady.isReady || isIE8NotReady ) {
return;
}
- docReady.isReady = true;
+ trigger();
+}
+
+function trigger() {
+ docReady.isReady = true;
// process queue
for ( var i=0, len = queue.length; i < len; i++ ) {
var fn = queue[i];
fn();
}
}
function defineDocReady( eventie ) {
- eventie.bind( document, 'DOMContentLoaded', init );
- eventie.bind( document, 'readystatechange', init );
- eventie.bind( window, 'load', init );
+ // trigger ready if page is ready
+ if ( document.readyState === 'complete' ) {
+ trigger();
+ } else {
+ // listen for events
+ eventie.bind( document, 'DOMContentLoaded', onReady );
+ eventie.bind( document, 'readystatechange', onReady );
+ eventie.bind( window, 'load', onReady );
+ }
return docReady;
}
// transport
if ( typeof define === 'function' && define.amd ) {
// AMD
- // if RequireJS, then doc is already ready
- docReady.isReady = typeof requirejs === 'function';
define( 'doc-ready/doc-ready',[ 'eventie/eventie' ], defineDocReady );
} else if ( typeof exports === 'object' ) {
module.exports = defineDocReady( require('eventie') );
} else {
// browser global
@@ -660,11 +707,11 @@
}
})( window );
/*!
- * EventEmitter v4.2.7 - git.io/ee
+ * EventEmitter v4.2.9 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
*/
@@ -683,11 +730,11 @@
var proto = EventEmitter.prototype;
var exports = this;
var originalGlobalValue = exports.EventEmitter;
/**
- * Finds the index of the listener for the event in it's storage array.
+ * Finds the index of the listener for the event in its storage array.
*
* @param {Function[]} listeners Array of listeners to search through.
* @param {Function} listener Method to look for.
* @return {Number} Index of the specified listener, -1 if not found
* @api private
@@ -814,11 +861,11 @@
*/
proto.on = alias('addListener');
/**
* Semi-alias of addListener. It will add a listener that will be
- * automatically removed after it's first execution.
+ * automatically removed after its first execution.
*
* @param {String|RegExp} evt Name of the event to attach the listener to.
* @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
* @return {Object} Current instance of EventEmitter for chaining.
*/
@@ -936,11 +983,11 @@
var i;
var value;
var single = remove ? this.removeListener : this.addListener;
var multiple = remove ? this.removeListeners : this.addListeners;
- // If evt is an object then pass each of it's properties to this method
+ // If evt is an object then pass each of its properties to this method
if (typeof evt === 'object' && !(evt instanceof RegExp)) {
for (i in evt) {
if (evt.hasOwnProperty(i) && (value = evt[i])) {
// Pass the single listener straight through to the singular method
if (typeof value === 'function') {
@@ -1128,11 +1175,11 @@
}
else if (typeof module === 'object' && module.exports){
module.exports = EventEmitter;
}
else {
- this.EventEmitter = EventEmitter;
+ exports.EventEmitter = EventEmitter;
}
}.call(this));
/**
* matchesSelector v1.0.2
@@ -1748,10 +1795,17 @@
'eventEmitter/EventEmitter',
'get-size/get-size',
'get-style-property/get-style-property'
],
outlayerItemDefinition );
+} else if (typeof exports === 'object') {
+ // CommonJS
+ module.exports = outlayerItemDefinition(
+ require('wolfy87-eventemitter'),
+ require('get-size'),
+ require('desandro-get-style-property')
+ );
} else {
// browser global
window.Outlayer = {};
window.Outlayer.Item = outlayerItemDefinition(
window.EventEmitter,
@@ -1761,11 +1815,11 @@
}
})( window );
/*!
- * Outlayer v1.2.0
+ * Outlayer v1.3.0
* the brains and guts of a layout library
* MIT license
*/
( function( window ) {
@@ -1775,11 +1829,10 @@
// ----- vars ----- //
var document = window.document;
var console = window.console;
var jQuery = window.jQuery;
-
var noop = function() {};
// -------------------------- helpers -------------------------- //
// extend objects
@@ -1813,11 +1866,11 @@
}
return ary;
}
// http://stackoverflow.com/a/384380/182183
-var isElement = ( typeof HTMLElement === 'object' ) ?
+var isElement = ( typeof HTMLElement === 'function' || typeof HTMLElement === 'object' ) ?
function isElementDOM2( obj ) {
return obj instanceof HTMLElement;
} :
function isElementQuirky( obj ) {
return obj && typeof obj === 'object' &&
@@ -2631,10 +2684,12 @@
item.destroy();
}
this.unbindResize();
+ var id = this.element.outlayerGUID;
+ delete instances[ id ]; // remove reference to instance by id
delete this.element.outlayerGUID;
// remove data for jQuery
if ( jQuery ) {
jQuery.removeData( this.element, this.constructor.namespace );
}
@@ -2756,10 +2811,20 @@
'get-size/get-size',
'matches-selector/matches-selector',
'./item'
],
outlayerDefinition );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = outlayerDefinition(
+ require('eventie'),
+ require('doc-ready'),
+ require('wolfy87-eventemitter'),
+ require('get-size'),
+ require('desandro-matches-selector'),
+ require('./item')
+ );
} else {
// browser global
window.Outlayer = outlayerDefinition(
window.eventie,
window.docReady,
@@ -2922,10 +2987,13 @@
// -------------------------- transport -------------------------- //
if ( typeof define === 'function' && define.amd ) {
// AMD
define( 'packery/js/rect',rectDefinition );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = rectDefinition();
} else {
// browser global
window.Packery = window.Packery || {};
window.Packery.Rect = rectDefinition();
}
@@ -3009,16 +3077,25 @@
}
}
this.spaces = revisedSpaces;
+ this.mergeSortSpaces();
+};
+
+Packer.prototype.mergeSortSpaces = function() {
// remove redundant spaces
Packer.mergeRects( this.spaces );
-
this.spaces.sort( this.sorter );
};
+// add a space back
+Packer.prototype.addSpace = function( rect ) {
+ this.spaces.push( rect );
+ this.mergeSortSpaces();
+};
+
// -------------------------- utility functions -------------------------- //
/**
* Remove redundant rectangle from array of rectangles
* @param {Array} rects: an array of Rects
@@ -3079,10 +3156,15 @@
// -------------------------- transport -------------------------- //
if ( typeof define === 'function' && define.amd ) {
// AMD
define( 'packery/js/packer',[ './rect' ], packerDefinition );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = packerDefinition(
+ require('./rect')
+ );
} else {
// browser global
var Packery = window.Packery = window.Packery || {};
Packery.Packer = packerDefinition( Packery.Rect );
}
@@ -3228,10 +3310,22 @@
Item.prototype.copyPlaceRectPosition = function() {
this.rect.x = this.placeRect.x;
this.rect.y = this.placeRect.y;
};
+// ----- ----- //
+
+// remove element from DOM
+Item.prototype.removeElem = function() {
+ this.element.parentNode.removeChild( this.element );
+ // add space back to packer
+ this.layout.packer.addSpace( this.rect );
+ this.emitEvent( 'remove', [ this ] );
+};
+
+// ----- ----- //
+
return Item;
}
// -------------------------- transport -------------------------- //
@@ -3242,10 +3336,17 @@
'get-style-property/get-style-property',
'outlayer/outlayer',
'./rect'
],
itemDefinition );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = itemDefinition(
+ require('desandro-get-style-property'),
+ require('outlayer'),
+ require('./rect')
+ );
} else {
// browser global
window.Packery.Item = itemDefinition(
window.getStyleProperty,
window.Outlayer,
@@ -3254,11 +3355,11 @@
}
})( window );
/*!
- * Packery v1.2.4
+ * Packery v1.3.0
* bin-packing layout library
* http://packery.metafizzy.co
*
* Commercial use requires one-time purchase of a commercial license
* http://packery.metafizzy.co/license.html
@@ -3712,9 +3813,19 @@
'packery/js/rect',
'packery/js/packer',
'packery/js/item'
],
packeryDefinition );
+} else if ( typeof exports === 'object' ) {
+ // CommonJS
+ module.exports = packeryDefinition(
+ require('desandro-classie'),
+ require('get-size'),
+ require('outlayer'),
+ require('./rect'),
+ require('./packer'),
+ require('./item')
+ );
} else {
// browser global
window.Packery = packeryDefinition(
window.classie,
window.getSize,