From ca8351919e16390f5eb442718177f90507603456 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 27 Mar 2014 07:24:04 +0000 Subject: [PATCH] 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 --- src/wp-includes/js/jquery/jquery.masonry.js | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/wp-includes/js/jquery/jquery.masonry.js b/src/wp-includes/js/jquery/jquery.masonry.js index 41bf6e1822..aceb766dfa 100644 --- a/src/wp-includes/js/jquery/jquery.masonry.js +++ b/src/wp-includes/js/jquery/jquery.masonry.js @@ -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 );