|
|
|
@ -80,7 +80,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
|
|
|
|
|
// create an Outlayer layout class
|
|
|
|
|
var Isotope = Outlayer.create( 'isotope', { |
|
|
|
|
layoutMode: "masonry", |
|
|
|
|
layoutMode: 'masonry', |
|
|
|
|
isJQueryFiltering: true, |
|
|
|
|
sortAscending: true |
|
|
|
|
}); |
|
|
|
@ -88,7 +88,9 @@ var trim = String.prototype.trim ?
|
|
|
|
|
Isotope.Item = Item; |
|
|
|
|
Isotope.LayoutMode = LayoutMode; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._create = function() { |
|
|
|
|
var proto = Isotope.prototype; |
|
|
|
|
|
|
|
|
|
proto._create = function() { |
|
|
|
|
this.itemGUID = 0; |
|
|
|
|
// functions that sort items
|
|
|
|
|
this._sorters = {}; |
|
|
|
@ -108,14 +110,14 @@ var trim = String.prototype.trim ?
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype.reloadItems = function() { |
|
|
|
|
proto.reloadItems = function() { |
|
|
|
|
// reset item ID counter
|
|
|
|
|
this.itemGUID = 0; |
|
|
|
|
// call super
|
|
|
|
|
Outlayer.prototype.reloadItems.call( this ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._itemize = function() { |
|
|
|
|
proto._itemize = function() { |
|
|
|
|
var items = Outlayer.prototype._itemize.apply( this, arguments ); |
|
|
|
|
// assign ID for original-order
|
|
|
|
|
for ( var i=0; i < items.length; i++ ) { |
|
|
|
@ -129,7 +131,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
|
|
|
|
|
// -------------------------- layout -------------------------- //
|
|
|
|
|
|
|
|
|
|
Isotope.prototype._initLayoutMode = function( name ) { |
|
|
|
|
proto._initLayoutMode = function( name ) { |
|
|
|
|
var Mode = LayoutMode.modes[ name ]; |
|
|
|
|
// set mode options
|
|
|
|
|
// HACK extend initial options, back-fill in default options
|
|
|
|
@ -141,7 +143,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Isotope.prototype.layout = function() { |
|
|
|
|
proto.layout = function() { |
|
|
|
|
// if first time doing layout, do all magic
|
|
|
|
|
if ( !this._isLayoutInited && this._getOption('initLayout') ) { |
|
|
|
|
this.arrange(); |
|
|
|
@ -151,7 +153,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// private method to be used in layout() & magic()
|
|
|
|
|
Isotope.prototype._layout = function() { |
|
|
|
|
proto._layout = function() { |
|
|
|
|
// don't animate first layout
|
|
|
|
|
var isInstant = this._getIsInstant(); |
|
|
|
|
// layout flow
|
|
|
|
@ -164,7 +166,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// filter + sort + layout
|
|
|
|
|
Isotope.prototype.arrange = function( opts ) { |
|
|
|
|
proto.arrange = function( opts ) { |
|
|
|
|
// set any options pass
|
|
|
|
|
this.option( opts ); |
|
|
|
|
this._getIsInstant(); |
|
|
|
@ -186,9 +188,9 @@ var trim = String.prototype.trim ?
|
|
|
|
|
this._layout(); |
|
|
|
|
}; |
|
|
|
|
// alias to _init for main plugin method
|
|
|
|
|
Isotope.prototype._init = Isotope.prototype.arrange; |
|
|
|
|
proto._init = proto.arrange; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._hideReveal = function( filtered ) { |
|
|
|
|
proto._hideReveal = function( filtered ) { |
|
|
|
|
this.reveal( filtered.needReveal ); |
|
|
|
|
this.hide( filtered.needHide ); |
|
|
|
|
}; |
|
|
|
@ -196,7 +198,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
// HACK
|
|
|
|
|
// Don't animate/transition first layout
|
|
|
|
|
// Or don't animate/transition other layouts
|
|
|
|
|
Isotope.prototype._getIsInstant = function() { |
|
|
|
|
proto._getIsInstant = function() { |
|
|
|
|
var isLayoutInstant = this._getOption('layoutInstant'); |
|
|
|
|
var isInstant = isLayoutInstant !== undefined ? isLayoutInstant : |
|
|
|
|
!this._isLayoutInited; |
|
|
|
@ -206,7 +208,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
|
|
|
|
|
// listen for layoutComplete, hideComplete and revealComplete
|
|
|
|
|
// to trigger arrangeComplete
|
|
|
|
|
Isotope.prototype._bindArrangeComplete = function() { |
|
|
|
|
proto._bindArrangeComplete = function() { |
|
|
|
|
// listen for 3 events to trigger arrangeComplete
|
|
|
|
|
var isLayoutComplete, isHideComplete, isRevealComplete; |
|
|
|
|
var _this = this; |
|
|
|
@ -231,7 +233,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
|
|
|
|
|
// -------------------------- filter -------------------------- //
|
|
|
|
|
|
|
|
|
|
Isotope.prototype._filter = function( items ) { |
|
|
|
|
proto._filter = function( items ) { |
|
|
|
|
var filter = this.options.filter; |
|
|
|
|
filter = filter || '*'; |
|
|
|
|
var matches = []; |
|
|
|
@ -270,7 +272,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// get a jQuery, function, or a matchesSelector test given the filter
|
|
|
|
|
Isotope.prototype._getFilterTest = function( filter ) { |
|
|
|
|
proto._getFilterTest = function( filter ) { |
|
|
|
|
if ( jQuery && this.options.isJQueryFiltering ) { |
|
|
|
|
// use jQuery
|
|
|
|
|
return function( item ) { |
|
|
|
@ -295,7 +297,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
* @params {Array} elems |
|
|
|
|
* @public |
|
|
|
|
*/ |
|
|
|
|
Isotope.prototype.updateSortData = function( elems ) { |
|
|
|
|
proto.updateSortData = function( elems ) { |
|
|
|
|
// get items
|
|
|
|
|
var items; |
|
|
|
|
if ( elems ) { |
|
|
|
@ -310,7 +312,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
this._updateItemsSortData( items ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._getSorters = function() { |
|
|
|
|
proto._getSorters = function() { |
|
|
|
|
var getSortData = this.options.getSortData; |
|
|
|
|
for ( var key in getSortData ) { |
|
|
|
|
var sorter = getSortData[ key ]; |
|
|
|
@ -322,7 +324,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
* @params {Array} items - of Isotope.Items |
|
|
|
|
* @private |
|
|
|
|
*/ |
|
|
|
|
Isotope.prototype._updateItemsSortData = function( items ) { |
|
|
|
|
proto._updateItemsSortData = function( items ) { |
|
|
|
|
// do not update if no items
|
|
|
|
|
var len = items && items.length; |
|
|
|
|
|
|
|
|
@ -400,7 +402,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
// ----- sort method ----- //
|
|
|
|
|
|
|
|
|
|
// sort filteredItem order
|
|
|
|
|
Isotope.prototype._sort = function() { |
|
|
|
|
proto._sort = function() { |
|
|
|
|
var sortByOpt = this.options.sortBy; |
|
|
|
|
if ( !sortByOpt ) { |
|
|
|
|
return; |
|
|
|
@ -439,7 +441,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
// -------------------------- methods -------------------------- //
|
|
|
|
|
|
|
|
|
|
// get layout mode
|
|
|
|
|
Isotope.prototype._mode = function() { |
|
|
|
|
proto._mode = function() { |
|
|
|
|
var layoutMode = this.options.layoutMode; |
|
|
|
|
var mode = this.modes[ layoutMode ]; |
|
|
|
|
if ( !mode ) { |
|
|
|
@ -452,32 +454,32 @@ var trim = String.prototype.trim ?
|
|
|
|
|
return mode; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._resetLayout = function() { |
|
|
|
|
proto._resetLayout = function() { |
|
|
|
|
// trigger original reset layout
|
|
|
|
|
Outlayer.prototype._resetLayout.call( this ); |
|
|
|
|
this._mode()._resetLayout(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._getItemLayoutPosition = function( item ) { |
|
|
|
|
proto._getItemLayoutPosition = function( item ) { |
|
|
|
|
return this._mode()._getItemLayoutPosition( item ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._manageStamp = function( stamp ) { |
|
|
|
|
proto._manageStamp = function( stamp ) { |
|
|
|
|
this._mode()._manageStamp( stamp ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._getContainerSize = function() { |
|
|
|
|
proto._getContainerSize = function() { |
|
|
|
|
return this._mode()._getContainerSize(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype.needsResizeLayout = function() { |
|
|
|
|
proto.needsResizeLayout = function() { |
|
|
|
|
return this._mode().needsResizeLayout(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// -------------------------- adding & removing -------------------------- //
|
|
|
|
|
|
|
|
|
|
// HEADS UP overwrites default Outlayer appended
|
|
|
|
|
Isotope.prototype.appended = function( elems ) { |
|
|
|
|
proto.appended = function( elems ) { |
|
|
|
|
var items = this.addItems( elems ); |
|
|
|
|
if ( !items.length ) { |
|
|
|
|
return; |
|
|
|
@ -489,7 +491,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// HEADS UP overwrites default Outlayer prepended
|
|
|
|
|
Isotope.prototype.prepended = function( elems ) { |
|
|
|
|
proto.prepended = function( elems ) { |
|
|
|
|
var items = this._itemize( elems ); |
|
|
|
|
if ( !items.length ) { |
|
|
|
|
return; |
|
|
|
@ -506,7 +508,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
this.items = items.concat( this.items ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype._filterRevealAdded = function( items ) { |
|
|
|
|
proto._filterRevealAdded = function( items ) { |
|
|
|
|
var filtered = this._filter( items ); |
|
|
|
|
this.hide( filtered.needHide ); |
|
|
|
|
// reveal all new items
|
|
|
|
@ -520,7 +522,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
* Filter, sort, and layout newly-appended item elements |
|
|
|
|
* @param {Array or NodeList or Element} elems |
|
|
|
|
*/ |
|
|
|
|
Isotope.prototype.insert = function( elems ) { |
|
|
|
|
proto.insert = function( elems ) { |
|
|
|
|
var items = this.addItems( elems ); |
|
|
|
|
if ( !items.length ) { |
|
|
|
|
return; |
|
|
|
@ -546,8 +548,8 @@ var trim = String.prototype.trim ?
|
|
|
|
|
this.reveal( filteredInsertItems ); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var _remove = Isotope.prototype.remove; |
|
|
|
|
Isotope.prototype.remove = function( elems ) { |
|
|
|
|
var _remove = proto.remove; |
|
|
|
|
proto.remove = function( elems ) { |
|
|
|
|
elems = utils.makeArray( elems ); |
|
|
|
|
var removeItems = this.getItems( elems ); |
|
|
|
|
// do regular thing
|
|
|
|
@ -565,7 +567,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Isotope.prototype.shuffle = function() { |
|
|
|
|
proto.shuffle = function() { |
|
|
|
|
// update random sortData
|
|
|
|
|
for ( var i=0; i < this.items.length; i++ ) { |
|
|
|
|
var item = this.items[i]; |
|
|
|
@ -584,7 +586,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
* @returns ret |
|
|
|
|
* @private |
|
|
|
|
*/ |
|
|
|
|
Isotope.prototype._noTransition = function( fn, args ) { |
|
|
|
|
proto._noTransition = function( fn, args ) { |
|
|
|
|
// save transitionDuration before disabling
|
|
|
|
|
var transitionDuration = this.options.transitionDuration; |
|
|
|
|
// disable transition
|
|
|
|
@ -602,7 +604,7 @@ var trim = String.prototype.trim ?
|
|
|
|
|
* getter method for getting filtered item elements |
|
|
|
|
* @returns {Array} elems - collection of item elements |
|
|
|
|
*/ |
|
|
|
|
Isotope.prototype.getFilteredItemElements = function() { |
|
|
|
|
proto.getFilteredItemElements = function() { |
|
|
|
|
return this.filteredItems.map( function( item ) { |
|
|
|
|
return item.element; |
|
|
|
|
}); |
|
|
|
|