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.

78 lines
1.7 KiB

11 years ago
/**
* Isotope Item
11 years ago
**/
10 years ago
( function( window, factory ) {
// universal module definition
/* jshint strict: false */ /*globals define, module, require */
if ( typeof define == 'function' && define.amd ) {
10 years ago
// AMD
define( [
'outlayer/outlayer'
],
factory );
} else if ( typeof module == 'object' && module.exports ) {
10 years ago
// CommonJS
module.exports = factory(
require('outlayer')
);
} else {
// browser global
window.Isotope = window.Isotope || {};
window.Isotope.Item = factory(
window.Outlayer
);
}
11 years ago
10 years ago
}( window, function factory( Outlayer ) {
11 years ago
'use strict';
// -------------------------- Item -------------------------- //
// sub-class Outlayer Item
function Item() {
Outlayer.Item.apply( this, arguments );
}
var proto = Item.prototype = Object.create( Outlayer.Item.prototype );
11 years ago
var _create = proto._create;
proto._create = function() {
11 years ago
// assign id, used for original-order sorting
this.id = this.layout.itemGUID++;
_create.call( this );
11 years ago
this.sortData = {};
};
proto.updateSortData = function() {
if ( this.isIgnored ) {
return;
}
11 years ago
// 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;
var sorters = this.layout._sorters;
11 years ago
for ( var key in getSortData ) {
var sorter = sorters[ key ];
11 years ago
this.sortData[ key ] = sorter( this.element, this );
}
};
var _destroy = proto.destroy;
proto.destroy = function() {
// call super
_destroy.apply( this, arguments );
// reset display, #741
this.css({
display: ''
});
};
11 years ago
return Item;
10 years ago
}));