Widgets: drop onto closed sidebars.
- Make dropping a widget easier by preventing the source sidebar from resizing while the widget is being dragged. - Move widgets dropped on closed sidebars to the top. UI Sortable places them randomly near the bottom. - Fix possible regression in wp_list_widget_controls(), add an optional argument to output the sidebar name inside the sortable container. - Updated styles for sidebar description and widget-hover class. Part props shaunandrews, fixes #25952. Built from https://develop.svn.wordpress.org/trunk@26426 git-svn-id: http://core.svn.wordpress.org/trunk@26326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
49a0254863
commit
f46e743343
|
@ -10012,15 +10012,14 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
|
||||
/* General Widget Styles */
|
||||
/* General Widgets Styles */
|
||||
|
||||
.widget {
|
||||
margin: 10px auto;
|
||||
/* min-width: 50%; Not sure if this is needed */
|
||||
margin: 0 auto 10px;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
|
||||
.widget-top {
|
||||
|
@ -10053,10 +10052,8 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
/* Widget Dragging Helpers */
|
||||
|
||||
.widget.ui-draggable-dragging {
|
||||
width: 280px !important;
|
||||
min-width: 280px !important;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.widget.ui-sortable-helper {
|
||||
|
@ -10066,7 +10063,7 @@ input.newtag:focus ~ div.taghint {
|
|||
|
||||
.widget-placeholder {
|
||||
border: 1px dashed #bbb;
|
||||
margin: 10px 0;
|
||||
margin: 0 auto 10px;
|
||||
height: 45px;
|
||||
width: 100%;
|
||||
-webkit-box-sizing: border-box;
|
||||
|
@ -10078,6 +10075,12 @@ input.newtag:focus ~ div.taghint {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
#widgets-right .closed .widget-placeholder {
|
||||
height: 0;
|
||||
border: 0;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
/* Widget Sidebars */
|
||||
.sidebar-name {
|
||||
border: none;
|
||||
|
@ -10106,14 +10109,15 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
.widgets-holder-wrap .description {
|
||||
padding: 0;
|
||||
padding: 0 0 15px;
|
||||
margin: 0;
|
||||
font-style: normal;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
#available-widgets.widgets-holder-wrap .description {
|
||||
padding-bottom: 10px;
|
||||
#widgets-right .widgets-holder-wrap .description {
|
||||
padding-right: 7px;
|
||||
padding-left: 7px;
|
||||
}
|
||||
|
||||
/* Widgets 2-col Layout */
|
||||
|
@ -10173,6 +10177,10 @@ div#widgets-left .widget-holder {
|
|||
font-size: 12px;
|
||||
}
|
||||
|
||||
#available-widgets #widget-list {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Inactive Sidebars */
|
||||
#widgets-left .inactive-sidebar {
|
||||
clear: both;
|
||||
|
@ -10227,22 +10235,13 @@ div#widgets-right .widgets-holder-wrap {
|
|||
margin: 10px 0 0 0;
|
||||
}
|
||||
|
||||
div#widgets-right .widget {
|
||||
margin: 0 auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-description {
|
||||
border-top: 1px solid #eeeeee;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
div#widgets-right .closed .sidebar-description {
|
||||
display: none;
|
||||
min-height: 20px;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-name h3 {
|
||||
padding: 15px 15px;
|
||||
padding: 15px 7px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-name .sidebar-name-arrow:before {
|
||||
|
@ -10258,27 +10257,12 @@ div#widgets-right .widgets-sortables {
|
|||
padding: 0 8px;
|
||||
margin-bottom: 9px;
|
||||
position: relative;
|
||||
min-height: 45px;
|
||||
min-height: 123px;
|
||||
}
|
||||
|
||||
div#widgets-right .widgets-sortables:after {
|
||||
display: block;
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
right: 8px;
|
||||
left: 8px;
|
||||
z-index: 1; /* Required so that widgets hide the default dropzone indicator (.widgets-sortables:after) */
|
||||
border: 1px dashed #bbb;
|
||||
margin: 10px 0;
|
||||
height: 45px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div#widgets-right .widgets-sortables .widget {
|
||||
z-index: 2; /* Required so that widgets hide the default dropzone indicator (.widgets-sortables:after) */
|
||||
div#widgets-right .closed .widgets-sortables {
|
||||
min-height: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.sidebar-name .spinner {
|
||||
|
@ -10286,10 +10270,18 @@ div#widgets-right .widgets-sortables .widget {
|
|||
float: none;
|
||||
}
|
||||
|
||||
/* Dragging a widget over a closed sidebar */
|
||||
#widgets-right .widgets-holder-wrap.closed.widget-hover {
|
||||
border-color: #777;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Accessibility Mode */
|
||||
#available-widgets .widget-control-edit .edit {
|
||||
display :none;
|
||||
}
|
||||
|
||||
#available-widgets .widget-control-edit .add {
|
||||
display: block;
|
||||
position: absolute;
|
||||
|
@ -10308,12 +10300,15 @@ div#widgets-right .widgets-sortables .widget {
|
|||
padding: 16px 15px;
|
||||
border-right: 1px solid #DDD;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit .add {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit:before {
|
||||
content: '\f111';
|
||||
display: inline-block;
|
||||
|
@ -10326,6 +10321,13 @@ div#widgets-right .widgets-sortables .widget {
|
|||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.widgets-holder-wrap .sidebar-name,
|
||||
.widgets-holder-wrap .sidebar-description {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.editwidget {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
@ -10333,11 +10335,12 @@ div#widgets-right .widgets-sortables .widget {
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.js .closed .widgets-sortables,
|
||||
.js .closed .widget-holder,
|
||||
.js .widgets-holder-wrap.closed .widget,
|
||||
.js .widgets-holder-wrap.closed .sidebar-description,
|
||||
.js .closed br.clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-menus-php .item-edit:before,
|
||||
.widget-top a.widget-action:after,
|
||||
.control-section .accordion-section-title:after,
|
||||
|
@ -10737,6 +10740,10 @@ li#wp-admin-bar-menu-toggle {
|
|||
float: right;
|
||||
}
|
||||
|
||||
.widget.ui-draggable-dragging {
|
||||
min-width: 49%;
|
||||
}
|
||||
|
||||
#widgets-right #available-widgets .widget:nth-child(even) {
|
||||
float: left;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10012,15 +10012,14 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
|
||||
/* General Widget Styles */
|
||||
/* General Widgets Styles */
|
||||
|
||||
.widget {
|
||||
margin: 10px auto;
|
||||
/* min-width: 50%; Not sure if this is needed */
|
||||
margin: 0 auto 10px;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
|
||||
.widget-top {
|
||||
|
@ -10053,10 +10052,8 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
/* Widget Dragging Helpers */
|
||||
|
||||
.widget.ui-draggable-dragging {
|
||||
width: 280px !important;
|
||||
min-width: 280px !important;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.widget.ui-sortable-helper {
|
||||
|
@ -10066,7 +10063,7 @@ input.newtag:focus ~ div.taghint {
|
|||
|
||||
.widget-placeholder {
|
||||
border: 1px dashed #bbb;
|
||||
margin: 10px 0;
|
||||
margin: 0 auto 10px;
|
||||
height: 45px;
|
||||
width: 100%;
|
||||
-webkit-box-sizing: border-box;
|
||||
|
@ -10078,6 +10075,12 @@ input.newtag:focus ~ div.taghint {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
#widgets-right .closed .widget-placeholder {
|
||||
height: 0;
|
||||
border: 0;
|
||||
margin-top: -10px;
|
||||
}
|
||||
|
||||
/* Widget Sidebars */
|
||||
.sidebar-name {
|
||||
border: none;
|
||||
|
@ -10106,14 +10109,15 @@ input.newtag:focus ~ div.taghint {
|
|||
}
|
||||
|
||||
.widgets-holder-wrap .description {
|
||||
padding: 0;
|
||||
padding: 0 0 15px;
|
||||
margin: 0;
|
||||
font-style: normal;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
#available-widgets.widgets-holder-wrap .description {
|
||||
padding-bottom: 10px;
|
||||
#widgets-right .widgets-holder-wrap .description {
|
||||
padding-left: 7px;
|
||||
padding-right: 7px;
|
||||
}
|
||||
|
||||
/* Widgets 2-col Layout */
|
||||
|
@ -10173,6 +10177,10 @@ div#widgets-left .widget-holder {
|
|||
font-size: 12px;
|
||||
}
|
||||
|
||||
#available-widgets #widget-list {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Inactive Sidebars */
|
||||
#widgets-left .inactive-sidebar {
|
||||
clear: both;
|
||||
|
@ -10227,22 +10235,13 @@ div#widgets-right .widgets-holder-wrap {
|
|||
margin: 10px 0 0 0;
|
||||
}
|
||||
|
||||
div#widgets-right .widget {
|
||||
margin: 0 auto;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-description {
|
||||
border-top: 1px solid #eeeeee;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
div#widgets-right .closed .sidebar-description {
|
||||
display: none;
|
||||
min-height: 20px;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-name h3 {
|
||||
padding: 15px 15px;
|
||||
padding: 15px 7px;
|
||||
}
|
||||
|
||||
div#widgets-right .sidebar-name .sidebar-name-arrow:before {
|
||||
|
@ -10258,27 +10257,12 @@ div#widgets-right .widgets-sortables {
|
|||
padding: 0 8px;
|
||||
margin-bottom: 9px;
|
||||
position: relative;
|
||||
min-height: 45px;
|
||||
min-height: 123px;
|
||||
}
|
||||
|
||||
div#widgets-right .widgets-sortables:after {
|
||||
display: block;
|
||||
content: '';
|
||||
position: absolute;
|
||||
bottom: -10px;
|
||||
left: 8px;
|
||||
right: 8px;
|
||||
z-index: 1; /* Required so that widgets hide the default dropzone indicator (.widgets-sortables:after) */
|
||||
border: 1px dashed #bbb;
|
||||
margin: 10px 0;
|
||||
height: 45px;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
div#widgets-right .widgets-sortables .widget {
|
||||
z-index: 2; /* Required so that widgets hide the default dropzone indicator (.widgets-sortables:after) */
|
||||
div#widgets-right .closed .widgets-sortables {
|
||||
min-height: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.sidebar-name .spinner {
|
||||
|
@ -10286,10 +10270,18 @@ div#widgets-right .widgets-sortables .widget {
|
|||
float: none;
|
||||
}
|
||||
|
||||
/* Dragging a widget over a closed sidebar */
|
||||
#widgets-right .widgets-holder-wrap.closed.widget-hover {
|
||||
border-color: #777;
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,0.3);
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Accessibility Mode */
|
||||
#available-widgets .widget-control-edit .edit {
|
||||
display :none;
|
||||
}
|
||||
|
||||
#available-widgets .widget-control-edit .add {
|
||||
display: block;
|
||||
position: absolute;
|
||||
|
@ -10308,12 +10300,15 @@ div#widgets-right .widgets-sortables .widget {
|
|||
padding: 16px 15px;
|
||||
border-left: 1px solid #DDD;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit .add {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit:hover {
|
||||
background: #444;
|
||||
}
|
||||
|
||||
#widgets-right .widget-control-edit:before {
|
||||
content: '\f111';
|
||||
display: inline-block;
|
||||
|
@ -10326,6 +10321,13 @@ div#widgets-right .widgets-sortables .widget {
|
|||
padding-right: 4px;
|
||||
}
|
||||
|
||||
.widgets-holder-wrap .sidebar-name,
|
||||
.widgets-holder-wrap .sidebar-description {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.editwidget {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
@ -10333,11 +10335,12 @@ div#widgets-right .widgets-sortables .widget {
|
|||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.js .closed .widgets-sortables,
|
||||
.js .closed .widget-holder,
|
||||
.js .widgets-holder-wrap.closed .widget,
|
||||
.js .widgets-holder-wrap.closed .sidebar-description,
|
||||
.js .closed br.clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.nav-menus-php .item-edit:before,
|
||||
.widget-top a.widget-action:after,
|
||||
.control-section .accordion-section-title:after,
|
||||
|
@ -10737,6 +10740,10 @@ li#wp-admin-bar-menu-toggle {
|
|||
float: left;
|
||||
}
|
||||
|
||||
.widget.ui-draggable-dragging {
|
||||
min-width: 49%;
|
||||
}
|
||||
|
||||
#widgets-left #available-widgets .widget:nth-child(even) {
|
||||
float: right;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -63,21 +63,35 @@ function _sort_name_callback( $a, $b ) {
|
|||
* @since 2.5.0
|
||||
*
|
||||
* @param string $sidebar id slug of the sidebar
|
||||
* @param string optional $sidebar_name Include the HTML for the sidebar name
|
||||
*/
|
||||
function wp_list_widget_controls( $sidebar ) {
|
||||
function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) {
|
||||
add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' );
|
||||
|
||||
$description = wp_sidebar_description( $sidebar );
|
||||
|
||||
if ( !empty( $description ) ) {
|
||||
echo "<div class='sidebar-description'>\n";
|
||||
echo "\t<p class='description'>$description</p>";
|
||||
echo "</div>\n";
|
||||
echo '<div id="' . esc_attr( $sidebar ) . '" class="widgets-sortables">';
|
||||
|
||||
if ( $sidebar_name ) {
|
||||
?>
|
||||
<div class="sidebar-name">
|
||||
<div class="sidebar-name-arrow"><br /></div>
|
||||
<h3><?php echo esc_html( $sidebar_name ); ?> <span class="spinner"></span></h3>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo "<div id='$sidebar' class='widgets-sortables'>\n";
|
||||
echo '<div class="sidebar-description">';
|
||||
|
||||
if ( ! empty( $description ) ) {
|
||||
echo '<p class="description">' . $description . '</p>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
|
||||
dynamic_sidebar( $sidebar );
|
||||
echo "</div>\n";
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,21 +13,22 @@ wpWidgets = {
|
|||
isRTL = !! ( 'undefined' !== typeof isRtl && isRtl );
|
||||
|
||||
$('#widgets-right .sidebar-name').click( function() {
|
||||
var $this = $(this), wrap = $this.closest('.widgets-holder-wrap');
|
||||
var $this = $(this),
|
||||
$wrap = $this.closest('.widgets-holder-wrap');
|
||||
|
||||
if ( wrap.hasClass('closed') ) {
|
||||
wrap.removeClass('closed');
|
||||
$this.siblings('.widgets-sortables').sortable('refresh');
|
||||
if ( $wrap.hasClass('closed') ) {
|
||||
$wrap.removeClass('closed');
|
||||
$this.parent().sortable('refresh');
|
||||
} else {
|
||||
wrap.addClass('closed');
|
||||
$wrap.addClass('closed');
|
||||
}
|
||||
});
|
||||
|
||||
$('#widgets-left').children('.widgets-holder-wrap').children('.sidebar-name').click(function() {
|
||||
$(this).parent().toggleClass('closed');
|
||||
$('#widgets-left .sidebar-name').click( function() {
|
||||
$(this).closest('.widgets-holder-wrap').toggleClass('closed');
|
||||
});
|
||||
|
||||
$(document.body).bind('click.widgets-toggle', function(e){
|
||||
$(document.body).bind('click.widgets-toggle', function(e) {
|
||||
var target = $(e.target),
|
||||
css = { 'z-index': 100 },
|
||||
widget, inside, targetWidth, widgetWidth, margin;
|
||||
|
@ -36,7 +37,7 @@ wpWidgets = {
|
|||
widget = target.closest('div.widget');
|
||||
inside = widget.children('.widget-inside');
|
||||
targetWidth = parseInt( widget.find('input.widget-width').val(), 10 ),
|
||||
widgetWidth = widget.width();
|
||||
widgetWidth = widget.parent().width();
|
||||
|
||||
if ( inside.is(':hidden') ) {
|
||||
if ( targetWidth > 250 && ( targetWidth + 30 > widgetWidth ) && widget.closest('div.widgets-sortables').length ) {
|
||||
|
@ -68,10 +69,13 @@ wpWidgets = {
|
|||
}
|
||||
});
|
||||
|
||||
sidebars.children('.widget').each(function() {
|
||||
wpWidgets.appendTitle(this);
|
||||
if ( $('p.widget-error', this).length ) {
|
||||
$('a.widget-action', this).click();
|
||||
sidebars.children('.widget').each( function() {
|
||||
var $this = $(this);
|
||||
|
||||
wpWidgets.appendTitle( this );
|
||||
|
||||
if ( $this.find( 'p.widget-error' ).length ) {
|
||||
$this.find( 'a.widget-action' ).trigger('click');
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -112,62 +116,131 @@ wpWidgets = {
|
|||
cursor: 'move',
|
||||
distance: 2,
|
||||
containment: 'document',
|
||||
start: function(e,ui) {
|
||||
var inside = ui.item.children('.widget-inside');
|
||||
start: function( event, ui ) {
|
||||
var $this = $(this),
|
||||
$wrap = $this.parent(),
|
||||
inside = ui.item.children('.widget-inside');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//console.log(this);console.log(ui);
|
||||
|
||||
|
||||
|
||||
|
||||
if ( inside.css('display') === 'block' ) {
|
||||
inside.hide();
|
||||
$(this).sortable('refreshPositions');
|
||||
}
|
||||
},
|
||||
stop: function(e,ui) {
|
||||
if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') ) {
|
||||
ui.item.draggable('destroy');
|
||||
}
|
||||
|
||||
if ( ui.item.hasClass('deleting') ) {
|
||||
wpWidgets.save( ui.item, 1, 0, 1 ); // delete widget
|
||||
ui.item.remove();
|
||||
if ( $wrap.hasClass('closed') ) {
|
||||
// There is a bug in UI Sortable that prevents firing of "over" when dragging a connected Draggable.
|
||||
// This won't be needed when the bug is fixed.
|
||||
$wrap.addClass('widget-hover');
|
||||
} else {
|
||||
// Lock all open sidebars min-height when starting to drag.
|
||||
// Prevents jumping when dragging a widget from an open sidebar to a closed sidebar below.
|
||||
$wrap.css( 'min-height', $wrap.height() + 'px' );
|
||||
$this.css( 'min-height', $this.height() - 2 + 'px' );
|
||||
}
|
||||
},
|
||||
|
||||
stop: function( event, ui ) {
|
||||
var addNew, widgetNumber, $sidebar, $children, child, item,
|
||||
$widget = ui.item,
|
||||
id = the_id;
|
||||
|
||||
if ( $widget.hasClass('deleting') ) {
|
||||
wpWidgets.save( $widget, 1, 0, 1 ); // delete widget
|
||||
$widget.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
var add = ui.item.find('input.add_new').val(),
|
||||
n = ui.item.find('input.multi_number').val(),
|
||||
id = the_id,
|
||||
sb = $(this).attr('id');
|
||||
addNew = $widget.find('input.add_new').val();
|
||||
widgetNumber = $widget.find('input.multi_number').val();
|
||||
|
||||
ui.item.attr( 'style', '' );
|
||||
$widget.attr( 'style', '' );
|
||||
the_id = '';
|
||||
|
||||
if ( add ) {
|
||||
if ( 'multi' === add ) {
|
||||
ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) );
|
||||
ui.item.attr( 'id', id.replace('__i__', n) );
|
||||
n++;
|
||||
$('div#' + id).find('input.multi_number').val(n);
|
||||
} else if ( 'single' === add ) {
|
||||
ui.item.attr( 'id', 'new-' + id );
|
||||
if ( addNew ) {
|
||||
if ( 'multi' === addNew ) {
|
||||
$widget.html(
|
||||
$widget.html().replace( /<[^<>]+>/g, function( tag ) {
|
||||
return tag.replace( /__i__|%i%/g, widgetNumber );
|
||||
})
|
||||
);
|
||||
|
||||
$widget.attr( 'id', id.replace( '__i__', widgetNumber ) );
|
||||
widgetNumber++;
|
||||
|
||||
$( 'div#' + id ).find( 'input.multi_number' ).val( widgetNumber );
|
||||
} else if ( 'single' === addNew ) {
|
||||
$widget.attr( 'id', 'new-' + id );
|
||||
rem = 'div#' + id;
|
||||
}
|
||||
wpWidgets.save( ui.item, 0, 0, 1 );
|
||||
ui.item.find('input.add_new').val('');
|
||||
ui.item.find('a.widget-action').click();
|
||||
|
||||
wpWidgets.save( $widget, 0, 0, 1 );
|
||||
$widget.find('input.add_new').val('');
|
||||
}
|
||||
|
||||
$sidebar = $widget.parent();
|
||||
|
||||
if ( $sidebar.parent().hasClass('closed') ) {
|
||||
$sidebar.parent().removeClass('widget-hover closed jump-open');
|
||||
$children = $sidebar.children('.widget');
|
||||
|
||||
// Make sure the dropped widget is at the top
|
||||
if ( $children.length > 1 ) {
|
||||
child = $children.get(0);
|
||||
item = $widget.get(0);
|
||||
|
||||
if ( child.id && item.id && child.id !== item.id ) {
|
||||
$( child ).before( $widget );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( addNew ) {
|
||||
$widget.find( 'a.widget-action' ).trigger('click');
|
||||
} else {
|
||||
wpWidgets.saveOrder( $sidebar.attr('id') );
|
||||
}
|
||||
},
|
||||
|
||||
over: function( event, ui ) {
|
||||
var $wrap = $(this).parent();
|
||||
|
||||
if ( $wrap.hasClass('closed') ) {
|
||||
$wrap.addClass('widget-hover');
|
||||
}
|
||||
},
|
||||
|
||||
out: function( event, ui ) {
|
||||
$(this).parent().removeClass('widget-hover');
|
||||
},
|
||||
|
||||
deactivate: function( event, ui ) {
|
||||
// Remove all min-height added on "start"
|
||||
$(this).css( 'min-height', '' ).parent().css( 'min-height', '' );
|
||||
},
|
||||
|
||||
receive: function( event, ui ) {
|
||||
var $sender = $( ui.sender );
|
||||
|
||||
// Don't add more widgets to orphaned sidebars
|
||||
if ( this.id.indexOf('orphaned_widgets') > -1 ) {
|
||||
$sender.sortable('cancel');
|
||||
return;
|
||||
}
|
||||
wpWidgets.saveOrder(sb);
|
||||
},
|
||||
receive: function(e, ui) {
|
||||
var sender = $(ui.sender);
|
||||
|
||||
if ( ! $(this).is(':visible') || this.id.indexOf('orphaned_widgets') > -1 ) {
|
||||
sender.sortable('cancel');
|
||||
}
|
||||
|
||||
if ( sender.attr('id').indexOf('orphaned_widgets') > -1 && !sender.children('.widget').length ) {
|
||||
sender.parents('.orphan-sidebar').slideUp(400, function(){ $(this).remove(); });
|
||||
// If the last widget was moved out of an orphaned sidebar, close and remove it.
|
||||
if ( $sender.attr('id').indexOf('orphaned_widgets') > -1 && ! $sender.children('.widget').length ) {
|
||||
$sender.parents('.orphan-sidebar').slideUp( 400, function(){ $(this).remove(); } );
|
||||
}
|
||||
}
|
||||
}).sortable('option', 'connectWith', 'div.widgets-sortables');
|
||||
}).sortable( 'option', 'connectWith', 'div.widgets-sortables' );
|
||||
|
||||
$('#available-widgets').droppable({
|
||||
tolerance: 'pointer',
|
||||
|
@ -210,17 +283,16 @@ wpWidgets = {
|
|||
});
|
||||
|
||||
$( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() {
|
||||
var widget = $(this).closest( '.widget' );
|
||||
var $widget = $(this).closest( '.widget' );
|
||||
|
||||
if ( widget.hasClass( 'widget-in-question' ) || ( $( '#widgets-left' ).hasClass( 'chooser' ) ) ) {
|
||||
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.addClass( 'widget-in-question' ).children( '.widget-description' ).after( chooser );
|
||||
|
||||
widget.find( '.widget-description' ).after( chooser );
|
||||
chooser.slideDown( 300, function() {
|
||||
selectSidebar.find('.widgets-chooser-selected').focus();
|
||||
});
|
||||
|
@ -257,37 +329,39 @@ wpWidgets = {
|
|||
});
|
||||
},
|
||||
|
||||
saveOrder : function(sb) {
|
||||
if ( sb ) {
|
||||
$('#' + sb).closest('div.widgets-holder-wrap').find('.spinner:first').css('display', 'inline-block');
|
||||
}
|
||||
|
||||
var a = {
|
||||
saveOrder : function( sidebarId ) {
|
||||
var data = {
|
||||
action: 'widgets-order',
|
||||
savewidgets: $('#_wpnonce_widgets').val(),
|
||||
sidebars: []
|
||||
};
|
||||
|
||||
if ( sidebarId ) {
|
||||
$( '#' + sidebarId ).find('.spinner:first').css('display', 'inline-block');
|
||||
}
|
||||
|
||||
$('div.widgets-sortables').each( function() {
|
||||
if ( $(this).sortable ) {
|
||||
a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');
|
||||
data['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');
|
||||
}
|
||||
});
|
||||
|
||||
$.post( ajaxurl, a, function() {
|
||||
$.post( ajaxurl, data, function() {
|
||||
$('.spinner').hide();
|
||||
});
|
||||
},
|
||||
|
||||
save : function(widget, del, animate, order) {
|
||||
var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a;
|
||||
save : function( widget, del, animate, order ) {
|
||||
var sidebarId = widget.closest('div.widgets-sortables').attr('id'),
|
||||
data = widget.find('form').serialize(), a;
|
||||
|
||||
widget = $(widget);
|
||||
$('.spinner', widget).show();
|
||||
|
||||
a = {
|
||||
action: 'save-widget',
|
||||
savewidgets: $('#_wpnonce_widgets').val(),
|
||||
sidebar: sb
|
||||
sidebar: sidebarId
|
||||
};
|
||||
|
||||
if ( del ) {
|
||||
|
@ -296,7 +370,7 @@ wpWidgets = {
|
|||
|
||||
data += '&' + $.param(a);
|
||||
|
||||
$.post( ajaxurl, data, function(r){
|
||||
$.post( ajaxurl, data, function(r) {
|
||||
var id;
|
||||
|
||||
if ( del ) {
|
||||
|
@ -321,8 +395,8 @@ wpWidgets = {
|
|||
} else {
|
||||
$('.spinner').hide();
|
||||
if ( r && r.length > 2 ) {
|
||||
$('div.widget-content', widget).html(r);
|
||||
wpWidgets.appendTitle(widget);
|
||||
$( 'div.widget-content', widget ).html(r);
|
||||
wpWidgets.appendTitle( widget );
|
||||
}
|
||||
}
|
||||
if ( order ) {
|
||||
|
@ -379,9 +453,9 @@ wpWidgets = {
|
|||
|
||||
// Open the widgets container
|
||||
sidebar.closest( '.widgets-holder-wrap' ).removeClass('closed');
|
||||
sidebar.sortable('refresh');
|
||||
|
||||
widget.prependTo( sidebar );
|
||||
sidebar.find('.sidebar-description').after( widget );
|
||||
sidebar.sortable('refresh');
|
||||
|
||||
wpWidgets.save( widget, 0, 0, 1 );
|
||||
// No longer "new" widget
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -332,14 +332,17 @@ do_action( 'widgets_admin_page' ); ?>
|
|||
<div id="widgets-left">
|
||||
<div id="available-widgets" class="widgets-holder-wrap">
|
||||
<div class="sidebar-name">
|
||||
<div class="sidebar-name-arrow"><br /></div>
|
||||
<h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3></div>
|
||||
<div class="widget-holder">
|
||||
<p class="description"><?php _e('Drag widgets from here to a sidebar on the right to activate them. Drag widgets back here to deactivate them and delete their settings.'); ?></p>
|
||||
<div id="widget-list">
|
||||
<?php wp_list_widgets(); ?>
|
||||
<div class="sidebar-name-arrow"><br /></div>
|
||||
<h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3>
|
||||
</div>
|
||||
<br class='clear' />
|
||||
<div class="widget-holder">
|
||||
<div class="sidebar-description">
|
||||
<p class="description"><?php _e('Drag widgets from here to a sidebar on the right to activate them. Drag widgets back here to deactivate them and delete their settings.'); ?></p>
|
||||
</div>
|
||||
<div id="widget-list">
|
||||
<?php wp_list_widgets(); ?>
|
||||
</div>
|
||||
<br class='clear' />
|
||||
</div>
|
||||
<br class="clear" />
|
||||
</div>
|
||||
|
@ -355,16 +358,13 @@ foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) {
|
|||
|
||||
?>
|
||||
<div class="<?php echo esc_attr( $wrap_class ); ?>">
|
||||
<div class="sidebar-name">
|
||||
<div class="sidebar-name-arrow"><br /></div>
|
||||
<h3><?php echo esc_html( $registered_sidebar['name'] ); ?> <span class="spinner"></span></h3>
|
||||
</div>
|
||||
<div class="widget-holder inactive">
|
||||
<?php wp_list_widget_controls( $registered_sidebar['id'] ); ?>
|
||||
<?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
} else {
|
||||
$theme_sidebars[$sidebar] = $registered_sidebar;
|
||||
}
|
||||
|
@ -407,11 +407,7 @@ foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) {
|
|||
|
||||
?>
|
||||
<div class="<?php echo esc_attr( $wrap_class ); ?>">
|
||||
<div class="sidebar-name">
|
||||
<div class="sidebar-name-arrow"><br /></div>
|
||||
<h3><?php echo esc_html( $registered_sidebar['name'] ); ?> <span class="spinner"></span></h3>
|
||||
</div>
|
||||
<?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?>
|
||||
<?php wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); // Show the control forms for each of the widgets in this sidebar ?>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
|
|
Loading…
Reference in New Issue