From 65534a21c0127c6c5f022e85d414dc1776c695b9 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Sun, 14 Oct 2012 17:05:16 +0000 Subject: [PATCH] jQuery Masonry for uploaded custom headers. props zamoose. fixes #20346. git-svn-id: http://core.svn.wordpress.org/trunk@22228 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/custom-header.js | 10 ++++++++++ wp-includes/js/jquery/jquery.masonry.min.js | 10 ++++++++++ wp-includes/script-loader.php | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 wp-admin/js/custom-header.js create mode 100644 wp-includes/js/jquery/jquery.masonry.min.js diff --git a/wp-admin/js/custom-header.js b/wp-admin/js/custom-header.js new file mode 100644 index 0000000000..9243498175 --- /dev/null +++ b/wp-admin/js/custom-header.js @@ -0,0 +1,10 @@ +(function($) { + + var headers = $('.available-headers'); + headers.imagesLoaded( function() { + headers.masonry({ + itemSelector: '.default-header' + }); + }); + +})(jQuery); diff --git a/wp-includes/js/jquery/jquery.masonry.min.js b/wp-includes/js/jquery/jquery.masonry.min.js new file mode 100644 index 0000000000..67be98867b --- /dev/null +++ b/wp-includes/js/jquery/jquery.masonry.min.js @@ -0,0 +1,10 @@ +/** + * jQuery Masonry v2.1.05 + * A dynamic layout plugin for jQuery + * The flip-side of CSS Floats + * http://masonry.desandro.com + * + * Licensed under the MIT license. + * Copyright 2012 David DeSandro + */ +(function(a,b,c){"use strict";var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,c){var d=this,f=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){b.event.handle.apply(d,f)},c==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()},b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[];var d=this.element[0].style;this.originalStyle={height:d.height||""};var e=this.options.containerStyle;for(var f in e)this.originalStyle[f]=d[f]||"";this.element.css(e),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top"),10)},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var g=this;setTimeout(function(){g.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){g.resize()}),this.reloadItems()},_init:function(a){this._getColumns(),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,b){for(var c=0,d=a.length;cadd( 'jquery-hotkeys', "/wp-includes/js/jquery/jquery.hotkeys$suffix.js", array('jquery'), '0.0.2m', 1 ); $scripts->add( 'jquery-table-hotkeys', "/wp-includes/js/jquery/jquery.table-hotkeys$suffix.js", array('jquery', 'jquery-hotkeys'), false, 1 ); $scripts->add( 'jquery-touch-punch', "/wp-includes/js/jquery/jquery.ui.touch-punch.js", array('jquery-ui-widget', 'jquery-ui-mouse'), '0.2.2', 1 ); + $scripts->add( 'jquery-masonry', "/wp-includes/js/jquery/jquery.masonry.min.js", array('jquery'), '2.1.05', 1 ); $scripts->add( 'thickbox', "/wp-includes/js/thickbox/thickbox.js", array('jquery'), '3.1-20111117', 1 ); did_action( 'init' ) && $scripts->localize( 'thickbox', 'thickboxL10n', array( @@ -477,6 +478,7 @@ function wp_default_scripts( &$scripts ) { 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') ) ); + $scripts->add( 'custom-header', "/wp-admin/js/custom-header.js", array( 'jquery-masonry' ), false, 1 ); $scripts->add( 'custom-background', "/wp-admin/js/custom-background$suffix.js", array( 'wp-color-picker' ), false, 1 ); $scripts->add( 'media-gallery', "/wp-admin/js/media-gallery$suffix.js", array('jquery'), false, 1 ); }