diff --git a/.jshintrc b/.jshintrc index a0d09a5..d011e96 100644 --- a/.jshintrc +++ b/.jshintrc @@ -4,7 +4,7 @@ "strict": true, "undef": true, "unused": true, - "predef": { + "globals": { "define": false, "module": false, "require": false diff --git a/bower.json b/bower.json index 777a9b4..7105fe8 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/js/isotope.js b/js/isotope.js index 7c71db7..90e8594 100644 --- a/js/isotope.js +++ b/js/isotope.js @@ -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(); @@ -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", @@ -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 ); }; @@ -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 @@ -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 ); } }; @@ -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 @@ -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 @@ -631,6 +584,7 @@ if ( typeof define === 'function' && define.amd ) { window.Outlayer, window.getSize, window.matchesSelector, + window.fizzyUIUtils, window.Isotope.Item, window.Isotope.LayoutMode ); diff --git a/package.json b/package.json index f746afe..54be531 100644 --- a/package.json +++ b/package.json @@ -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", @@ -33,7 +35,6 @@ "url": "https://github.com/metafizzy/isotope/issues" }, "homepage": "http://isotope.metafizzy.co", - "main": "js/isotope.js", "directories": { "test": "test" }, @@ -48,5 +49,5 @@ "filter", "sort" ], - "author": "David DeSandro / Metafizzy" + "author": "Metafizzy" } diff --git a/sandbox/basic.html b/sandbox/basic.html index adbde4f..8c7efbd 100644 --- a/sandbox/basic.html +++ b/sandbox/basic.html @@ -43,6 +43,7 @@ + diff --git a/sandbox/bottom-up.html b/sandbox/bottom-up.html index 4ecf62a..9fde2ff 100644 --- a/sandbox/bottom-up.html +++ b/sandbox/bottom-up.html @@ -78,17 +78,18 @@
- - - - - - - - - - - + + + + + + + + + + + + diff --git a/sandbox/cells-by-row.html b/sandbox/cells-by-row.html index 1d8e990..7810e25 100644 --- a/sandbox/cells-by-row.html +++ b/sandbox/cells-by-row.html @@ -151,6 +151,7 @@ + diff --git a/sandbox/combination-filters-inclusive.html b/sandbox/combination-filters-inclusive.html index 0fdcf1a..7c349bd 100644 --- a/sandbox/combination-filters-inclusive.html +++ b/sandbox/combination-filters-inclusive.html @@ -204,6 +204,7 @@ + diff --git a/sandbox/filter-sort.html b/sandbox/filter-sort.html index 38ac2c3..dda3e51 100644 --- a/sandbox/filter-sort.html +++ b/sandbox/filter-sort.html @@ -148,6 +148,7 @@ + @@ -198,11 +199,20 @@ docReady( function() { 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 ) { @@ -213,6 +223,3 @@ function getText( elem ) { - - - diff --git a/sandbox/fitrows.html b/sandbox/fitrows.html index 0ba54b2..dd8d756 100644 --- a/sandbox/fitrows.html +++ b/sandbox/fitrows.html @@ -96,6 +96,7 @@ + diff --git a/sandbox/horizontal-layout-modes.html b/sandbox/horizontal-layout-modes.html index 167ccae..26020c7 100644 --- a/sandbox/horizontal-layout-modes.html +++ b/sandbox/horizontal-layout-modes.html @@ -154,6 +154,7 @@ + diff --git a/sandbox/insert.html b/sandbox/insert.html index b13af5b..f814e03 100644 --- a/sandbox/insert.html +++ b/sandbox/insert.html @@ -36,6 +36,7 @@ + diff --git a/sandbox/js/require-js.js b/sandbox/js/require-js.js index ac6eb9e..68d2918 100644 --- a/sandbox/js/require-js.js +++ b/sandbox/js/require-js.js @@ -36,7 +36,7 @@ requirejs( [ '../dist/isotope.pkgd.js' ], function( Isotope ) { requirejs.config({ baseUrl: '../bower_components', paths: { - jquery: 'jquery/jquery' + jquery: 'jquery/dist/jquery' } }) @@ -61,7 +61,7 @@ requirejs( [ // /* requirejs.config({ paths: { - jquery: '../../bower_components/jquery/jquery' + jquery: '../../bower_components/jquery/dist/jquery' } }); diff --git a/sandbox/masonry-horizontal.html b/sandbox/masonry-horizontal.html index 1207434..ffa0052 100644 --- a/sandbox/masonry-horizontal.html +++ b/sandbox/masonry-horizontal.html @@ -183,6 +183,7 @@ + diff --git a/sandbox/masonry.html b/sandbox/masonry.html index 7d164cd..e95fd61 100644 --- a/sandbox/masonry.html +++ b/sandbox/masonry.html @@ -152,6 +152,7 @@ + diff --git a/sandbox/right-to-left.html b/sandbox/right-to-left.html index 5da5adc..6dcb679 100644 --- a/sandbox/right-to-left.html +++ b/sandbox/right-to-left.html @@ -86,6 +86,7 @@ + diff --git a/sandbox/sorting.html b/sandbox/sorting.html index debbb08..ac047cb 100644 --- a/sandbox/sorting.html +++ b/sandbox/sorting.html @@ -139,6 +139,7 @@ + diff --git a/sandbox/stamps.html b/sandbox/stamps.html index 8ed68ff..a7d19d0 100644 --- a/sandbox/stamps.html +++ b/sandbox/stamps.html @@ -89,6 +89,7 @@ + diff --git a/sandbox/transition-bug.html b/sandbox/transition-bug.html index 46683f7..1a78a5c 100644 --- a/sandbox/transition-bug.html +++ b/sandbox/transition-bug.html @@ -42,6 +42,7 @@ + diff --git a/test/index.html b/test/index.html index 56d27e3..6473c13 100644 --- a/test/index.html +++ b/test/index.html @@ -19,6 +19,7 @@ +