Ticket #47131: 47131.4.patch
| File 47131.4.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 }, 1323 1324 /** 1325 * Disable sortables if there is only one metabox, or the screen is in one column mode. Otherwise, enable sortables. 1326 * 1327 * @since 5.3.0 1328 * 1329 * @returns {void} 1330 */ 1331 maybeDisableSortables: function() { 1332 var width = navigator.userAgent.indexOf('AppleWebKit/') > -1 ? $window.width() : window.innerWidth; 1324 1333 1334 if ( 1335 ( width <= 782 ) || 1336 ( 1 >= $sortables.find( 'h2:visible' ).length && jQuery( '.columns-prefs-1 input' ).prop( 'checked' ) ) 1337 ) { 1338 this.disableSortables(); 1339 } else { 1340 this.enableSortables(); 1341 } 1342 }, 1343 1325 1344 /** 1326 1345 * Changes properties of body and admin menu. 1327 1346 * … … 1356 1375 deactivate: function() { 1357 1376 setPinMenu(); 1358 1377 $adminmenu.removeData('wp-responsive'); 1359 this.enableSortables(); 1378 1379 this.maybeDisableSortables(); 1360 1380 }, 1361 1381 1362 1382 /** … … 1391 1411 } else { 1392 1412 this.disableOverlay(); 1393 1413 } 1414 1415 this.maybeDisableSortables(); 1394 1416 }, 1395 1417 1396 1418 /** … … 1439 1461 if ( $sortables.length ) { 1440 1462 try { 1441 1463 $sortables.sortable( 'disable' ); 1464 $sortables.find( 'h2' ).css( 'cursor', 'auto' ); 1442 1465 } catch ( e ) {} 1443 1466 } 1444 1467 }, … … 1454 1477 if ( $sortables.length ) { 1455 1478 try { 1456 1479 $sortables.sortable( 'enable' ); 1480 $sortables.find( 'h2' ).css( 'cursor', 'move' ); 1457 1481 } catch ( e ) {} 1458 1482 } 1459 1483 }