mirror of https://github.com/metafizzy/isotope
Filter & sort magical layouts
http://isotope.metafizzy.co
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.3 KiB
63 lines
1.3 KiB
11 years ago
|
/**
|
||
11 years ago
|
* Isotope Item
|
||
11 years ago
|
**/
|
||
|
|
||
|
( function( window ) {
|
||
|
|
||
|
'use strict';
|
||
|
|
||
|
// -------------------------- Item -------------------------- //
|
||
|
|
||
|
function itemDefinition( Outlayer ) {
|
||
|
|
||
|
// sub-class Outlayer Item
|
||
|
function Item() {
|
||
|
Outlayer.Item.apply( this, arguments );
|
||
|
}
|
||
|
|
||
|
Item.prototype = new Outlayer.Item();
|
||
|
|
||
|
Item.prototype._create = function() {
|
||
|
// assign id, used for original-order sorting
|
||
|
this.id = this.layout.itemGUID++;
|
||
|
Outlayer.Item.prototype._create.call( this );
|
||
|
this.sortData = {};
|
||
|
};
|
||
|
|
||
|
Item.prototype.updateSortData = function() {
|
||
|
// default sorters
|
||
|
this.sortData.id = this.id;
|
||
|
// for backward compatibility
|
||
|
this.sortData['original-order'] = this.id;
|
||
|
this.sortData.random = Math.random();
|
||
|
// go thru getSortData obj and apply the sorters
|
||
|
var getSortData = this.layout.options.getSortData;
|
||
11 years ago
|
var sorters = this.layout._sorters;
|
||
11 years ago
|
for ( var key in getSortData ) {
|
||
11 years ago
|
var sorter = sorters[ key ];
|
||
11 years ago
|
this.sortData[ key ] = sorter( this.element, this );
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return Item;
|
||
|
|
||
|
}
|
||
|
|
||
|
// -------------------------- transport -------------------------- //
|
||
|
|
||
|
if ( typeof define === 'function' && define.amd ) {
|
||
|
// AMD
|
||
|
define( [
|
||
|
'outlayer/outlayer'
|
||
|
],
|
||
|
itemDefinition );
|
||
|
} else {
|
||
|
// browser global
|
||
|
window.Isotope = window.Isotope || {};
|
||
|
window.Isotope.Item = itemDefinition(
|
||
|
window.Outlayer
|
||
|
);
|
||
|
}
|
||
|
|
||
|
})( window );
|