mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-14 12:11:37 +01:00
1cb9788f1b
The new script handle is 'masonry'. The old 'jquery-masonry' handle is the official shiv that sits on top of the v3 library. While v3 no longer depends on jQuery, a theme or plugin may have bee n implicitly loading jQuery though Masonry, rather than additionally declaring it as a dependency for themselves. Thus, the shiv is separate. Themes should switch to 'masonry' and declare jQuery as a dependency on their own if they need it. Upgrade guide: http://masonry.desandro.com/appendix.html#upgrading-from-v2. imagesLoaded remai ns included with Masonry here. props shelob9. fixes #25351. Built from https://develop.svn.wordpress.org/trunk@27271 git-svn-id: http://core.svn.wordpress.org/trunk@27127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
/*!
|
|
* Masonry v2 shim
|
|
* to maintain backwards compatibility
|
|
* as of Masonry v3.1.2
|
|
*
|
|
* Cascading grid layout library
|
|
* http://masonry.desandro.com
|
|
* MIT License
|
|
* by David DeSandro
|
|
*/
|
|
( function( window ) {
|
|
|
|
var Masonry = window.Masonry;
|
|
|
|
Masonry.prototype._remapV2Options = function() {
|
|
// map v2 options to v3 equivalents
|
|
this._remapOption( 'gutterWidth', 'gutter' );
|
|
this._remapOption( 'isResizable', 'isResizeBound' );
|
|
this._remapOption( 'isRTL', 'isOriginLeft', function( opt ) {
|
|
return !opt;
|
|
});
|
|
|
|
// override transitionDuration with isAnimated
|
|
var isAniOption = this.options.isAnimated;
|
|
if ( isAniOption !== undefined ) {
|
|
this.options.transitionDuration = isAniOption ?
|
|
Masonry.prototype.options.transitionDuration : 0;
|
|
}
|
|
|
|
if ( isAniOption === undefined || isAniOption ) {
|
|
// use animation Duration option in place of transitionDuration
|
|
var aniOptions = this.options.animationOptions;
|
|
var aniDuration = aniOptions && aniOptions.duration;
|
|
if ( aniDuration ) {
|
|
this.options.transitionDuration = typeof aniDuration === 'string' ?
|
|
aniDuration : aniDuration + 'ms';
|
|
}
|
|
}
|
|
};
|
|
|
|
Masonry.prototype._remapOption = function( from, to, munge ) {
|
|
var fromOption = this.options[ from ];
|
|
if ( fromOption !== undefined ) {
|
|
this.options[ to ] = munge ? munge( fromOption ) : fromOption;
|
|
}
|
|
};
|
|
|
|
// remap v2 options for necessary methods
|
|
|
|
var __create = Masonry.prototype._create;
|
|
Masonry.prototype._create = function() {
|
|
this._remapV2Options();
|
|
__create.apply( this, arguments );
|
|
};
|
|
|
|
var _layout = Masonry.prototype.layout;
|
|
Masonry.prototype.layout = function() {
|
|
this._remapV2Options();
|
|
_layout.apply( this, arguments );
|
|
};
|
|
|
|
var _option = Masonry.prototype.option;
|
|
Masonry.prototype.option = function() {
|
|
_option.apply( this, arguments );
|
|
this._remapV2Options();
|
|
};
|
|
|
|
// re-enable using function for columnWidth
|
|
var _measureColumns = Masonry.prototype.measureColumns;
|
|
Masonry.prototype.measureColumns = function() {
|
|
var colWOpt = this.options.columnWidth;
|
|
if ( colWOpt && typeof colWOpt === 'function' ) {
|
|
this.getContainerWidth();
|
|
this.columnWidth = colWOpt( this.containerWidth );
|
|
}
|
|
_measureColumns.apply( this, arguments );
|
|
};
|
|
|
|
})( window );
|