config redirect

This commit is contained in:
Nuno Coração
2023-01-29 22:30:24 +00:00
parent 17557c7d73
commit 5fb4bd8083
9905 changed files with 1258996 additions and 36355 deletions

6
node_modules/outlayer/.jshintrc generated vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"browser": true,
"strict": true,
"undef": true,
"unused": true
}

5
node_modules/outlayer/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,5 @@
components/
bower_components/
node_modules/
npm-debug.log
sandbox/**/bundle.js

125
node_modules/outlayer/README.md generated vendored Normal file
View File

@@ -0,0 +1,125 @@
# Outlayer
_Brains and guts of a layout library_
Outlayer is a base layout class for layout libraries like [Isotope](http://isotope.metafizzy.co), [Packery](http://packery.metafizzy.co), and [Masonry](http://masonry.desandro.com)
Outlayer layouts work with a container element and children item elements.
``` html
<div class="grid">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
...
</div>
```
## Install
Install with [Bower](http://bower.io): `bower install outlayer`
[Install with npm](http://npmjs.org/package/outlayer): `npm install outlayer`
## Outlayer.create()
Create a layout class with `Outlayer.create()`
``` js
var Layout = Outlayer.create( namespace );
// for example
var Masonry = Outlayer.create('masonry');
```
+ `namespace` _{String}_ should be camelCased
+ returns `LayoutClass` _{Function}_
Create a new layout class. `namespace` is used for jQuery plugin, and for declarative initialization.
The `Layout` inherits from [`Outlayer.prototype`](docs/outlayer.md).
```
var elem = document.querySelector('.selector');
var msnry = new Masonry( elem, {
// set options...
columnWidth: 200
});
```
## Item
Layouts work with Items, accessible as `Layout.Item`. See [Item API](docs/item.md).
## Declarative
An Outlayer layout class can be initialized via HTML, by setting an attribute of `data-namespace` on the element. Options are set in JSON. For example:
``` html
<!-- var Masonry = Outlayer.create('masonry') -->
<div class="grid" data-masonry='{ "itemSelector": ".item", "columnWidth": 200 }'>
...
</div>
```
The declarative attributes and class will be dashed. i.e. `Outlayer.create('myNiceLayout')` will use `data-my-nice-layout` as the attribute.
## .data()
Get a layout instance from an element.
```
var myMasonry = Masonry.data( document.querySelector('.grid') );
```
## jQuery plugin
The layout class also works as jQuery plugin.
``` js
// create Masonry layout class, namespace will be the jQuery method
var Masonry = Outlayer.create('masonry');
// rock some jQuery
$( function() {
// .masonry() to initialize
var $grid = $('.grid').masonry({
// options...
});
// methods are available by passing a string as first parameter
$grid.masonry( 'reveal', elems );
});
```
## RequireJS
To use Outlayer with [RequireJS](http://requirejs.org/), you'll need to set some config.
Set [baseUrl](http://requirejs.org/docs/api.html#config-baseUrl) to bower_components and set a [path config](http://requirejs.org/docs/api.html#config-paths) for all your application code.
``` js
requirejs.config({
baseUrl: 'bower_components',
paths: {
app: '../'
}
});
requirejs( [ 'outlayer/outlayer', 'app/my-component.js' ], function( Outlayer, myComp ) {
new Outlayer( /*...*/ )
});
```
Or set a path config for all Outlayer dependencies.
``` js
requirejs.config({
paths: {
'ev-emitter': 'bower_components/ev-emitter',
'get-size': 'bower_components/get-size',
'matches-selector': 'bower_components/matches-selector'
}
});
```
## MIT license
Outlayer is released under the [MIT license](http://desandro.mit-license.org).

43
node_modules/outlayer/bower.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "outlayer",
"description": "the brains and guts of a layout library",
"main": "outlayer.js",
"dependencies": {
"ev-emitter": "^1.0.0",
"get-size": "^2.0.2",
"fizzy-ui-utils": "^2.0.0"
},
"devDependencies": {
"jquery-bridget": "2.x",
"jquery": ">=1.4.3 <4",
"qunit": "^1.17.0"
},
"ignore": [
"test/",
"docs/",
"sandbox/",
".*",
"notes.md",
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"package.json"
],
"homepage": "https://github.com/metafizzy/outlayer",
"authors": [
"Metafizzy"
],
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"layout",
"masonry",
"isotope"
],
"license": "MIT"
}

58
node_modules/outlayer/docs/item.md generated vendored Normal file
View File

@@ -0,0 +1,58 @@
# Item
## Prototype methods
``` js
Item.prototype._create = function() {}
Item.prototype.getSize = function() {}
/**
* apply CSS styles to element
* @param {Object} style
*/
Item.prototype.css = function( style ) {}
// measure position, and sets it
Item.prototype.getPosition = function() {}
// moves position with transition
Item.prototype.moveTo = function( x, y ) {}
// moves position instantly
Item.prototype.goTo = function( x, y ) {}
/**
* sets CSS transition
* @param {Object} args - arguments
* @param {Object} to - style to transition to
* @param {Object} from - style to start transition from
* @param {Boolean} isCleaning - removes transition styles after transition
* @param {Function} onTransitionEnd - callback
*/
Item.prototype.transition = function( args ) {}
/**
* removes style property from element
* @param {Object} style
**/
Item.prototype._removeStyles = function( style ) {}
Item.prototype.removeTransitionStyles = function() {}
// hides, then removes element from DOM
Item.prototype.remove = function() {};
Item.prototype.reveal = function() {}
Item.prototype.hide = function() {}
Item.prototype.destroy = function() {}
```
## Options
+ transitionDuration
+ hiddenStyle
+ visibleStyle

31
node_modules/outlayer/docs/notes.md generated vendored Normal file
View File

@@ -0,0 +1,31 @@
## need test for
Check that text entity don't get added as Items
ignore
unignore
layoutItems does not layout ignored items
## To do
## docs
### methods you can overwrite
Outlayer._layoutItem( item )
Outlayer._resetLayout()
Outlayer._postLayout()
Outlayer._getContainerSize()
Outlayer._create()
Outlayer._manageStamp( stamp )
### Possibly
Outlayer.resize()
Outlayer.destroy()

214
node_modules/outlayer/docs/outlayer.md generated vendored Normal file
View File

@@ -0,0 +1,214 @@
# Outlayer
``` js
/**
* @param {Element, String} element
* @param {Object} options
* @constructor
*/
function Outlayer( element, options ) {}
```
## Prototype methods
``` js
/**
* set options
* @param {Object} opts
*/
Outlayer.prototype.option = function( opts ) {}
Outlayer.prototype._create = function() {}
// goes through all children again and gets bricks in proper order
Outlayer.prototype.reloadItems = function() {}
/**
* get item elements to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - collection of new Outlayer Items
*/
Outlayer.prototype._getItems = function( elems ) {}
/**
* get item elements to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - item elements
*/
Outlayer.prototype._filterFindItemElements = function( elems ) {}
/**
* getter method for getting item elements
* @returns {Array} elems - collection of item elements
*/
Outlayer.prototype.getItemElements = function() {}
// ----- layout ----- //
/**
* lays out all items
*/
Outlayer.prototype.layout = function() {}
/**
* logic before any new layout
*/
Outlayer.prototype._resetLayout = function() {}
Outlayer.prototype.getSize = function() {}
/**
* get measurement from option, for columnWidth, rowHeight, gutter
* if option is String -> get element from selector string, & get size of element
* if option is Element -> get size of element
* else use option as a number
*
* @param {String} measurement
* @param {String} size - width or height
* @private
*/
Outlayer.prototype._getMeasurement = function( measurement, size ) {}
/**
* layout a collection of item elements
*/
Outlayer.prototype.layoutItems = function( items, isInstant ) {}
/**
* Sets position of item in DOM
* @param {Outlayer.Item} item
* @param {Number} x - horizontal position
* @param {Number} y - vertical position
* @param {Boolean} isInstant - disables transitions
*/
Outlayer.prototype._layoutItem = function( item, x, y, isInstant ) {}
/**
* trigger a callback for a collection of items events
* @param {Array} items - Outlayer.Items
* @param {String} eventName
* @param {Function} callback
*/
Outlayer.prototype._itemsOn = function( items, eventName, callback ) {}
// ----- resize ----- //
/**
* Bind layout to window resizing
*/
Outlayer.prototype.bindResize = function() {}
/**
* Unbind layout to window resizing
*/
Outlayer.prototype.unbindResize = function() {
// debounced, layout on resize
Outlayer.prototype.resize = function() {}
// -------------------------- methods -------------------------- //
/**
* add items to Outlayer instance
* @param {Array or NodeList or Element} elems
* @returns {Array} items - Outlayer.Items
**/
Outlayer.prototype.addItems = function( elems ) {}
/**
* Layout newly-appended item elements
* @param {Array or NodeList or Element} elems
*/
Outlayer.prototype.appended = function( elems ) {}
/**
* Layout prepended elements
* @param {Array or NodeList or Element} elems
*/
Outlayer.prototype.prepended = function( elems ) {}
// reveal a collection of items
Outlayer.prototype.reveal = function( items ) {}
/**
* get Outlayer.Item, given an Element
* @param {Element} elem
* @param {Function} callback
* @returns {Outlayer.Item} item
*/
Outlayer.prototype.getItem = function( elem ) {}
/**
* get collection of Outlayer.Items, given Elements
* @param {Array} elems
* @returns {Array} items - Outlayer.Items
*/
Outlayer.prototype.getItems = function( elems ) {}
/**
* remove element(s) from instance and DOM
* @param {Array or NodeList or Element} elems
*/
Outlayer.prototype.remove = function( elems ) {}
/**
* reveal a collection of items
* @param {Array of Outlayer.Items} items
*/
Outlayer.prototype.reveal = function( items ) {}
/**
* hide a collection of items
* @param {Array of Outlayer.Items} items
*/
Outlayer.prototype.hide = function( items ) {}
/**
* reveal item elements
* @param {Array}, {Element}, {NodeList} items
*/
Outlayer.prototype.revealItemElements = function( elems ) {}
/**
* hide item elements
* @param {Array}, {Element}, {NodeList} items
*/
Outlayer.prototype.hideItemElements = function( elems ) {}
// remove and disable Outlayer instance
Outlayer.prototype.destroy = function() {}
```
## Utility methods
``` js
/**
* get Outlayer instance from element
* @param {Element} elem
* @returns {Outlayer}
*/
Outlayer.data = function( elem ) {}
/**
* create a layout class
* @param {String} namespace
*/
Outlayer.create = function( namespace ) {}
```
## Options
+ containerStyle `{ position: 'relative' }`
+ initLayout or isInitLayout `true`
+ layoutInstant or isLayoutInstant
+ originLeft or isOriginLeft `true`
+ originTop or isOriginTop `true`
+ resize or isResizeBound `true`
+ resizeContainer or isResizingContainer `true`
+ itemOptions
+ itemSelector
+ stamp
+ percentPosition

554
node_modules/outlayer/item.js generated vendored Normal file
View File

@@ -0,0 +1,554 @@
/**
* Outlayer Item
*/
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( [
'ev-emitter/ev-emitter',
'get-size/get-size'
],
factory
);
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory(
require('ev-emitter'),
require('get-size')
);
} else {
// browser global
window.Outlayer = {};
window.Outlayer.Item = factory(
window.EvEmitter,
window.getSize
);
}
}( window, function factory( EvEmitter, getSize ) {
'use strict';
// ----- helpers ----- //
function isEmptyObj( obj ) {
for ( var prop in obj ) {
return false;
}
prop = null;
return true;
}
// -------------------------- CSS3 support -------------------------- //
var docElemStyle = document.documentElement.style;
var transitionProperty = typeof docElemStyle.transition == 'string' ?
'transition' : 'WebkitTransition';
var transformProperty = typeof docElemStyle.transform == 'string' ?
'transform' : 'WebkitTransform';
var transitionEndEvent = {
WebkitTransition: 'webkitTransitionEnd',
transition: 'transitionend'
}[ transitionProperty ];
// cache all vendor properties that could have vendor prefix
var vendorProperties = {
transform: transformProperty,
transition: transitionProperty,
transitionDuration: transitionProperty + 'Duration',
transitionProperty: transitionProperty + 'Property',
transitionDelay: transitionProperty + 'Delay'
};
// -------------------------- Item -------------------------- //
function Item( element, layout ) {
if ( !element ) {
return;
}
this.element = element;
// parent layout class, i.e. Masonry, Isotope, or Packery
this.layout = layout;
this.position = {
x: 0,
y: 0
};
this._create();
}
// inherit EvEmitter
var proto = Item.prototype = Object.create( EvEmitter.prototype );
proto.constructor = Item;
proto._create = function() {
// transition objects
this._transn = {
ingProperties: {},
clean: {},
onEnd: {}
};
this.css({
position: 'absolute'
});
};
// trigger specified handler for event type
proto.handleEvent = function( event ) {
var method = 'on' + event.type;
if ( this[ method ] ) {
this[ method ]( event );
}
};
proto.getSize = function() {
this.size = getSize( this.element );
};
/**
* apply CSS styles to element
* @param {Object} style
*/
proto.css = function( style ) {
var elemStyle = this.element.style;
for ( var prop in style ) {
// use vendor property if available
var supportedProp = vendorProperties[ prop ] || prop;
elemStyle[ supportedProp ] = style[ prop ];
}
};
// measure position, and sets it
proto.getPosition = function() {
var style = getComputedStyle( this.element );
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
var xValue = style[ isOriginLeft ? 'left' : 'right' ];
var yValue = style[ isOriginTop ? 'top' : 'bottom' ];
var x = parseFloat( xValue );
var y = parseFloat( yValue );
// convert percent to pixels
var layoutSize = this.layout.size;
if ( xValue.indexOf('%') != -1 ) {
x = ( x / 100 ) * layoutSize.width;
}
if ( yValue.indexOf('%') != -1 ) {
y = ( y / 100 ) * layoutSize.height;
}
// clean up 'auto' or other non-integer values
x = isNaN( x ) ? 0 : x;
y = isNaN( y ) ? 0 : y;
// remove padding from measurement
x -= isOriginLeft ? layoutSize.paddingLeft : layoutSize.paddingRight;
y -= isOriginTop ? layoutSize.paddingTop : layoutSize.paddingBottom;
this.position.x = x;
this.position.y = y;
};
// set settled position, apply padding
proto.layoutPosition = function() {
var layoutSize = this.layout.size;
var style = {};
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
// x
var xPadding = isOriginLeft ? 'paddingLeft' : 'paddingRight';
var xProperty = isOriginLeft ? 'left' : 'right';
var xResetProperty = isOriginLeft ? 'right' : 'left';
var x = this.position.x + layoutSize[ xPadding ];
// set in percentage or pixels
style[ xProperty ] = this.getXValue( x );
// reset other property
style[ xResetProperty ] = '';
// y
var yPadding = isOriginTop ? 'paddingTop' : 'paddingBottom';
var yProperty = isOriginTop ? 'top' : 'bottom';
var yResetProperty = isOriginTop ? 'bottom' : 'top';
var y = this.position.y + layoutSize[ yPadding ];
// set in percentage or pixels
style[ yProperty ] = this.getYValue( y );
// reset other property
style[ yResetProperty ] = '';
this.css( style );
this.emitEvent( 'layout', [ this ] );
};
proto.getXValue = function( x ) {
var isHorizontal = this.layout._getOption('horizontal');
return this.layout.options.percentPosition && !isHorizontal ?
( ( x / this.layout.size.width ) * 100 ) + '%' : x + 'px';
};
proto.getYValue = function( y ) {
var isHorizontal = this.layout._getOption('horizontal');
return this.layout.options.percentPosition && isHorizontal ?
( ( y / this.layout.size.height ) * 100 ) + '%' : y + 'px';
};
proto._transitionTo = function( x, y ) {
this.getPosition();
// get current x & y from top/left
var curX = this.position.x;
var curY = this.position.y;
var didNotMove = x == this.position.x && y == this.position.y;
// save end position
this.setPosition( x, y );
// if did not move and not transitioning, just go to layout
if ( didNotMove && !this.isTransitioning ) {
this.layoutPosition();
return;
}
var transX = x - curX;
var transY = y - curY;
var transitionStyle = {};
transitionStyle.transform = this.getTranslate( transX, transY );
this.transition({
to: transitionStyle,
onTransitionEnd: {
transform: this.layoutPosition
},
isCleaning: true
});
};
proto.getTranslate = function( x, y ) {
// flip cooridinates if origin on right or bottom
var isOriginLeft = this.layout._getOption('originLeft');
var isOriginTop = this.layout._getOption('originTop');
x = isOriginLeft ? x : -x;
y = isOriginTop ? y : -y;
return 'translate3d(' + x + 'px, ' + y + 'px, 0)';
};
// non transition + transform support
proto.goTo = function( x, y ) {
this.setPosition( x, y );
this.layoutPosition();
};
proto.moveTo = proto._transitionTo;
proto.setPosition = function( x, y ) {
this.position.x = parseFloat( x );
this.position.y = parseFloat( y );
};
// ----- transition ----- //
/**
* @param {Object} style - CSS
* @param {Function} onTransitionEnd
*/
// non transition, just trigger callback
proto._nonTransition = function( args ) {
this.css( args.to );
if ( args.isCleaning ) {
this._removeStyles( args.to );
}
for ( var prop in args.onTransitionEnd ) {
args.onTransitionEnd[ prop ].call( this );
}
};
/**
* proper transition
* @param {Object} args - arguments
* @param {Object} to - style to transition to
* @param {Object} from - style to start transition from
* @param {Boolean} isCleaning - removes transition styles after transition
* @param {Function} onTransitionEnd - callback
*/
proto.transition = function( args ) {
// redirect to nonTransition if no transition duration
if ( !parseFloat( this.layout.options.transitionDuration ) ) {
this._nonTransition( args );
return;
}
var _transition = this._transn;
// keep track of onTransitionEnd callback by css property
for ( var prop in args.onTransitionEnd ) {
_transition.onEnd[ prop ] = args.onTransitionEnd[ prop ];
}
// keep track of properties that are transitioning
for ( prop in args.to ) {
_transition.ingProperties[ prop ] = true;
// keep track of properties to clean up when transition is done
if ( args.isCleaning ) {
_transition.clean[ prop ] = true;
}
}
// set from styles
if ( args.from ) {
this.css( args.from );
// force redraw. http://blog.alexmaccaw.com/css-transitions
var h = this.element.offsetHeight;
// hack for JSHint to hush about unused var
h = null;
}
// enable transition
this.enableTransition( args.to );
// set styles that are transitioning
this.css( args.to );
this.isTransitioning = true;
};
// dash before all cap letters, including first for
// WebkitTransform => -webkit-transform
function toDashedAll( str ) {
return str.replace( /([A-Z])/g, function( $1 ) {
return '-' + $1.toLowerCase();
});
}
var transitionProps = 'opacity,' + toDashedAll( transformProperty );
proto.enableTransition = function(/* style */) {
// HACK changing transitionProperty during a transition
// will cause transition to jump
if ( this.isTransitioning ) {
return;
}
// make `transition: foo, bar, baz` from style object
// HACK un-comment this when enableTransition can work
// while a transition is happening
// var transitionValues = [];
// for ( var prop in style ) {
// // dash-ify camelCased properties like WebkitTransition
// prop = vendorProperties[ prop ] || prop;
// transitionValues.push( toDashedAll( prop ) );
// }
// munge number to millisecond, to match stagger
var duration = this.layout.options.transitionDuration;
duration = typeof duration == 'number' ? duration + 'ms' : duration;
// enable transition styles
this.css({
transitionProperty: transitionProps,
transitionDuration: duration,
transitionDelay: this.staggerDelay || 0
});
// listen for transition end event
this.element.addEventListener( transitionEndEvent, this, false );
};
// ----- events ----- //
proto.onwebkitTransitionEnd = function( event ) {
this.ontransitionend( event );
};
proto.onotransitionend = function( event ) {
this.ontransitionend( event );
};
// properties that I munge to make my life easier
var dashedVendorProperties = {
'-webkit-transform': 'transform'
};
proto.ontransitionend = function( event ) {
// disregard bubbled events from children
if ( event.target !== this.element ) {
return;
}
var _transition = this._transn;
// get property name of transitioned property, convert to prefix-free
var propertyName = dashedVendorProperties[ event.propertyName ] || event.propertyName;
// remove property that has completed transitioning
delete _transition.ingProperties[ propertyName ];
// check if any properties are still transitioning
if ( isEmptyObj( _transition.ingProperties ) ) {
// all properties have completed transitioning
this.disableTransition();
}
// clean style
if ( propertyName in _transition.clean ) {
// clean up style
this.element.style[ event.propertyName ] = '';
delete _transition.clean[ propertyName ];
}
// trigger onTransitionEnd callback
if ( propertyName in _transition.onEnd ) {
var onTransitionEnd = _transition.onEnd[ propertyName ];
onTransitionEnd.call( this );
delete _transition.onEnd[ propertyName ];
}
this.emitEvent( 'transitionEnd', [ this ] );
};
proto.disableTransition = function() {
this.removeTransitionStyles();
this.element.removeEventListener( transitionEndEvent, this, false );
this.isTransitioning = false;
};
/**
* removes style property from element
* @param {Object} style
**/
proto._removeStyles = function( style ) {
// clean up transition styles
var cleanStyle = {};
for ( var prop in style ) {
cleanStyle[ prop ] = '';
}
this.css( cleanStyle );
};
var cleanTransitionStyle = {
transitionProperty: '',
transitionDuration: '',
transitionDelay: ''
};
proto.removeTransitionStyles = function() {
// remove transition
this.css( cleanTransitionStyle );
};
// ----- stagger ----- //
proto.stagger = function( delay ) {
delay = isNaN( delay ) ? 0 : delay;
this.staggerDelay = delay + 'ms';
};
// ----- show/hide/remove ----- //
// remove element from DOM
proto.removeElem = function() {
this.element.parentNode.removeChild( this.element );
// remove display: none
this.css({ display: '' });
this.emitEvent( 'remove', [ this ] );
};
proto.remove = function() {
// just remove element if no transition support or no transition
if ( !transitionProperty || !parseFloat( this.layout.options.transitionDuration ) ) {
this.removeElem();
return;
}
// start transition
this.once( 'transitionEnd', function() {
this.removeElem();
});
this.hide();
};
proto.reveal = function() {
delete this.isHidden;
// remove display: none
this.css({ display: '' });
var options = this.layout.options;
var onTransitionEnd = {};
var transitionEndProperty = this.getHideRevealTransitionEndProperty('visibleStyle');
onTransitionEnd[ transitionEndProperty ] = this.onRevealTransitionEnd;
this.transition({
from: options.hiddenStyle,
to: options.visibleStyle,
isCleaning: true,
onTransitionEnd: onTransitionEnd
});
};
proto.onRevealTransitionEnd = function() {
// check if still visible
// during transition, item may have been hidden
if ( !this.isHidden ) {
this.emitEvent('reveal');
}
};
/**
* get style property use for hide/reveal transition end
* @param {String} styleProperty - hiddenStyle/visibleStyle
* @returns {String}
*/
proto.getHideRevealTransitionEndProperty = function( styleProperty ) {
var optionStyle = this.layout.options[ styleProperty ];
// use opacity
if ( optionStyle.opacity ) {
return 'opacity';
}
// get first property
for ( var prop in optionStyle ) {
return prop;
}
};
proto.hide = function() {
// set flag
this.isHidden = true;
// remove display: none
this.css({ display: '' });
var options = this.layout.options;
var onTransitionEnd = {};
var transitionEndProperty = this.getHideRevealTransitionEndProperty('hiddenStyle');
onTransitionEnd[ transitionEndProperty ] = this.onHideTransitionEnd;
this.transition({
from: options.visibleStyle,
to: options.hiddenStyle,
// keep hidden stuff hidden
isCleaning: true,
onTransitionEnd: onTransitionEnd
});
};
proto.onHideTransitionEnd = function() {
// check if still hidden
// during transition, item may have been un-hidden
if ( this.isHidden ) {
this.css({ display: 'none' });
this.emitEvent('hide');
}
};
proto.destroy = function() {
this.css({
position: '',
left: '',
right: '',
top: '',
bottom: '',
transition: '',
transform: ''
});
};
return Item;
}));

939
node_modules/outlayer/outlayer.js generated vendored Normal file
View File

@@ -0,0 +1,939 @@
/*!
* Outlayer v2.1.1
* the brains and guts of a layout library
* MIT license
*/
( function( window, factory ) {
'use strict';
// universal module definition
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD - RequireJS
define( [
'ev-emitter/ev-emitter',
'get-size/get-size',
'fizzy-ui-utils/utils',
'./item'
],
function( EvEmitter, getSize, utils, Item ) {
return factory( window, EvEmitter, getSize, utils, Item);
}
);
} else if ( typeof module == 'object' && module.exports ) {
// CommonJS - Browserify, Webpack
module.exports = factory(
window,
require('ev-emitter'),
require('get-size'),
require('fizzy-ui-utils'),
require('./item')
);
} else {
// browser global
window.Outlayer = factory(
window,
window.EvEmitter,
window.getSize,
window.fizzyUIUtils,
window.Outlayer.Item
);
}
}( window, function factory( window, EvEmitter, getSize, utils, Item ) {
'use strict';
// ----- vars ----- //
var console = window.console;
var jQuery = window.jQuery;
var noop = function() {};
// -------------------------- Outlayer -------------------------- //
// globally unique identifiers
var GUID = 0;
// internal store of all Outlayer intances
var instances = {};
/**
* @param {Element, String} element
* @param {Object} options
* @constructor
*/
function Outlayer( element, options ) {
var queryElement = utils.getQueryElement( element );
if ( !queryElement ) {
if ( console ) {
console.error( 'Bad element for ' + this.constructor.namespace +
': ' + ( queryElement || element ) );
}
return;
}
this.element = queryElement;
// add jQuery
if ( jQuery ) {
this.$element = jQuery( this.element );
}
// options
this.options = utils.extend( {}, this.constructor.defaults );
this.option( options );
// add id for Outlayer.getFromElement
var id = ++GUID;
this.element.outlayerGUID = id; // expando
instances[ id ] = this; // associate via id
// kick it off
this._create();
var isInitLayout = this._getOption('initLayout');
if ( isInitLayout ) {
this.layout();
}
}
// settings are for internal use only
Outlayer.namespace = 'outlayer';
Outlayer.Item = Item;
// default options
Outlayer.defaults = {
containerStyle: {
position: 'relative'
},
initLayout: true,
originLeft: true,
originTop: true,
resize: true,
resizeContainer: true,
// item options
transitionDuration: '0.4s',
hiddenStyle: {
opacity: 0,
transform: 'scale(0.001)'
},
visibleStyle: {
opacity: 1,
transform: 'scale(1)'
}
};
var proto = Outlayer.prototype;
// inherit EvEmitter
utils.extend( proto, EvEmitter.prototype );
/**
* set options
* @param {Object} opts
*/
proto.option = function( opts ) {
utils.extend( this.options, opts );
};
/**
* get backwards compatible option value, check old name
*/
proto._getOption = function( option ) {
var oldOption = this.constructor.compatOptions[ option ];
return oldOption && this.options[ oldOption ] !== undefined ?
this.options[ oldOption ] : this.options[ option ];
};
Outlayer.compatOptions = {
// currentName: oldName
initLayout: 'isInitLayout',
horizontal: 'isHorizontal',
layoutInstant: 'isLayoutInstant',
originLeft: 'isOriginLeft',
originTop: 'isOriginTop',
resize: 'isResizeBound',
resizeContainer: 'isResizingContainer'
};
proto._create = function() {
// get items from children
this.reloadItems();
// elements that affect layout, but are not laid out
this.stamps = [];
this.stamp( this.options.stamp );
// set container style
utils.extend( this.element.style, this.options.containerStyle );
// bind resize method
var canBindResize = this._getOption('resize');
if ( canBindResize ) {
this.bindResize();
}
};
// goes through all children again and gets bricks in proper order
proto.reloadItems = function() {
// collection of item elements
this.items = this._itemize( this.element.children );
};
/**
* turn elements into Outlayer.Items to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - collection of new Outlayer Items
*/
proto._itemize = function( elems ) {
var itemElems = this._filterFindItemElements( elems );
var Item = this.constructor.Item;
// create new Outlayer Items for collection
var items = [];
for ( var i=0; i < itemElems.length; i++ ) {
var elem = itemElems[i];
var item = new Item( elem, this );
items.push( item );
}
return items;
};
/**
* get item elements to be used in layout
* @param {Array or NodeList or HTMLElement} elems
* @returns {Array} items - item elements
*/
proto._filterFindItemElements = function( elems ) {
return utils.filterFindElements( elems, this.options.itemSelector );
};
/**
* getter method for getting item elements
* @returns {Array} elems - collection of item elements
*/
proto.getItemElements = function() {
return this.items.map( function( item ) {
return item.element;
});
};
// ----- init & layout ----- //
/**
* lays out all items
*/
proto.layout = function() {
this._resetLayout();
this._manageStamps();
// don't animate first layout
var layoutInstant = this._getOption('layoutInstant');
var isInstant = layoutInstant !== undefined ?
layoutInstant : !this._isLayoutInited;
this.layoutItems( this.items, isInstant );
// flag for initalized
this._isLayoutInited = true;
};
// _init is alias for layout
proto._init = proto.layout;
/**
* logic before any new layout
*/
proto._resetLayout = function() {
this.getSize();
};
proto.getSize = function() {
this.size = getSize( this.element );
};
/**
* get measurement from option, for columnWidth, rowHeight, gutter
* if option is String -> get element from selector string, & get size of element
* if option is Element -> get size of element
* else use option as a number
*
* @param {String} measurement
* @param {String} size - width or height
* @private
*/
proto._getMeasurement = function( measurement, size ) {
var option = this.options[ measurement ];
var elem;
if ( !option ) {
// default to 0
this[ measurement ] = 0;
} else {
// use option as an element
if ( typeof option == 'string' ) {
elem = this.element.querySelector( option );
} else if ( option instanceof HTMLElement ) {
elem = option;
}
// use size of element, if element
this[ measurement ] = elem ? getSize( elem )[ size ] : option;
}
};
/**
* layout a collection of item elements
* @api public
*/
proto.layoutItems = function( items, isInstant ) {
items = this._getItemsForLayout( items );
this._layoutItems( items, isInstant );
this._postLayout();
};
/**
* get the items to be laid out
* you may want to skip over some items
* @param {Array} items
* @returns {Array} items
*/
proto._getItemsForLayout = function( items ) {
return items.filter( function( item ) {
return !item.isIgnored;
});
};
/**
* layout items
* @param {Array} items
* @param {Boolean} isInstant
*/
proto._layoutItems = function( items, isInstant ) {
this._emitCompleteOnItems( 'layout', items );
if ( !items || !items.length ) {
// no items, emit event with empty array
return;
}
var queue = [];
items.forEach( function( item ) {
// get x/y object from method
var position = this._getItemLayoutPosition( item );
// enqueue
position.item = item;
position.isInstant = isInstant || item.isLayoutInstant;
queue.push( position );
}, this );
this._processLayoutQueue( queue );
};
/**
* get item layout position
* @param {Outlayer.Item} item
* @returns {Object} x and y position
*/
proto._getItemLayoutPosition = function( /* item */ ) {
return {
x: 0,
y: 0
};
};
/**
* iterate over array and position each item
* Reason being - separating this logic prevents 'layout invalidation'
* thx @paul_irish
* @param {Array} queue
*/
proto._processLayoutQueue = function( queue ) {
this.updateStagger();
queue.forEach( function( obj, i ) {
this._positionItem( obj.item, obj.x, obj.y, obj.isInstant, i );
}, this );
};
// set stagger from option in milliseconds number
proto.updateStagger = function() {
var stagger = this.options.stagger;
if ( stagger === null || stagger === undefined ) {
this.stagger = 0;
return;
}
this.stagger = getMilliseconds( stagger );
return this.stagger;
};
/**
* Sets position of item in DOM
* @param {Outlayer.Item} item
* @param {Number} x - horizontal position
* @param {Number} y - vertical position
* @param {Boolean} isInstant - disables transitions
*/
proto._positionItem = function( item, x, y, isInstant, i ) {
if ( isInstant ) {
// if not transition, just set CSS
item.goTo( x, y );
} else {
item.stagger( i * this.stagger );
item.moveTo( x, y );
}
};
/**
* Any logic you want to do after each layout,
* i.e. size the container
*/
proto._postLayout = function() {
this.resizeContainer();
};
proto.resizeContainer = function() {
var isResizingContainer = this._getOption('resizeContainer');
if ( !isResizingContainer ) {
return;
}
var size = this._getContainerSize();
if ( size ) {
this._setContainerMeasure( size.width, true );
this._setContainerMeasure( size.height, false );
}
};
/**
* Sets width or height of container if returned
* @returns {Object} size
* @param {Number} width
* @param {Number} height
*/
proto._getContainerSize = noop;
/**
* @param {Number} measure - size of width or height
* @param {Boolean} isWidth
*/
proto._setContainerMeasure = function( measure, isWidth ) {
if ( measure === undefined ) {
return;
}
var elemSize = this.size;
// add padding and border width if border box
if ( elemSize.isBorderBox ) {
measure += isWidth ? elemSize.paddingLeft + elemSize.paddingRight +
elemSize.borderLeftWidth + elemSize.borderRightWidth :
elemSize.paddingBottom + elemSize.paddingTop +
elemSize.borderTopWidth + elemSize.borderBottomWidth;
}
measure = Math.max( measure, 0 );
this.element.style[ isWidth ? 'width' : 'height' ] = measure + 'px';
};
/**
* emit eventComplete on a collection of items events
* @param {String} eventName
* @param {Array} items - Outlayer.Items
*/
proto._emitCompleteOnItems = function( eventName, items ) {
var _this = this;
function onComplete() {
_this.dispatchEvent( eventName + 'Complete', null, [ items ] );
}
var count = items.length;
if ( !items || !count ) {
onComplete();
return;
}
var doneCount = 0;
function tick() {
doneCount++;
if ( doneCount == count ) {
onComplete();
}
}
// bind callback
items.forEach( function( item ) {
item.once( eventName, tick );
});
};
/**
* emits events via EvEmitter and jQuery events
* @param {String} type - name of event
* @param {Event} event - original event
* @param {Array} args - extra arguments
*/
proto.dispatchEvent = function( type, event, args ) {
// add original event to arguments
var emitArgs = event ? [ event ].concat( args ) : args;
this.emitEvent( type, emitArgs );
if ( jQuery ) {
// set this.$element
this.$element = this.$element || jQuery( this.element );
if ( event ) {
// create jQuery event
var $event = jQuery.Event( event );
$event.type = type;
this.$element.trigger( $event, args );
} else {
// just trigger with type if no event available
this.$element.trigger( type, args );
}
}
};
// -------------------------- ignore & stamps -------------------------- //
/**
* keep item in collection, but do not lay it out
* ignored items do not get skipped in layout
* @param {Element} elem
*/
proto.ignore = function( elem ) {
var item = this.getItem( elem );
if ( item ) {
item.isIgnored = true;
}
};
/**
* return item to layout collection
* @param {Element} elem
*/
proto.unignore = function( elem ) {
var item = this.getItem( elem );
if ( item ) {
delete item.isIgnored;
}
};
/**
* adds elements to stamps
* @param {NodeList, Array, Element, or String} elems
*/
proto.stamp = function( elems ) {
elems = this._find( elems );
if ( !elems ) {
return;
}
this.stamps = this.stamps.concat( elems );
// ignore
elems.forEach( this.ignore, this );
};
/**
* removes elements to stamps
* @param {NodeList, Array, or Element} elems
*/
proto.unstamp = function( elems ) {
elems = this._find( elems );
if ( !elems ){
return;
}
elems.forEach( function( elem ) {
// filter out removed stamp elements
utils.removeFrom( this.stamps, elem );
this.unignore( elem );
}, this );
};
/**
* finds child elements
* @param {NodeList, Array, Element, or String} elems
* @returns {Array} elems
*/
proto._find = function( elems ) {
if ( !elems ) {
return;
}
// if string, use argument as selector string
if ( typeof elems == 'string' ) {
elems = this.element.querySelectorAll( elems );
}
elems = utils.makeArray( elems );
return elems;
};
proto._manageStamps = function() {
if ( !this.stamps || !this.stamps.length ) {
return;
}
this._getBoundingRect();
this.stamps.forEach( this._manageStamp, this );
};
// update boundingLeft / Top
proto._getBoundingRect = function() {
// get bounding rect for container element
var boundingRect = this.element.getBoundingClientRect();
var size = this.size;
this._boundingRect = {
left: boundingRect.left + size.paddingLeft + size.borderLeftWidth,
top: boundingRect.top + size.paddingTop + size.borderTopWidth,
right: boundingRect.right - ( size.paddingRight + size.borderRightWidth ),
bottom: boundingRect.bottom - ( size.paddingBottom + size.borderBottomWidth )
};
};
/**
* @param {Element} stamp
**/
proto._manageStamp = noop;
/**
* get x/y position of element relative to container element
* @param {Element} elem
* @returns {Object} offset - has left, top, right, bottom
*/
proto._getElementOffset = function( elem ) {
var boundingRect = elem.getBoundingClientRect();
var thisRect = this._boundingRect;
var size = getSize( elem );
var offset = {
left: boundingRect.left - thisRect.left - size.marginLeft,
top: boundingRect.top - thisRect.top - size.marginTop,
right: thisRect.right - boundingRect.right - size.marginRight,
bottom: thisRect.bottom - boundingRect.bottom - size.marginBottom
};
return offset;
};
// -------------------------- resize -------------------------- //
// enable event handlers for listeners
// i.e. resize -> onresize
proto.handleEvent = utils.handleEvent;
/**
* Bind layout to window resizing
*/
proto.bindResize = function() {
window.addEventListener( 'resize', this );
this.isResizeBound = true;
};
/**
* Unbind layout to window resizing
*/
proto.unbindResize = function() {
window.removeEventListener( 'resize', this );
this.isResizeBound = false;
};
proto.onresize = function() {
this.resize();
};
utils.debounceMethod( Outlayer, 'onresize', 100 );
proto.resize = function() {
// don't trigger if size did not change
// or if resize was unbound. See #9
if ( !this.isResizeBound || !this.needsResizeLayout() ) {
return;
}
this.layout();
};
/**
* check if layout is needed post layout
* @returns Boolean
*/
proto.needsResizeLayout = function() {
var size = getSize( this.element );
// check that this.size and size are there
// IE8 triggers resize on body size change, so they might not be
var hasSizes = this.size && size;
return hasSizes && size.innerWidth !== this.size.innerWidth;
};
// -------------------------- methods -------------------------- //
/**
* add items to Outlayer instance
* @param {Array or NodeList or Element} elems
* @returns {Array} items - Outlayer.Items
**/
proto.addItems = function( elems ) {
var items = this._itemize( elems );
// add items to collection
if ( items.length ) {
this.items = this.items.concat( items );
}
return items;
};
/**
* Layout newly-appended item elements
* @param {Array or NodeList or Element} elems
*/
proto.appended = function( elems ) {
var items = this.addItems( elems );
if ( !items.length ) {
return;
}
// layout and reveal just the new items
this.layoutItems( items, true );
this.reveal( items );
};
/**
* Layout prepended elements
* @param {Array or NodeList or Element} elems
*/
proto.prepended = function( elems ) {
var items = this._itemize( elems );
if ( !items.length ) {
return;
}
// add items to beginning of collection
var previousItems = this.items.slice(0);
this.items = items.concat( previousItems );
// start new layout
this._resetLayout();
this._manageStamps();
// layout new stuff without transition
this.layoutItems( items, true );
this.reveal( items );
// layout previous items
this.layoutItems( previousItems );
};
/**
* reveal a collection of items
* @param {Array of Outlayer.Items} items
*/
proto.reveal = function( items ) {
this._emitCompleteOnItems( 'reveal', items );
if ( !items || !items.length ) {
return;
}
var stagger = this.updateStagger();
items.forEach( function( item, i ) {
item.stagger( i * stagger );
item.reveal();
});
};
/**
* hide a collection of items
* @param {Array of Outlayer.Items} items
*/
proto.hide = function( items ) {
this._emitCompleteOnItems( 'hide', items );
if ( !items || !items.length ) {
return;
}
var stagger = this.updateStagger();
items.forEach( function( item, i ) {
item.stagger( i * stagger );
item.hide();
});
};
/**
* reveal item elements
* @param {Array}, {Element}, {NodeList} items
*/
proto.revealItemElements = function( elems ) {
var items = this.getItems( elems );
this.reveal( items );
};
/**
* hide item elements
* @param {Array}, {Element}, {NodeList} items
*/
proto.hideItemElements = function( elems ) {
var items = this.getItems( elems );
this.hide( items );
};
/**
* get Outlayer.Item, given an Element
* @param {Element} elem
* @param {Function} callback
* @returns {Outlayer.Item} item
*/
proto.getItem = function( elem ) {
// loop through items to get the one that matches
for ( var i=0; i < this.items.length; i++ ) {
var item = this.items[i];
if ( item.element == elem ) {
// return item
return item;
}
}
};
/**
* get collection of Outlayer.Items, given Elements
* @param {Array} elems
* @returns {Array} items - Outlayer.Items
*/
proto.getItems = function( elems ) {
elems = utils.makeArray( elems );
var items = [];
elems.forEach( function( elem ) {
var item = this.getItem( elem );
if ( item ) {
items.push( item );
}
}, this );
return items;
};
/**
* remove element(s) from instance and DOM
* @param {Array or NodeList or Element} elems
*/
proto.remove = function( elems ) {
var removeItems = this.getItems( elems );
this._emitCompleteOnItems( 'remove', removeItems );
// bail if no items to remove
if ( !removeItems || !removeItems.length ) {
return;
}
removeItems.forEach( function( item ) {
item.remove();
// remove item from collection
utils.removeFrom( this.items, item );
}, this );
};
// ----- destroy ----- //
// remove and disable Outlayer instance
proto.destroy = function() {
// clean up dynamic styles
var style = this.element.style;
style.height = '';
style.position = '';
style.width = '';
// destroy items
this.items.forEach( function( item ) {
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 );
}
};
// -------------------------- data -------------------------- //
/**
* get Outlayer instance from element
* @param {Element} elem
* @returns {Outlayer}
*/
Outlayer.data = function( elem ) {
elem = utils.getQueryElement( elem );
var id = elem && elem.outlayerGUID;
return id && instances[ id ];
};
// -------------------------- create Outlayer class -------------------------- //
/**
* create a layout class
* @param {String} namespace
*/
Outlayer.create = function( namespace, options ) {
// sub-class Outlayer
var Layout = subclass( Outlayer );
// apply new options and compatOptions
Layout.defaults = utils.extend( {}, Outlayer.defaults );
utils.extend( Layout.defaults, options );
Layout.compatOptions = utils.extend( {}, Outlayer.compatOptions );
Layout.namespace = namespace;
Layout.data = Outlayer.data;
// sub-class Item
Layout.Item = subclass( Item );
// -------------------------- declarative -------------------------- //
utils.htmlInit( Layout, namespace );
// -------------------------- jQuery bridge -------------------------- //
// make into jQuery plugin
if ( jQuery && jQuery.bridget ) {
jQuery.bridget( namespace, Layout );
}
return Layout;
};
function subclass( Parent ) {
function SubClass() {
Parent.apply( this, arguments );
}
SubClass.prototype = Object.create( Parent.prototype );
SubClass.prototype.constructor = SubClass;
return SubClass;
}
// ----- helpers ----- //
// how many milliseconds are in each unit
var msUnits = {
ms: 1,
s: 1000
};
// munge time-like parameter into millisecond number
// '0.4s' -> 40
function getMilliseconds( time ) {
if ( typeof time == 'number' ) {
return time;
}
var matches = time.match( /(^\d*\.?\d*)(\w*)/ );
var num = matches && matches[1];
var unit = matches && matches[2];
if ( !num.length ) {
return 0;
}
num = parseFloat( num );
var mult = msUnits[ unit ] || 1;
return num * mult;
}
// ----- fin ----- //
// back in global
Outlayer.Item = Item;
return Outlayer;
}));

38
node_modules/outlayer/package.json generated vendored Normal file
View File

@@ -0,0 +1,38 @@
{
"name": "outlayer",
"version": "2.1.1",
"description": "the brains and guts of a layout library",
"main": "outlayer.js",
"dependencies": {
"ev-emitter": "^1.0.0",
"get-size": "^2.0.2",
"fizzy-ui-utils": "^2.0.0"
},
"devDependencies": {
"jquery": ">=1.4.3 <4",
"jquery-bridget": "2.x",
"qunitjs": "^1.17.0"
},
"repository": {
"type": "git",
"url": "https://github.com/metafizzy/outlayer.git"
},
"bugs": {
"url": "https://github.com/metafizzy/outlayer/issues"
},
"homepage": "https://github.com/metafizzy/outlayer",
"directories": {
"doc": "docs",
"example": "examples",
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"DOM",
"layout"
],
"author": "David DeSandro",
"license": "MIT"
}

View File

@@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>browserify</title>
<link rel="stylesheet" href="../examples.css" />
</head>
<body>
<h1>browserify</h1>
<div id="basic" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script src="bundle.js"></script>
</body>
</html>

3
node_modules/outlayer/sandbox/browserify/main.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
var CellsByRow = require('../cells-by-row');
new CellsByRow('#basic');

100
node_modules/outlayer/sandbox/cells-by-row.html generated vendored Normal file
View File

@@ -0,0 +1,100 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CellsByRow</title>
<link rel="stylesheet" href="examples.css" />
<style>
#horizontal {
height: 300px;
}
</style>
</head>
<body>
<h1>CellsByRow</h1>
<div id="basic" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="container" data-cells-by-row='{ "columnWidth": 120 }'>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="bottom-right" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="horizontal" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script src="cells-by-row.js"></script>
<script>
( function() {
var container = document.querySelector('#basic');
var layout = new CellsByRow( container );
})();
( function() {
var container = document.querySelector('#bottom-right');
var layout = new CellsByRow( container, {
originLeft: false,
originTop: false
});
})();
( function() {
new CellsByRow( '#horizontal', {
isHorizontal: true
});
})();
</script>
</body>
</html>

86
node_modules/outlayer/sandbox/cells-by-row.js generated vendored Normal file
View File

@@ -0,0 +1,86 @@
/**
* CellsByRow example
*/
( function( window, factory ) {
/* jshint strict: false */ /* globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
// AMD
define( [
'../outlayer'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
module.exports = factory(
require('../outlayer')
);
} else {
// browser global
window.CellsByRow = factory(
window.Outlayer
);
}
}( window, function factory( Outlayer) {
'use strict';
var CellsByRow = Outlayer.create( 'cellsByRow', {
columnWidth: 100,
rowHeight: 100
});
CellsByRow.prototype._resetLayout = function() {
this.getSize();
this._getMeasurement( 'columnWidth', 'outerWidth' );
this._getMeasurement( 'rowHeight', 'outerHeight' );
var isHorizontal = this._getOption('horizontal');
if ( isHorizontal ) {
this.rows = Math.floor( this.size.innerHeight / this.rowHeight );
this.rows = Math.max( this.rows, 1 );
} else {
this.cols = Math.floor( this.size.innerWidth / this.columnWidth );
this.cols = Math.max( this.cols, 1 );
}
this.itemIndex = 0;
};
CellsByRow.prototype._getItemLayoutPosition = function( item ) {
item.getSize();
var column, row;
var isHorizontal = this._getOption('horizontal');
if ( isHorizontal ) {
row = this.itemIndex % this.rows;
column = Math.floor( this.itemIndex / this.rows );
} else {
column = this.itemIndex % this.cols;
row = Math.floor( this.itemIndex / this.cols );
}
var x = column * this.columnWidth;
var y = row * this.rowHeight;
this.itemIndex++;
return {
x: x,
y: y
};
};
CellsByRow.prototype._getContainerSize = function() {
var isHorizontal = this._getOption('horizontal');
if ( isHorizontal ) {
return {
width: Math.ceil( this.itemIndex / this.rows ) * this.columnWidth
};
} else {
return {
height: Math.ceil( this.itemIndex / this.cols ) * this.rowHeight
};
}
};
return CellsByRow;
}));

22
node_modules/outlayer/sandbox/examples.css generated vendored Normal file
View File

@@ -0,0 +1,22 @@
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: sans-serif;
}
.container {
background: #EEE;
width: 50%;
margin-bottom: 1.0em;
}
.item {
border: 1px solid;
background: #09F;
width: 50px;
height: 50px;
}

44
node_modules/outlayer/sandbox/fit-rows.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
/*globals Outlayer */
( function() {
'use strict';
var FitRows = window.FitRows = Outlayer.create('fitRows');
var proto = FitRows.prototype;
proto._resetLayout = function() {
this.getSize();
this.x = 0;
this.y = 0;
this.maxY = 0;
this._getMeasurement( 'gutter', 'outerWidth' );
};
proto._getItemLayoutPosition = function( item ) {
item.getSize();
var itemWidth = item.size.outerWidth + this.gutter;
// if this element cannot fit in the current row
var containerWidth = this.size.innerWidth + this.gutter;
if ( this.x !== 0 && itemWidth + this.x > containerWidth ) {
this.x = 0;
this.y = this.maxY;
}
var position = {
x: this.x,
y: this.y
};
this.maxY = Math.max( this.maxY, this.y + item.size.outerHeight );
this.x += itemWidth;
return position;
};
proto._getContainerSize = function() {
return { height: this.maxY };
};
})();

53
node_modules/outlayer/sandbox/item-methods.html generated vendored Normal file
View File

@@ -0,0 +1,53 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Item Methods</title>
<link rel="stylesheet" href="examples.css" />
</head>
<body>
<h1>Item Methods</h1>
<p>
<button id="reveal">reveal</button>
<button id="hide">hide</button>
<button id="move">move</button>
</p>
<div class="container">
<div class="item"></div>
</div>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script>
var basic = document.querySelector('.container');
var layout = new Outlayer( basic );
var item = layout.items[0];
document.querySelector('#reveal').onclick = function() {
item.reveal();
};
document.querySelector('#hide').onclick = function() {
item.hide();
};
document.querySelector('#move').onclick = function() {
var x = Math.random() * 400;
var y = Math.random() * 200;
item.moveTo( x, y )
};
</script>
</body>
</html>

120
node_modules/outlayer/sandbox/padding-percent.html generated vendored Normal file
View File

@@ -0,0 +1,120 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>padding percent</title>
<style>
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body { font-family: sans-serif; }
/* ---- grid ---- */
.container {
width: 400px;
background: #DDD;
}
.grid {
background: #EEE;
/* max-width: 1200px;*/
padding: 20px 10%;
}
/* clearfix */
.grid:after {
content: '';
display: block;
clear: both;
}
/* ---- grid-item ---- */
.grid-item {
width: 20%;
height: 120px;
float: left;
background: #D26;
border: 2px solid #333;
border-color: hsla(0, 0%, 0%, 0.5);
border-radius: 5px;
}
/*.grid-item--width2 { width: 30%; }
.grid-item--width3 { width: 45%; }*/
.grid-item--height2 { height: 200px; }
.grid-item--height3 { height: 260px; }
.grid-item--height4 { height: 360px; }
</style>
</head>
<body>
<h1>padding + percent width bug</h1>
<p><button class="toggle-button">Toggle</button></p>
<div class="container">
<div class="grid">
<div class="grid-item"></div>
<!-- <div class="grid-item grid-item--width2 grid-item--height2"></div>
<div class="grid-item grid-item--height3"></div>
<div class="grid-item grid-item--height2"></div> -->
<!-- <div class="grid-item grid-item--width3"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item grid-item--width2 grid-item--height3"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--width2 grid-item--height2"></div>
<div class="grid-item grid-item--width2"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--height3"></div>
<div class="grid-item grid-item--height2"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item grid-item--height2"></div> -->
</div>
</div>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script src="fit-rows.js"></script>
<script>
var layout = new FitRows( '.grid', {
transitionDuration: '0.8s',
percentPosition: true
});
var container = document.querySelector('.container');
var isToggled = false;
document.querySelector('.toggle-button').onclick = function() {
isToggled = !isToggled;
container.style.width = isToggled ? '500px' : '400px';
layout.layout();
}
</script>
</body>
</html>

13
node_modules/outlayer/sandbox/requirejs/main.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
requirejs.config({
baseUrl: '../../bower_components'
// OR
// paths: {
// 'ev-emitter': 'bower_components/ev-emitter',
// 'get-size': 'bower_components/get-size',
// 'matches-selector': 'bower_components/matches-selector'
// }
});
requirejs( [ '../sandbox/cells-by-row' ], function( CellsByRow ) {
new CellsByRow( document.querySelector('#basic') );
});

33
node_modules/outlayer/sandbox/requirejs/requirejs.html generated vendored Normal file
View File

@@ -0,0 +1,33 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>require js</title>
<link rel="stylesheet" href="../examples.css" />
<script data-main="main" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.5/require.js"></script>
</head>
<body>
<h1>require js</h1>
<div id="basic" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>

64
node_modules/outlayer/sandbox/stagger.html generated vendored Normal file
View File

@@ -0,0 +1,64 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>stagger</title>
<style>
* { box-sizing: border-box; }
.grid {
background: #DDD;
}
.grid-item {
float: left;
width: 100px;
height: 100px;
border: 1px solid;
background: #19F;
}
</style>
</head>
<body>
<h1>stagger</h1>
<p>
<button class="reveal-button">Reveal</button>
</p>
<div class="grid">
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
</div>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script src="fit-rows.js"></script>
<script>
var layout = new FitRows( '.grid', {
stagger: 50
});
document.querySelector('.reveal-button').onclick = function() {
layout.reveal( layout.items );
};
</script>
</body>
</html>

95
node_modules/outlayer/sandbox/toggler.html generated vendored Normal file
View File

@@ -0,0 +1,95 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CellsByRow toggler</title>
<link rel="stylesheet" href="examples.css" />
</head>
<body>
<h1>CellsByRow toggler</h1>
<button id="toggler">Toggle</button>
<div id="basic" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script src="cells-by-row.js"></script>
<script>
var basic = document.querySelector('#basic');
var layout = new CellsByRow( basic );
var button = document.querySelector('button');
var isToggled = false;
button.onclick = function() {
isToggled = !isToggled;
basic.style.width = isToggled ? '800px' : '400px';
layout.layout();
}
</script>
</body>
</html>

12
node_modules/outlayer/test/.jshintrc generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"browser": true,
"devel": true,
"undef": true,
"unused": true,
"globals": {
"CellsByRow": false,
"gimmeAnItemElement": true,
"QUnit": false,
"Outlayer": false
}
}

9
node_modules/outlayer/test/helpers.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
( function() {
window.gimmeAnItemElement = function() {
var elem = document.createElement('div');
elem.className = 'item';
return elem;
};
})();

301
node_modules/outlayer/test/index.html generated vendored Normal file
View File

@@ -0,0 +1,301 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Outlayer tests</title>
<link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css" />
<link rel="stylesheet" href="tests.css" />
<script src="../bower_components/ev-emitter/ev-emitter.js"></script>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/matches-selector/matches-selector.js"></script>
<script src="../bower_components/fizzy-ui-utils/utils.js"></script>
<script src="../bower_components/qunit/qunit/qunit.js"></script>
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<script src="../bower_components/jquery-bridget/jquery-bridget.js"></script>
<script src="../item.js"></script>
<script src="../outlayer.js"></script>
<script src="helpers.js"></script>
<script src="../sandbox/cells-by-row.js"></script>
<script src="unit/basics.js"></script>
<script src="unit/defaults.js"></script>
<script src="unit/options.js"></script>
<script src="unit/filter-find.js"></script>
<script src="unit/remove.js"></script>
<script src="unit/add-items.js"></script>
<script src="unit/prepend.js"></script>
<script src="unit/stamp.js"></script>
<script src="unit/offset.js"></script>
<!-- <script src="item-on-transition-end.js"></script> -->
<!-- with CellsByRow -->
<script src="unit/create.js"></script>
<script src="unit/layout.js"></script>
<script src="unit/percent-position.js"></script>
<script src="unit/hide-reveal.js"></script>
<script src="unit/get-measurements.js"></script>
<script src="unit/origin.js"></script>
<script src="unit/transition-duration.js"></script>
<script src="unit/container-size.js"></script>
<script src="unit/destroy.js"></script>
<script src="unit/declarative.js"></script>
<script src="unit/jquery-plugin.js"></script>
</head>
<body>
<h1>Outlayer tests</h1>
<div id="qunit"></div>
<div id="empty"></div>
<h2>Defaults</h2>
<div id="defaults" class="container">
<div class="item"></div>
</div>
<h2>Options</h2>
<div id="options" class="container">
<div class="item"></div>
</div>
<h2>filter find</h2>
<div id="children">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="filtered" class="container">
<div class="item w2"></div>
<div class="item h2"></div>
<div></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
<div class="foobar"></div>
</div>
<div id="found" class="container">
<div><div class="item w2"></div></div>
<div><div class="item h2"></div></div>
<div><div class="item w2"></div></div>
<div><div class="item"></div></div>
</div>
<div id="filter-found" class="container">
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
<div class="foobar"></div>
<div><div class="item w2"></div></div>
<div><div class="item"></div></div>
</div>
<h2>remove</h2>
<div id="remove" class="container">
<div class="item"></div>
<div class="item w2"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item w2"></div>
<div class="item w2"></div>
<div class="item"></div>
<div class="item h2"></div>
<div class="item h2"></div>
<div class="item"></div>
</div>
<h2>Adding</h2>
<div id="add-items" class="container">
<div class="item"></div>
<div class="item"></div>
</div>
<h2>Prepend</h2>
<div id="prepend" class="container">
<div class="item"></div>
<div class="item"></div>
</div>
<h2>stamp</h2>
<div id="stamps1" class="container">
<div class="stamp stamp1"></div>
<div class="stamp stamp2"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>layout</h2>
<div id="layout" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>percentPosition</h2>
<div id="percent-position" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>hide/reveal</h2>
<div id="hide-reveal" class="container">
<div class="item"></div>
<div class="item hideable"></div>
<div class="item"></div>
<div class="item hideable"></div>
<div class="item hideable"></div>
<div class="item hideable"></div>
</div>
<h2>getMeasurements</h2>
<div id="get-measurements" class="container">
<div class="grid-sizer"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>_getElementOffset</h2>
<div id="offset" class="container">
<div class="stamp stamp1"></div>
<div class="stamp stamp2"></div>
</div>
<!-- <h2>item onTransitionEnd</h2>
<div id="item-on-transition-end" class="container">
<div class="item"></div>
</div> -->
<h2>origin</h2>
<div id="origin" class="container">
<div class="item item1"></div>
<div class="item item2"></div>
<div class="item item3"></div>
</div>
<h2>transitionDuration</h2>
<div id="transition-duration" class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>destroy</h2>
<div id="destroy" class="container">
<div class="item item1"></div>
<div class="item item2"></div>
<div class="item item3"></div>
</div>
<h2>Declarative</h2>
<div id="declarative-attr" class="container" data-cells-by-row>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<!-- wrong quote marks for JSON -->
<div id="declarative-attr-bad-json" class="container" data-cells-by-row="{ 'columnWidth': 30 }">
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="declarative-attr-good-json" class="container" data-cells-by-row='{ "columnWidth": 25, "rowHeight": 30, "isResizable": false, "foo": "bar" }'>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="declarative-js-class" class="container js-cells-by-row">
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<!-- wrong quote marks for JSON -->
<div id="declarative-js-class-bad-json" class="container js-cells-by-row" data-cells-by-row-options="{ 'columnWidth': 30 }">
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div id="declarative-js-class-good-json" class="container js-cells-by-row" data-cells-by-row-options='{ "columnWidth": 25, "rowHeight": 30, "isResizable": false, "foo": "bar" }'>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item w2"></div>
<div class="item h2"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<h2>container size</h2>
<div id="container-size" class="container"></div>
<h2>jQuery plugin</h2>
<div id="jquery">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</body>
</html>

56
node_modules/outlayer/test/tests.css generated vendored Normal file
View File

@@ -0,0 +1,56 @@
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
background: #EEE;
width: 200px;
margin-bottom: 1.0em;
}
.item {
border: 1px solid;
background: #09F;
width: 50px;
height: 50px;
}
.stamp {
background: red;
border: 1px solid;
}
#get-measurements .grid-sizer {
width: 75px;
height: 90px;
}
#offset {
width: 300px;
border-style: solid;
border-color: #654;
border-width: 0;
/* border-width: 40px 30px 20px 10px;*/
/* padding: 10px 20px 30px 40px;*/
}
#offset .stamp {
position: absolute;
border: 1px solid;
}
#offset .stamp1 {
width: 100px;
height: 50px;
left: 0px;
top: 0px;
}
#offset .stamp2 {
width: 80px;
height: 60px;
right: 0px;
bottom: 0px;
}

39
node_modules/outlayer/test/unit/add-items.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
QUnit.test( 'addItems', function( assert ) {
var olayer = new Outlayer( '#add-items', {
itemSelector: '.item'
});
var elem = gimmeAnItemElement();
var expectedItemCount = olayer.items.length;
var items = olayer.addItems( elem );
assert.equal( items.length, 1, 'method return array of 1' );
assert.equal( olayer.items[2].element, elem, 'item was added, element matches' );
assert.equal( items[0] instanceof Outlayer.Item, true, 'item is instance of Outlayer.Item' );
expectedItemCount += 1;
assert.equal( olayer.items.length, expectedItemCount, 'item added to items' );
// try it with an array
var elems = [ gimmeAnItemElement(), gimmeAnItemElement(), document.createElement('div') ];
items = olayer.addItems( elems );
assert.equal( items.length, 2, 'method return array of 2' );
assert.equal( olayer.items[3].element, elems[0], 'item was added, element matches' );
expectedItemCount += 2;
assert.equal( olayer.items.length, expectedItemCount, 'two items added to items' );
// try it with HTMLCollection / NodeList
var fragment = document.createDocumentFragment();
fragment.appendChild( gimmeAnItemElement() );
fragment.appendChild( document.createElement('div') );
fragment.appendChild( gimmeAnItemElement() );
var divs = fragment.querySelectorAll('div');
items = olayer.addItems( divs );
assert.equal( items.length, 2, 'method return array of 2' );
assert.equal( olayer.items[5].element, divs[0], 'item was added, element matches' );
expectedItemCount += 2;
assert.equal( olayer.items.length, expectedItemCount, 'two items added to items' );
});

5
node_modules/outlayer/test/unit/basics.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
QUnit.test( 'basics', function( assert ) {
assert.equal( typeof Outlayer, 'function', 'Outlayer is a function' );
// TODO pckry should be null or something
// var olayer = new Outlayer();
});

49
node_modules/outlayer/test/unit/container-size.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
QUnit.test( 'container size', function( assert ) {
// test layout that just sets size
var Sizer = Outlayer.create( 'sizer', {
width: 220,
height: 120
});
Sizer.prototype._getContainerSize = function() {
return {
width: this.options.width,
height: this.options.height
};
};
var elem = document.querySelector('#container-size');
var layout = new Sizer( elem );
function checkSize( width, height ) {
assert.equal( elem.style.width, width + 'px', 'width = ' + width );
assert.equal( elem.style.height, height + 'px', 'height = ' + height );
}
checkSize( 220, 120 );
// disable resizing
layout.options.resizeContainer = false;
layout.options.width = 180;
layout.options.height = 230;
layout.layout();
checkSize( 220, 120 );
layout.options.resizeContainer = true;
layout.options.width = 220;
layout.options.height = 120;
if ( layout.size.isBorderBox ) {
elem.style.padding = '10px 20px 30px 40px';
layout.layout();
checkSize( 280, 160 );
elem.style.borderStyle = 'solid';
elem.style.borderWidth = '4px 3px 2px 1px';
layout.layout();
checkSize( 284, 166 );
}
});

24
node_modules/outlayer/test/unit/create.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
QUnit.test( 'create Layouts', function( assert ) {
var Leiout = Outlayer.create('leiout');
Leiout.Item.prototype.foo = 'bar';
Leiout.compatOptions.fitWidth = 'isFitWidth';
var elem = document.createElement('div');
var lei = new Leiout( elem, {
isFitWidth: 300
});
var outlayr = new Outlayer( elem );
assert.equal( typeof CellsByRow, 'function', 'CellsByRow is a function' );
assert.equal( CellsByRow.namespace, 'cellsByRow', 'cellsByRow namespace' );
assert.equal( Outlayer.namespace, 'outlayer', 'Outlayer namespace unchanged' );
assert.equal( Leiout.namespace, 'leiout', 'Leiout namespace' );
assert.equal( CellsByRow.defaults.resize, true, 'resize option there' );
assert.equal( CellsByRow.defaults.columnWidth, 100, 'columnWidth option set' );
assert.strictEqual( Outlayer.defaults.columnWidth, undefined, 'Outlayer has no default columnWidth' );
assert.strictEqual( Leiout.defaults.columnWidth, undefined, 'Leiout has no default columnWidth' );
assert.equal( lei.constructor.Item, Leiout.Item, 'Leiout.Item is on constructor.Item' );
assert.equal( lei._getOption('fitWidth'), 300, 'backwards compatible _getOption' );
assert.equal( outlayr.constructor.Item, Outlayer.Item, 'outlayr.Item is still correct Item' );
});

70
node_modules/outlayer/test/unit/declarative.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
QUnit.test( 'declarative', function( assert ) {
var $ = window.jQuery;
// data-cells-by-row, no data-cells-by-row-options
( function() {
var container = document.querySelector('#declarative-attr');
var cellsLayout = CellsByRow.data( container );
assert.ok( cellsLayout instanceof CellsByRow, '.data() works, retrieves instance' );
assert.deepEqual( cellsLayout.options, CellsByRow.defaults, 'options match defaults' );
assert.ok( cellsLayout._isLayoutInited, 'cellsLayout._isLayoutInited' );
var itemElem = cellsLayout.items[0].element;
assert.equal( itemElem.style.left, '0px', 'first item style left set' );
assert.equal( itemElem.style.top, '0px', 'first item style top set' );
})();
// data-cells-by-row, has data-cells-by-row-options, but bad JSON
( function() {
var container = document.querySelector('#declarative-attr-bad-json');
var cellsLayout = CellsByRow.data( container );
assert.ok( !cellsLayout, 'bad JSON in data-cells-by-row-options does not init CellsByRow' );
assert.ok( !container.outlayerGUID, 'no expando property on element' );
})();
// data-cells-by-row, has good data-packery-options
( function() {
var container = document.querySelector('#declarative-attr-good-json');
var cellsLayout = CellsByRow.data( container );
assert.ok( cellsLayout instanceof CellsByRow, '.data() got CellByRow instance retrieved from element, with good JSON in data-cells-by-row-options' );
assert.strictEqual( cellsLayout.options.columnWidth, 25, 'columnWidth option was set' );
assert.strictEqual( cellsLayout.options.rowHeight, 30, 'rowHeight option was set' );
assert.strictEqual( cellsLayout.options.isResizable, false, 'isResizable option was set' );
assert.strictEqual( cellsLayout.options.foo, 'bar', 'foo option was set' );
assert.equal( $.data( container, 'cellsByRow' ), cellsLayout, 'jQuery.data( elem, "cellsByRow") returns CellsByRow instance' );
})();
// js-cells-by-row, no data-cells-by-row-options
( function() {
var container = document.querySelector('#declarative-js-class');
var cellsLayout = CellsByRow.data( container );
assert.ok( cellsLayout instanceof CellsByRow, '.data() works, retrieves instance' );
assert.deepEqual( cellsLayout.options, CellsByRow.defaults, 'options match defaults' );
assert.ok( cellsLayout._isLayoutInited, 'cellsLayout._isLayoutInited' );
var itemElem = cellsLayout.items[0].element;
assert.equal( itemElem.style.left, '0px', 'first item style left set' );
assert.equal( itemElem.style.top, '0px', 'first item style top set' );
})();
// js-cells-by-row, has data-cells-by-row-options, but bad JSON
( function() {
var container = document.querySelector('#declarative-js-class-bad-json');
var cellsLayout = CellsByRow.data( container );
assert.ok( !cellsLayout, 'bad JSON in data-cells-by-row-options does not init CellsByRow' );
assert.ok( !container.outlayerGUID, 'no expando property on element' );
})();
// js-cells-by-row, has good data-packery-options
( function() {
var container = document.querySelector('#declarative-js-class-good-json');
var cellsLayout = CellsByRow.data( container );
assert.ok( cellsLayout instanceof CellsByRow, '.data() got CellByRow instance retrieved from element, with good JSON in data-cells-by-row-options' );
assert.strictEqual( cellsLayout.options.columnWidth, 25, 'columnWidth option was set' );
assert.strictEqual( cellsLayout.options.rowHeight, 30, 'rowHeight option was set' );
assert.strictEqual( cellsLayout.options.isResizable, false, 'isResizable option was set' );
assert.strictEqual( cellsLayout.options.foo, 'bar', 'foo option was set' );
assert.equal( $.data( container, 'cellsByRow' ), cellsLayout, 'jQuery.data( elem, "cellsByRow") returns CellsByRow instance' );
})();
});

13
node_modules/outlayer/test/unit/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
QUnit.test( 'defaults', function( assert ) {
var container = document.querySelector('#defaults');
var olayer = new Outlayer( container );
var item = olayer.items[0];
assert.deepEqual( olayer.options, Outlayer.defaults, 'default options match prototype' );
assert.equal( typeof olayer.items, 'object', 'items is object' );
assert.equal( olayer.items.length, 1, 'one item' );
assert.equal( Outlayer.data( container ), olayer, 'data method returns instance' );
assert.ok( olayer.resize, 'resize' );
assert.deepEqual( item.options, Outlayer.Item.prototype.options, 'default item options match Outlayer.Item' );
});

35
node_modules/outlayer/test/unit/destroy.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
QUnit.test( 'destroy', function( assert ) {
var container = document.querySelector('#destroy');
var layout = new CellsByRow( container );
layout.destroy();
assert.ok( !CellsByRow.data( container ), '.data() returns falsey' );
function checkStyle( elem, property ) {
assert.ok( !elem.style[ property ], elem + ' has no ' + property + ' style' );
}
checkStyle( container, 'height' );
checkStyle( container, 'position' );
var items = container.querySelectorAll('.item');
for ( var i=0, len = items.length; i < len; i++ ) {
var itemElem = items[i];
checkStyle( itemElem, 'position' );
checkStyle( itemElem, 'left' );
checkStyle( itemElem, 'top' );
}
// try to force a resize
container.style.width = '300px';
layout.resize();
checkStyle( container, 'height' );
checkStyle( container, 'position' );
checkStyle( items[0], 'position' );
checkStyle( items[0], 'left' );
checkStyle( items[0], 'top' );
});

29
node_modules/outlayer/test/unit/filter-find.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
QUnit.test( 'filter find item elements', function( assert ) {
( function() {
var olayer = new Outlayer( '#children' );
assert.equal( olayer.items.length, 3, 'no itemSeletor, gets all children' );
})();
( function() {
var olayer = new Outlayer( '#filtered', {
itemSelector: '.item'
});
assert.equal( olayer.items.length, 6, 'filtered, itemSelector = .item, not all children' );
})();
( function() {
var olayer = new Outlayer( '#found', {
itemSelector: '.item'
});
assert.equal( olayer.items.length, 4, 'found itemSelector = .item, querySelectoring' );
})();
( function() {
var olayer = new Outlayer( '#filter-found', {
itemSelector: '.item'
});
assert.equal( olayer.items.length, 5, 'filter found' );
})();
});

26
node_modules/outlayer/test/unit/get-measurements.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
QUnit.test( 'getMeasurements', function( assert ) {
var container = document.querySelector('#get-measurements');
var layout = new CellsByRow( container, {
itemSelector: '.item',
columnWidth: 80,
rowHeight: 65
});
assert.equal( layout.columnWidth, 80, 'columnWidth option set 80' );
assert.equal( layout.rowHeight, 65, 'rowHeight option set 65' );
var gridSizer = container.querySelector('.grid-sizer');
layout.options.columnWidth = gridSizer;
layout.options.rowHeight = gridSizer;
layout.layout();
assert.equal( layout.columnWidth, 75, 'columnWidth element sized as 75px' );
assert.equal( layout.rowHeight, 90, 'rowHeight element sized as 90px' );
gridSizer.style.width = '50%';
layout.layout();
assert.equal( layout.columnWidth, 100, 'columnWidth element sized as 50% => 100px' );
});

151
node_modules/outlayer/test/unit/hide-reveal.js generated vendored Normal file
View File

@@ -0,0 +1,151 @@
QUnit.test( 'hide/reveal', function( assert ) {
var CellsByRow = window.CellsByRow;
var gridElem = document.querySelector('#hide-reveal');
var layout = new CellsByRow( gridElem, {
columnWidth: 60,
rowHeight: 60,
transitionDuration: '0.2s'
});
var hideElems = gridElem.querySelectorAll('.hideable');
var hideItems = layout.getItems( hideElems );
var lastIndex = hideItems.length - 1;
var firstItemElem = hideItems[0].element;
var lastItemElem = hideItems[ lastIndex ].element;
var done = assert.async();
layout.once( 'hideComplete', function( hideCompleteItems ) {
assert.ok( true, 'hideComplete event did fire' );
assert.equal( hideCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( hideCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( hideCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, 'none', 'first item hidden' );
assert.equal( lastItemElem.style.display, 'none', 'last item hidden' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
setTimeout( nextReveal );
});
layout.hide( hideItems );
// -------------------------- -------------------------- //
function nextReveal() {
layout.once( 'revealComplete', function( revealCompleteItems ) {
assert.ok( true, 'revealComplete event did fire' );
assert.equal( revealCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( revealCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( revealCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, '', 'first item no display' );
assert.equal( lastItemElem.style.display, '', 'last item no display' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
setTimeout( nextHideNoTransition );
});
layout.reveal( hideItems );
}
// -------------------------- -------------------------- //
function nextHideNoTransition() {
layout.once( 'hideComplete', function( hideCompleteItems ) {
assert.ok( true, 'hideComplete event did fire' );
assert.equal( hideCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( hideCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( hideCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, 'none', 'first item hidden' );
assert.equal( lastItemElem.style.display, 'none', 'last item hidden' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
setTimeout( nextRevealNoTransition );
// start();
});
layout.transitionDuration = 0;
layout.hide( hideItems );
}
// -------------------------- -------------------------- //
function nextRevealNoTransition() {
layout.once( 'revealComplete', function( revealCompleteItems ) {
assert.ok( true, 'revealComplete event did fire' );
assert.equal( revealCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( revealCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( revealCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, '', 'first item no display' );
assert.equal( lastItemElem.style.display, '', 'last item no display' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
setTimeout( nextHideNone );
// start();
});
layout.reveal( hideItems );
}
function nextHideNone() {
var emptyArray = [];
layout.once( 'hideComplete', function( hideCompleteItems ) {
assert.ok( true, 'hideComplete event did fire with no items' );
assert.equal( hideCompleteItems, emptyArray, 'returns same object passed in' );
setTimeout( nextRevealNone );
// start();
});
layout.hide( emptyArray );
}
function nextRevealNone() {
var emptyArray = [];
layout.once( 'revealComplete', function( revealCompleteItems ) {
assert.ok( true, 'revealComplete event did fire with no items' );
assert.equal( revealCompleteItems, emptyArray, 'returns same object passed in' );
setTimeout( nextHideItemElements );
// start();
});
layout.reveal( emptyArray );
}
// -------------------------- -------------------------- //
function nextHideItemElements() {
layout.once( 'hideComplete', function( hideCompleteItems ) {
assert.ok( true, 'hideComplete event did fire after hideItemElements' );
assert.equal( hideCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( hideCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( hideCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, 'none', 'first item hidden' );
assert.equal( lastItemElem.style.display, 'none', 'last item hidden' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
setTimeout( nextRevealItemElements );
// start();
});
layout.hideItemElements( hideElems );
}
function nextRevealItemElements() {
layout.once( 'revealComplete', function( revealCompleteItems ) {
assert.ok( true, 'revealComplete event did fire after revealItemElements' );
assert.equal( revealCompleteItems.length, hideItems.length, 'event-emitted items matches layout items length' );
assert.strictEqual( revealCompleteItems[0], hideItems[0], 'event-emitted items has same first item' );
assert.strictEqual( revealCompleteItems[ lastIndex ], hideItems[ lastIndex ], 'event-emitted items has same last item' );
assert.equal( firstItemElem.style.display, '', 'first item no display' );
assert.equal( lastItemElem.style.display, '', 'last item no display' );
assert.equal( firstItemElem.style.opacity, '', 'first item opacity not set' );
assert.equal( lastItemElem.style.opacity, '', 'last item opacity not set' );
// setTimeout( nextHideNoTransition );
done();
});
layout.revealItemElements( hideElems );
}
});

View File

@@ -0,0 +1,28 @@
QUnit.test( 'item onTransitionEnd', function( assert ) {
var container = document.querySelector('#item-on-transition-end');
var layout = new Outlayer( container, {
containerStyle: { top: 0 },
transitionDuration: '1s'
});
var item = layout.items[0];
item.addListener( 'transitionEnd', function() {
console.log( item.element.style.display ); } );
// item.on( 'transitionEnd', function() {
// console.log( item.element.style.display ); } );
// var itemElem = layout.items[0].element;
var done = assert.async();
// hide, then immediate reveal again, while item is still transitioning
layout.hide( [ item ] );
setTimeout( function() {
item.addListener( 'transitionEnd', function() {
console.log('second', item.element.style.display );
// console.log( item.element.style.display );
assert.ok( true, true );
// assert.equal( item.element.style.display, '', 'item was not hidden');
done();
});
layout.reveal( [ item ] );
}, 500 );
});

18
node_modules/outlayer/test/unit/jquery-plugin.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
QUnit.test( 'jQuery plugin', function( assert ) {
var $ = window.jQuery;
var $elem = $('#jquery');
assert.ok( $.fn.cellsByRow, '.cellsByRow is in jQuery.fn namespace' );
assert.equal( typeof $elem.cellsByRow, 'function', '.cellsByRow is a plugin' );
$elem.cellsByRow();
var layout = $elem.data('cellsByRow');
assert.ok( layout, 'CellsByRow instance via .data()' );
assert.equal( layout, CellsByRow.data( $elem[0] ), 'instance matches the same one via CellsByRow.data()' );
// destroy and re-init
$elem.cellsByRow('destroy');
$elem.cellsByRow();
assert.notEqual( $elem.data('cellsByRow'), layout, 'new CellsByRow instance after destroy' );
});

22
node_modules/outlayer/test/unit/layout.js generated vendored Normal file
View File

@@ -0,0 +1,22 @@
QUnit.test( 'layout', function( assert ) {
var cellsLayout = new CellsByRow( document.querySelector('#layout') );
var items = cellsLayout.items;
assert.ok( cellsLayout._isLayoutInited, '_isLayoutInited' );
var done = assert.async();
cellsLayout.once( 'layoutComplete', function onLayout( layoutItems ) {
assert.ok( true, 'layoutComplete event did fire' );
assert.equal( layoutItems.length, items.length, 'event-emitted items matches layout items length' );
assert.strictEqual( layoutItems[0], items[0], 'event-emitted items has same first item' );
var len = layoutItems.length - 1;
assert.strictEqual( layoutItems[ len ], items[ len ], 'event-emitted items has same last item' );
done();
});
cellsLayout.options.columnWidth = 60;
cellsLayout.options.rowHeight = 60;
cellsLayout.layout();
});

69
node_modules/outlayer/test/unit/offset.js generated vendored Normal file
View File

@@ -0,0 +1,69 @@
QUnit.test( 'offset', function( assert ) {
var container = document.querySelector('#offset');
var stamp1 = container.querySelector('.stamp1');
var stamp2 = container.querySelector('.stamp2');
var layout = new Outlayer( container, {
itemSelector: '.item'
});
container.style.height = '300px';
layout.getSize();
layout._getBoundingRect();
var offset1 = layout._getElementOffset( stamp1 );
var offset2 = layout._getElementOffset( stamp2 );
// console.log( offset );
assert.equal( offset1.left, 0, 'stamp1 offset left: 0' );
assert.equal( offset1.top, 0, 'stamp1 offset top: 0' );
assert.equal( offset2.right, 0, 'stamp2 offset right: 0' );
assert.equal( offset2.bottom, 0, 'stamp2 offset bottom: 0' );
stamp1.style.left = '40px';
stamp1.style.top = '20px';
stamp2.style.right = '50px';
stamp2.style.bottom = '30px';
offset1 = layout._getElementOffset( stamp1 );
offset2 = layout._getElementOffset( stamp2 );
// console.log( offset );
assert.equal( offset1.left, 40, 'stamp1 offset left: 40' );
assert.equal( offset1.top, 20, 'stamp1 offset top: 20' );
assert.equal( offset2.right, 50, 'stamp2 offset right: 50' );
assert.equal( offset2.bottom, 30, 'stamp2 offset bottom: 30' );
// add border to container
container.style.borderWidth = '40px 30px 20px 10px';
layout.getSize();
layout._getBoundingRect();
offset1 = layout._getElementOffset( stamp1 );
offset2 = layout._getElementOffset( stamp2 );
// left/top should still be the same
assert.equal( offset1.left, 40, 'stamp1 offset with border left: 40' );
assert.equal( offset1.top, 20, 'stamp1 offset with border top: 20' );
assert.equal( offset2.right, 50, 'stamp2 offset with border right: 50' );
assert.equal( offset2.bottom, 30, 'stamp2 offset with border bottom: 30' );
// add padding to container
container.style.padding = '10px 20px 30px 40px';
layout.getSize();
layout._getBoundingRect();
offset1 = layout._getElementOffset( stamp1 );
offset2 = layout._getElementOffset( stamp2 );
assert.equal( offset1.left, 0, 'stamp1 offset with border and padding, left: 0' );
assert.equal( offset1.top, 10, 'stamp1 offset with border and padding, top: 10' );
assert.equal( offset2.right, 30, 'stamp2 offset with border and padding, right: 30' );
assert.equal( offset2.bottom, 0, 'stamp2 offset with border and padding, bottom: 0' );
// add margin to stamps
stamp1.style.margin = '5px 10px 15px 20px';
stamp2.style.margin = '5px 10px 15px 20px';
layout.getSize();
layout._getBoundingRect();
offset1 = layout._getElementOffset( stamp1 );
offset2 = layout._getElementOffset( stamp2 );
assert.equal( offset1.left, 0, 'stamp1 offset with margin, left: 0' );
assert.equal( offset1.top, 10, 'stamp1 offset with margin, top: 10' );
assert.equal( offset2.right, 30, 'stamp2 offset with margin, right: 30' );
assert.equal( offset2.bottom, 0, 'stamp2 offset with margin, bottom: 0' );
});

11
node_modules/outlayer/test/unit/options.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
QUnit.test( 'options', function( assert ) {
var container = document.querySelector('#options');
var olayer = new Outlayer( container, {
initLayout: false,
transitionDuration: '600ms'
});
assert.ok( !olayer._isLayoutInited, 'olayer is not layout initialized' );
assert.equal( olayer.options.transitionDuration, '600ms', 'transition option set');
});

62
node_modules/outlayer/test/unit/origin.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
QUnit.test( 'origin', function( assert ) {
var elem = document.querySelector('#origin');
var layout = new CellsByRow( elem, {
itemOptions: {
transitionDuration: '0.1s'
}
});
function checkItemPosition( itemIndex, x, y ) {
var itemElem = layout.items[ itemIndex ].element;
var message = 'item ' + itemIndex + ' ';
var xProperty = layout.options.originLeft ? 'left' : 'right';
var yProperty = layout.options.originTop ? 'top' : 'bottom';
assert.equal( itemElem.style[ xProperty ], x + 'px', message + xProperty + ' = ' + x );
assert.equal( itemElem.style[ yProperty ], y + 'px', message + yProperty + ' = ' + y );
}
// top left
checkItemPosition( 0, 0, 0 );
checkItemPosition( 1, 100, 0 );
checkItemPosition( 2, 0, 100 );
// top right
layout.options.originLeft = false;
layout.once( 'layoutComplete', function() {
checkItemPosition( 0, 0, 0 );
checkItemPosition( 1, 100, 0 );
checkItemPosition( 2, 0, 100 );
setTimeout( testBottomRight );
// start();
});
var done = assert.async();
layout.layout();
// bottom right
function testBottomRight() {
layout.options.originTop = false;
layout.once( 'layoutComplete', function() {
checkItemPosition( 0, 0, 0 );
checkItemPosition( 1, 100, 0 );
checkItemPosition( 2, 0, 100 );
setTimeout( testBottomLeft );
});
layout.layout();
}
// bottom right
function testBottomLeft() {
layout.options.originLeft = true;
layout.once( 'layoutComplete', function() {
checkItemPosition( 0, 0, 0 );
checkItemPosition( 1, 100, 0 );
checkItemPosition( 2, 0, 100 );
done();
});
layout.layout();
}
});

28
node_modules/outlayer/test/unit/percent-position.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
QUnit.test( 'percentPosition', function( assert ) {
var gridElem = document.querySelector('#percent-position');
var layout = new CellsByRow( gridElem, {
percentPosition: true,
columnWidth: 50,
rowHeight: 50,
transitionDuration: 0
});
var itemElems = gridElem.querySelectorAll('.item');
assert.equal( itemElems[0].style.left, '0%', 'first item left 0%' );
assert.equal( itemElems[1].style.left, '25%', '2nd item left 25%' );
assert.equal( itemElems[2].style.left, '50%', 'first item left 50%' );
assert.equal( itemElems[3].style.left, '75%', 'first item left 75%' );
// set top
gridElem.style.height = '200px';
layout.options.horizontal = true;
layout.layout();
assert.equal( itemElems[0].style.top, '0%', 'first item top 0%' );
assert.equal( itemElems[1].style.top, '25%', 'second item top 25%' );
assert.equal( itemElems[2].style.top, '50%', 'first item top 50%' );
assert.equal( itemElems[3].style.top, '75%', 'first item top 75%' );
});

35
node_modules/outlayer/test/unit/prepend.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
QUnit.test( 'prepend', function( assert ) {
var container = document.querySelector('#prepend');
var olayer = new Outlayer( container );
var itemElemA = olayer.items[0].element;
var itemElemB = olayer.items[1].element;
var itemElemC = gimmeAnItemElement();
itemElemC.style.background = 'orange';
var itemElemD = gimmeAnItemElement();
itemElemD.style.background = 'magenta';
// TODO re-enable this, possible with CellsByRow
// var ticks = 0;
// olayer.on( 'layoutComplete', function() {
// assert.ok( true, 'layoutComplete triggered' );
// ticks++;
// if ( ticks == 2 ) {
// assert.ok( true, '2 layoutCompletes triggered' );
// start();
// }
// });
//
// stop();
var fragment = document.createDocumentFragment();
fragment.appendChild( itemElemC );
fragment.appendChild( itemElemD );
container.insertBefore( fragment, container.firstChild );
olayer.prepended([ itemElemC, itemElemD ]);
assert.equal( olayer.items[0].element, itemElemC, 'item C is first' );
assert.equal( olayer.items[1].element, itemElemD, 'item D is second' );
assert.equal( olayer.items[2].element, itemElemA, 'item A is third' );
assert.equal( olayer.items[3].element, itemElemB, 'item B is fourth' );
});

54
node_modules/outlayer/test/unit/remove.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
QUnit.test( 'remove', function( assert ) {
var container = document.querySelector('#remove');
// packery starts with 4 items
var olayer = new Outlayer( container, {
itemSelector: '.item'
});
// remove .w2 items
var w2Elems = container.querySelectorAll('.w2');
var expectedRemovedCount = olayer.items.length - w2Elems.length;
olayer.once( 'removeComplete', function( removedItems ) {
assert.ok( true, 'removeComplete event did fire' );
assert.equal( removedItems.length, w2Elems.length, 'remove elems length matches 2nd argument length' );
for ( var i=0, len = removedItems.length; i < len; i++ ) {
assert.equal( removedItems[i].element, w2Elems[i], 'removedItems element matches' );
}
assert.equal( container.children.length, expectedRemovedCount, 'elements removed from DOM' );
assert.equal( container.querySelectorAll('.w2').length, 0, 'matched elements were removed' );
setTimeout( removeNoTransition, 20 );
// start();
});
var done = assert.async();
olayer.remove( w2Elems );
assert.equal( olayer.items.length, expectedRemovedCount, 'items removed from Packery instance' );
// check items are remove with no transition
function removeNoTransition() {
// disable transition by setting transition duration to 0
olayer.options.transitionDuration = 0;
var h2Elems = container.querySelectorAll('.h2');
expectedRemovedCount -= h2Elems.length;
olayer.once( 'removeComplete', function( removedItems ) {
assert.ok( true, 'no transition, removeComplete event did fire' );
assert.equal( h2Elems.length, removedItems.length, 'no transition, remove elems length matches argument length' );
assert.equal( container.children.length, expectedRemovedCount, 'no transition, elements removed from DOM' );
assert.equal( container.querySelectorAll('.h2').length, 0, 'no transition, matched elements were removed' );
setTimeout( removeNone, 20 );
// start();
});
olayer.remove( h2Elems );
}
function removeNone() {
var noneItems = container.querySelector('.foo');
olayer.remove( noneItems );
assert.ok( true, 'removing no items is cool' );
done();
}
});

76
node_modules/outlayer/test/unit/stamp.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
QUnit.test( 'stamp selector string', function( assert ) {
var container = document.querySelector('#stamps1');
var stampElems = container.querySelectorAll('.stamp');
var stamp1 = container.querySelector('.stamp1');
var stamp2 = container.querySelector('.stamp2');
var layout = new Outlayer( container, {
stamp: '.stamp'
});
assert.equal( layout.stamps.length, stampElems.length, 'lenght matches' );
assert.equal( layout.stamps[0], stamp1, 'stamp1 matches' );
assert.equal( layout.stamps[1], stamp2, 'stamp2 matches' );
assert.ok( !stamp1.style.left, 'stamp 1 has no left style' );
assert.ok( !stamp1.style.top, 'stamp 1 has no top style' );
layout.destroy();
});
QUnit.test( 'stamp with NodeList', function( assert ) {
var container = document.querySelector('#stamps1');
var stampElems = container.querySelectorAll('.stamp');
var stamp1 = container.querySelector('.stamp1');
var stamp2 = container.querySelector('.stamp2');
var layout = new Outlayer( container, {
stamp: stampElems
});
assert.equal( layout.stamps.length, stampElems.length, 'lenght matches' );
assert.equal( layout.stamps[0], stamp1, 'stamp1 matches' );
assert.equal( layout.stamps[1], stamp2, 'stamp2 matches' );
layout.destroy();
});
QUnit.test( 'stamp with array', function( assert ) {
var container = document.querySelector('#stamps1');
var stampElems = container.querySelectorAll('.stamp');
var stamp1 = container.querySelector('.stamp1');
var stamp2 = container.querySelector('.stamp2');
var layout = new Outlayer( container, {
stamp: [ stamp1, stamp2 ]
});
assert.equal( layout.stamps.length, stampElems.length, 'lenght matches' );
assert.equal( layout.stamps[0], stamp1, 'stamp1 matches' );
assert.equal( layout.stamps[1], stamp2, 'stamp2 matches' );
layout.destroy();
});
QUnit.test( 'stamp and unstamp method', function( assert ) {
var container = document.querySelector('#stamps1');
var stamp1 = container.querySelector('.stamp1');
var stamp2 = container.querySelector('.stamp2');
var layout = new Outlayer( container );
assert.equal( layout.stamps.length, 0, 'start with 0 stamps' );
layout.stamp( stamp1 );
assert.equal( layout.stamps.length, 1, 'stamp length = 1' );
assert.equal( layout.stamps[0], stamp1, 'stamp1 matches' );
layout.stamp('.stamp2');
assert.equal( layout.stamps.length, 2, 'stamp length = 2' );
assert.equal( layout.stamps[0], stamp1, 'stamp1 matches' );
assert.equal( layout.stamps[1], stamp2, 'stamp2 matches' );
layout.unstamp('.stamp1');
assert.equal( layout.stamps.length, 1, 'unstamped, and stamp length = 1' );
assert.equal( layout.stamps[0], stamp2, 'stamp2 matches' );
});

18
node_modules/outlayer/test/unit/transition-duration.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
QUnit.test( 'transition duration', function( assert ) {
var layout = new CellsByRow( '#transition-duration', {
transitionDuration: '0s'
});
var done = assert.async();
layout.options.columnWidth = 75;
layout.options.rowHeight = 120;
layout.once( 'layoutComplete', function() {
assert.ok( true, 'layoutComplete triggered when transition duration = 0' );
done();
});
layout.layout();
});