Update Masonry v2/v3 shim from upstream.

props kovshenin.
see #27510.


git-svn-id: https://develop.svn.wordpress.org/trunk@27779 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2014-03-27 07:24:04 +00:00
parent f4089c7a58
commit ca8351919e
1 changed files with 26 additions and 0 deletions

View File

@ -10,6 +10,8 @@
*/
( function( window ) {
'use strict';
var Masonry = window.Masonry;
Masonry.prototype._remapV2Options = function() {
@ -49,8 +51,12 @@
var __create = Masonry.prototype._create;
Masonry.prototype._create = function() {
var that = this;
this._remapV2Options();
__create.apply( this, arguments );
setTimeout( function() {
jQuery( that.element ).addClass( 'masonry' );
}, 0 );
};
var _layout = Masonry.prototype.layout;
@ -65,6 +71,13 @@
this._remapV2Options();
};
var __itemize = Masonry.prototype._itemize;
Masonry.prototype._itemize = function( elements ) {
var items = __itemize.apply( this, arguments );
jQuery( elements ).addClass( 'masonry-brick' );
return items;
};
// re-enable using function for columnWidth
var _measureColumns = Masonry.prototype.measureColumns;
Masonry.prototype.measureColumns = function() {
@ -76,4 +89,17 @@
_measureColumns.apply( this, arguments );
};
Masonry.prototype.reload = function() {
this.reloadItems.apply( this, arguments );
this.layout.apply( this );
};
var _destroy = Masonry.prototype.destroy;
Masonry.prototype.destroy = function() {
var items = this.getItemElements();
jQuery( this.element ).removeClass( 'masonry' );
jQuery( items ).removeClass( 'masonry-brick' );
_destroy.apply( this, arguments );
};
})( window );