Ticket #47131: 47131.3.patch
| File 47131.3.patch, 2.5 KB (added by , 7 years ago) |
|---|
-
src/js/_enqueues/admin/common.js
1274 1274 init: function() { 1275 1275 var self = this; 1276 1276 1277 this.maybeDisableSortables = this.maybeDisableSortables.bind( this ); 1278 1277 1279 // Modify functionality based on custom activate/deactivate event 1278 1280 $document.on( 'wp-responsive-activate.wp-responsive', function() { 1279 1281 self.activate(); … … 1313 1315 $document.on( 'wp-window-resized.wp-responsive', $.proxy( this.trigger, this ) ); 1314 1316 1315 1317 // This needs to run later as UI Sortable may be initialized later on $(document).ready(). 1316 $window.on( 'load.wp-responsive', function() { 1317 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; 1318 $window.on( 'load.wp-responsive', this.maybeDisableSortables ); 1318 1319 1319 if ( width <= 782 ) { 1320 self.disableSortables(); 1321 } 1322 }); 1320 // When the screen columns are changed, potentially disable sortables. 1321 $( '#screen-options-wrap input' ).on( 'click', this.maybeDisableSortables ); 1323 1322 }, 1324 1323 1325 1324 /** 1325 * Disable sortables if there is only one metabox, and the screen is in one column mode. Otherwise, enable sortables. 1326 */ 1327 maybeDisableSortables: function() { 1328 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; 1329 1330 if ( 1331 ( width <= 782 ) || 1332 ( 1 >= $sortables.find( 'h2:visible' ).length && jQuery( '.columns-prefs-1 input' ).prop( 'checked' ) ) 1333 ) { 1334 this.disableSortables(); 1335 } else { 1336 this.enableSortables(); 1337 } 1338 }, 1339 1340 /** 1326 1341 * Changes properties of body and admin menu. 1327 1342 * 1328 1343 * Pins and unpins the menu and adds the auto-fold class to the body. … … 1356 1371 deactivate: function() { 1357 1372 setPinMenu(); 1358 1373 $adminmenu.removeData('wp-responsive'); 1359 this.enableSortables(); 1374 1375 this.maybeDisableSortables(); 1360 1376 }, 1361 1377 1362 1378 /** … … 1391 1407 } else { 1392 1408 this.disableOverlay(); 1393 1409 } 1410 1411 this.maybeDisableSortables(); 1394 1412 }, 1395 1413 1396 1414 /** … … 1439 1457 if ( $sortables.length ) { 1440 1458 try { 1441 1459 $sortables.sortable( 'disable' ); 1460 $sortables.find( 'h2' ).css( 'cursor', 'auto' ); 1442 1461 } catch ( e ) {} 1443 1462 } 1444 1463 }, … … 1454 1473 if ( $sortables.length ) { 1455 1474 try { 1456 1475 $sortables.sortable( 'enable' ); 1476 $sortables.find( 'h2' ).css( 'cursor', 'move' ); 1457 1477 } catch ( e ) {} 1458 1478 } 1459 1479 }