|
|
@ -100,6 +100,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
this.itemGUID = 0; |
|
|
|
this.itemGUID = 0; |
|
|
|
// functions that sort items
|
|
|
|
// functions that sort items
|
|
|
|
this._sorters = {}; |
|
|
|
this._sorters = {}; |
|
|
|
|
|
|
|
this._getSorters(); |
|
|
|
// call super
|
|
|
|
// call super
|
|
|
|
Outlayer.prototype._create.call( this ); |
|
|
|
Outlayer.prototype._create.call( this ); |
|
|
|
|
|
|
|
|
|
|
@ -129,7 +130,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
var item = items[i]; |
|
|
|
var item = items[i]; |
|
|
|
item.id = this.itemGUID++; |
|
|
|
item.id = this.itemGUID++; |
|
|
|
} |
|
|
|
} |
|
|
|
this.updateSortData( items ); |
|
|
|
this._updateItemsSortData( items ); |
|
|
|
return items; |
|
|
|
return items; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -224,17 +225,16 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// HACK
|
|
|
|
var _this = this; |
|
|
|
// disable transition if instant
|
|
|
|
function hideReveal() { |
|
|
|
var _transitionDuration = this.options.transitionDuration; |
|
|
|
_this.reveal( hiddenMatched ); |
|
|
|
if ( this._isInstant ) { |
|
|
|
_this.hide( visibleUnmatched ); |
|
|
|
this.options.transitionDuration = 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
this.reveal( hiddenMatched ); |
|
|
|
|
|
|
|
this.hide( visibleUnmatched ); |
|
|
|
|
|
|
|
// set back
|
|
|
|
|
|
|
|
if ( this._isInstant ) { |
|
|
|
if ( this._isInstant ) { |
|
|
|
this.options.transitionDuration = _transitionDuration; |
|
|
|
this._noTransition( hideReveal ); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
hideReveal(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return matches; |
|
|
|
return matches; |
|
|
@ -242,40 +242,56 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
|
|
|
|
|
|
|
|
// get a jQuery, function, or a matchesSelector test given the filter
|
|
|
|
// get a jQuery, function, or a matchesSelector test given the filter
|
|
|
|
Isotope.prototype._getFilterTest = function( filter ) { |
|
|
|
Isotope.prototype._getFilterTest = function( filter ) { |
|
|
|
var test; |
|
|
|
|
|
|
|
if ( jQuery && this.options.isJQueryFiltering ) { |
|
|
|
if ( jQuery && this.options.isJQueryFiltering ) { |
|
|
|
test = function( item ) { |
|
|
|
// use jQuery
|
|
|
|
|
|
|
|
return function( item ) { |
|
|
|
return jQuery( item.element ).is( filter ); |
|
|
|
return jQuery( item.element ).is( filter ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else if ( typeof filter === 'function' ) { |
|
|
|
} |
|
|
|
test = function( item ) { |
|
|
|
if ( typeof filter === 'function' ) { |
|
|
|
|
|
|
|
// use filter as function
|
|
|
|
|
|
|
|
return function( item ) { |
|
|
|
return filter( item.element ); |
|
|
|
return filter( item.element ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
} else { |
|
|
|
} |
|
|
|
test = function( item ) { |
|
|
|
// default, use filter as selector string
|
|
|
|
|
|
|
|
return function( item ) { |
|
|
|
return matchesSelector( item.element, filter ); |
|
|
|
return matchesSelector( item.element, filter ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
return test; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// -------------------------- sorting -------------------------- //
|
|
|
|
// -------------------------- sorting -------------------------- //
|
|
|
|
|
|
|
|
|
|
|
|
Isotope.prototype.updateSortData = function( items ) { |
|
|
|
/** |
|
|
|
// update sorters
|
|
|
|
* @params {Array} elems |
|
|
|
|
|
|
|
* @public |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Isotope.prototype.updateSortData = function( elems ) { |
|
|
|
|
|
|
|
this._getSorters(); |
|
|
|
|
|
|
|
// update item sort data
|
|
|
|
|
|
|
|
// default to all items if none are passed in
|
|
|
|
|
|
|
|
elems = makeArray( elems ); |
|
|
|
|
|
|
|
var items = this.getItems( elems ); |
|
|
|
|
|
|
|
// if no items found, update all items
|
|
|
|
|
|
|
|
items = items.length ? items : this.items; |
|
|
|
|
|
|
|
this._updateItemsSortData( items ); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Isotope.prototype._getSorters = function() { |
|
|
|
var getSortData = this.options.getSortData; |
|
|
|
var getSortData = this.options.getSortData; |
|
|
|
for ( var key in getSortData ) { |
|
|
|
for ( var key in getSortData ) { |
|
|
|
var sorter = getSortData[ key ]; |
|
|
|
var sorter = getSortData[ key ]; |
|
|
|
this._sorters[ key ] = mungeSorter( sorter ); |
|
|
|
this._sorters[ key ] = mungeSorter( sorter ); |
|
|
|
} |
|
|
|
} |
|
|
|
// update item sort data
|
|
|
|
}; |
|
|
|
// default to all items if none are passed in
|
|
|
|
|
|
|
|
items = items || this.items; |
|
|
|
/** |
|
|
|
|
|
|
|
* @params {Array} items - of Isotope.Items |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Isotope.prototype._updateItemsSortData = function( items ) { |
|
|
|
for ( var i=0, len = items.length; i < len; i++ ) { |
|
|
|
for ( var i=0, len = items.length; i < len; i++ ) { |
|
|
|
var item = items[i]; |
|
|
|
var item = items[i]; |
|
|
|
if ( item.isIgnored ) { |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
item.updateSortData(); |
|
|
|
item.updateSortData(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
@ -303,7 +319,7 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
var attr = attrMatch && attrMatch[1]; |
|
|
|
var attr = attrMatch && attrMatch[1]; |
|
|
|
var getValue = getValueGetter( attr, query ); |
|
|
|
var getValue = getValueGetter( attr, query ); |
|
|
|
// use second argument as a parser
|
|
|
|
// use second argument as a parser
|
|
|
|
var parser = getParser( args[1] ); |
|
|
|
var parser = Isotope.sortDataParsers[ args[1] ]; |
|
|
|
// parse the value, if there was a parser
|
|
|
|
// parse the value, if there was a parser
|
|
|
|
sorter = parser ? function( elem ) { |
|
|
|
sorter = parser ? function( elem ) { |
|
|
|
return elem && parser( getValue( elem ) ); |
|
|
|
return elem && parser( getValue( elem ) ); |
|
|
@ -334,33 +350,18 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
return getValue; |
|
|
|
return getValue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// return a parser function if arg matches
|
|
|
|
|
|
|
|
function getParser( arg ) { |
|
|
|
|
|
|
|
var parser; |
|
|
|
|
|
|
|
switch ( arg ) { |
|
|
|
|
|
|
|
case 'parseInt' : |
|
|
|
|
|
|
|
parser = function( val ) { |
|
|
|
|
|
|
|
return parseInt( val, 10 ); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 'parseFloat' : |
|
|
|
|
|
|
|
parser = function( val ) { |
|
|
|
|
|
|
|
return parseFloat( val ); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default : |
|
|
|
|
|
|
|
// just return val if parser isn't one of these
|
|
|
|
|
|
|
|
// TODO - console log that that parser doesn't exist
|
|
|
|
|
|
|
|
parser = function( val ) { |
|
|
|
|
|
|
|
return val; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return parser; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mungeSorter; |
|
|
|
return mungeSorter; |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// parsers used in getSortData shortcut strings
|
|
|
|
|
|
|
|
Isotope.sortDataParsers = { |
|
|
|
|
|
|
|
'parseInt': function( val ) { |
|
|
|
|
|
|
|
return parseInt( val, 10 ); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
'parseFloat': function( val ) { |
|
|
|
|
|
|
|
return parseFloat( val ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// ----- sort method ----- //
|
|
|
|
// ----- sort method ----- //
|
|
|
|
|
|
|
|
|
|
|
@ -477,12 +478,9 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Isotope.prototype._filterRevealAdded = function( items ) { |
|
|
|
Isotope.prototype._filterRevealAdded = function( items ) { |
|
|
|
// disable transition for filtering
|
|
|
|
var filteredItems = this._noTransition( function() { |
|
|
|
var transitionDuration = this.options.transitionDuration; |
|
|
|
return this._filter( items ); |
|
|
|
this.options.transitionDuration = 0; |
|
|
|
}); |
|
|
|
var filteredItems = this._filter( items ); |
|
|
|
|
|
|
|
// re-enable transition for reveal
|
|
|
|
|
|
|
|
this.options.transitionDuration = transitionDuration; |
|
|
|
|
|
|
|
// layout and reveal just the new items
|
|
|
|
// layout and reveal just the new items
|
|
|
|
this.layoutItems( filteredItems, true ); |
|
|
|
this.layoutItems( filteredItems, true ); |
|
|
|
this.reveal( filteredItems ); |
|
|
|
this.reveal( filteredItems ); |
|
|
@ -498,7 +496,35 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
if ( !items.length ) { |
|
|
|
if ( !items.length ) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// filter new stuff
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
// this way adds hides new filtered items with NO transition
|
|
|
|
|
|
|
|
// so user can't see if new hidden items have been inserted
|
|
|
|
|
|
|
|
var filteredInsertItems; |
|
|
|
|
|
|
|
this._noTransition( function() { |
|
|
|
|
|
|
|
filteredInsertItems = this._filter( items ); |
|
|
|
|
|
|
|
// hide all new items
|
|
|
|
|
|
|
|
this.hide( filteredInsertItems ); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// this way hides new filtered items with transition
|
|
|
|
|
|
|
|
// so user at least sees that something has been added
|
|
|
|
|
|
|
|
var filteredInsertItems = this._filter( items ); |
|
|
|
|
|
|
|
// hide all newitems
|
|
|
|
|
|
|
|
this._noTransition( function() { |
|
|
|
|
|
|
|
this.hide( filteredInsertItems ); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// */
|
|
|
|
|
|
|
|
// set flag
|
|
|
|
|
|
|
|
for ( var i=0, len = items.length; i < len; i++ ) { |
|
|
|
|
|
|
|
items[i].isLayoutInstant = true; |
|
|
|
|
|
|
|
} |
|
|
|
this.arrange(); |
|
|
|
this.arrange(); |
|
|
|
|
|
|
|
// reset flag
|
|
|
|
|
|
|
|
for ( i=0; i < len; i++ ) { |
|
|
|
|
|
|
|
delete items[i].isLayoutInstant; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.reveal( filteredInsertItems ); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var _remove = Isotope.prototype.remove; |
|
|
|
var _remove = Isotope.prototype.remove; |
|
|
@ -519,6 +545,25 @@ function isotopeDefinition( Outlayer, getSize, matchesSelector, Item, LayoutMode |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* trigger fn without transition |
|
|
|
|
|
|
|
* kind of hacky to have this in the first place |
|
|
|
|
|
|
|
* @param {Function} fn |
|
|
|
|
|
|
|
* @returns ret |
|
|
|
|
|
|
|
* @private |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
Isotope.prototype._noTransition = function( fn ) { |
|
|
|
|
|
|
|
// save transitionDuration before disabling
|
|
|
|
|
|
|
|
var transitionDuration = this.options.transitionDuration; |
|
|
|
|
|
|
|
// disable transition
|
|
|
|
|
|
|
|
this.options.transitionDuration = 0; |
|
|
|
|
|
|
|
// do it
|
|
|
|
|
|
|
|
var returnValue = fn.call( this ); |
|
|
|
|
|
|
|
// re-enable transition for reveal
|
|
|
|
|
|
|
|
this.options.transitionDuration = transitionDuration; |
|
|
|
|
|
|
|
return returnValue; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// ----- ----- //
|
|
|
|
// ----- ----- //
|
|
|
|
|
|
|
|
|
|
|
|
return Isotope; |
|
|
|
return Isotope; |
|
|
|