Changeset 33014
- Timestamp:
- 07/01/2015 12:57:03 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets.js
r32689 r33014 5 5 6 6 wpWidgets = { 7 /** 8 * A closed Sidebar that gets a Widget dragged over it. 9 * 10 * @var element|null 11 */ 12 hoveredSidebar: null, 7 13 8 14 init : function() { … … 95 101 zIndex: 100, 96 102 containment: '#wpwrap', 103 refreshPositions: true, 97 104 start: function( event, ui ) { 98 105 var chooser = $(this).find('.widgets-chooser'); … … 117 124 } 118 125 }); 126 127 /** 128 * Opens and closes previously closed Sidebars when Widgets are dragged over/out of them. 129 */ 130 sidebars.droppable( { 131 tolerance: 'pointer', 132 133 /** 134 * Open Sidebar when a Widget gets dragged over it. 135 * 136 * @param event 137 */ 138 over: function( event ) { 139 var $wrap = $( event.target ).parent(); 140 141 if ( wpWidgets.hoveredSidebar && ! $wrap.is( wpWidgets.hoveredSidebar ) ) { 142 // Close the previous Sidebar as the Widget has been dragged onto another Sidebar. 143 wpWidgets.closeSidebar( event ); 144 } 145 146 if ( $wrap.hasClass( 'closed' ) ) { 147 wpWidgets.hoveredSidebar = $wrap; 148 $wrap.removeClass( 'closed' ); 149 } 150 }, 151 152 /** 153 * Close Sidebar when the Widget gets dragged out of it. 154 * 155 * @param event 156 */ 157 out: function( event ) { 158 if ( wpWidgets.hoveredSidebar ) { 159 wpWidgets.closeSidebar( event ); 160 } 161 } 162 } ); 119 163 120 164 sidebars.sortable({ … … 149 193 id = the_id; 150 194 195 // Reset the var to hold a previously closed sidebar. 196 wpWidgets.hoveredSidebar = null; 197 151 198 if ( $widget.hasClass('deleting') ) { 152 199 wpWidgets.save( $widget, 1, 0, 1 ); // delete widget … … 492 539 $( '#widgets-left' ).removeClass( 'chooser' ); 493 540 $( '.widget-in-question' ).removeClass( 'widget-in-question' ); 541 }, 542 543 /** 544 * Closes a Sidebar that was previously closed, but opened by dragging a Widget over it. 545 * 546 * Used when a Widget gets dragged in/out of the Sidebar and never dropped. 547 * 548 * @param sidebar 549 */ 550 closeSidebar: function( sidebar ) { 551 this.hoveredSidebar.addClass( 'closed' ); 552 $( sidebar.target ).css( 'min-height', '' ); 553 this.hoveredSidebar = null; 494 554 } 495 555 };
Note: See TracChangeset
for help on using the changeset viewer.