Ticket #25952: 25952.3.diff
File 25952.3.diff, 4.4 KB (added by , 11 years ago) |
---|
-
src/wp-admin/css/wp-admin.css
10314 10314 margin: 10px 0 0 0; 10315 10315 } 10316 10316 10317 /* Dropping a widget over a closed sidebar */ 10318 div#widgets-right .widgets-holder-wrap.was-closed { 10319 box-shadow: 0 0 3px 2px rgba(16, 117, 160, 0.9); 10320 } 10321 div#widgets-right .widgets-holder-wrap.ui-sidebar-droppable .sidebar-description, 10322 div#widgets-right .widgets-holder-wrap.ui-sidebar-droppable .widgets-sortables { 10323 opacity: 0.3; 10324 } 10325 10317 10326 div#widgets-right .widget { 10318 10327 margin: 0 auto; 10319 10328 border: 1px solid #dedede !important; /* ln 991 in colors-fresh.css */ … … 12804 12813 #wpadminbar #wp-admin-bar-wp-logo { 12805 12814 display: none; 12806 12815 } 12807 } 12808 No newline at end of file 12816 } -
src/wp-admin/js/widgets.js
85 85 zIndex: 100, 86 86 containment: 'document', 87 87 start: function(e,ui) { 88 // Mark the widget that is dragged. Needed as a workaround for dropping on a closed sidebar. 89 $(this).addClass('widget-in-question'); 90 88 91 ui.helper.find('div.widget-description').hide(); 89 92 the_id = this.id; 90 93 }, 91 94 stop: function() { 95 $(this).removeClass('widget-in-question'); 96 92 97 if ( rem ) 93 98 $(rem).hide(); 94 99 … … 178 183 } 179 184 }); 180 185 186 // Open the sidebar (the sortable container) when dragging a widget over its title 187 $('#widgets-right .widgets-holder-wrap').droppable({ 188 accept: '.widget', 189 tolerance: 'pointer', 190 over: function( event, ui ) { 191 var sidebarWrap = $(this); 192 193 if ( sidebarWrap.hasClass( 'closed' ) ) { 194 sidebarWrap.addClass( 'was-closed' ); 195 196 // Spring-loaded sidebars 197 //window.sidebar_spring = setTimeout( function() { 198 // sidebarWrap.removeClass( 'closed' ); 199 //}, 1200 ); 200 } 201 }, 202 out: function() { 203 var sidebarWrap = $(this); 204 //clearTimeout( window.sidebar_spring ); 205 if ( sidebarWrap.hasClass( 'was-closed' ) ) { 206 sidebarWrap.addClass( 'closed' ).removeClass( 'was-closed' ); 207 } 208 }, 209 drop: function( event, ui ) { 210 var sidebarWrap = $(this); 211 212 if ( sidebarWrap.hasClass( 'was-closed' ) ) { 213 sidebarWrap.removeClass( 'was-closed' ); 214 215 // Prepend the widget and save position 216 self.addWidget( sidebarWrap.children('.widgets-sortables').attr('id') ); 217 self.clearWidgetSelection(); 218 } 219 } 220 }); 221 181 222 // Area Chooser 182 223 $( '#widgets-right .widgets-holder-wrap' ).each( function( index, element ) { 183 224 var $element = $( element ), … … 216 257 var $target = $( event.target ); 217 258 218 259 if ( $target.hasClass('button-primary') ) { 219 self.addWidget( chooser );260 self.addWidget( chooser.find( '.widgets-chooser-selected' ).data('sidebarId') ); 220 261 self.closeChooser(); 221 262 } else if ( $target.hasClass('button-secondary') ) { 222 263 self.closeChooser(); … … 336 377 }); 337 378 }, 338 379 339 addWidget: function( chooser ) { 340 var widget = $('#available-widgets').find('.widget-in-question').clone(), 380 addWidget: function( sidebarId ) { 381 var top, 382 widget = $('#available-widgets').find('.widget-in-question').clone(), 341 383 widgetId = widget.attr('id'), 342 384 add = widget.find( 'input.add_new' ).val(), 343 385 n = widget.find( 'input.multi_number' ).val(), 344 sidebarId = chooser.find( '.widgets-chooser-selected' ).data('sidebarId'),345 386 sidebar = $( '#' + sidebarId ); 346 387 347 388 if ( 'multi' === add ) { … … 369 410 // No longer "new" widget 370 411 widget.find( 'input.add_new' ).val(''); 371 412 372 $( 'html, body' ).animate({ 373 scrollTop: sidebar.offset().top - 130 374 }, 200 ); 413 top = sidebar.offset().top; 375 414 415 if ( top && top - 130 > 0 ) { 416 $( 'html, body' ).animate({ 417 scrollTop: ( top - 130 ) 418 }, 200 ); 419 } 420 376 421 window.setTimeout( function() { 377 // Cannot use a callback in the animation above as it fires twice,378 // have to queue this "by hand".379 422 widget.find( '.widget-title' ).trigger('click'); 380 423 }, 250 ); 381 424 }, … … 391 434 392 435 clearWidgetSelection: function() { 393 436 $( '#widgets-left' ).removeClass( 'chooser' ); 394 $( ' #available-widgets' ).find( '.widget-in-question' ).removeClass( 'widget-in-question' );437 $( '.widget-in-question' ).removeClass( 'widget-in-question' ); 395 438 } 396 439 }; 397 440