<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[26054] trunk/src/wp-admin: Merge the Widgets Area Chooser feature plugin.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/26054">26054</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2013-11-08 23:04:35 +0000 (Fri, 08 Nov 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge the Widgets Area Chooser feature plugin. First run, see <a href="http://core.trac.wordpress.org/ticket/25821">#25821</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsswpadmincss">trunk/src/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunksrcwpadminjswidgetsjs">trunk/src/wp-admin/js/widgets.js</a></li>
<li><a href="#trunksrcwpadminwidgetsphp">trunk/src/wp-admin/widgets.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/css/wp-admin.css (26053 => 26054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/css/wp-admin.css 2013-11-08 22:51:03 UTC (rev 26053)
+++ trunk/src/wp-admin/css/wp-admin.css 2013-11-08 23:04:35 UTC (rev 26054)
</span><span class="lines">@@ -9051,6 +9051,121 @@
</span><span class="cx"> cursor: default;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+/* Widgets Area Chooser merge */
+.widget-liquid-left #widgets-left.chooser #available-widgets .widget,
+.widget-liquid-left #widgets-left.chooser .inactive-sidebar {
+ transition: opacity 0.2s ease-in-out;
+}
+
+.widget-liquid-left #widgets-left.chooser #available-widgets .widget,
+.widget-liquid-left #widgets-left.chooser .inactive-sidebar {
+ /* -webkit-filter: blur(1px); */
+ opacity: 0.2;
+ pointer-events: none;
+}
+
+.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question {
+ /* -webkit-filter: none; */
+ opacity: 1;
+ pointer-events: auto;
+}
+
+.widget-liquid-left #widgets-left.chooser #available-widgets .widget-in-question .widget-top {
+ background: #fff;
+ border: 1px solid #bbb;
+ box-shadow: 0 1px 3px rgba(0,0,0,0.2);
+}
+
+#widgets-chooser {
+ display: none;
+ margin: auto;
+ padding-bottom: 10px;
+ max-width: 400px;
+}
+
+#widgets-chooser h3 {
+ font-size: 14px;
+ margin: 15px 0;
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars {
+ margin: 0 0 20px 0;
+ list-style-type: none;
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars li {
+ padding: 10px 15px 10px 35px;
+ background: #fff;
+ border: 1px solid #ccc;
+ border-bottom: none;
+ margin: 0;
+ cursor: pointer;
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars li:hover {
+ background: rgba(255,255,255,0.7);
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars li.widgets-chooser-selected {
+ background: #1075a0;
+ color: #fff;
+ position: relative;
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars li.widgets-chooser-selected:before {
+ content: '\f147';
+ display: block;
+ -webkit-font-smoothing: antialiased;
+ font: normal 26px/1 'dashicons';
+ position: absolute;
+ top: 7px;
+ left: 5px;
+}
+
+#widgets-chooser ul.widgets-chooser-sidebars li:last-child {
+ border-bottom: 1px solid #ccc;
+}
+
+#widgets-chooser select {
+ width: 100%;
+ margin-bottom: 20px;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+#widgets-chooser .sidebar-radios {
+ text-align: left;
+ margin: 0 20px 20px 20px;
+}
+
+#widgets-chooser .sidebar-radios li {
+ margin-top: 15px;
+}
+
+#widgets-chooser .sidebar-radios label {
+ font-size: 15px;
+}
+
+#widgets-chooser .sidebar-radios input {
+ margin-right: 10px;
+}
+
+#widgets-chooser .widgets-chooser-actions {
+ clear: both;
+ text-align: center;
+}
+
+#widgets-chooser button {
+ margin-right: 5px;
+}
+
+#available-widgets .widget .widget-top {
+ cursor: pointer;
+}
+/* End Widgets Area Chooser merge */
+
</ins><span class="cx"> /* Enable draggable on IE10 touch events until it's rolled into jQuery UI core */
</span><span class="cx"> .ui-sortable,
</span><span class="cx"> .ui-draggable {
</span></span></pre></div>
<a id="trunksrcwpadminjswidgetsjs"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/js/widgets.js (26053 => 26054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/js/widgets.js 2013-11-08 22:51:03 UTC (rev 26053)
+++ trunk/src/wp-admin/js/widgets.js 2013-11-08 23:04:35 UTC (rev 26054)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+/*global ajaxurl, isRtl */
</ins><span class="cx"> var wpWidgets;
</span><span class="cx"> (function($) {
</span><span class="cx">
</span><span class="lines">@@ -4,17 +5,21 @@
</span><span class="cx"> wpWidgets = {
</span><span class="cx">
</span><span class="cx"> init : function() {
</span><del>- var rem, sidebars = $('div.widgets-sortables'), isRTL = !! ( 'undefined' != typeof isRtl && isRtl ),
- margin = ( isRtl ? 'marginRight' : 'marginLeft' ), the_id;
</del><ins>+ var rem, the_id,
+ self = this,
+ chooser = $('#widgets-chooser'),
+ selectSidebar = chooser.find('.widgets-chooser-sidebars'),
+ sidebars = $('div.widgets-sortables'),
+ isRTL = !! ( 'undefined' !== typeof isRtl && isRtl ),
+ margin = ( isRTL ? 'marginRight' : 'marginLeft' );
</ins><span class="cx">
</span><del>- $('#widgets-right').children('.widgets-holder-wrap').children('.sidebar-name').click(function(){
- var c = $(this).siblings('.widgets-sortables'), p = $(this).parent();
- if ( !p.hasClass('closed') ) {
- c.sortable('disable');
- p.addClass('closed');
</del><ins>+ $('#widgets-right').children('.widgets-holder-wrap').children('.sidebar-name').click( function() {
+ var $this = $(this), parent = $this.parent();
+ if ( parent.hasClass('closed') ) {
+ parent.removeClass('closed');
+ $this.siblings('.widgets-sortables').sortable('refresh');
</ins><span class="cx"> } else {
</span><del>- p.removeClass('closed');
- c.sortable('enable').sortable('refresh');
</del><ins>+ parent.addClass('closed');
</ins><span class="cx"> }
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -41,7 +46,7 @@
</span><span class="cx">
</span><span class="cx"> if ( inside.is(':hidden') ) {
</span><span class="cx"> if ( w > 250 && inside.closest('div.widgets-sortables').length ) {
</span><del>- css['width'] = w + 30 + 'px';
</del><ins>+ css.width = w + 30 + 'px';
</ins><span class="cx"> if ( inside.closest('div.widget-liquid-right').length )
</span><span class="cx"> css[margin] = 235 - w + 'px';
</span><span class="cx"> widget.css(css);
</span><span class="lines">@@ -83,7 +88,7 @@
</span><span class="cx"> ui.helper.find('div.widget-description').hide();
</span><span class="cx"> the_id = this.id;
</span><span class="cx"> },
</span><del>- stop: function(e,ui) {
</del><ins>+ stop: function() {
</ins><span class="cx"> if ( rem )
</span><span class="cx"> $(rem).hide();
</span><span class="cx">
</span><span class="lines">@@ -121,12 +126,12 @@
</span><span class="cx"> the_id = '';
</span><span class="cx">
</span><span class="cx"> if ( add ) {
</span><del>- if ( 'multi' == add ) {
</del><ins>+ if ( 'multi' === add ) {
</ins><span class="cx"> ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
</span><span class="cx"> ui.item.attr( 'id', id.replace('__i__', n) );
</span><span class="cx"> n++;
</span><span class="cx"> $('div#' + id).find('input.multi_number').val(n);
</span><del>- } else if ( 'single' == add ) {
</del><ins>+ } else if ( 'single' === add ) {
</ins><span class="cx"> ui.item.attr( 'id', 'new-' + id );
</span><span class="cx"> rem = 'div#' + id;
</span><span class="cx"> }
</span><span class="lines">@@ -140,19 +145,19 @@
</span><span class="cx"> receive: function(e, ui) {
</span><span class="cx"> var sender = $(ui.sender);
</span><span class="cx">
</span><del>- if ( !$(this).is(':visible') || this.id.indexOf('orphaned_widgets') != -1 )
</del><ins>+ if ( !$(this).is(':visible') || this.id.indexOf('orphaned_widgets') > -1 )
</ins><span class="cx"> sender.sortable('cancel');
</span><span class="cx">
</span><del>- if ( sender.attr('id').indexOf('orphaned_widgets') != -1 && !sender.children('.widget').length ) {
</del><ins>+ if ( sender.attr('id').indexOf('orphaned_widgets') > -1 && !sender.children('.widget').length ) {
</ins><span class="cx"> sender.parents('.orphan-sidebar').slideUp(400, function(){ $(this).remove(); });
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- }).sortable('option', 'connectWith', 'div.widgets-sortables').parent().filter('.closed').children('.widgets-sortables').sortable('disable');
</del><ins>+ }).sortable('option', 'connectWith', 'div.widgets-sortables');
</ins><span class="cx">
</span><span class="cx"> $('#available-widgets').droppable({
</span><span class="cx"> tolerance: 'pointer',
</span><span class="cx"> accept: function(o){
</span><del>- return $(o).parent().attr('id') != 'widget-list';
</del><ins>+ return $(o).parent().attr('id') !== 'widget-list';
</ins><span class="cx"> },
</span><span class="cx"> drop: function(e,ui) {
</span><span class="cx"> ui.draggable.addClass('deleting');
</span><span class="lines">@@ -172,6 +177,54 @@
</span><span class="cx"> $('#removing-widget').hide().children('span').html('');
</span><span class="cx"> }
</span><span class="cx"> });
</span><ins>+
+ // Area Chooser
+ $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) {
+ var $element = $( element ),
+ name = $element.find( '.sidebar-name h3' ).text(),
+ id = $element.find( '.widgets-sortables' ).attr( 'id' ),
+ li = $('<li tabindex="0">').text( $.trim( name ) );
+
+ if ( index === 0 ) {
+ li.addClass( 'widgets-chooser-selected' );
+ }
+
+ selectSidebar.append( li );
+ li.data( 'sidebarId', id );
+ });
+
+ $( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() {
+ var widget = $(this).closest( '.widget' );
+
+ if ( widget.hasClass( 'widget-in-question' ) || ( $( '#widgets-left' ).hasClass( 'chooser' ) ) ) {
+ self.closeChooser();
+ } else {
+ // Open the chooser
+ self.clearWidgetSelection();
+ $( '#widgets-left' ).addClass( 'chooser' );
+ widget.addClass( 'widget-in-question' );
+
+ widget.after( chooser );
+ chooser.slideDown( 200, function() {
+ selectSidebar.find('.widgets-chooser-selected').focus();
+ });
+ }
+ });
+
+ // Add event handlers
+ chooser.on( 'click.widgets-chooser', function( event ) {
+ var $target = $( event.target );
+
+ if ( $target.hasClass('button-primary') ) {
+ self.addWidget( chooser );
+ self.closeChooser();
+ } else if ( $target.hasClass('button-secondary') ) {
+ self.closeChooser();
+ } else if ( $target.is('.widgets-chooser-sidebars li') ) {
+ chooser.find('.widgets-chooser-selected').removeClass( 'widgets-chooser-selected' );
+ $target.addClass( 'widgets-chooser-selected' );
+ }
+ });
</ins><span class="cx"> },
</span><span class="cx">
</span><span class="cx"> saveOrder : function(sb) {
</span><span class="lines">@@ -208,7 +261,7 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> if ( del )
</span><del>- a['delete_widget'] = 1;
</del><ins>+ a.delete_widget = 1;
</ins><span class="cx">
</span><span class="cx"> data += '&' + $.param(a);
</span><span class="cx">
</span><span class="lines">@@ -219,7 +272,7 @@
</span><span class="cx"> if ( !$('input.widget_number', widget).val() ) {
</span><span class="cx"> id = $('input.widget-id', widget).val();
</span><span class="cx"> $('#available-widgets').find('input.widget-id').each(function(){
</span><del>- if ( $(this).val() == id )
</del><ins>+ if ( $(this).val() === id )
</ins><span class="cx"> $(this).closest('div.widget').show();
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="lines">@@ -272,7 +325,7 @@
</span><span class="cx"> fixLabels : function(widget) {
</span><span class="cx"> widget.children('.widget-inside').find('label').each(function(){
</span><span class="cx"> var f = $(this).attr('for');
</span><del>- if ( f && f == $('input', this).attr('id') )
</del><ins>+ if ( f && f === $('input', this).attr('id') )
</ins><span class="cx"> $(this).removeAttr('for');
</span><span class="cx"> });
</span><span class="cx"> },
</span><span class="lines">@@ -281,9 +334,69 @@
</span><span class="cx"> widget.children('.widget-inside').slideUp('fast', function(){
</span><span class="cx"> widget.css({'width':'', margin:''});
</span><span class="cx"> });
</span><ins>+ },
+
+ addWidget: function( chooser ) {
+ var widget = $('#available-widgets').find('.widget-in-question').clone(),
+ widgetId = widget.attr('id'),
+ add = widget.find( 'input.add_new' ).val(),
+ n = widget.find( 'input.multi_number' ).val(),
+ sidebarId = chooser.find( '.widgets-chooser-selected' ).data('sidebarId'),
+ sidebar = $( '#' + sidebarId );
+
+ if ( 'multi' === add ) {
+ widget.html(
+ widget.html().replace( /<[^<>]+>/g, function(m) {
+ return m.replace( /__i__|%i%/g, n );
+ })
+ );
+
+ widget.attr( 'id', widgetId.replace( '__i__', n ) );
+ n++;
+ $( '#' + widgetId ).find('input.multi_number').val(n);
+ } else if ( 'single' === add ) {
+ widget.attr( 'id', 'new-' + widgetId );
+ $( '#' + widgetId ).hide();
+ }
+
+ // Open the widgets container
+ sidebar.closest( '.widgets-holder-wrap' ).removeClass('closed');
+ sidebar.sortable('refresh');
+
+ // Change for MP6
+ // widget.prependTo( sidebar );
+ sidebar.find( '.sidebar-description' ).after( widget );
+
+ wpWidgets.save( widget, 0, 0, 1 );
+ // No longer "new" widget
+ widget.find( 'input.add_new' ).val('');
+
+ $( 'html, body' ).animate({
+ scrollTop: sidebar.offset().top - 130
+ }, 200 );
+
+ window.setTimeout( function() {
+ // Cannot use a callback in the animation above as it fires twice,
+ // have to queue this "by hand".
+ widget.find( '.widget-title' ).trigger('click');
+ }, 250 );
+ },
+
+ closeChooser: function() {
+ var self = this;
+
+ $( '#widgets-chooser' ).slideUp( 200, function() {
+ $('#wpbody-content').append( this );
+ self.clearWidgetSelection();
+ });
+ },
+
+ clearWidgetSelection: function() {
+ $( '#widgets-left' ).removeClass( 'chooser' );
+ $( '#available-widgets' ).find( '.widget-in-question' ).removeClass( 'widget-in-question' );
</ins><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-$(document).ready(function($){ wpWidgets.init(); });
</del><ins>+$(document).ready( function(){ wpWidgets.init(); } );
</ins><span class="cx">
</span><span class="cx"> })(jQuery);
</span></span></pre></div>
<a id="trunksrcwpadminwidgetsphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-admin/widgets.php (26053 => 26054)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-admin/widgets.php 2013-11-08 22:51:03 UTC (rev 26053)
+++ trunk/src/wp-admin/widgets.php 2013-11-08 23:04:35 UTC (rev 26054)
</span><span class="lines">@@ -406,6 +406,15 @@
</span><span class="cx"> <br class="clear" />
</span><span class="cx"> </div>
</span><span class="cx">
</span><ins>+<div id="widgets-chooser">
+ <h3><?php _e( 'Choose an area to place this widget…' ); ?></h3>
+ <ul class="widgets-chooser-sidebars"></ul>
+ <div class="widgets-chooser-actions">
+ <button class="button-primary"><?php _e( 'Add Widget' ); ?></button>
+ <button class="button-secondary"><?php _e( 'Cancel' ); ?></button>
+ </div>
+</div>
+
</ins><span class="cx"> <?php
</span><span class="cx">
</span><span class="cx"> /**
</span></span></pre>
</div>
</div>
</body>
</html>