Ticket #25952: 25952.8.patch
File 25952.8.patch, 17.9 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/wp-admin.css
9980 9980 } 9981 9981 9982 9982 9983 /* General Widget Styles */9983 /* General Widgets Styles */ 9984 9984 9985 9985 .widget { 9986 margin: 10px auto; 9987 /* min-width: 50%; Not sure if this is needed */ 9986 margin: 0 auto 10px; 9988 9987 position: relative; 9989 9988 box-sizing: border-box; 9990 -moz-box-sizing: border-box;9991 -webkit-box-sizing: border-box;9989 -moz-box-sizing: border-box; 9990 -webkit-box-sizing: border-box; 9992 9991 } 9993 9992 9994 9993 .widget-top { … … 10021 10020 } 10022 10021 10023 10022 /* Widget Dragging Helpers */ 10024 10025 10023 .widget.ui-draggable-dragging { 10026 width: 280px !important; 10027 min-width: 280px !important; 10024 width: 100%; 10028 10025 } 10029 10026 10030 10027 .widget.ui-sortable-helper { … … 10034 10031 10035 10032 .widget-placeholder { 10036 10033 border: 1px dashed #bbb; 10037 margin: 10px 0;10034 margin: 0 auto 10px; 10038 10035 height: 45px; 10039 10036 width: 100%; 10040 10037 -webkit-box-sizing: border-box; … … 10046 10043 margin-top: 0; 10047 10044 } 10048 10045 10046 /* Override UI Sortable and Draggable inline style */ 10047 #widgets-right .closed .widget-placeholder { 10048 height: 0; 10049 border: 0; 10050 margin-top: -10px; 10051 } 10052 10049 10053 /* Widget Sidebars */ 10050 10054 .sidebar-name { 10051 10055 border: none; … … 10074 10078 } 10075 10079 10076 10080 .widgets-holder-wrap .description { 10077 padding: 0 ;10081 padding: 0 0 15px; 10078 10082 margin: 0; 10079 10083 font-style: normal; 10080 10084 color: #777; 10081 10085 } 10082 10086 10083 #available-widgets.widgets-holder-wrap .description { 10084 padding-bottom: 10px; 10087 #widgets-right .widgets-holder-wrap .description { 10088 padding-left: 15px; 10089 padding-right: 15px; 10085 10090 } 10086 10091 10087 10092 /* Widgets 2-col Layout */ … … 10141 10146 font-size: 12px; 10142 10147 } 10143 10148 10149 #available-widgets #widget-list { 10150 position: relative; 10151 } 10152 10144 10153 /* Inactive Sidebars */ 10145 10154 #widgets-left .inactive-sidebar { 10146 10155 clear: both; … … 10195 10204 margin: 10px 0 0 0; 10196 10205 } 10197 10206 10198 div#widgets-right .widget {10199 margin: 0 auto;10200 margin-bottom: 10px;10201 }10202 10203 10207 div#widgets-right .sidebar-description { 10204 border-top: 1px solid #eeeeee;10205 padding: 10px 15px;10208 min-height: 20px; 10209 margin-top: -5px; 10206 10210 } 10207 10211 10208 div#widgets-right .closed .sidebar-description {10209 display: none;10210 }10211 10212 10212 div#widgets-right .sidebar-name h3 { 10213 padding: 15px 15px;10213 padding: 15px; 10214 10214 } 10215 10215 10216 10216 div#widgets-right .sidebar-name .sidebar-name-arrow:before { … … 10226 10226 padding: 0 8px; 10227 10227 margin-bottom: 9px; 10228 10228 position: relative; 10229 min-height: 50px;10229 min-height: 140px; 10230 10230 } 10231 10231 10232 div#widgets-right .closed .widgets-sortables { 10233 min-height: 0; 10234 margin-bottom: 0; 10235 } 10236 10232 10237 .sidebar-name .spinner { 10233 10238 margin: -5px 5px; 10234 10239 float: none; 10235 10240 } 10236 10241 10242 /* Dragging a widget over a closed sidebar */ 10243 #widgets-right .widgets-holder-wrap.closed.widget-hover { 10244 border-color: #777; 10245 box-shadow: 0 1px 2px rgba(0,0,0,0.3); 10246 opacity: 0.6; 10247 } 10248 10237 10249 /* Accessibility Mode */ 10238 10250 #available-widgets .widget-control-edit .edit { 10239 10251 display :none; 10240 10252 } 10253 10241 10254 #available-widgets .widget-control-edit .add { 10242 10255 display: block; 10243 10256 position: absolute; … … 10256 10269 padding: 16px 15px; 10257 10270 border-left: 1px solid #DDD; 10258 10271 } 10272 10259 10273 #widgets-right .widget-control-edit .add { 10260 10274 display: none; 10261 10275 } 10276 10262 10277 #widgets-right .widget-control-edit:hover { 10263 10278 background: #444; 10264 10279 } 10280 10265 10281 #widgets-right .widget-control-edit:before { 10266 10282 content: '\f111'; 10267 10283 display: inline-block; … … 10274 10290 padding-right: 4px; 10275 10291 } 10276 10292 10293 .widgets-holder-wrap .sidebar-name, 10294 .widgets-holder-wrap .sidebar-description { 10295 -webkit-user-select: none; 10296 -moz-user-select: none; 10297 user-select: none; 10298 } 10299 10277 10300 .editwidget { 10278 10301 margin: 0 auto; 10279 10302 } … … 10281 10304 margin-top: 20px; 10282 10305 } 10283 10306 10284 .js . closed .widgets-sortables,10285 .js . closed .widget-holder,10307 .js .widgets-holder-wrap.closed .widget, 10308 .js .widgets-holder-wrap.closed .sidebar-description, 10286 10309 .js .closed br.clear { 10287 10310 display: none; 10288 10311 } 10312 10289 10313 .nav-menus-php .item-edit:before, 10290 10314 .widget-top a.widget-action:after, 10291 10315 .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 … … 112 116 cursor: 'move', 113 117 distance: 2, 114 118 containment: 'document', 115 start: function(e,ui) { 116 var inside = ui.item.children('.widget-inside'); 119 start: function( event, ui ) { 120 var inside = ui.item.children('.widget-inside'), 121 $wrap = $(this).parent(); 117 122 118 123 if ( inside.css('display') === 'block' ) { 119 124 inside.hide(); 120 125 $(this).sortable('refreshPositions'); 121 126 } 127 128 // There is a bug in UI Sortable that prevents firing of "over" when dragging a connected Draggable. 129 // This won't be needed when the bug is fixed. 130 if ( $wrap.hasClass('closed') ) { 131 $wrap.addClass('widget-hover'); 132 } 122 133 }, 123 stop: function(e,ui) {124 if ( ui.item.hasClass('ui-draggable') && ui.item.data('draggable') ) {125 ui.item.draggable('destroy');126 }127 134 128 if ( ui.item.hasClass('deleting') ) { 129 wpWidgets.save( ui.item, 1, 0, 1 ); // delete widget 130 ui.item.remove(); 135 stop: function( event, ui ) { 136 var addNew, widgetNumber, $sidebar, $children, child, item, 137 $widget = ui.item, 138 id = the_id; 139 140 if ( $widget.hasClass('deleting') ) { 141 wpWidgets.save( $widget, 1, 0, 1 ); // delete widget 142 $widget.remove(); 131 143 return; 132 144 } 133 145 134 var add = ui.item.find('input.add_new').val(), 135 n = ui.item.find('input.multi_number').val(), 136 id = the_id, 137 sb = $(this).attr('id'); 146 addNew = $widget.find('input.add_new').val(); 147 widgetNumber = $widget.find('input.multi_number').val(); 138 148 139 ui.item.attr( 'style', '' );149 $widget.attr( 'style', '' ); 140 150 the_id = ''; 141 151 142 if ( add ) { 143 if ( 'multi' === add ) { 144 ui.item.html( ui.item.html().replace(/<[^<>]+>/g, function(m){ return m.replace(/__i__|%i%/g, n); }) ); 145 ui.item.attr( 'id', id.replace('__i__', n) ); 146 n++; 147 $('div#' + id).find('input.multi_number').val(n); 148 } else if ( 'single' === add ) { 149 ui.item.attr( 'id', 'new-' + id ); 152 if ( addNew ) { 153 if ( 'multi' === addNew ) { 154 $widget.html( 155 $widget.html().replace( /<[^<>]+>/g, function( tag ) { 156 return tag.replace( /__i__|%i%/g, widgetNumber ); 157 }) 158 ); 159 160 $widget.attr( 'id', id.replace( '__i__', widgetNumber ) ); 161 widgetNumber++; 162 163 $( 'div#' + id ).find( 'input.multi_number' ).val( widgetNumber ); 164 } else if ( 'single' === addNew ) { 165 $widget.attr( 'id', 'new-' + id ); 150 166 rem = 'div#' + id; 151 167 } 152 wpWidgets.save( ui.item, 0, 0, 1 ); 153 ui.item.find('input.add_new').val(''); 154 ui.item.find('a.widget-action').click(); 155 return; 168 169 wpWidgets.save( $widget, 0, 0, 1 ); 170 $widget.find('input.add_new').val(''); 156 171 } 157 wpWidgets.saveOrder(sb); 172 173 $sidebar = $widget.parent(); 174 175 if ( $sidebar.parent().hasClass('closed') ) { 176 $sidebar.parent().removeClass('widget-hover closed jump-open'); 177 $children = $sidebar.children('.widget'); 178 179 // Make sure the dropped widget is at the top 180 if ( $children.length > 1 ) { 181 child = $children.get(0); 182 item = $widget.get(0); 183 184 if ( child.id && item.id && child.id !== item.id ) { 185 $( child ).before( $widget ); 186 } 187 } 188 } 189 190 if ( addNew ) { 191 $widget.find( 'a.widget-action' ).trigger('click'); 192 } else { 193 wpWidgets.saveOrder( $sidebar.attr('id') ); 194 } 158 195 }, 159 receive: function(e, ui) {160 var sender = $(ui.sender);161 196 162 if ( ! $(this).is(':visible') || this.id.indexOf('orphaned_widgets') > -1 ) { 163 sender.sortable('cancel'); 197 over: function( event, ui ) { 198 var $wrap = $(this).parent(); 199 200 if ( $wrap.hasClass('closed') ) { 201 $wrap.addClass('widget-hover'); 164 202 } 203 }, 165 204 166 if ( sender.attr('id').indexOf('orphaned_widgets') > -1 && !sender.children('.widget').length ) { 167 sender.parents('.orphan-sidebar').slideUp(400, function(){ $(this).remove(); }); 205 out: function( event, ui ) { 206 $(this).parent().removeClass('widget-hover'); 207 }, 208 209 activate: function( event, ui ) { 210 // Lock all sidebars min-height when starting to drag. 211 // Prevents jumping when dragging a widget from an open sidebar to a closed sidebar below. 212 $(this).css( 'min-height', $(this).height() + 'px' ); 213 }, 214 215 deactivate: function( event, ui ) { 216 $(this).css( 'min-height', '' ); 217 }, 218 219 receive: function( event, ui ) { 220 var $sender = $( ui.sender ); 221 222 // Don't add more widgets to orphaned sidebars 223 if ( this.id.indexOf('orphaned_widgets') > -1 ) { 224 $sender.sortable('cancel'); 225 return; 168 226 } 227 228 // If the last widget was moved out of an orphaned sidebar, close and remove it. 229 if ( $sender.attr('id').indexOf('orphaned_widgets') > -1 && ! $sender.children('.widget').length ) { 230 $sender.parents('.orphan-sidebar').slideUp( 400, function(){ $(this).remove(); } ); 231 } 169 232 } 170 }).sortable( 'option', 'connectWith', 'div.widgets-sortables');233 }).sortable( 'option', 'connectWith', 'div.widgets-sortables' ); 171 234 172 235 $('#available-widgets').droppable({ 173 236 tolerance: 'pointer', … … 210 273 }); 211 274 212 275 $( '#available-widgets .widget .widget-title' ).on( 'click.widgets-chooser', function() { 213 var widget = $(this).closest( '.widget' );276 var $widget = $(this).closest( '.widget' ); 214 277 215 if ( widget.hasClass( 'widget-in-question' ) || ( $( '#widgets-left' ).hasClass( 'chooser' )) ) {278 if ( $widget.hasClass( 'widget-in-question' ) || $( '#widgets-left' ).hasClass( 'chooser' ) ) { 216 279 self.closeChooser(); 217 280 } else { 218 281 // Open the chooser 219 282 self.clearWidgetSelection(); 220 283 $( '#widgets-left' ).addClass( 'chooser' ); 221 widget.addClass( 'widget-in-question');284 $widget.addClass( 'widget-in-question' ).children( '.widget-description' ).after( chooser ); 222 285 223 widget.find( '.widget-description' ).after( chooser );224 286 chooser.slideDown( 300, function() { 225 287 selectSidebar.find('.widgets-chooser-selected').focus(); 226 288 }); … … 257 319 }); 258 320 }, 259 321 260 saveOrder : function(sb) { 261 if ( sb ) { 262 $('#' + sb).closest('div.widgets-holder-wrap').find('.spinner:first').css('display', 'inline-block'); 263 } 264 265 var a = { 322 saveOrder : function( sidebarId ) { 323 var data = { 266 324 action: 'widgets-order', 267 325 savewidgets: $('#_wpnonce_widgets').val(), 268 326 sidebars: [] 269 327 }; 270 328 329 if ( sidebarId ) { 330 $( '#' + sidebarId ).find('.spinner:first').css('display', 'inline-block'); 331 } 332 271 333 $('div.widgets-sortables').each( function() { 272 334 if ( $(this).sortable ) { 273 a['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(',');335 data['sidebars[' + $(this).attr('id') + ']'] = $(this).sortable('toArray').join(','); 274 336 } 275 337 }); 276 338 277 $.post( ajaxurl, a, function() {339 $.post( ajaxurl, data, function() { 278 340 $('.spinner').hide(); 279 341 }); 280 342 }, 281 343 282 save : function(widget, del, animate, order) { 283 var sb = widget.closest('div.widgets-sortables').attr('id'), data = widget.find('form').serialize(), a; 344 save : function( widget, del, animate, order ) { 345 var sidebarId = widget.closest('div.widgets-sortables').attr('id'), 346 data = widget.find('form').serialize(), a; 347 284 348 widget = $(widget); 285 349 $('.spinner', widget).show(); 286 350 … … 287 351 a = { 288 352 action: 'save-widget', 289 353 savewidgets: $('#_wpnonce_widgets').val(), 290 sidebar: s b354 sidebar: sidebarId 291 355 }; 292 356 293 357 if ( del ) { … … 296 360 297 361 data += '&' + $.param(a); 298 362 299 $.post( ajaxurl, data, function(r) {363 $.post( ajaxurl, data, function(r) { 300 364 var id; 301 365 302 366 if ( del ) { … … 321 385 } else { 322 386 $('.spinner').hide(); 323 387 if ( r && r.length > 2 ) { 324 $( 'div.widget-content', widget).html(r);325 wpWidgets.appendTitle( widget);388 $( 'div.widget-content', widget ).html(r); 389 wpWidgets.appendTitle( widget ); 326 390 } 327 391 } 328 392 if ( order ) { … … 379 443 380 444 // Open the widgets container 381 445 sidebar.closest( '.widgets-holder-wrap' ).removeClass('closed'); 446 447 sidebar.find('.sidebar-description').after( widget ); 382 448 sidebar.sortable('refresh'); 383 449 384 widget.prependTo( sidebar );385 386 450 wpWidgets.save( widget, 0, 0, 1 ); 387 451 // No longer "new" widget 388 452 widget.find( 'input.add_new' ).val(''); -
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