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

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();
});