Ticket #25952: 25952.7.patch
File 25952.7.patch, 17.3 KB (added by , 11 years ago) |
---|
-
src/wp-admin/css/wp-admin.css
10039 10039 margin-top: 0; 10040 10040 } 10041 10041 10042 /* Override UI Sortable and Draggable inline style */ 10043 #widgets-right .closed .widget-placeholder { 10044 height: 0; 10045 border: 0; 10046 margin-top: -10px; 10047 } 10048 10042 10049 /* Widget Sidebars */ 10043 10050 .sidebar-name { 10044 10051 border: none; … … 10067 10074 } 10068 10075 10069 10076 .widgets-holder-wrap .description { 10070 padding: 0 ;10077 padding: 0 0 15px 0; 10071 10078 margin: 0; 10072 10079 font-style: normal; 10073 10080 color: #777; 10074 10081 } 10075 10082 10076 #available-widgets.widgets-holder-wrap .description { 10077 padding-bottom: 10px; 10083 #widgets-right .widgets-holder-wrap .description { 10084 padding-left: 15px; 10085 margin-top: -5px; 10078 10086 } 10079 10087 10080 10088 /* Widgets 2-col Layout */ … … 10194 10202 } 10195 10203 10196 10204 div#widgets-right .sidebar-description { 10197 border-top: 1px solid #eeeeee; 10198 padding: 10px 15px; 10205 min-height: 20px; 10199 10206 } 10200 10207 10201 div#widgets-right .closed .sidebar-description {10202 display: none;10203 }10204 10205 10208 div#widgets-right .sidebar-name h3 { 10206 padding: 15px 15px;10209 padding: 15px; 10207 10210 } 10208 10211 10209 10212 div#widgets-right .sidebar-name .sidebar-name-arrow:before { … … 10219 10222 padding: 0 8px; 10220 10223 margin-bottom: 9px; 10221 10224 position: relative; 10222 min-height: 50px;10225 min-height: 140px; 10223 10226 } 10224 10227 10228 div#widgets-right .closed .widgets-sortables { 10229 min-height: 0; 10230 margin-bottom: 0; 10231 } 10232 10225 10233 .sidebar-name .spinner { 10226 10234 margin: -5px 5px; 10227 10235 float: none; 10228 10236 } 10229 10237 10238 /* Dragging a widget over a closed sidebar */ 10239 #widgets-right .widgets-holder-wrap.closed.widget-hover { 10240 border-color: #777; 10241 box-shadow: 0 1px 2px rgba(0,0,0,0.3); 10242 opacity: 0.6; 10243 } 10244 10230 10245 /* Accessibility Mode */ 10231 10246 #available-widgets .widget-control-edit .edit { 10232 10247 display :none; 10233 10248 } 10249 10234 10250 #available-widgets .widget-control-edit .add { 10235 10251 display: block; 10236 10252 position: absolute; … … 10249 10265 padding: 16px 15px; 10250 10266 border-left: 1px solid #DDD; 10251 10267 } 10268 10252 10269 #widgets-right .widget-control-edit .add { 10253 10270 display: none; 10254 10271 } 10272 10255 10273 #widgets-right .widget-control-edit:hover { 10256 10274 background: #444; 10257 10275 } 10276 10258 10277 #widgets-right .widget-control-edit:before { 10259 10278 content: '\f111'; 10260 10279 display: inline-block; … … 10267 10286 padding-right: 4px; 10268 10287 } 10269 10288 10289 .widgets-holder-wrap .sidebar-name, 10290 .widgets-holder-wrap .sidebar-description { 10291 -webkit-user-select: none; 10292 -moz-user-select: none; 10293 user-select: none; 10294 } 10295 10270 10296 .editwidget { 10271 10297 margin: 0 auto; 10272 10298 } … … 10274 10300 margin-top: 20px; 10275 10301 } 10276 10302 10277 .js . closed .widgets-sortables,10278 .js . closed .widget-holder,10303 .js .widgets-holder-wrap.closed .widget, 10304 .js .widgets-holder-wrap.closed .sidebar-description, 10279 10305 .js .closed br.clear { 10280 10306 display: none; 10281 10307 } 10308 10282 10309 .nav-menus-php .item-edit:before, 10283 10310 .widget-top a.widget-action:after, 10284 10311 .control-section .accordion-section-title:after, -
src/wp-admin/includes/widgets.php
63 63 * @since 2.5.0 64 64 * 65 65 * @param string $sidebar id slug of the sidebar 66 * @param string optional $sidebar_name Include the HTML for the sidebar name 66 67 */ 67 function wp_list_widget_controls( $sidebar ) {68 function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { 68 69 add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' ); 69 70 70 71 $description = wp_sidebar_description( $sidebar ); 71 72 72 if ( !empty( $description ) ) { 73 echo "<div class='sidebar-description'>\n"; 74 echo "\t<p class='description'>$description</p>"; 75 echo "</div>\n"; 73 echo '<div id="' . esc_attr( $sidebar ) . '" class="widgets-sortables">'; 74 75 if ( $sidebar_name ) { 76 ?> 77 <div class="sidebar-name"> 78 <div class="sidebar-name-arrow"><br /></div> 79 <h3><?php echo esc_html( $sidebar_name ); ?> <span class="spinner"></span></h3> 80 </div> 81 <?php 76 82 } 77 83 78 echo "<div id='$sidebar' class='widgets-sortables'>\n"; 84 echo '<div class="sidebar-description">'; 85 86 if ( ! empty( $description ) ) { 87 echo '<p class="description">' . $description . '</p>'; 88 } 89 90 echo '</div>'; 91 79 92 dynamic_sidebar( $sidebar ); 80 echo "</div>\n"; 93 94 echo '</div>'; 81 95 } 82 96 83 97 /** -
src/wp-admin/js/widgets.js
13 13 isRTL = !! ( 'undefined' !== typeof isRtl && isRtl ); 14 14 15 15 $('#widgets-right .sidebar-name').click( function() { 16 var $this = $(this), wrap = $this.closest('.widgets-holder-wrap'); 16 var $this = $(this), 17 $wrap = $this.closest('.widgets-holder-wrap'); 17 18 18 if ( wrap.hasClass('closed') ) {19 wrap.removeClass('closed');20 $this. siblings('.widgets-sortables').sortable('refresh');19 if ( $wrap.hasClass('closed') ) { 20 $wrap.removeClass('closed'); 21 $this.parent().sortable('refresh'); 21 22 } else { 22 wrap.addClass('closed');23 $wrap.addClass('closed'); 23 24 } 24 25 }); 25 26 26 $('#widgets-left ').children('.widgets-holder-wrap').children('.sidebar-name').click(function() {27 $(this). parent().toggleClass('closed');27 $('#widgets-left .sidebar-name').click( function() { 28 $(this).closest('.widgets-holder-wrap').toggleClass('closed'); 28 29 }); 29 30 30 $(document.body).bind('click.widgets-toggle', function(e) {31 $(document.body).bind('click.widgets-toggle', function(e) { 31 32 var target = $(e.target), 32 33 css = { 'z-index': 100 }, 33 34 widget, inside, targetWidth, widgetWidth, margin; … … 36 37 widget = target.closest('div.widget'); 37 38 inside = widget.children('.widget-inside'); 38 39 targetWidth = parseInt( widget.find('input.widget-width').val(), 10 ), 39 widgetWidth = widget. width();40 widgetWidth = widget.parent().width(); 40 41 41 42 if ( inside.is(':hidden') ) { 42 43 if ( targetWidth > 250 && ( targetWidth + 30 > widgetWidth ) && widget.closest('div.widgets-sortables').length ) { … … 68 69 } 69 70 }); 70 71 71 sidebars.children('.widget').each(function() { 72 wpWidgets.appendTitle(this); 73 if ( $('p.widget-error', this).length ) { 74 $('a.widget-action', this).click(); 72 sidebars.children('.widget').each( function() { 73 var $this = $(this); 74 75 wpWidgets.appendTitle( this ); 76 77 if ( $this.find( 'p.widget-error' ).length ) { 78 $this.find( 'a.widget-action' ).trigger('click'); 75 79 } 76 80 }); 77 81 … … 80 84 handle: '> .widget-top > .widget-title', 81 85 distance: 2, 82 86 helper: 'clone', 87 cursor: 'move', 83 88 zIndex: 100, 84 89 containment: 'document', 85 start: function( e,ui) {90 start: function( event, ui ) { 86 91 ui.helper.find('div.widget-description').hide(); 87 92 the_id = this.id; 88 93 }, … … 102 107 cursor: 'move', 103 108 distance: 2, 104 109 containment: 'document', 105 start: function(e,ui) { 106 ui.item.children('.widget-inside').hide(); 110 start: function( event, ui ) { 111 var $wrap = $(this).parent(); 112 113 ui.item.find('.widget-inside').hide(); 114 115 // There is a bug in UI Sortable that prevents firing of "over" when dragging a connected Draggable. 116 // This won't be needed when the bug is fixed. 117 if ( $wrap.hasClass('closed') ) { 118 $wrap.addClass('widget-hover'); 119 } 107 120 }, 108 stop: function(e,ui) {109 if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') ) {110 ui.item.draggable('destroy');111 }112 121 113 if ( ui.item.hasClass('deleting') ) { 114 wpWidgets.save( ui.item, 1, 0, 1 ); // delete widget 115 ui.item.remove(); 122 stop: function( event, ui ) { 123 var addNew, widgetNumber, $sidebar, $children, child, item, 124 $widget = ui.item, 125 id = the_id; 126 127 if ( $widget.hasClass('deleting') ) { 128 wpWidgets.save( $widget, 1, 0, 1 ); // delete widget 129 $widget.remove(); 116 130 return; 117 131 } 118 132 119 var add = ui.item.find('input.add_new').val(), 120 n = ui.item.find('input.multi_number').val(), 121 id = the_id, 122 sb = $(this).attr('id'); 133 addNew = $widget.find('input.add_new').val(); 134 widgetNumber = $widget.find('input.multi_number').val(); 123 135 124 ui.item.attr( 'style', '' );136 $widget.attr( 'style', '' ); 125 137 the_id = ''; 126 138 127 if ( add ) { 128 if ( 'multi' === add ) { 129 ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) ); 130 ui.item.attr( 'id', id.replace('__i__', n) ); 131 n++; 132 $('div#' + id).find('input.multi_number').val(n); 133 } else if ( 'single' === add ) { 134 ui.item.attr( 'id', 'new-' + id ); 139 if ( addNew ) { 140 if ( 'multi' === addNew ) { 141 $widget.html( 142 $widget.html().replace( /<[^<>]+>/g, function( tag ) { 143 return tag.replace( /__i__|%i%/g, widgetNumber ); 144 }) 145 ); 146 147 $widget.attr( 'id', id.replace( '__i__', widgetNumber ) ); 148 widgetNumber++; 149 150 $( 'div#' + id ).find( 'input.multi_number' ).val( widgetNumber ); 151 } else if ( 'single' === addNew ) { 152 $widget.attr( 'id', 'new-' + id ); 135 153 rem = 'div#' + id; 136 154 } 137 wpWidgets.save( ui.item, 0, 0, 1 ); 138 ui.item.find('input.add_new').val(''); 139 ui.item.find('a.widget-action').click(); 140 return; 155 156 wpWidgets.save( $widget, 0, 0, 1 ); 157 $widget.find('input.add_new').val(''); 141 158 } 142 wpWidgets.saveOrder(sb); 159 160 $sidebar = $widget.parent(); 161 162 if ( $sidebar.parent().hasClass('closed') ) { 163 $sidebar.parent().removeClass('widget-hover closed jump-open'); 164 $children = $sidebar.children('.widget'); 165 166 // Make sure the dropped widget is at the top 167 if ( $children.length > 1 ) { 168 child = $children.get(0); 169 item = $widget.get(0); 170 171 if ( child.id && item.id && child.id !== item.id ) { 172 $( child ).before( $widget ); 173 } 174 } 175 } 176 177 if ( addNew ) { 178 $widget.find( 'a.widget-action' ).trigger('click'); 179 } else { 180 wpWidgets.saveOrder( $sidebar.attr('id') ); 181 } 143 182 }, 144 receive: function(e, ui) {145 var sender = $(ui.sender);146 183 147 if ( ! $(this).is(':visible') || this.id.indexOf('orphaned_widgets') > -1 ) { 148 sender.sortable('cancel'); 184 over: function( event, ui ) { 185 var $wrap = $(this).parent(); 186 187 if ( $wrap.hasClass('closed') ) { 188 $wrap.addClass('widget-hover'); 149 189 } 190 }, 150 191 151 if ( sender.attr('id').indexOf('orphaned_widgets') > -1 && !sender.children('.widget').length ) { 152 sender.parents('.orphan-sidebar').slideUp(400, function(){ $(this).remove(); }); 192 out: function( event, ui ) { 193 $(this).parent().removeClass('widget-hover'); 194 }, 195 196 activate: function( event, ui ) { 197 // Lock all sidebars min-height when starting to drag. 198 // Prevents jumping when dragging a widget from an open sidebar to a closed sidebar below. 199 $(this).css( 'min-height', $(this).height() + 'px' ); 200 }, 201 202 deactivate: function( event, ui ) { 203 $(this).css( 'min-height', '' ); 204 }, 205 206 receive: function( event, ui ) { 207 var $sender = $( ui.sender ); 208 209 // Don't add more widgets to orphaned sidebars 210 if ( this.id.indexOf('orphaned_widgets') > -1 ) { 211 $sender.sortable('cancel'); 212 return; 153 213 } 214 215 // If the last widget was moved out of an orphaned sidebar, close and remove it. 216 if ( $sender.attr('id').indexOf('orphaned_widgets') > -1 && ! $sender.children('.widget').length ) { 217 $sender.parents('.orphan-sidebar').slideUp( 400, function(){ $(this).remove(); } ); 218 } 154 219 } 155 }).sortable( 'option', 'connectWith', 'div.widgets-sortables');220 }).sortable( 'option', 'connectWith', 'div.widgets-sortables' ); 156 221 157 222 $('#available-widgets').droppable({ 158 223 tolerance: 'pointer', … … 195 260 }); 196 261 197 262 $( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() { 198 var widget = $(this).closest( '.widget' );263 var $widget = $(this).closest( '.widget' ); 199 264 200 if ( widget.hasClass( 'widget-in-question' ) || ( $( '#widgets-left' ).hasClass( 'chooser' )) ) {265 if ( $widget.hasClass( 'widget-in-question' ) || $( '#widgets-left' ).hasClass( 'chooser' ) ) { 201 266 self.closeChooser(); 202 267 } else { 203 268 // Open the chooser 204 269 self.clearWidgetSelection(); 205 270 $( '#widgets-left' ).addClass( 'chooser' ); 206 widget.addClass( 'widget-in-question' ).draggable('disable'); 271 $widget.addClass( 'widget-in-question' ).draggable('disable'); 272 $widget.find( '.widget-description' ).after( chooser ); 207 273 208 widget.find( '.widget-description' ).after( chooser );209 274 chooser.slideDown( 300, function() { 210 275 selectSidebar.find('.widgets-chooser-selected').focus(); 211 276 }); … … 242 307 }); 243 308 }, 244 309 245 saveOrder : function(sb) { 246 if ( sb ) { 247 $('#' + sb).closest('div.widgets-holder-wrap').find('.spinner:first').css('display', 'inline-block'); 248 } 249 250 var a = { 310 saveOrder : function( sidebarId ) { 311 var data = { 251 312 action: 'widgets-order', 252 313 savewidgets: $('#_wpnonce_widgets').val(), 253 314 sidebars: [] 254 315 }; 255 316 317 if ( sidebarId ) { 318 $( '#' + sidebarId ).find('.spinner:first').css('display', 'inline-block'); 319 } 320 256 321 $('div.widgets-sortables').each( function() { 257 322 if ( $(this).sortable ) { 258 a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');323 data['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(','); 259 324 } 260 325 }); 261 326 262 $.post( ajaxurl, a, function() {327 $.post( ajaxurl, data, function() { 263 328 $('.spinner').hide(); 264 329 }); 265 330 }, 266 331 267 save : function(widget, del, animate, order) { 268 var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a; 332 save : function( widget, del, animate, order ) { 333 var sidebarId = widget.closest('div.widgets-sortables').attr('id'), 334 data = widget.find('form').serialize(), a; 335 269 336 widget = $(widget); 270 337 $('.spinner', widget).show(); 271 338 272 339 a = { 273 340 action: 'save-widget', 274 341 savewidgets: $('#_wpnonce_widgets').val(), 275 sidebar: s b342 sidebar: sidebarId 276 343 }; 277 344 278 345 if ( del ) { … … 281 348 282 349 data += '&' + $.param(a); 283 350 284 $.post( ajaxurl, data, function(r) {351 $.post( ajaxurl, data, function(r) { 285 352 var id; 286 353 287 354 if ( del ) { … … 306 373 } else { 307 374 $('.spinner').hide(); 308 375 if ( r && r.length > 2 ) { 309 $( 'div.widget-content', widget).html(r);310 wpWidgets.appendTitle( widget);376 $( 'div.widget-content', widget ).html(r); 377 wpWidgets.appendTitle( widget ); 311 378 } 312 379 } 313 380 if ( order ) { … … 364 431 365 432 // Open the widgets container 366 433 sidebar.closest( '.widgets-holder-wrap' ).removeClass('closed'); 434 435 sidebar.find('.sidebar-description').after( widget ); 367 436 sidebar.sortable('refresh'); 368 437 369 widget.prependTo( sidebar );370 371 438 wpWidgets.save( widget, 0, 0, 1 ); 372 439 // No longer "new" widget 373 440 widget.find( 'input.add_new' ).val(''); … … 389 456 $( '#widgets-chooser' ).slideUp( 200, function() { 390 457 $( '#wpbody-content' ).append( this ); 391 458 $( '#widgets-left .widget-in-question' ).draggable('enable'); 459 $( '#widgets-left .widget-in-question' ).draggable('enable'); 392 460 self.clearWidgetSelection(); 393 461 }); 394 462 }, -
src/wp-admin/widgets.php
332 332 <div id="widgets-left"> 333 333 <div id="available-widgets" class="widgets-holder-wrap"> 334 334 <div class="sidebar-name"> 335 <div class="sidebar-name-arrow"><br /></div> 336 <h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3></div> 335 <div class="sidebar-name-arrow"><br /></div> 336 <h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3> 337 </div> 337 338 <div class="widget-holder"> 338 <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> 339 <div id="widget-list"> 340 <?php wp_list_widgets(); ?> 339 <div class="sidebar-description"> 340 <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> 341 </div> 342 <div id="widget-list"> 343 <?php wp_list_widgets(); ?> 344 </div> 345 <br class='clear' /> 341 346 </div> 342 <br class='clear' />343 </div>344 347 <br class="clear" /> 345 348 </div> 346 349 … … 355 358 356 359 ?> 357 360 <div class="<?php echo esc_attr( $wrap_class ); ?>"> 358 <div class="sidebar-name">359 <div class="sidebar-name-arrow"><br /></div>360 <h3><?php echo esc_html( $registered_sidebar['name'] ); ?> <span class="spinner"></span></h3>361 </div>362 361 <div class="widget-holder inactive"> 363 <?php wp_list_widget_controls( $registered_sidebar['id'] ); ?>362 <?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?> 364 363 <div class="clear"></div> 365 364 </div> 366 365 </div> 367 366 <?php 367 368 368 } else { 369 369 $theme_sidebars[$sidebar] = $registered_sidebar; 370 370 } … … 407 407 408 408 ?> 409 409 <div class="<?php echo esc_attr( $wrap_class ); ?>"> 410 <div class="sidebar-name"> 411 <div class="sidebar-name-arrow"><br /></div> 412 <h3><?php echo esc_html( $registered_sidebar['name'] ); ?> <span class="spinner"></span></h3> 413 </div> 414 <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?> 410 <?php wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); // Show the control forms for each of the widgets in this sidebar ?> 415 411 </div> 416 412 <?php 417 413