Skip to content

Commit

Permalink
update Outlayer to v1.4.0; add fizzy-ui-utils
Browse files Browse the repository at this point in the history
add fizzy-ui-utils to manifest.json
implement fizzyUIUtils in isotope source
fix requirejs jquery path
update bower.json, package.json, dependencies
.jshintrc globals
  • Loading branch information
desandro committed Apr 8, 2015
1 parent 5bd5acb commit eb98c79
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"strict": true,
"undef": true,
"unused": true,
"predef": {
"globals": {
"define": false,
"module": false,
"require": false
Expand Down
16 changes: 5 additions & 11 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@
"name": "isotope",
"version": "2.1.1",
"description": "Filter and sort magical layouts",
"main": [
"js/item.js",
"js/layout-mode.js",
"js/isotope.js",
"js/layout-modes/vertical.js",
"js/layout-modes/fit-rows.js",
"js/layout-modes/masonry.js"
],
"main": "js/isotope.js",
"dependencies": {
"get-size": ">=1.2.2 <1.3",
"get-size": "~1.2.2",
"matches-selector": ">=1 <2",
"outlayer": "1.3.x",
"masonry": "3.2.x"
"outlayer": "~1.4.0",
"masonry": "3.2.x",
"fizzy-ui-utils": "~1.0.1"
},
"devDependencies": {
"doc-ready": "1.x",
Expand Down
68 changes: 11 additions & 57 deletions js/isotope.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ var jQuery = window.jQuery;

// -------------------------- helpers -------------------------- //

// extend objects
function extend( a, b ) {
for ( var prop in b ) {
a[ prop ] = b[ prop ];
}
return a;
}

var trim = String.prototype.trim ?
function( str ) {
return str.trim();
Expand All @@ -40,52 +32,10 @@ var getText = docElem.textContent ?
return elem.innerText;
};

var objToString = Object.prototype.toString;
function isArray( obj ) {
return objToString.call( obj ) === '[object Array]';
}

// index of helper cause IE8
var indexOf = Array.prototype.indexOf ? function( ary, obj ) {
return ary.indexOf( obj );
} : function( ary, obj ) {
for ( var i=0, len = ary.length; i < len; i++ ) {
if ( ary[i] === obj ) {
return i;
}
}
return -1;
};

// turn element or nodeList into an array
function makeArray( obj ) {
var ary = [];
if ( isArray( obj ) ) {
// use object if already an array
ary = obj;
} else if ( obj && typeof obj.length === 'number' ) {
// convert nodeList to array
for ( var i=0, len = obj.length; i < len; i++ ) {
ary.push( obj[i] );
}
} else {
// array of single index
ary.push( obj );
}
return ary;
}

function removeFrom( obj, ary ) {
var index = indexOf( ary, obj );
if ( index !== -1 ) {
ary.splice( index, 1 );
}
}

// -------------------------- isotopeDefinition -------------------------- //

// used for AMD definition and requires
function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode ) {
function isotopeDefinition( Outlayer, getSize, matchesSelector, utils, Item, LayoutMode ) {
// create an Outlayer layout class
var Isotope = Outlayer.create( 'isotope', {
layoutMode: "masonry",
Expand Down Expand Up @@ -143,7 +93,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
// HACK extend initial options, back-fill in default options
var initialOpts = this.options[ name ] || {};
this.options[ name ] = Mode.options ?
extend( Mode.options, initialOpts ) : initialOpts;
utils.extend( Mode.options, initialOpts ) : initialOpts;
// init layout mode instance
this.modes[ name ] = new Mode( this );
};
Expand Down Expand Up @@ -280,7 +230,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode
// get items
var items;
if ( elems ) {
elems = makeArray( elems );
elems = utils.makeArray( elems );
items = this.getItems( elems );
} else {
// update all items if no elems provided
Expand Down Expand Up @@ -531,19 +481,20 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode

var _remove = Isotope.prototype.remove;
Isotope.prototype.remove = function( elems ) {
elems = makeArray( elems );
elems = utils.makeArray( elems );
var removeItems = this.getItems( elems );
// do regular thing
_remove.call( this, elems );
// bail if no items to remove
if ( !removeItems || !removeItems.length ) {
var len = removeItems && removeItems.length;
if ( !len ) {
return;
}
// remove elems from filteredItems
for ( var i=0, len = removeItems.length; i < len; i++ ) {
for ( var i=0; i < len; i++ ) {
var item = removeItems[i];
// remove item from collection
removeFrom( item, this.filteredItems );
utils.removeFrom( this.filteredItems, item );
}
};

Expand Down Expand Up @@ -604,6 +555,7 @@ if ( typeof define === 'function' && define.amd ) {
'outlayer/outlayer',
'get-size/get-size',
'matches-selector/matches-selector',
'fizzy-ui-utils/utils',
'./item',
'./layout-mode',
// include default layout modes
Expand All @@ -618,6 +570,7 @@ if ( typeof define === 'function' && define.amd ) {
require('outlayer'),
require('get-size'),
require('desandro-matches-selector'),
require('fizzy-ui-utils'),
require('./item'),
require('./layout-mode'),
// include default layout modes
Expand All @@ -631,6 +584,7 @@ if ( typeof define === 'function' && define.amd ) {
window.Outlayer,
window.getSize,
window.matchesSelector,
window.fizzyUIUtils,
window.Isotope.Item,
window.Isotope.LayoutMode
);
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
"name": "isotope-layout",
"version": "2.1.1",
"description": "Filter and sort magical layouts",
"main": "js/isotope.js",
"dependencies": {
"get-size": ">=1.2.2 <1.3",
"get-size": "~1.2.2",
"desandro-matches-selector": ">=1 <2",
"outlayer": "1.3.x",
"masonry-layout": "3.2.x"
"outlayer": "~1.4.0",
"masonry-layout": "3.2.x",
"fizzy-ui-utils": "~1.0.1"
},
"devDependencies": {
"desandro-matches-selector": "^1.0.2",
Expand All @@ -33,7 +35,6 @@
"url": "https://github.com/metafizzy/isotope/issues"
},
"homepage": "http://isotope.metafizzy.co",
"main": "js/isotope.js",
"directories": {
"test": "test"
},
Expand All @@ -48,5 +49,5 @@
"filter",
"sort"
],
"author": "David DeSandro / Metafizzy"
"author": "Metafizzy"
}
1 change: 1 addition & 0 deletions sandbox/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h1>basic</h1>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
23 changes: 12 additions & 11 deletions sandbox/bottom-up.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,18 @@ <h1>bottom up</h1>
<div class="item"></div>
</div>

<script src="../components/classie/classie.js"></script>
<script src="../components/eventEmitter/EventEmitter.js"></script>
<script src="../components/eventEmitter/EventEmitter.min.js"></script>
<script src="../components/eventie/eventie.js"></script>
<script src="../components/doc-ready/doc-ready.js"></script>
<script src="../components/get-style-property/get-style-property.js"></script>
<script src="../components/get-size/get-size.js"></script>
<script src="../components/jquery-bridget/jquery.bridget.js"></script>
<script src="../components/matches-selector/matches-selector.js"></script>
<script src="../components/outlayer/item.js"></script>
<script src="../components/outlayer/outlayer.js"></script>
<script src="../bower_components/classie/classie.js"></script>
<script src="../bower_components/eventEmitter/EventEmitter.js"></script>
<script src="../bower_components/eventEmitter/EventEmitter.min.js"></script>
<script src="../bower_components/eventie/eventie.js"></script>
<script src="../bower_components/doc-ready/doc-ready.js"></script>
<script src="../bower_components/get-style-property/get-style-property.js"></script>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

<script src="../masonry.js"></script>

Expand Down
1 change: 1 addition & 0 deletions sandbox/cells-by-row.html
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
1 change: 1 addition & 0 deletions sandbox/combination-filters-inclusive.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ <h3>Shape</h3>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
15 changes: 11 additions & 4 deletions sandbox/filter-sort.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down Expand Up @@ -198,11 +199,20 @@ <h2 class="name">Actinium</h2>
return parseInt( numberText, 10 ) > 40;
};
}
console.log( key, value );
// console.log( key, value );
iso.options[ key ] = value;
iso.arrange();
});

// iso.on( 'hideComplete', function( items ) {
// console.log( 'hideComplete', items );
// })

// iso.on( 'revealComplete', function( items ) {
// console.log( 'revealComplete', items );
// })


});

function getText( elem ) {
Expand All @@ -213,6 +223,3 @@ <h2 class="name">Actinium</h2>

</body>
</html>



1 change: 1 addition & 0 deletions sandbox/fitrows.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ <h1>fitRows</h1>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
1 change: 1 addition & 0 deletions sandbox/horizontal-layout-modes.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
1 change: 1 addition & 0 deletions sandbox/insert.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h1>insert</h1>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions sandbox/js/require-js.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ requirejs( [ '../dist/isotope.pkgd.js' ], function( Isotope ) {
requirejs.config({
baseUrl: '../bower_components',
paths: {
jquery: 'jquery/jquery'
jquery: 'jquery/dist/jquery'
}
})
Expand All @@ -61,7 +61,7 @@ requirejs( [
// /*
requirejs.config({
paths: {
jquery: '../../bower_components/jquery/jquery'
jquery: '../../bower_components/jquery/dist/jquery'
}
});

Expand Down
1 change: 1 addition & 0 deletions sandbox/masonry-horizontal.html
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
1 change: 1 addition & 0 deletions sandbox/masonry.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
1 change: 1 addition & 0 deletions sandbox/right-to-left.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ <h1>right to left</h1>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
1 change: 1 addition & 0 deletions sandbox/sorting.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ <h2 class="name">Actinium</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
1 change: 1 addition & 0 deletions sandbox/stamps.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ <h1>stamps</h1>
<script src="../bower_components/get-style-property/get-style-property.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down
1 change: 1 addition & 0 deletions sandbox/transition-bug.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h2 class="name">Antimony</h2>
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>

Expand Down
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="../bower_components/get-size/get-size.js"></script>
<script src="../bower_components/jquery-bridget/jquery.bridget.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/outlayer/item.js"></script>
<script src="../bower_components/outlayer/outlayer.js"></script>
<script src="../bower_components/masonry/masonry.js"></script>
Expand Down

0 comments on commit eb98c79

Please sign in to comment.