Ticket #34391: 34391_1.patch
| File 34391_1.patch, 103.2 KB (added by , 10 years ago) |
|---|
-
src/wp-admin/css/customize-controls.css
From 21273f97bb893e32c232681f717e6d6c12737cbe Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Sat, 6 Feb 2016 16:02:02 +0100 Subject: [PATCH 1/9] Tac-34391 - Under development, so far a dirty solution --- src/wp-admin/css/customize-controls.css | 109 +++++++++++-- src/wp-admin/customize.php | 2 +- src/wp-admin/js/customize-controls.js | 263 ++++++++++++++++++++++---------- 3 files changed, 277 insertions(+), 97 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index ced9735..db7e561 100644
a b body { 217 217 box-sizing: border-box; 218 218 } 219 219 220 221 222 223 #customize-info, 224 #customize-theme-controls .customize-pane-parent, 225 #customize-theme-controls .customize-pane-child { 226 width: 100%; 227 margin: 0; 228 padding: 0; 229 -webkit-box-sizing: border-box; 230 -moz-box-sizing: border-box; 231 box-sizing: border-box; 232 233 transition: 0.36s transform cubic-bezier(0.19, 1, 0.22, 1); 234 /*visibility: visible !important;*/ 235 overflow: visible !important; 236 } 237 238 #customize-info, 239 #customize-theme-controls .customize-pane-parent { 240 position: relative; 241 visibility: visible; 242 transform: translateX(0); 243 } 244 245 .section-open #customize-theme-controls .customize-pane-parent, 246 .in-sub-panel #customize-theme-controls .customize-pane-parent, 247 .section-open #customize-info, 248 .in-sub-panel #customize-info, 249 .in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel { 250 transform: translateX(-100%); 251 /*visibility: hidden;*/ 252 } 253 254 .section-open #customize-theme-controls .customize-pane-parent, 255 .in-sub-panel #customize-theme-controls .customize-pane-parent, 256 .section-open #customize-info, 257 .in-sub-panel #customize-info, 258 .animating.section-open.in-sub-panel #customize-theme-controls .customize-pane-parent, 259 .animating.section-open.in-sub-panel #customize-info, { 260 visibility: hidden; 261 } 262 263 .animating.section-open #customize-theme-controls .customize-pane-parent, 264 .animating.in-sub-panel #customize-theme-controls .customize-pane-parent, 265 .animating.section-open #customize-info, 266 .animating.in-sub-panel #customize-info { 267 visibility: visible; 268 } 269 270 #customize-theme-controls .customize-pane-child { 271 position: absolute; 272 top: 0; 273 left: 0; 274 transform: translateX(100%); 275 visibility: hidden; 276 } 277 278 #customize-theme-controls .customize-pane-child.accordion-section-content, 279 #customize-theme-controls .customize-pane-child.accordion-sub-container { 280 display: block; 281 } 282 283 #customize-theme-controls .customize-pane-child.accordion-section-content { 284 padding: 12px; 285 } 286 287 #customize-theme-controls .customize-pane-child.open, 288 #customize-theme-controls .customize-pane-child.current-panel { 289 transform: translateX(0); 290 } 291 292 #customize-theme-controls .customize-pane-child.open, 293 #customize-theme-controls .customize-pane-child.current-panel, 294 #customize-theme-controls .customize-pane-child.animating { 295 visibility: visible; 296 } 297 298 299 300 220 301 .customize-section-description-container { 221 302 margin-bottom: 15px; 222 303 } … … h3.customize-section-title { 256 337 color: #555; 257 338 } 258 339 259 #customize-theme-controls {340 /*#customize-theme-controls { 260 341 position: relative; 261 342 left: 0; 262 343 -webkit-transition: .18s left ease-in-out; 263 344 transition: .18s left ease-in-out; 264 } 345 }*/ 265 346 266 .ios #customize-theme-controls {347 /*.ios #customize-theme-controls { 267 348 -webkit-transition: left 0s; 268 349 transition: left 0s; 269 } 350 }*/ 270 351 271 .section-open #customize-info,352 /*.section-open #customize-info, 272 353 .section-open #customize-theme-controls { 273 354 left: -100%; 274 } 355 }*/ 275 356 276 357 .accordion-sub-container.control-panel-content { 277 358 display: none; … … h3.customize-section-title { 410 491 padding-left: 62px; 411 492 } 412 493 413 #customize-info,494 /*#customize-info, 414 495 #customize-theme-controls > ul > .accordion-section { 415 496 position: relative; 416 497 left: 0; … … h3.customize-section-title { 423 504 -webkit-transition: left 0s; 424 505 transition: left 0s; 425 506 } 426 427 .in-sub-panel #customize-info,507 */ 508 /*.in-sub-panel #customize-info, 428 509 .in-sub-panel #customize-theme-controls > ul > .accordion-section { 429 510 left: -300px; 430 511 width: 300px; 431 } 512 }*/ 432 513 433 .in-sub-panel #customize-theme-controls .accordion-section.current-panel {514 /*.in-sub-panel #customize-theme-controls .accordion-section.current-panel { 434 515 width: 100%; 435 516 } 436 517 */ 437 518 #customize-theme-controls .control-section.current-panel { 438 519 padding: 0; 439 520 } … … h3.customize-section-title { 459 540 overflow-y: hidden; 460 541 } 461 542 462 .wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open {543 /*.wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open { 463 544 visibility: visible; 464 545 } 465 546 466 547 .wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open .accordion-section-content { 467 548 overflow-y: auto; 468 } 549 }*/ 469 550 470 551 p.customize-section-description { 471 552 font-style: normal; -
src/wp-admin/customize.php
diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php index aa949e5..39b35f3 100644
a b 142 142 </div> 143 143 144 144 <div id="customize-theme-controls"> 145 <ul ><?php // Panels and sections are managed here via JavaScript ?></ul>145 <ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul> 146 146 </div> 147 147 </div> 148 148 </div> -
src/wp-admin/js/customize-controls.js
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index e78d2c9..19f508d 100644
a b 163 163 }; 164 164 165 165 /** 166 * Return browser supported `transitionend` event name 167 * 168 * @since 169 * 170 * @returns {String} 171 */ 172 api.utils.getNormalizedTransitionendEvent = function () { 173 var t, 174 undefined, 175 el = document.createElement( 'div' ), 176 transitions = { 177 'transition' : 'transitionend', 178 'OTransition' : 'oTransitionEnd', 179 'MozTransition' : 'transitionend', 180 'WebkitTransition': 'webkitTransitionEnd' 181 }; 182 183 for ( t in transitions ) { 184 if ( transitions.hasOwnProperty( t ) && undefined !== el.style[ t ] ) { 185 return transitions[t]; 186 } 187 } 188 }; 189 190 /** 166 191 * Base class for Panel and Section. 167 192 * 168 193 * @since 4.1.0 … … 214 239 container.container = $( container.getContainer() ); 215 240 } 216 241 242 container.content = container.getContent(); 243 217 244 container.deferred = { 218 245 embedded: new $.Deferred() 219 246 }; … … 481 508 } 482 509 483 510 return '<li></li>'; 511 }, 512 513 getContent: function () { 514 var container = this, 515 list = container.container.find( 'ul:first' ), 516 contentId = 'sub-accordion-list-' + container.id; 517 518 container.setOwnership( contentId ); 519 520 return list.detach().attr( { 521 id: contentId, 522 class: 'customize-pane-child ' + list.attr( 'class' ) 523 } ); 524 }, 525 526 setOwnership: function ( elementId ) { 527 var container = this.container, 528 ownedElements = container.attr( 'aria-owns' ); 529 530 if ( _.isUndefined( ownedElements ) ) { 531 container.attr( { 532 'aria-owns': elementId 533 } ); 534 } else { 535 container.attr( { 536 'aria-owns': ownedElements + ' ' + elementId 537 } ); 538 } 484 539 } 485 540 }); 486 541 … … 543 598 * @since 4.1.0 544 599 */ 545 600 embed: function () { 546 var section = this, inject; 601 var inject, 602 section = this, 603 container = $( '#customize-theme-controls' ); 547 604 548 605 // Watch for changes to the panel state 549 606 inject = function ( panelId ) { … … 553 610 api.panel( panelId, function ( panel ) { 554 611 // The panel has been registered, wait for it to become ready/initialized 555 612 panel.deferred.embedded.done( function () { 556 parentContainer = panel.cont ainer.find( 'ul:first' );613 parentContainer = panel.content; // panel.container.find( 'ul:first' ); 557 614 if ( ! section.container.parent().is( parentContainer ) ) { 558 615 parentContainer.append( section.container ); 616 //section.setOwnership( section.content.attr( 'id' ) ); 617 container.append( section.content ); 559 618 } 560 619 section.deferred.embedded.resolve(); 561 620 }); 562 621 } ); 563 622 } else { 564 623 // There is no panel, so embed the section in the root of the customizer 565 parentContainer = $( ' #customize-theme-controls' ).children( 'ul' ); // @todo This should be defined elsewhere, and to be configurable624 parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable 566 625 if ( ! section.container.parent().is( parentContainer ) ) { 567 626 parentContainer.append( section.container ); 627 container.append( section.content ); 568 628 } 569 629 section.deferred.embedded.resolve(); 570 630 } … … 586 646 * @since 4.1.0 587 647 */ 588 648 attachEvents: function () { 589 var section = this; 649 var section = this, 650 expandCollapseEventTypes = 'click keydown', 651 expandCollapseEventHandler, 652 overlay = section.content.closest( '.wp-full-overlay' ), 653 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 590 654 591 655 // Expand/Collapse accordion sections on click. 592 section.container.find( '.accordion-section-title, .customize-section-back' ).on( 'click keydown', function( event ) {656 expandCollapseEventHandler = function ( event ) { 593 657 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 594 658 return; 595 659 } … … 600 664 } else { 601 665 section.expand(); 602 666 } 667 }; 668 669 section.container.find( '.accordion-section-title' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 670 section.content.find( '.customize-section-back' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 671 672 section.content.on( normalizedTransitionendEventName, function() { 673 section.content.removeClass( 'animating' ); 674 overlay.removeClass( 'animating' ); 603 675 }); 604 676 }, 605 677 … … 644 716 onChangeExpanded: function ( expanded, args ) { 645 717 var section = this, 646 718 container = section.container.closest( '.wp-full-overlay-sidebar-content' ), 647 content = section.cont ainer.find( '.accordion-section-content' ),719 content = section.content, //section.container.find( '.accordion-section-content' ), 648 720 overlay = section.container.closest( '.wp-full-overlay' ), 649 backBtn = section.container.find( '.customize-section-back' ), 650 sectionTitle = section.container.find( '.accordion-section-title' ).first(), 651 headerActionsHeight = $( '#customize-header-actions' ).height(), 652 resizeContentHeight, expand, position, scroll; 721 backBtn = content.find( '.customize-section-back' ), //section.container.find( '.customize-section-back' ), 722 sectionTitle = content.find( '.accordion-section-title' ).first(), // section.container.find( '.accordion-section-title' ).first(), 723 // headerActionsHeight = $( '#customize-header-actions' ).height(), 724 // resizeContentHeight, 725 expand, position, scroll; 653 726 654 if ( expanded && ! section.container.hasClass( 'open' ) ) { 727 // if ( expanded && ! section.container.hasClass( 'open' ) ) { 728 if ( expanded && ! content.hasClass( 'open' ) ) { 655 729 656 730 if ( args.unchanged ) { 657 731 expand = args.completeCallback; 658 732 } else { 659 733 container.scrollTop( 0 ); 660 resizeContentHeight = function() {661 var matchMedia, offset;662 matchMedia = window.matchMedia || window.msMatchMedia;663 offset = 90; // 45px for customize header actions + 45px for footer actions.664 665 // No footer on small screens.666 if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) {667 offset = 45;668 }669 content.css( 'height', ( window.innerHeight - offset ) );670 };734 // resizeContentHeight = function() { 735 // var matchMedia, offset; 736 // matchMedia = window.matchMedia || window.msMatchMedia; 737 // offset = 90; // 45px for customize header actions + 45px for footer actions. 738 739 // // No footer on small screens. 740 // if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) { 741 // offset = 45; 742 // } 743 // content.css( 'height', ( window.innerHeight - offset ) ); 744 // }; 671 745 expand = function() { 672 section.container.addClass( 'open' ); 746 // section.container.addClass( 'open' ); 747 content.addClass( 'open' ); 748 content.addClass( 'animating' ); 673 749 overlay.addClass( 'section-open' ); 674 position = content.offset().top; 675 scroll = container.scrollTop(); 676 content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); 677 resizeContentHeight(); 750 overlay.addClass( 'animating' ); 751 // position = content.offset().top; 752 // scroll = container.scrollTop(); 753 // content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); 754 // resizeContentHeight(); 678 755 sectionTitle.attr( 'tabindex', '-1' ); 679 756 backBtn.attr( 'tabindex', '0' ); 680 backBtn.focus();757 // backBtn.focus(); 681 758 if ( args.completeCallback ) { 682 759 args.completeCallback(); 683 760 } 684 761 685 762 // Fix the height after browser resize. 686 $( window ).on( 'resize.customizer-section', _.debounce( resizeContentHeight, 100 ) );763 // $( window ).on( 'resize.customizer-section', _.debounce( resizeContentHeight, 100 ) ); 687 764 688 765 section._recalculateTopMargin(); 689 766 }; … … 709 786 expand(); 710 787 } 711 788 712 } else if ( ! expanded && section.container.hasClass( 'open' ) ) { 713 section.container.removeClass( 'open' ); 789 // } else if ( ! expanded && section.container.hasClass( 'open' ) ) { 790 } else if ( ! expanded && content.hasClass( 'open' ) ) { 791 // section.container.removeClass( 'open' ); 792 content.removeClass( 'open' ); 793 content.addClass( 'animating' ); 714 794 overlay.removeClass( 'section-open' ); 715 content.css( 'margin-top', '' ); 716 container.scrollTop( 0 ); 795 overlay.addClass( 'animating' ); 796 // content.css( 'margin-top', '' ); 797 // container.scrollTop( 0 ); 717 798 backBtn.attr( 'tabindex', '-1' ); 718 799 sectionTitle.attr( 'tabindex', '0' ); 719 sectionTitle.focus();800 // sectionTitle.focus(); 720 801 if ( args.completeCallback ) { 721 802 args.completeCallback(); 722 803 } 723 $( window ).off( 'resize.customizer-section' );804 // $( window ).off( 'resize.customizer-section' ); 724 805 } else { 725 806 if ( args.completeCallback ) { 726 807 args.completeCallback(); … … 735 816 * @private 736 817 */ 737 818 _recalculateTopMargin: function() { 738 var section = this, content, offset, headerActionsHeight; 739 content = section.container.find( '.accordion-section-content' ); 740 if ( 0 === content.length ) { 741 return; 742 } 743 headerActionsHeight = $( '#customize-header-actions' ).height(); 744 offset = ( content.offset().top - headerActionsHeight ); 745 if ( 0 < offset ) { 746 content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - offset ) ); 747 } 819 return; 820 // var section = this, content, offset, headerActionsHeight; 821 // content = section.container.find( '.accordion-section-content' ); 822 // if ( 0 === content.length ) { 823 // return; 824 // } 825 // headerActionsHeight = $( '#customize-header-actions' ).height(); 826 // offset = ( content.offset().top - headerActionsHeight ); 827 // if ( 0 < offset ) { 828 // content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - offset ) ); 829 // } 748 830 } 749 831 }); 750 832 … … 982 1064 * @private 983 1065 */ 984 1066 _recalculateTopMargin: function() { 985 api.Panel.prototype._recalculateTopMargin.call( this ); 1067 return; 1068 // api.Panel.prototype._recalculateTopMargin.call( this ); 986 1069 }, 987 1070 988 1071 /** … … 1211 1294 */ 1212 1295 embed: function () { 1213 1296 var panel = this, 1214 parentContainer = $( '#customize-theme-controls > ul' ); // @todo This should be defined elsewhere, and to be configurable 1297 container = $( '#customize-theme-controls' ), 1298 parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable 1215 1299 1216 1300 if ( ! panel.container.parent().is( parentContainer ) ) { 1217 1301 parentContainer.append( panel.container ); 1302 container.append( panel.content ); 1218 1303 panel.renderContent(); 1219 1304 } 1220 1305 1221 api.bind( 'pane-contents-reflowed', _.debounce( function() {1222 panel._recalculateTopMargin();1223 }, 100 ) );1306 // api.bind( 'pane-contents-reflowed', _.debounce( function() { 1307 // panel._recalculateTopMargin(); 1308 // }, 100 ) ); 1224 1309 1225 1310 panel.deferred.embedded.resolve(); 1226 1311 }, … … 1229 1314 * @since 4.1.0 1230 1315 */ 1231 1316 attachEvents: function () { 1232 var meta, panel = this; 1317 var meta, panel = this, 1318 overlay = panel.content.closest( '.wp-full-overlay' ), 1319 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 1233 1320 1234 1321 // Expand/Collapse accordion sections on click. 1235 1322 panel.container.find( '.accordion-section-title' ).on( 'click keydown', function( event ) { … … 1244 1331 }); 1245 1332 1246 1333 // Close panel. 1247 panel.container.find( '.customize-panel-back' ).on( 'click keydown', function( event ) { 1334 // panel.container.find( '.customize-panel-back' ).on( 'click keydown', function( event ) { 1335 panel.content.find( '.customize-panel-back' ).on( 'click keydown', function( event ) { 1248 1336 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 1249 1337 return; 1250 1338 } … … 1255 1343 } 1256 1344 }); 1257 1345 1258 meta = panel.cont ainer.find( '.panel-meta:first' );1346 meta = panel.content.find( '.panel-meta:first' ); 1259 1347 1260 1348 meta.find( '> .accordion-section-title .customize-help-toggle' ).on( 'click keydown', function( event ) { 1261 1349 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { … … 1263 1351 } 1264 1352 event.preventDefault(); // Keep this AFTER the key filter above 1265 1353 1266 meta = panel.container.find( '.panel-meta' );1354 // meta = panel.container.find( '.panel-meta' ); 1267 1355 if ( meta.hasClass( 'cannot-expand' ) ) { 1268 1356 return; 1269 1357 } … … 1280 1368 } 1281 1369 }); 1282 1370 1371 panel.content.on( normalizedTransitionendEventName, function() { 1372 panel.content.removeClass( 'animating' ); 1373 overlay.removeClass( 'animating' ); 1374 }); 1375 1283 1376 }, 1284 1377 1285 1378 /** … … 1335 1428 // Note: there is a second argument 'args' passed 1336 1429 var position, scroll, 1337 1430 panel = this, 1338 accordionSection = panel.cont ainer.closest( '.accordion-section' ),1431 accordionSection = panel.content; // .closest( '.accordion-section' ), 1339 1432 overlay = accordionSection.closest( '.wp-full-overlay' ), 1340 1433 container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), 1341 1434 siblings = container.find( '.open' ), 1342 topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), 1435 // topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), 1436 topPanel = accordionSection.find( '.accordion-section-title' ), 1343 1437 backBtn = accordionSection.find( '.customize-panel-back' ), 1344 panelTitle = accordionSection.find( '.accordion-section-title' ).first() ,1345 content =accordionSection.find( '.control-panel-content' ),1346 headerActionsHeight = $( '#customize-header-actions' ).height();1438 panelTitle = accordionSection.find( '.accordion-section-title' ).first(); 1439 // content = panel.content, // accordionSection.find( '.control-panel-content' ), 1440 // headerActionsHeight = $( '#customize-header-actions' ).height(); 1347 1441 1348 1442 if ( expanded ) { 1349 1443 … … 1359 1453 } 1360 1454 }); 1361 1455 1362 content.show( 0, function() {1363 content.parent().show();1364 position = content.offset().top;1365 scroll = container.scrollTop();1366 content.css( 'margin-top', ( headerActionsHeight - position - scroll ) );1456 // content.show( 0, function() { 1457 // content.parent().show(); 1458 // position = content.offset().top; 1459 // scroll = container.scrollTop(); 1460 // content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); 1367 1461 accordionSection.addClass( 'current-panel' ); 1368 1462 overlay.addClass( 'in-sub-panel' ); 1369 container.scrollTop( 0 ); 1463 accordionSection.addClass( 'animating' ); 1464 overlay.addClass( 'animating' ); 1465 // container.scrollTop( 0 ); 1370 1466 if ( args.completeCallback ) { 1371 1467 args.completeCallback(); 1372 1468 } 1373 } );1469 // } ); 1374 1470 topPanel.attr( 'tabindex', '-1' ); 1375 1471 backBtn.attr( 'tabindex', '0' ); 1376 backBtn.focus();1377 panel._recalculateTopMargin();1472 // backBtn.focus(); 1473 // panel._recalculateTopMargin(); 1378 1474 } else { 1379 1475 siblings.removeClass( 'open' ); 1380 1476 accordionSection.removeClass( 'current-panel' ); 1381 1477 overlay.removeClass( 'in-sub-panel' ); 1382 content.delay( 180 ).hide( 0, function() { 1383 content.css( 'margin-top', 'inherit' ); // Reset 1478 accordionSection.addClass( 'animating' ); 1479 overlay.addClass( 'animating' ); 1480 // content.delay( 180 ).hide( 0, function() { 1481 // content.css( 'margin-top', 'inherit' ); // Reset 1384 1482 if ( args.completeCallback ) { 1385 1483 args.completeCallback(); 1386 1484 } 1387 } );1485 // } ); 1388 1486 topPanel.attr( 'tabindex', '0' ); 1389 1487 backBtn.attr( 'tabindex', '-1' ); 1390 panelTitle.focus();1488 // panelTitle.focus(); 1391 1489 container.scrollTop( 0 ); 1392 1490 } 1393 1491 }, … … 1399 1497 * @private 1400 1498 */ 1401 1499 _recalculateTopMargin: function() { 1402 var panel = this, headerActionsHeight, content, accordionSection; 1403 headerActionsHeight = $( '#customize-header-actions' ).height(); 1404 accordionSection = panel.container.closest( '.accordion-section' ); 1405 content = accordionSection.find( '.control-panel-content' ); 1406 content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - ( content.offset().top - headerActionsHeight ) ) ); 1500 return; 1501 // var panel = this, headerActionsHeight, content, accordionSection; 1502 // headerActionsHeight = $( '#customize-header-actions' ).height(); 1503 // accordionSection = panel.container.closest( '.accordion-section' ); 1504 // content = accordionSection.find( '.control-panel-content' ); 1505 // content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - ( content.offset().top - headerActionsHeight ) ) ); 1407 1506 }, 1408 1507 1409 1508 /** … … 1424 1523 template = wp.template( 'customize-panel-default-content' ); 1425 1524 } 1426 1525 if ( template && panel.container ) { 1427 panel.cont ainer.find( '.accordion-sub-container' ).html( template( panel.params ) );1526 panel.content.html( template( panel.params ) ); 1428 1527 } 1429 1528 } 1430 1529 }); … … 1557 1656 api.section( sectionId, function ( section ) { 1558 1657 // Wait for the section to be ready/initialized 1559 1658 section.deferred.embedded.done( function () { 1560 parentContainer = section.cont ainer.find( 'ul:first' );1659 parentContainer = section.content; // section.container.find( 'ul:first' ); 1561 1660 if ( ! control.container.parent().is( parentContainer ) ) { 1562 1661 parentContainer.append( control.container ); 1563 1662 control.renderContent(); … … 3451 3550 var sections = panel.sections(), 3452 3551 sectionContainers = _.pluck( sections, 'container' ); 3453 3552 rootNodes.push( panel ); 3454 appendContainer = panel.cont ainer.find( 'ul:first' );3553 appendContainer = panel.content; // panel.container.find( 'ul:first' ); 3455 3554 if ( ! api.utils.areElementListsEqual( sectionContainers, appendContainer.children( '[id]' ) ) ) { 3456 3555 _( sections ).each( function ( section ) { 3457 3556 appendContainer.append( section.container ); … … 3467 3566 if ( ! section.panel() ) { 3468 3567 rootNodes.push( section ); 3469 3568 } 3470 appendContainer = section.cont ainer.find( 'ul:first' );3569 appendContainer = section.content; // section.container.find( 'ul:first' ); 3471 3570 if ( ! api.utils.areElementListsEqual( controlContainers, appendContainer.children( '[id]' ) ) ) { 3472 3571 _( controls ).each( function ( control ) { 3473 3572 appendContainer.append( control.container ); … … 3479 3578 // Sort the root panels and sections 3480 3579 rootNodes.sort( api.utils.prioritySort ); 3481 3580 rootContainers = _.pluck( rootNodes, 'container' ); 3482 appendContainer = $( ' #customize-theme-controls' ).children( 'ul' ); // @todo This should be defined elsewhere, and to be configurable3581 appendContainer = $( '.customize-pane-parent' ); //$( '#customize-theme-controls' ).children( 'ul' ); // @todo This should be defined elsewhere, and to be configurable 3483 3582 if ( ! api.utils.areElementListsEqual( rootContainers, appendContainer.children() ) ) { 3484 3583 _( rootNodes ).each( function ( rootNode ) { 3485 3584 appendContainer.append( rootNode.container ); -
src/wp-admin/js/customize-controls.js
From 5d422a665c05721fb6b66f8c23230807e4d1ec43 Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Fri, 12 Feb 2016 21:49:47 +0100 Subject: [PATCH 2/9] WIP: Harden panel/section UI code by removing contents from being logically nested --- src/wp-admin/js/customize-controls.js | 48 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 19f508d..695771d 100644
a b 649 649 var section = this, 650 650 expandCollapseEventTypes = 'click keydown', 651 651 expandCollapseEventHandler, 652 overlay = section.content.closest( '.wp-full-overlay' ) ,653 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent();652 overlay = section.content.closest( '.wp-full-overlay' ); 653 //normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 654 654 655 655 // Expand/Collapse accordion sections on click. 656 656 expandCollapseEventHandler = function ( event ) { … … 669 669 section.container.find( '.accordion-section-title' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 670 670 section.content.find( '.customize-section-back' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 671 671 672 section.content.on( normalizedTransitionendEventName, function() {673 section.content.removeClass( 'animating' );674 overlay.removeClass( 'animating' );675 });672 // section.content.on( normalizedTransitionendEventName, function() { 673 // section.content.removeClass( 'animating' ); 674 // overlay.removeClass( 'animating' ); 675 // }); 676 676 }, 677 677 678 678 /** … … 722 722 sectionTitle = content.find( '.accordion-section-title' ).first(), // section.container.find( '.accordion-section-title' ).first(), 723 723 // headerActionsHeight = $( '#customize-header-actions' ).height(), 724 724 // resizeContentHeight, 725 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(), 725 726 expand, position, scroll; 726 727 727 728 // if ( expanded && ! section.container.hasClass( 'open' ) ) { … … 745 746 expand = function() { 746 747 // section.container.addClass( 'open' ); 747 748 content.addClass( 'open' ); 748 content.addClass( 'animating' );749 749 overlay.addClass( 'section-open' ); 750 content.addClass( 'animating' ); 750 751 overlay.addClass( 'animating' ); 752 content.one( normalizedTransitionendEventName, function() { 753 content.removeClass( 'animating' ); 754 overlay.removeClass( 'animating' ); 755 }); 751 756 // position = content.offset().top; 752 757 // scroll = container.scrollTop(); 753 758 // content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); … … 790 795 } else if ( ! expanded && content.hasClass( 'open' ) ) { 791 796 // section.container.removeClass( 'open' ); 792 797 content.removeClass( 'open' ); 793 content.addClass( 'animating' );794 798 overlay.removeClass( 'section-open' ); 799 content.addClass( 'animating' ); 795 800 overlay.addClass( 'animating' ); 801 content.one( normalizedTransitionendEventName, function() { 802 content.removeClass( 'animating' ); 803 overlay.removeClass( 'animating' ); 804 }); 796 805 // content.css( 'margin-top', '' ); 797 806 // container.scrollTop( 0 ); 798 807 backBtn.attr( 'tabindex', '-1' ); … … 1315 1324 */ 1316 1325 attachEvents: function () { 1317 1326 var meta, panel = this, 1318 overlay = panel.content.closest( '.wp-full-overlay' ) ,1319 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent();1327 overlay = panel.content.closest( '.wp-full-overlay' ); 1328 //normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 1320 1329 1321 1330 // Expand/Collapse accordion sections on click. 1322 1331 panel.container.find( '.accordion-section-title' ).on( 'click keydown', function( event ) { … … 1368 1377 } 1369 1378 }); 1370 1379 1371 panel.content.on( normalizedTransitionendEventName, function() {1372 panel.content.removeClass( 'animating' );1373 overlay.removeClass( 'animating' );1374 });1380 // panel.content.on( normalizedTransitionendEventName, function() { 1381 // panel.content.removeClass( 'animating' ); 1382 // overlay.removeClass( 'animating' ); 1383 // }); 1375 1384 1376 1385 }, 1377 1386 … … 1435 1444 // topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ), 1436 1445 topPanel = accordionSection.find( '.accordion-section-title' ), 1437 1446 backBtn = accordionSection.find( '.customize-panel-back' ), 1438 panelTitle = accordionSection.find( '.accordion-section-title' ).first(); 1447 panelTitle = accordionSection.find( '.accordion-section-title' ).first(), 1448 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 1439 1449 // content = panel.content, // accordionSection.find( '.control-panel-content' ), 1440 1450 // headerActionsHeight = $( '#customize-header-actions' ).height(); 1441 1451 … … 1462 1472 overlay.addClass( 'in-sub-panel' ); 1463 1473 accordionSection.addClass( 'animating' ); 1464 1474 overlay.addClass( 'animating' ); 1475 accordionSection.one( normalizedTransitionendEventName, function() { 1476 accordionSection.removeClass( 'animating' ); 1477 overlay.removeClass( 'animating' ); 1478 }); 1465 1479 // container.scrollTop( 0 ); 1466 1480 if ( args.completeCallback ) { 1467 1481 args.completeCallback(); … … 1477 1491 overlay.removeClass( 'in-sub-panel' ); 1478 1492 accordionSection.addClass( 'animating' ); 1479 1493 overlay.addClass( 'animating' ); 1494 accordionSection.one( normalizedTransitionendEventName, function() { 1495 accordionSection.removeClass( 'animating' ); 1496 overlay.removeClass( 'animating' ); 1497 }); 1480 1498 // content.delay( 180 ).hide( 0, function() { 1481 1499 // content.css( 'margin-top', 'inherit' ); // Reset 1482 1500 if ( args.completeCallback ) { -
src/wp-admin/css/common.css
From 6055301c7fbfbee0387d5e92cc9108399d62501d Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Sat, 20 Feb 2016 23:52:02 +0100 Subject: [PATCH 3/9] Fix transitioning and class handling. Add focus() support. Not browser tested yet. --- src/wp-admin/css/common.css | 6 +- src/wp-admin/css/customize-controls.css | 48 +++--- src/wp-admin/js/customize-controls.js | 261 ++++++++++++-------------------- 3 files changed, 120 insertions(+), 195 deletions(-) diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index 679b0b9..3886902 100644
a b img { 3213 3213 display: none; 3214 3214 } 3215 3215 3216 .control-section .accordion-section-title { 3216 .control-section .accordion-section-title, 3217 .customize-pane-child .accordion-section-title { 3217 3218 border-left: none; 3218 3219 border-right: none; 3219 3220 padding: 10px 10px 11px 14px; … … img { 3221 3222 background: #fff; 3222 3223 } 3223 3224 3224 .control-section .accordion-section-title:after { 3225 .control-section .accordion-section-title:after, 3226 .customize-pane-child .accordion-section-title:after { 3225 3227 top: 11px; 3226 3228 } 3227 3229 -
src/wp-admin/css/customize-controls.css
diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index 70f4f13..a45c228 100644
a b body { 77 77 line-height: 24px; 78 78 } 79 79 80 #customize-controls .c ontrol-section.customize-section-title h3,81 #customize-controls .c ontrol-sectionh3.customize-section-title,80 #customize-controls .customize-pane-child .customize-section-title h3, 81 #customize-controls .customize-pane-child h3.customize-section-title, 82 82 #customize-controls .customize-info .panel-title { 83 83 font-size: 20px; 84 84 font-weight: 200; … … body { 217 217 box-sizing: border-box; 218 218 } 219 219 220 221 222 223 220 #customize-info, 224 221 #customize-theme-controls .customize-pane-parent, 225 222 #customize-theme-controls .customize-pane-child { 223 overflow: visible; 226 224 width: 100%; 227 225 margin: 0; 228 226 padding: 0; 229 227 -webkit-box-sizing: border-box; 230 228 -moz-box-sizing: border-box; 231 229 box-sizing: border-box; 232 233 transition: 0.36s transform cubic-bezier(0.19, 1, 0.22, 1); 234 /*visibility: visible !important;*/ 235 overflow: visible !important; 230 transition: 0.36s transform cubic-bezier(0.19, 1, 0.22, 1); /* http://easings.net/#easeOutExpo */ 236 231 } 237 232 238 233 #customize-info, … … body { 248 243 .in-sub-panel #customize-info, 249 244 .in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel { 250 245 transform: translateX(-100%); 251 /*visibility: hidden;*/ 246 } 247 248 #customize-theme-controls .customize-pane-child.open, 249 #customize-theme-controls .customize-pane-child.current-panel { 250 transform: translateX(0); 252 251 } 253 252 254 253 .section-open #customize-theme-controls .customize-pane-parent, 255 254 .in-sub-panel #customize-theme-controls .customize-pane-parent, 256 255 .section-open #customize-info, 257 256 .in-sub-panel #customize-info, 258 .animating.section-open.in-sub-panel #customize-theme-controls .customize-pane-parent, 259 .animating.section-open.in-sub-panel #customize-info, { 257 .section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel { 260 258 visibility: hidden; 261 259 } 262 260 263 .animating.section-open #customize-theme-controls .customize-pane-parent, 264 .animating.in-sub-panel #customize-theme-controls .customize-pane-parent, 265 .animating.section-open #customize-info, 266 .animating.in-sub-panel #customize-info { 261 .section-open #customize-theme-controls .customize-pane-parent.closing, 262 .in-sub-panel #customize-theme-controls .customize-pane-parent.closing, 263 .section-open #customize-info.closing, 264 .in-sub-panel #customize-info.closing, 265 .transitioning.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel, 266 #customize-theme-controls .customize-pane-child.open, 267 #customize-theme-controls .customize-pane-child.current-panel, 268 #customize-theme-controls .customize-pane-child.closing { 267 269 visibility: visible; 268 270 } 269 271 … … body { 284 286 padding: 12px; 285 287 } 286 288 287 #customize-theme-controls .customize-pane-child.open,288 #customize-theme-controls .customize-pane-child.current-panel {289 transform: translateX(0);290 }291 292 #customize-theme-controls .customize-pane-child.open,293 #customize-theme-controls .customize-pane-child.current-panel,294 #customize-theme-controls .customize-pane-child.animating {295 visibility: visible;296 }297 298 299 300 301 289 .customize-section-description-container { 302 290 margin-bottom: 15px; 303 291 } -
src/wp-admin/js/customize-controls.js
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index ce4e83c..1c1ec8e 100644
a b 1 1 /* global _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer */ 2 2 (function( exports, $ ){ 3 var Container, focus, api = wp.customize; 3 var Container, focus, normalizedTransitionendEventName, api = wp.customize; 4 5 normalizedTransitionendEventName = (function () { 6 var el, transitions, prop; 7 el = document.createElement( 'div' ); 8 transitions = { 9 'transition' : 'transitionend', 10 'OTransition' : 'oTransitionEnd', 11 'MozTransition' : 'transitionend', 12 'WebkitTransition': 'webkitTransitionEnd' 13 }; 14 prop = _.find( _.keys( transitions ), function( prop ) { 15 return ! _.isUndefined( el.style[ prop ] ); 16 } ); 17 if ( prop ) { 18 return transitions[ prop ]; 19 } else { 20 return null; 21 } 22 })(); 4 23 5 24 /** 6 25 * A Customizer Setting. … … 610 629 api.panel( panelId, function ( panel ) { 611 630 // The panel has been registered, wait for it to become ready/initialized 612 631 panel.deferred.embedded.done( function () { 613 parentContainer = panel.content; // panel.container.find( 'ul:first' );632 parentContainer = panel.content; 614 633 if ( ! section.container.parent().is( parentContainer ) ) { 615 634 parentContainer.append( section.container ); 616 //section.setOwnership( section.content.attr( 'id' ) );617 635 container.append( section.content ); 618 636 } 619 637 section.deferred.embedded.resolve(); … … 631 649 }; 632 650 section.panel.bind( inject ); 633 651 inject( section.panel.get() ); // Since a section may never get a panel, assume that it won't ever get one 634 635 section.deferred.embedded.done(function() {636 // Fix the top margin after reflow.637 api.bind( 'pane-contents-reflowed', _.debounce( function() {638 section._recalculateTopMargin();639 }, 100 ) );640 });641 652 }, 642 653 643 654 /** … … 650 661 expandCollapseEventTypes = 'click keydown', 651 662 expandCollapseEventHandler, 652 663 overlay = section.content.closest( '.wp-full-overlay' ); 653 //normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent();654 664 655 665 // Expand/Collapse accordion sections on click. 656 666 expandCollapseEventHandler = function ( event ) { … … 668 678 669 679 section.container.find( '.accordion-section-title' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 670 680 section.content.find( '.customize-section-back' ).on( expandCollapseEventTypes, expandCollapseEventHandler ); 671 672 // section.content.on( normalizedTransitionendEventName, function() {673 // section.content.removeClass( 'animating' );674 // overlay.removeClass( 'animating' );675 // });676 681 }, 677 682 678 683 /** … … 716 721 onChangeExpanded: function ( expanded, args ) { 717 722 var section = this, 718 723 container = section.container.closest( '.wp-full-overlay-sidebar-content' ), 719 content = section.content, //section.container.find( '.accordion-section-content' ),724 content = section.content, 720 725 overlay = section.container.closest( '.wp-full-overlay' ), 721 backBtn = content.find( '.customize-section-back' ), //section.container.find( '.customize-section-back' ), 722 sectionTitle = content.find( '.accordion-section-title' ).first(), // section.container.find( '.accordion-section-title' ).first(), 723 // headerActionsHeight = $( '#customize-header-actions' ).height(), 724 // resizeContentHeight, 725 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(), 726 expand, position, scroll; 727 728 // if ( expanded && ! section.container.hasClass( 'open' ) ) { 726 info = overlay.find( '#customize-info' ), 727 parent = overlay.find( '.customize-pane-parent' ), 728 backBtn = content.find( '.customize-section-back' ), 729 sectionTitle = content.find( '.accordion-section-title' ).first(), 730 expand; 731 729 732 if ( expanded && ! content.hasClass( 'open' ) ) { 730 733 731 734 if ( args.unchanged ) { 732 735 expand = args.completeCallback; 733 736 } else { 734 737 container.scrollTop( 0 ); 735 // resizeContentHeight = function() {736 // var matchMedia, offset;737 // matchMedia = window.matchMedia || window.msMatchMedia;738 // offset = 90; // 45px for customize header actions + 45px for footer actions.739 740 // // No footer on small screens.741 // if ( matchMedia && matchMedia( '(max-width: 640px)' ).matches ) {742 // offset = 45;743 // }744 // content.css( 'height', ( window.innerHeight - offset ) );745 // };746 738 expand = function() { 747 // section.container.addClass( 'open' ); 739 content.one( normalizedTransitionendEventName, function () { 740 info.removeClass( 'closing' ); 741 parent.removeClass( 'closing' ); 742 overlay.removeClass( 'transitioning' ); 743 backBtn.focus(); 744 } ); 745 748 746 content.addClass( 'open' ); 749 overlay.addClass( 'section-open' ); 750 content.addClass( 'animating' ); 751 overlay.addClass( 'animating' ); 752 content.one( normalizedTransitionendEventName, function() { 753 content.removeClass( 'animating' ); 754 overlay.removeClass( 'animating' ); 755 }); 756 // position = content.offset().top; 757 // scroll = container.scrollTop(); 758 // content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); 759 // resizeContentHeight(); 747 info.addClass( 'closing' ); 748 parent.addClass( 'closing' ); 749 overlay.addClass( 'section-open transitioning' ); 750 760 751 sectionTitle.attr( 'tabindex', '-1' ); 761 752 backBtn.attr( 'tabindex', '0' ); 762 // backBtn.focus(); 753 763 754 if ( args.completeCallback ) { 764 755 args.completeCallback(); 765 756 } 766 767 // Fix the height after browser resize.768 // $( window ).on( 'resize.customizer-section', _.debounce( resizeContentHeight, 100 ) );769 770 section._recalculateTopMargin();771 757 }; 772 758 } 773 759 … … 791 777 expand(); 792 778 } 793 779 794 // } else if ( ! expanded && section.container.hasClass( 'open' ) ) {795 780 } else if ( ! expanded && content.hasClass( 'open' ) ) { 796 // section.container.removeClass( 'open' ); 797 content.removeClass( 'open' ); 798 overlay.removeClass( 'section-open' ); 799 content.addClass( 'animating' ); 800 overlay.addClass( 'animating' ); 801 content.one( normalizedTransitionendEventName, function() { 802 content.removeClass( 'animating' ); 803 overlay.removeClass( 'animating' ); 804 }); 805 // content.css( 'margin-top', '' ); 806 // container.scrollTop( 0 ); 781 782 content.one( normalizedTransitionendEventName, function () { 783 content.removeClass( 'closing' ); 784 info.removeClass( 'closing' ); 785 parent.removeClass( 'closing' ); 786 overlay.removeClass( 'transitioning' ); 787 sectionTitle.focus(); 788 } ); 789 790 content.removeClass( 'open' ).addClass( 'closing' ); 791 info.addClass( 'closing' ); 792 parent.addClass( 'closing' ); 793 overlay.removeClass( 'section-open transitioning' ); 794 807 795 backBtn.attr( 'tabindex', '-1' ); 808 796 sectionTitle.attr( 'tabindex', '0' ); 809 // sectionTitle.focus(); 797 810 798 if ( args.completeCallback ) { 811 799 args.completeCallback(); 812 800 } 813 // $( window ).off( 'resize.customizer-section' );814 801 } else { 815 802 if ( args.completeCallback ) { 816 803 args.completeCallback(); 817 804 } 818 805 } 819 },820 821 /**822 * Recalculate the top margin.823 *824 * @since 4.4.0825 * @private826 */827 _recalculateTopMargin: function() {828 return;829 // var section = this, content, offset, headerActionsHeight;830 // content = section.container.find( '.accordion-section-content' );831 // if ( 0 === content.length ) {832 // return;833 // }834 // headerActionsHeight = $( '#customize-header-actions' ).height();835 // offset = ( content.offset().top - headerActionsHeight );836 // if ( 0 < offset ) {837 // content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - offset ) );838 // }839 806 } 840 807 }); 841 808 … … 1312 1279 panel.renderContent(); 1313 1280 } 1314 1281 1315 // api.bind( 'pane-contents-reflowed', _.debounce( function() {1316 // panel._recalculateTopMargin();1317 // }, 100 ) );1318 1319 1282 panel.deferred.embedded.resolve(); 1320 1283 }, 1321 1284 … … 1325 1288 attachEvents: function () { 1326 1289 var meta, panel = this, 1327 1290 overlay = panel.content.closest( '.wp-full-overlay' ); 1328 //normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent();1329 1291 1330 1292 // Expand/Collapse accordion sections on click. 1331 1293 panel.container.find( '.accordion-section-title' ).on( 'click keydown', function( event ) { … … 1340 1302 }); 1341 1303 1342 1304 // Close panel. 1343 // panel.container.find( '.customize-panel-back' ).on( 'click keydown', function( event ) {1344 1305 panel.content.find( '.customize-panel-back' ).on( 'click keydown', function( event ) { 1345 1306 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 1346 1307 return; … … 1360 1321 } 1361 1322 event.preventDefault(); // Keep this AFTER the key filter above 1362 1323 1363 // meta = panel.container.find( '.panel-meta' );1364 1324 if ( meta.hasClass( 'cannot-expand' ) ) { 1365 1325 return; 1366 1326 } … … 1376 1336 $( this ).attr( 'aria-expanded', true ); 1377 1337 } 1378 1338 }); 1379 1380 // panel.content.on( normalizedTransitionendEventName, function() {1381 // panel.content.removeClass( 'animating' );1382 // overlay.removeClass( 'animating' );1383 // });1384 1385 1339 }, 1386 1340 1387 1341 /** … … 1435 1389 } 1436 1390 1437 1391 // Note: there is a second argument 'args' passed 1438 var position, scroll, 1439 panel = this, 1440 accordionSection = panel.content; // .closest( '.accordion-section' ), 1392 var panel = this, 1393 accordionSection = panel.content, 1441 1394 overlay = accordionSection.closest( '.wp-full-overlay' ), 1442 1395 container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), 1443 siblings = container.find( '.open' ),1444 // topPanel = overlay.find( '#customize-theme-controls > ul > .accordion-section > .accordion-section-title' ),1396 info = overlay.find( '#customize-info' ), 1397 parent = overlay.find( '.customize-pane-parent' ), 1445 1398 topPanel = accordionSection.find( '.accordion-section-title' ), 1446 1399 backBtn = accordionSection.find( '.customize-panel-back' ), 1447 panelTitle = accordionSection.find( '.accordion-section-title' ).first(), 1448 normalizedTransitionendEventName = api.utils.getNormalizedTransitionendEvent(); 1449 // content = panel.content, // accordionSection.find( '.control-panel-content' ), 1450 // headerActionsHeight = $( '#customize-header-actions' ).height(); 1400 panelTitle = accordionSection.find( '.accordion-section-title' ).first(); 1451 1401 1452 if ( expanded ) {1402 if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { 1453 1403 1454 1404 // Collapse any sibling sections/panels 1455 1405 api.section.each( function ( section ) { … … 1463 1413 } 1464 1414 }); 1465 1415 1466 // content.show( 0, function() { 1467 // content.parent().show(); 1468 // position = content.offset().top; 1469 // scroll = container.scrollTop(); 1470 // content.css( 'margin-top', ( headerActionsHeight - position - scroll ) ); 1471 accordionSection.addClass( 'current-panel' ); 1472 overlay.addClass( 'in-sub-panel' ); 1473 accordionSection.addClass( 'animating' ); 1474 overlay.addClass( 'animating' ); 1475 accordionSection.one( normalizedTransitionendEventName, function() { 1476 accordionSection.removeClass( 'animating' ); 1477 overlay.removeClass( 'animating' ); 1478 }); 1479 // container.scrollTop( 0 ); 1480 if ( args.completeCallback ) { 1481 args.completeCallback(); 1482 } 1483 // } ); 1416 accordionSection.one( normalizedTransitionendEventName, function () { 1417 info.removeClass( 'closing' ); 1418 parent.removeClass( 'closing' ); 1419 overlay.removeClass( 'transitioning' ); 1420 backBtn.focus(); 1421 } ); 1422 1423 accordionSection.addClass( 'current-panel' ); 1424 info.addClass( 'closing' ); 1425 parent.addClass( 'closing' ); 1426 overlay.addClass( 'in-sub-panel transitioning' ); 1427 1428 container.scrollTop( 0 ); 1429 if ( args.completeCallback ) { 1430 args.completeCallback(); 1431 } 1432 1484 1433 topPanel.attr( 'tabindex', '-1' ); 1485 1434 backBtn.attr( 'tabindex', '0' ); 1486 // backBtn.focus(); 1487 // panel._recalculateTopMargin(); 1488 } else { 1489 siblings.removeClass( 'open' ); 1490 accordionSection.removeClass( 'current-panel' ); 1491 overlay.removeClass( 'in-sub-panel' ); 1492 accordionSection.addClass( 'animating' ); 1493 overlay.addClass( 'animating' ); 1494 accordionSection.one( normalizedTransitionendEventName, function() { 1495 accordionSection.removeClass( 'animating' ); 1496 overlay.removeClass( 'animating' ); 1497 }); 1498 // content.delay( 180 ).hide( 0, function() { 1499 // content.css( 'margin-top', 'inherit' ); // Reset 1500 if ( args.completeCallback ) { 1501 args.completeCallback(); 1502 } 1503 // } ); 1435 1436 } else if ( ! expanded && accordionSection.hasClass( 'current-panel' ) ) { 1437 accordionSection.one( normalizedTransitionendEventName, function () { 1438 accordionSection.removeClass( 'closing' ); 1439 info.removeClass( 'closing' ); 1440 parent.removeClass( 'closing' ); 1441 overlay.removeClass( 'transitioning' ); 1442 panelTitle.focus(); 1443 } ); 1444 1445 accordionSection.removeClass( 'current-panel' ).addClass( 'closing' ); 1446 info.addClass( 'closing' ); 1447 parent.addClass( 'closing' ); 1448 overlay.removeClass( 'in-sub-panel' ).addClass( 'transitioning' ); 1449 1450 if ( args.completeCallback ) { 1451 args.completeCallback(); 1452 } 1453 1504 1454 topPanel.attr( 'tabindex', '0' ); 1505 1455 backBtn.attr( 'tabindex', '-1' ); 1506 // panelTitle.focus(); 1456 1507 1457 container.scrollTop( 0 ); 1508 1458 } 1509 1459 }, 1510 1460 1511 1461 /** 1512 * Recalculate the top margin.1513 *1514 * @since 4.4.01515 * @private1516 */1517 _recalculateTopMargin: function() {1518 return;1519 // var panel = this, headerActionsHeight, content, accordionSection;1520 // headerActionsHeight = $( '#customize-header-actions' ).height();1521 // accordionSection = panel.container.closest( '.accordion-section' );1522 // content = accordionSection.find( '.control-panel-content' );1523 // content.css( 'margin-top', ( parseInt( content.css( 'margin-top' ), 10 ) - ( content.offset().top - headerActionsHeight ) ) );1524 },1525 1526 /**1527 1462 * Render the panel from its JS template, if it exists. 1528 1463 * 1529 1464 * The panel's container must already exist in the DOM. -
src/wp-admin/css/customize-controls.css
From 04662b902d6db816876c7b5a4568a6f66268087d Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Sun, 28 Feb 2016 20:45:17 +0100 Subject: [PATCH 4/9] WIP. Make themes panel work. Fix minor issues with scroll bar. Still pending code cleanup and cross-browser testing. --- src/wp-admin/css/customize-controls.css | 121 +++++++++++++++------------- src/wp-admin/js/customize-controls.js | 135 +++++++++++++++++--------------- 2 files changed, 140 insertions(+), 116 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index 1ae1aa2..60b4000 100644
a b body { 227 227 -webkit-box-sizing: border-box; 228 228 -moz-box-sizing: border-box; 229 229 box-sizing: border-box; 230 transition: 0. 36s transform cubic-bezier(0.19, 1, 0.22, 1); /* http://easings.net/#easeOutExpo */230 transition: 0.48s transform cubic-bezier(0.19, 1, 0.22, 1); /* easeOutExpo */ 231 231 } 232 232 233 233 #customize-info, 234 234 #customize-theme-controls .customize-pane-parent { 235 235 position: relative; 236 236 visibility: visible; 237 height: auto; 238 max-height: none; 239 overflow: auto; 237 240 transform: translateX(0); 238 241 } 239 242 … … body { 245 248 transform: translateX(-100%); 246 249 } 247 250 248 #customize-theme-controls .customize-pane-child.open,249 #customize-theme-controls .customize-pane-child.current-panel{250 transform: translateX( 0);251 .in-themes-panel #customize-theme-controls .customize-pane-parent, 252 .in-themes-panel #customize-info { 253 transform: translateX(100%); 251 254 } 252 255 253 256 .section-open #customize-theme-controls .customize-pane-parent, … … body { 256 259 .in-sub-panel #customize-info, 257 260 .section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel { 258 261 visibility: hidden; 262 height: 0; 263 overflow: hidden; 259 264 } 260 265 261 266 .section-open #customize-theme-controls .customize-pane-parent.closing, … … body { 267 272 #customize-theme-controls .customize-pane-child.current-panel, 268 273 #customize-theme-controls .customize-pane-child.closing { 269 274 visibility: visible; 275 height: auto; 276 overflow: auto; 270 277 } 271 278 272 279 #customize-theme-controls .customize-pane-child { … … body { 275 282 left: 0; 276 283 transform: translateX(100%); 277 284 visibility: hidden; 285 height: 0; 286 max-height: none; 287 overflow: hidden; 288 } 289 290 #customize-theme-controls .customize-pane-parent.closing, 291 #customize-info.closing, 292 #customize-theme-controls .customize-pane-child.closing { 293 max-height: 100%; 294 } 295 296 #customize-theme-controls .customize-pane-child.open, 297 #customize-theme-controls .customize-pane-child.current-panel { 298 transform: translateX(0); 299 } 300 301 #customize-theme-controls .customize-themes-panel.customize-pane-child { 302 transform: translateX(-100%); 303 } 304 305 #customize-theme-controls .customize-themes-panel.customize-pane-child.current-panel { 306 transform: translateX(0); 278 307 } 279 308 280 309 #customize-theme-controls .customize-pane-child.accordion-section-content, … … body { 286 315 padding: 12px; 287 316 } 288 317 318 .wp-full-overlay #customize-controls .wp-full-overlay-sidebar-content { 319 /* Promote to separate layer to avoid full-screen repaints */ 320 transform: translate3d(0,0,0); 321 } 322 289 323 .customize-section-description-container { 290 324 margin-bottom: 15px; 291 325 } … … h3.customize-section-title { 357 391 transition: left 0s; 358 392 } 359 393 360 .accordion-sub-container.control-panel-content. animating {394 .accordion-sub-container.control-panel-content.closing { 361 395 display: block; 362 396 } 363 397 … … h3.customize-section-title { 479 513 padding-left: 62px; 480 514 } 481 515 482 /*#customize-info,483 #customize-theme-controls > ul > .accordion-section {484 position: relative;485 left: 0;486 -webkit-transition: left ease-in-out .18s;487 transition: left ease-in-out .18s;488 }489 490 .ios #customize-info,491 .ios #customize-theme-controls > ul > .accordion-section {492 -webkit-transition: left 0s;493 transition: left 0s;494 }495 */496 /*.in-sub-panel #customize-info,497 .in-sub-panel #customize-theme-controls > ul > .accordion-section {498 left: -300px;499 width: 300px;500 }*/501 502 /*.in-sub-panel #customize-theme-controls .accordion-section.current-panel {503 width: 100%;504 }505 */506 516 #customize-theme-controls .control-section.current-panel { 507 517 padding: 0; 508 518 } … … h3.customize-section-title { 523 533 transition: left 0s; 524 534 } 525 535 526 .wp-full-overlay.section-open #customize-controls .wp-full-overlay-sidebar-content {536 /*.wp-full-overlay.section-open #customize-controls .wp-full-overlay-sidebar-content { 527 537 visibility: hidden; 528 538 overflow-y: hidden; 529 539 } 530 540 */ 531 541 /*.wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open { 532 542 visibility: visible; 533 543 } … … p.customize-section-description { 1089 1099 animation: customize-reload .75s; 1090 1100 } 1091 1101 1092 .control-section-themes .accordion-section-title {1102 #customize-controls .control-section-themes .accordion-section-title { 1093 1103 cursor: default; 1094 1104 } 1095 1105 … … p.customize-section-description { 1099 1109 background-color: #fff; 1100 1110 } 1101 1111 1102 .control-section-themes .accordion-section-title {1112 #customize-controls .control-section-themes .accordion-section-title { 1103 1113 margin: 15px 0; 1104 1114 } 1105 1115 1106 .customize-themes-panel .accordion-section-title {1116 #customize-controls .customize-themes-panel .accordion-section-title { 1107 1117 margin: 15px -8px; 1108 1118 } 1109 1119 1110 .control-section-themes .accordion-section-title { 1120 #customize-controls .control-section-themes .accordion-section-title, 1121 #customize-controls .customize-themes-panel .accordion-section-title { 1111 1122 padding-right: 100px; /* Space for the button */ 1112 1123 } 1113 1124 1114 .control-section-themes .accordion-section-title span.customize-action,1125 #customize-controls .control-section-themes .accordion-section-title span.customize-action, 1115 1126 #customize-controls .customize-section-title span.customize-action { 1116 1127 font-size: 13px; 1117 1128 display: block; 1118 1129 font-weight: 400; 1119 1130 } 1120 1131 1121 .control-section-themes .accordion-section-title .change-theme,1122 .control-section-themes.accordion-section-title .customize-theme {1132 #customize-controls .control-section-themes .accordion-section-title .change-theme, 1133 #customize-controls .customize-themes-panel .accordion-section-title .customize-theme { 1123 1134 position: absolute; 1124 1135 right: 10px; 1125 1136 top: 50%; … … p.customize-section-description { 1127 1138 font-weight: normal; 1128 1139 } 1129 1140 1130 .control-section-themes .accordion-section-title:before {1141 #customize-controls .control-section-themes .accordion-section-title:before { 1131 1142 display: none; 1132 1143 } 1133 1144 1134 .customize-themes-panel { 1135 display: none; 1145 #customize-controls .customize-themes-panel { 1136 1146 padding: 0 8px; 1137 1147 background: #f1f1f1; 1138 1148 -webkit-box-sizing: border-box; … … p.customize-section-description { 1140 1150 box-sizing: border-box; 1141 1151 } 1142 1152 1143 .customize-themes-panel .accordion-section-title:first-child {1153 #customize-controls .customize-themes-panel .accordion-section-title:first-child { 1144 1154 margin-top: 0; 1145 1155 } 1146 1156 … … p.customize-section-description { 1149 1159 font-weight: 600; 1150 1160 } 1151 1161 1152 .customize-themes-panel > h2 {1162 #customize-controls .customize-themes-panel > h2 { 1153 1163 padding: 15px 8px 0 8px; 1154 1164 } 1155 1165 1156 .control-section.open .customize-themes-panel {1166 /*.control-section.open .customize-themes-panel { 1157 1167 display: block; 1158 } 1168 }*/ 1159 1169 1160 1170 #customize-theme-controls .customize-themes-panel .accordion-section-content { 1161 1171 background: transparent; … … p.customize-section-description { 1202 1212 width: 100%; 1203 1213 } 1204 1214 1205 #accordion-section-themes .accordion-section-title:after { 1215 /*#accordion-section-themes .accordion-section-title:after {*/ 1216 .control-section-themes .accordion-section-title:after, 1217 .customize-themes-panel .accordion-section-title:after { 1206 1218 display: none; 1207 1219 } 1208 1220 1209 #customize-theme-controls .control-section-themes.current-panel > h3.accordion-section-title {1221 /*#customize-theme-controls .control-section-themes.current-panel > h3.accordion-section-title { 1210 1222 left: 0; 1211 } 1223 }*/ 1212 1224 1213 1225 .customize-themes-panel.control-panel-content { 1214 position: absolute;1226 /* position: absolute; 1215 1227 left: -100%; 1216 1228 top: 0; 1217 width: 100%; 1229 width: 100%;*/ 1218 1230 border-top: 1px solid #ddd; 1219 1231 } 1220 1232 1221 .in-themes-panel #customize-info,1233 /*.in-themes-panel #customize-info, 1222 1234 .in-themes-panel #customize-theme-controls > ul > .accordion-section { 1223 1235 left: 100%; 1224 } 1236 }*/ 1225 1237 1226 1238 /* Details View */ 1227 1239 .wp-customizer .theme-overlay { … … p.customize-section-description { 1256 1268 text-align: right; /* Because there's only one action, match the pattern of media modals and right-align the action. */ 1257 1269 } 1258 1270 1259 .modal-open .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content { 1260 overflow: visible; /* Prevent the top-level Customizer controls from becoming visible when elements on the right of the details modal are focused. */ 1271 .in-themes-panel #customize-controls .wp-full-overlay-sidebar-content, 1272 .in-themes-panel #customize-controls #customize-theme-controls .control-panel-content { 1273 transform: none; /* Prevent creating new stacking contexts and containing blocks for themes modal. */ 1261 1274 } 1262 1275 1263 1276 .ie8 .wp-customizer .theme-overlay .theme-header, -
src/wp-admin/js/customize-controls.js
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 2b5a7a3..249114b 100644
a b 257 257 if ( 0 === container.container.length ) { 258 258 container.container = $( container.getContainer() ); 259 259 } 260 261 260 container.content = container.getContent(); 262 261 263 262 container.deferred = { … … 529 528 return '<li></li>'; 530 529 }, 531 530 531 /** 532 * Detach and return the content html, extracted from the container html, if it exists. 533 * 534 * @since 535 */ 532 536 getContent: function () { 533 537 var container = this, 534 list = container.container.find( ' ul:first' ),538 list = container.container.find( '.accordion-section-content, .control-panel-content' ).first(), // container.container.find( 'ul:first' ), 535 539 contentId = 'sub-accordion-list-' + container.id; 536 540 537 541 container.setOwnership( contentId ); … … 542 546 } ); 543 547 }, 544 548 549 /** 550 * Add new element to `aria-owned` property of the container. 551 * 552 * @since 553 */ 545 554 setOwnership: function ( elementId ) { 546 555 var container = this.container, 547 556 ownedElements = container.attr( 'aria-owns' ); … … 658 667 */ 659 668 attachEvents: function () { 660 669 var section = this, 661 expandCollapseEventTypes = 'click keydown', 662 expandCollapseEventHandler, 663 overlay = section.content.closest( '.wp-full-overlay' ); 670 toggleHandler; 664 671 665 672 // Expand/Collapse accordion sections on click. 666 expandCollapseEventHandler = function ( event ) {673 toggleHandler = function ( event ) { 667 674 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 668 675 return; 669 676 } … … 676 683 } 677 684 }; 678 685 679 section.container.find( '.accordion-section-title' ).on( expandCollapseEventTypes, expandCollapseEventHandler );680 section.content.find( '.customize-section-back' ).on( expandCollapseEventTypes, expandCollapseEventHandler );686 section.container.find( '.accordion-section-title' ).on( 'click keydown', toggleHandler ); 687 section.content.find( '.customize-section-back' ).on( 'click keydown', toggleHandler ); 681 688 }, 682 689 683 690 /** … … 836 843 */ 837 844 ready: function () { 838 845 var section = this; 839 section.overlay = section.cont ainer.find( '.theme-overlay' );846 section.overlay = section.content.find( '.theme-overlay' ); 840 847 section.template = wp.template( 'customize-themes-details-view' ); 841 848 842 849 // Bind global keyboard events. … … 883 890 * @since 4.2.0 884 891 */ 885 892 attachEvents: function () { 886 var section = this; 893 var section = this, 894 content = section.content, 895 toggleHandler; 887 896 888 897 // Expand/Collapse section/panel. 889 section.container.find( '.change-theme, .customize-theme' ).on( 'click keydown', function( event ) {898 toggleHandler = function ( event ) { 890 899 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 891 900 return; 892 901 } … … 897 906 } else { 898 907 section.expand(); 899 908 } 900 }); 909 }; 910 911 section.container.find( '.change-theme' ).on( 'click keydown', toggleHandler ); 912 content.find( '.customize-theme' ).on( 'click keydown', toggleHandler ); 901 913 902 914 // Theme navigation in details view. 903 section.container.on( 'click keydown', '.left', function( event ) {915 content.on( 'click keydown', '.left', function( event ) { 904 916 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 905 917 return; 906 918 } … … 910 922 section.previousTheme(); 911 923 }); 912 924 913 section.container.on( 'click keydown', '.right', function( event ) {925 content.on( 'click keydown', '.right', function( event ) { 914 926 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 915 927 return; 916 928 } … … 920 932 section.nextTheme(); 921 933 }); 922 934 923 section.container.on( 'click keydown', '.theme-backdrop, .close', function( event ) {935 content.on( 'click keydown', '.theme-backdrop, .close', function( event ) { 924 936 if ( api.utils.isKeydownButNotEnterEvent( event ) ) { 925 937 return; 926 938 } … … 931 943 }); 932 944 933 945 var renderScreenshots = _.throttle( _.bind( section.renderScreenshots, this ), 100 ); 934 section.container.on( 'input', '#themes-filter', function( event ) {946 content.on( 'input', '#themes-filter', function( event ) { 935 947 var count, 936 948 term = event.currentTarget.value.toLowerCase().trim().replace( '-', ' ' ), 937 949 controls = section.controls(); … … 943 955 renderScreenshots(); 944 956 945 957 // Update theme count. 946 count = section.container.find( 'li.customize-control:visible' ).length;947 section.container.find( '.theme-count' ).text( count );958 count = content.find( 'li.customize-control:visible' ).length; 959 content.find( '.theme-count' ).text( count ); 948 960 }); 949 961 950 962 // Pre-load the first 3 theme screenshots. … … 980 992 } 981 993 982 994 // Note: there is a second argument 'args' passed 983 var position, scroll, 984 panel = this, 985 section = panel.container.closest( '.accordion-section' ), 995 var panel = this, 996 section = panel.content, 986 997 overlay = section.closest( '.wp-full-overlay' ), 987 998 container = section.closest( '.wp-full-overlay-sidebar-content' ), 988 siblings = container.find( '.open' ), 999 info = overlay.find( '#customize-info' ), 1000 parent = overlay.find( '.customize-pane-parent' ), 989 1001 customizeBtn = section.find( '.customize-theme' ), 990 changeBtn = section.find( '.change-theme' ), 991 content = section.find( '.control-panel-content' ); 1002 changeBtn = section.find( '.change-theme' ); 992 1003 993 1004 if ( expanded ) { 994 995 1005 // Collapse any sibling sections/panels 996 1006 api.section.each( function ( otherSection ) { 997 1007 if ( otherSection !== panel ) { … … 1002 1012 otherPanel.collapse( { duration: 0 } ); 1003 1013 }); 1004 1014 1005 content.show( 0, function() { 1006 position = content.offset().top; 1007 scroll = container.scrollTop(); 1008 content.css( 'margin-top', ( $( '#customize-header-actions' ).height() - position - scroll ) ); 1009 section.addClass( 'current-panel' ); 1010 overlay.addClass( 'in-themes-panel' ); 1011 container.scrollTop( 0 ); 1012 _.delay( panel.renderScreenshots, 10 ); // Wait for the controls 1013 panel.$customizeSidebar.on( 'scroll.customize-themes-section', _.throttle( panel.renderScreenshots, 300 ) ); 1014 if ( args.completeCallback ) { 1015 args.completeCallback(); 1016 } 1015 section.one( normalizedTransitionendEventName, function () { 1016 info.removeClass( 'closing' ); 1017 parent.removeClass( 'closing' ); 1018 overlay.removeClass( 'transitioning' ); 1019 customizeBtn.focus(); 1020 _.delay( panel.renderScreenshots, 10 ); 1017 1021 } ); 1018 customizeBtn.focus(); 1022 1023 section.addClass( 'current-panel' ); 1024 info.addClass( 'closing' ); 1025 parent.addClass( 'closing' ); 1026 overlay.addClass( 'in-themes-panel transitioning' ); 1027 1028 container.scrollTop( 0 ); 1029 panel.$customizeSidebar.on( 'scroll.customize-themes-section', _.throttle( panel.renderScreenshots, 300 ) ); 1030 1031 if ( args.completeCallback ) { 1032 args.completeCallback(); 1033 } 1019 1034 } else { 1020 siblings.removeClass( 'open' ); 1021 section.removeClass( 'current-panel' ); 1022 overlay.removeClass( 'in-themes-panel' ); 1023 panel.$customizeSidebar.off( 'scroll.customize-themes-section' ); 1024 content.delay( 180 ).hide( 0, function() { 1025 content.css( 'margin-top', 'inherit' ); // Reset 1026 if ( args.completeCallback ) { 1027 args.completeCallback(); 1028 } 1035 section.one( normalizedTransitionendEventName, function () { 1036 section.removeClass( 'closing' ); 1037 info.removeClass( 'closing' ); 1038 parent.removeClass( 'closing' ); 1039 overlay.removeClass( 'transitioning' ); 1040 changeBtn.focus(); 1029 1041 } ); 1042 1043 section.removeClass( 'current-panel' ).addClass( 'closing' ); 1044 info.addClass( 'closing' ); 1045 parent.addClass( 'closing' ); 1046 overlay.removeClass( 'in-themes-panel' ).addClass( 'transitioning' ); 1047 panel.$customizeSidebar.off( 'scroll.customize-themes-section' ); 1048 1030 1049 customizeBtn.attr( 'tabindex', '0' ); 1031 changeBtn.focus();1032 1050 container.scrollTop( 0 ); 1051 1052 if ( args.completeCallback ) { 1053 args.completeCallback(); 1054 } 1033 1055 } 1034 1056 }, 1035 1057 1036 1058 /** 1037 * Recalculate the top margin.1038 *1039 * @since 4.4.01040 * @private1041 */1042 _recalculateTopMargin: function() {1043 return;1044 // api.Panel.prototype._recalculateTopMargin.call( this );1045 },1046 1047 /**1048 1059 * Render control's screenshot if the control comes into view. 1049 1060 * 1050 1061 * @since 4.2.0 … … 1609 1620 api.section( sectionId, function ( section ) { 1610 1621 // Wait for the section to be ready/initialized 1611 1622 section.deferred.embedded.done( function () { 1612 parentContainer = section.content; // section.container.find( 'ul:first' );1623 parentContainer = ( section.content.is( 'ul' ) ) ? section.content : section.content.find( 'ul:first' ); 1613 1624 if ( ! control.container.parent().is( parentContainer ) ) { 1614 1625 parentContainer.append( control.container ); 1615 1626 control.renderContent(); … … 3507 3518 var sections = panel.sections(), 3508 3519 sectionContainers = _.pluck( sections, 'container' ); 3509 3520 rootNodes.push( panel ); 3510 appendContainer = panel.content; // panel.container.find( 'ul:first' );3521 appendContainer = ( panel.content.is( 'ul' ) ) ? panel.content : panel.content.find( 'ul:first' ); 3511 3522 if ( ! api.utils.areElementListsEqual( sectionContainers, appendContainer.children( '[id]' ) ) ) { 3512 3523 _( sections ).each( function ( section ) { 3513 3524 appendContainer.append( section.container ); … … 3523 3534 if ( ! section.panel() ) { 3524 3535 rootNodes.push( section ); 3525 3536 } 3526 appendContainer = section.content; // section.container.find( 'ul:first' );3537 appendContainer = ( section.content.is( 'ul' ) ) ? section.content : section.content.find( 'ul:first' ); 3527 3538 if ( ! api.utils.areElementListsEqual( controlContainers, appendContainer.children( '[id]' ) ) ) { 3528 3539 _( controls ).each( function ( control ) { 3529 3540 appendContainer.append( control.container ); -
src/wp-admin/css/customize-controls.css
From 667947a73e80266d8ea7d1605e1a3bf31e21d613 Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Sat, 5 Mar 2016 21:24:21 +0100 Subject: [PATCH 5/9] Fix 'Menus' panel to work with new sliding panes implementation. Fix `tabindex` and `focus` implementation. --- src/wp-admin/css/customize-controls.css | 1 + src/wp-admin/css/customize-nav-menus.css | 8 +++--- src/wp-admin/js/customize-controls.js | 19 +++++++------- src/wp-admin/js/customize-nav-menus.js | 43 ++++++++++++++++++++------------ 4 files changed, 42 insertions(+), 29 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index b1b6ef5..8a92ba2 100644
a b body { 309 309 #customize-theme-controls .customize-pane-child.accordion-section-content, 310 310 #customize-theme-controls .customize-pane-child.accordion-sub-container { 311 311 display: block; 312 overflow-x: hidden; 312 313 } 313 314 314 315 #customize-theme-controls .customize-pane-child.accordion-section-content { -
src/wp-admin/css/customize-nav-menus.css
diff --git a/src/wp-admin/css/customize-nav-menus.css b/src/wp-admin/css/customize-nav-menus.css index 16480e9..5f07560 100644
a b 355 355 .reordering .menu-item-depth-10 > .menu-item-bar { margin-right: 150px; } 356 356 .reordering .menu-item-depth-11 > .menu-item-bar { margin-right: 165px; } 357 357 358 . control-section-nav_menu.menu .menu-item-edit-active {358 .accordion-section-content.menu .menu-item-edit-active { 359 359 margin-left: 0; 360 360 } 361 361 362 . control-section-nav_menu.menu .menu-item-edit-active .menu-item-bar {362 .accordion-section-content.menu .menu-item-edit-active .menu-item-bar { 363 363 margin-right: 0; 364 364 } 365 365 366 . control-section-nav_menu.menu .sortable-placeholder {366 .accordion-section-content.menu .sortable-placeholder { 367 367 margin-top: 0; 368 368 margin-bottom: 1px; 369 369 max-width: -webkit-calc(100% - 2px); … … 377 377 float: none; 378 378 } 379 379 380 . control-section-nav_menu.menu ul.menu-item-transport .menu-item-bar {380 .accordion-section-content.menu ul.menu-item-transport .menu-item-bar { 381 381 margin-top: 0; 382 382 } 383 383 -
src/wp-admin/js/customize-controls.js
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 045cc57..09571a7 100644
a b 392 392 construct.container.stop( true, true ).slideUp( duration, args.completeCallback ); 393 393 } 394 394 } 395 396 // Recalculate the margin-top immediately, not waiting for debounced reflow, to prevent momentary (100ms) vertical jiggle.397 if ( expandedOtherPanel ) {398 expandedOtherPanel._recalculateTopMargin();399 }400 395 }, 401 396 402 397 /** … … 641 636 parentContainer = panel.content; 642 637 if ( ! section.container.parent().is( parentContainer ) ) { 643 638 parentContainer.append( section.container ); 639 } 640 if ( ! section.content.parent().is( section.container ) ) { 644 641 container.append( section.content ); 645 642 } 646 643 section.deferred.embedded.resolve(); … … 651 648 parentContainer = $( '.customize-pane-parent' ); // @todo This should be defined elsewhere, and to be configurable 652 649 if ( ! section.container.parent().is( parentContainer ) ) { 653 650 parentContainer.append( section.container ); 651 } 652 if ( ! section.content.parent().is( section.container ) ) { 654 653 container.append( section.content ); 655 654 } 656 655 section.deferred.embedded.resolve(); … … 733 732 info = overlay.find( '#customize-info' ), 734 733 parent = overlay.find( '.customize-pane-parent' ), 735 734 backBtn = content.find( '.customize-section-back' ), 736 sectionTitle = content.find( '.accordion-section-title' ).first(),735 sectionTitle = section.container.find( '.accordion-section-title' ).first(), 737 736 expand; 738 737 739 738 if ( expanded && ! content.hasClass( 'open' ) ) { … … 999 998 info = overlay.find( '#customize-info' ), 1000 999 parent = overlay.find( '.customize-pane-parent' ), 1001 1000 customizeBtn = section.find( '.customize-theme' ), 1002 changeBtn = section.find( '.change-theme' );1001 changeBtn = panel.container.find( '.change-theme' ); 1003 1002 1004 1003 if ( expanded ) { 1005 1004 // Collapse any sibling sections/panels … … 1286 1285 1287 1286 if ( ! panel.container.parent().is( parentContainer ) ) { 1288 1287 parentContainer.append( panel.container ); 1288 } 1289 if ( ! panel.content.parent().is( panel.container ) ) { 1289 1290 container.append( panel.content ); 1290 1291 panel.renderContent(); 1291 1292 } … … 1406 1407 container = accordionSection.closest( '.wp-full-overlay-sidebar-content' ), 1407 1408 info = overlay.find( '#customize-info' ), 1408 1409 parent = overlay.find( '.customize-pane-parent' ), 1409 topPanel = accordionSection.find( '.accordion-section-title' ),1410 topPanel = panel.container.find( '.accordion-section-title' ), 1410 1411 backBtn = accordionSection.find( '.customize-panel-back' ), 1411 1412 panelTitle = accordionSection.find( '.accordion-section-title' ).first(); 1412 1413 … … 1450 1451 info.removeClass( 'closing' ); 1451 1452 parent.removeClass( 'closing' ); 1452 1453 overlay.removeClass( 'transitioning' ); 1453 panelTitle.focus();1454 topPanel.focus(); 1454 1455 } ); 1455 1456 1456 1457 accordionSection.removeClass( 'current-panel' ).addClass( 'closing' ); -
src/wp-admin/js/customize-nav-menus.js
diff --git a/src/wp-admin/js/customize-nav-menus.js b/src/wp-admin/js/customize-nav-menus.js index cad39c6..cdeeac4 100644
a b 539 539 api.Panel.prototype.attachEvents.call( this ); 540 540 541 541 var panel = this, 542 panelMeta = panel.cont ainer.find( '.panel-meta' ),542 panelMeta = panel.content.find( '.panel-meta' ), 543 543 help = panelMeta.find( '.customize-help-toggle' ), 544 544 content = panelMeta.find( '.customize-panel-description' ), 545 545 options = $( '#screen-options-wrap' ), … … 712 712 713 713 api.bind( 'pane-contents-reflowed', function() { 714 714 // Skip menus that have been removed. 715 if ( ! section.cont ainer.parent().length ) {715 if ( ! section.content.parent().length ) { 716 716 return; 717 717 } 718 section.cont ainer.find( '.menu-item .menu-item-reorder-nav button' ).attr({ 'tabindex': '0', 'aria-hidden': 'false' });719 section.cont ainer.find( '.menu-item.move-up-disabled .menus-move-up' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });720 section.cont ainer.find( '.menu-item.move-down-disabled .menus-move-down' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });721 section.cont ainer.find( '.menu-item.move-left-disabled .menus-move-left' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });722 section.cont ainer.find( '.menu-item.move-right-disabled .menus-move-right' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' });718 section.content.find( '.menu-item .menu-item-reorder-nav button' ).attr({ 'tabindex': '0', 'aria-hidden': 'false' }); 719 section.content.find( '.menu-item.move-up-disabled .menus-move-up' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); 720 section.content.find( '.menu-item.move-down-disabled .menus-move-down' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); 721 section.content.find( '.menu-item.move-left-disabled .menus-move-left' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); 722 section.content.find( '.menu-item.move-right-disabled .menus-move-right' ).attr({ 'tabindex': '-1', 'aria-hidden': 'true' }); 723 723 } ); 724 724 }, 725 725 … … 830 830 var section = this; 831 831 832 832 if ( expanded ) { 833 wpNavMenu.menuList = section.cont ainer.find( '.accordion-section-content:first' );833 wpNavMenu.menuList = section.content; 834 834 wpNavMenu.targetList = wpNavMenu.menuList; 835 835 836 836 // Add attributes needed by wpNavMenu … … 892 892 onChangeExpanded: function( expanded ) { 893 893 var section = this, 894 894 button = section.container.find( '.add-menu-toggle' ), 895 content = section.cont ainer.find( '.new-menu-section-content' ),895 content = section.content, 896 896 customizer = section.container.closest( '.wp-full-overlay-sidebar-content' ); 897 897 if ( expanded ) { 898 898 button.addClass( 'open' ); … … 906 906 content.slideUp( 'fast' ); 907 907 content.find( '.menu-name-field' ).removeClass( 'invalid' ); 908 908 } 909 }, 910 911 /** 912 * Detach and return the content html, extracted from the container html, if it exists. 913 * 914 * @since 915 */ 916 getContent: function () { 917 return this.container.find( 'ul:first' ); 909 918 } 910 919 }); 911 920 … … 1797 1806 */ 1798 1807 ready: function() { 1799 1808 var control = this, 1809 section = api.section( control.section() ), 1800 1810 menuId = control.params.menu_id, 1801 1811 menu = control.setting(), 1802 1812 name, … … 1813 1823 * being deactivated. 1814 1824 */ 1815 1825 control.active.validate = function() { 1816 var value , section = api.section( control.section() );1826 var value; 1817 1827 if ( section ) { 1818 1828 value = section.active(); 1819 1829 } else { … … 1822 1832 return value; 1823 1833 }; 1824 1834 1825 control.$controlSection = control.container.closest( '.control-section' );1835 control.$controlSection = section.container; 1826 1836 control.$sectionContent = control.container.closest( '.accordion-section-content' ); 1827 1837 1828 1838 this._setupModel(); … … 2005 2015 section = api.section( control.section() ); 2006 2016 removeSection = function() { 2007 2017 section.container.remove(); 2018 section.content.remove(); 2008 2019 api.section.remove( section.id ); 2009 2020 }; 2010 2021 … … 2096 2107 return; 2097 2108 } 2098 2109 2099 var section = control.container.closest( '.accordion-section'),2110 var section = api.section( control.section() ), 2100 2111 menuId = control.params.menu_id, 2101 controlTitle = section. find( '.accordion-section-title' ),2102 sectionTitle = section. find( '.customize-section-title h3' ),2103 location = section. find( '.menu-in-location' ),2112 controlTitle = section.container.find( '.accordion-section-title' ), 2113 sectionTitle = section.content.find( '.customize-section-title h3' ), 2114 location = section.container.find( '.menu-in-location' ), 2104 2115 action = sectionTitle.find( '.customize-action' ), 2105 2116 name = displayNavMenuName( menu.name ); 2106 2117 … … 2124 2135 } ); 2125 2136 2126 2137 // Update the nav menu name in all location checkboxes. 2127 section. find( '.customize-control-checkbox input' ).each( function() {2138 section.content.find( '.customize-control-checkbox input' ).each( function() { 2128 2139 if ( $( this ).prop( 'checked' ) ) { 2129 2140 $( '.current-menu-location-name-' + $( this ).data( 'location-id' ) ).text( name ); 2130 2141 } -
src/wp-admin/js/customize-controls.js
From 0b64cfd4194259786eab51dc5fe9c20adf360c7e Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Fri, 22 Apr 2016 18:57:56 +0200 Subject: [PATCH 6/9] Fix expanding/collapsing of Themes panel. Remove unused `getNormalizedTransitionendEvent` function. --- src/wp-admin/js/customize-controls.js | 56 ++++++++++++----------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 74e8191..8e9fdad 100644
a b 2 2 (function( exports, $ ){ 3 3 var Container, focus, normalizedTransitionendEventName, api = wp.customize; 4 4 5 normalizedTransitionendEventName = (function () {6 var el, transitions, prop;7 el = document.createElement( 'div' );8 transitions = {9 'transition' : 'transitionend',10 'OTransition' : 'oTransitionEnd',11 'MozTransition' : 'transitionend',12 'WebkitTransition': 'webkitTransitionEnd'13 };14 prop = _.find( _.keys( transitions ), function( prop ) {15 return ! _.isUndefined( el.style[ prop ] );16 } );17 if ( prop ) {18 return transitions[ prop ];19 } else {20 return null;21 }22 })();23 24 5 /** 25 6 * A Customizer Setting. 26 7 * … … 192 173 * 193 174 * @returns {String} 194 175 */ 195 api.utils.getNormalizedTransitionendEvent = function () { 196 var t, 197 undefined, 198 el = document.createElement( 'div' ), 199 transitions = { 200 'transition' : 'transitionend', 201 'OTransition' : 'oTransitionEnd', 202 'MozTransition' : 'transitionend', 203 'WebkitTransition': 'webkitTransitionEnd' 204 }; 205 206 for ( t in transitions ) { 207 if ( transitions.hasOwnProperty( t ) && undefined !== el.style[ t ] ) { 208 return transitions[t]; 209 } 176 normalizedTransitionendEventName = (function () { 177 var el, transitions, prop; 178 el = document.createElement( 'div' ); 179 transitions = { 180 'transition' : 'transitionend', 181 'OTransition' : 'oTransitionEnd', 182 'MozTransition' : 'transitionend', 183 'WebkitTransition': 'webkitTransitionEnd' 184 }; 185 prop = _.find( _.keys( transitions ), function( prop ) { 186 return ! _.isUndefined( el.style[ prop ] ); 187 } ); 188 if ( prop ) { 189 return transitions[ prop ]; 190 } else { 191 return null; 210 192 } 211 } ;193 })(); 212 194 213 195 /** 214 196 * Base class for Panel and Section. … … 1004 986 customizeBtn = section.find( '.customize-theme' ), 1005 987 changeBtn = panel.container.find( '.change-theme' ); 1006 988 1007 if ( expanded ) {989 if ( expanded && ! section.hasClass( 'current-panel' ) ) { 1008 990 // Collapse any sibling sections/panels 1009 991 api.section.each( function ( otherSection ) { 1010 992 if ( otherSection !== panel ) { … … 1034 1016 if ( args.completeCallback ) { 1035 1017 args.completeCallback(); 1036 1018 } 1037 } else {1019 } else if ( ! expanded && section.hasClass( 'current-panel' ) ) { 1038 1020 section.one( normalizedTransitionendEventName, function () { 1039 1021 section.removeClass( 'closing' ); 1040 1022 info.removeClass( 'closing' ); -
src/wp-admin/js/customize-controls.js
From 128aeac27023e957db781cb6295679c059adec35 Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Fri, 22 Apr 2016 20:36:12 +0200 Subject: [PATCH 7/9] Fix bugs related to focusing on control (particularly on shift+click). --- src/wp-admin/js/customize-controls.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 8e9fdad..3a6464b 100644
a b 77 77 * @param {Function} [params.completeCallback] 78 78 */ 79 79 focus = function ( params ) { 80 var construct, completeCallback, focus, focusElement; 81 construct = this; 80 var construct = this, 81 completeCallback, focus; 82 82 83 params = params || {}; 83 84 focus = function () { 84 var focusContainer; 85 if ( construct.extended( api.Panel ) && construct.expanded && construct.expanded() ) { 86 focusContainer = construct.container.find( 'ul.control-panel-content' ); 87 } else if ( construct.extended( api.Section ) && construct.expanded && construct.expanded() ) { 88 focusContainer = construct.container.find( 'ul.accordion-section-content' ); 89 } else { 90 focusContainer = construct.container; 91 } 85 var focusContainer = construct.container, 86 focusElement; 92 87 93 focusElement = focusContainer.find( '.control-focus:first' ); 88 if ( ( construct.extended( api.Panel ) || construct.extended( api.Section ) ) && construct.expanded && construct.expanded() ) { 89 focusContainer = ( construct.content.is( 'ul' ) ) ? construct.content : construct.content.find( 'ul:first' ); 90 } 91 focusElement = focusContainer.find( '.control-focus, input, select, textarea, button' ).filter( ':visible' ).first(); 94 92 if ( 0 === focusElement.length ) { 95 93 // Note that we can't use :focusable due to a jQuery UI issue. See: https://github.com/jquery/jquery-ui/pull/1583 96 focusElement = focusContainer.find( ' input, select, textarea, button,object, a[href], [tabindex]' ).filter( ':visible' ).first();94 focusElement = focusContainer.find( 'object, a[href], [tabindex]' ).filter( ':visible' ).first(); 97 95 } 98 96 focusElement.focus(); 99 97 }; 98 100 99 if ( params.completeCallback ) { 101 100 completeCallback = params.completeCallback; 102 101 params.completeCallback = function () { … … 516 515 */ 517 516 getContent: function () { 518 517 var container = this, 519 list = container.container.find( '.accordion-section-content, .control-panel-content' ).first(), // container.container.find( 'ul:first' ),518 list = container.container.find( '.accordion-section-content, .control-panel-content' ).first(), 520 519 contentId = 'sub-accordion-list-' + container.id; 521 520 522 521 container.setOwnership( contentId ); … … 790 789 if ( args.completeCallback ) { 791 790 args.completeCallback(); 792 791 } 792 793 793 } else { 794 794 if ( args.completeCallback ) { 795 795 args.completeCallback(); -
src/wp-admin/js/customize-controls.js
From 540e939472de426abbc4c9640c565c1086449132 Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Wed, 4 May 2016 22:33:49 +0200 Subject: [PATCH 8/9] Clear jshint errors. --- src/wp-admin/js/customize-controls.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 245bf06..39de2d2 100644
a b 521 521 container.setOwnership( contentId ); 522 522 523 523 return list.detach().attr( { 524 id: contentId,525 class: 'customize-pane-child ' + list.attr( 'class' )524 'id': contentId, 525 'class': 'customize-pane-child ' + list.attr( 'class' ) 526 526 } ); 527 527 }, 528 528 … … 1284 1284 * @since 4.1.0 1285 1285 */ 1286 1286 attachEvents: function () { 1287 var meta, panel = this, 1288 overlay = panel.content.closest( '.wp-full-overlay' ); 1287 var meta, panel = this; 1289 1288 1290 1289 // Expand/Collapse accordion sections on click. 1291 1290 panel.container.find( '.accordion-section-title' ).on( 'click keydown', function( event ) { … … 1394 1393 info = overlay.find( '#customize-info' ), 1395 1394 parent = overlay.find( '.customize-pane-parent' ), 1396 1395 topPanel = panel.container.find( '.accordion-section-title' ), 1397 backBtn = accordionSection.find( '.customize-panel-back' ), 1398 panelTitle = accordionSection.find( '.accordion-section-title' ).first(); 1396 backBtn = accordionSection.find( '.customize-panel-back' ); 1399 1397 1400 1398 if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { 1401 1399 -
src/wp-admin/css/customize-controls.css
From a8e46e18b3676314afd7c7e61b63fd3e21186536 Mon Sep 17 00:00:00 2001 From: Piotr Delawski <piotr.delawski@xwp.co> Date: Sat, 7 May 2016 22:09:48 +0200 Subject: [PATCH 9/9] Refine transitions handling in new panel/section structure. Clean JS and CSS code. --- src/wp-admin/css/customize-controls.css | 163 +++++----------------- src/wp-admin/js/customize-controls.js | 238 +++++++++++++++++++++----------- 2 files changed, 195 insertions(+), 206 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index d38e02a..9b9e001 100644
a b body { 218 218 box-sizing: border-box; 219 219 } 220 220 221 .wp-full-overlay #customize-controls .wp-full-overlay-sidebar-content { 222 /* Promote to separate layer to avoid full-screen repaints */ 223 transform: translate3d(0,0,0); 224 } 225 221 226 #customize-info, 222 227 #customize-theme-controls .customize-pane-parent, 223 228 #customize-theme-controls .customize-pane-child { … … body { 228 233 -webkit-box-sizing: border-box; 229 234 -moz-box-sizing: border-box; 230 235 box-sizing: border-box; 231 transition: 0. 48s transform cubic-bezier(0.19, 1, 0.22, 1); /* easeOutExpo */236 transition: 0.6s transform cubic-bezier(0.19, 1, 0.22, 1); /* easeOutExpo */ 232 237 } 233 238 234 239 #customize-info, … … body { 238 243 height: auto; 239 244 max-height: none; 240 245 overflow: auto; 241 transform: translateX(0);246 transform: none; 242 247 } 243 248 244 .section-open #customize-theme-controls .customize-pane-parent, 245 .in-sub-panel #customize-theme-controls .customize-pane-parent, 246 .section-open #customize-info, 247 .in-sub-panel #customize-info, 248 .in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel { 249 transform: translateX(-100%); 249 #customize-theme-controls .customize-pane-child { 250 position: absolute; 251 top: 0; 252 left: 0; 253 transform: translateX(100%); 254 visibility: hidden; 255 height: 0; 256 max-height: none; 257 overflow: hidden; 250 258 } 251 259 252 .in-themes-panel #customize-theme-controls .customize-pane-parent, 253 .in-themes-panel #customize-info { 254 transform: translateX(100%); 260 #customize-theme-controls .customize-pane-child.open, 261 #customize-theme-controls .customize-pane-child.current-panel, 262 #customize-theme-controls .customize-themes-panel.customize-pane-child.current-panel { 263 transform: none; 255 264 } 256 265 266 #customize-theme-controls .customize-themes-panel.customize-pane-child, 257 267 .section-open #customize-theme-controls .customize-pane-parent, 258 268 .in-sub-panel #customize-theme-controls .customize-pane-parent, 259 269 .section-open #customize-info, 260 270 .in-sub-panel #customize-info, 261 .section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel { 271 .in-sub-panel.section-open #customize-theme-controls .customize-pane-child.current-panel, 272 .in-themes-panel #customize-theme-controls .customize-pane-parent, 273 .in-themes-panel #customize-info { 262 274 visibility: hidden; 263 275 height: 0; 264 276 overflow: hidden; 277 transform: translateX(-100%); 265 278 } 266 279 267 .section-open #customize-theme-controls .customize-pane-parent.closing, 268 .in-sub-panel #customize-theme-controls .customize-pane-parent.closing, 269 .section-open #customize-info.closing, 270 .in-sub-panel #customize-info.closing, 280 .section-open #customize-theme-controls .customize-pane-parent.transitioning, 281 .in-sub-panel #customize-theme-controls .customize-pane-parent.transitioning, 282 .in-themes-panel #customize-theme-controls .customize-pane-parent.transitioning, 283 .section-open #customize-info.transitioning, 284 .in-sub-panel #customize-info.transitioning, 285 .in-themes-panel #customize-info.transitioning, 271 286 .transitioning.section-open.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel, 272 287 #customize-theme-controls .customize-pane-child.open, 273 288 #customize-theme-controls .customize-pane-child.current-panel, 274 #customize-theme-controls .customize-pane-child. closing {289 #customize-theme-controls .customize-pane-child.transitioning { 275 290 visibility: visible; 276 291 height: auto; 277 292 overflow: auto; 278 293 } 279 294 280 #customize-theme-controls .customize-pane-child { 281 position: absolute; 282 top: 0; 283 left: 0; 295 .in-themes-panel #customize-theme-controls .customize-pane-parent, 296 .in-themes-panel #customize-info { 284 297 transform: translateX(100%); 285 visibility: hidden;286 height: 0;287 max-height: none;288 overflow: hidden;289 }290 291 #customize-theme-controls .customize-pane-parent.closing,292 #customize-info.closing,293 #customize-theme-controls .customize-pane-child.closing {294 max-height: 100%;295 }296 297 #customize-theme-controls .customize-pane-child.open,298 #customize-theme-controls .customize-pane-child.current-panel {299 transform: translateX(0);300 }301 302 #customize-theme-controls .customize-themes-panel.customize-pane-child {303 transform: translateX(-100%);304 }305 306 #customize-theme-controls .customize-themes-panel.customize-pane-child.current-panel {307 transform: translateX(0);308 298 } 309 299 310 300 #customize-theme-controls .customize-pane-child.accordion-section-content, … … body { 317 307 padding: 12px; 318 308 } 319 309 320 .wp-full-overlay #customize-controls .wp-full-overlay-sidebar-content {321 /* Promote to separate layer to avoid full-screen repaints */322 transform: translate3d(0,0,0);323 }324 325 310 .customize-section-description-container { 326 311 margin-bottom: 15px; 327 312 } … … h3.customize-section-title { 361 346 color: #555; 362 347 } 363 348 364 /*#customize-theme-controls {365 position: relative;366 left: 0;367 -webkit-transition: .18s left ease-in-out;368 transition: .18s left ease-in-out;369 }*/370 371 /*.ios #customize-theme-controls {372 -webkit-transition: left 0s;373 transition: left 0s;374 }*/375 376 /*.section-open #customize-info,377 .section-open #customize-theme-controls {378 left: -100%;379 }*/380 381 349 .accordion-sub-container.control-panel-content { 382 350 display: none; 383 351 position: absolute; … … h3.customize-section-title { 393 361 transition: left 0s; 394 362 } 395 363 396 .accordion-sub-container.control-panel-content. closing {364 .accordion-sub-container.control-panel-content.transitioning { 397 365 display: block; 398 366 } 399 367 … … h3.customize-section-title { 436 404 -webkit-box-shadow: none; 437 405 box-shadow: none; 438 406 cursor: pointer; 439 -webkit-transition: left .18s ease-in-out,color .1s ease-in-out, background .1s ease-in-out;440 transition: left .18s ease-in-out,color .1s ease-in-out, background .1s ease-in-out;407 -webkit-transition: color .1s ease-in-out, background .1s ease-in-out; 408 transition: color .1s ease-in-out, background .1s ease-in-out; 441 409 } 442 410 443 411 .customize-section-back { 444 412 height: 74px; 445 413 } 446 414 447 .ios .customize-panel-back,448 .ios .customize-section-back {449 -webkit-transition: left 0s;450 transition: left 0s;451 }452 453 415 .ios .customize-panel-back { 454 416 display: none; 455 417 } … … h3.customize-section-title { 515 477 padding-left: 62px; 516 478 } 517 479 518 #customize-theme-controls .control-section.current-panel {519 padding: 0;520 }521 522 #customize-theme-controls .control-section > h3.accordion-section-title {523 position: relative;524 left: 0;525 }526 527 #customize-theme-controls .control-section.current-panel > h3.accordion-section-title {528 left: -354px;529 -webkit-transition: left ease-in-out .18s;530 transition: left ease-in-out .18s;531 }532 533 .ios #customize-theme-controls .control-section.current-panel > h3.accordion-section-title {534 -webkit-transition: left 0s;535 transition: left 0s;536 }537 538 /*.wp-full-overlay.section-open #customize-controls .wp-full-overlay-sidebar-content {539 visibility: hidden;540 overflow-y: hidden;541 }542 */543 /*.wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open {544 visibility: visible;545 }546 547 .wp-full-overlay.section-open .wp-full-overlay-sidebar-content .accordion-section.open .accordion-section-content {548 overflow-y: auto;549 }*/550 551 480 p.customize-section-description { 552 481 font-style: normal; 553 482 margin-top: 22px; … … p.customize-section-description { 1159 1088 padding: 15px 8px 0 8px; 1160 1089 } 1161 1090 1162 /*.control-section.open .customize-themes-panel {1163 display: block;1164 }*/1165 1166 1091 #customize-theme-controls .customize-themes-panel .accordion-section-content { 1167 1092 background: transparent; 1168 1093 display: block; … … p.customize-section-description { 1208 1133 width: 100%; 1209 1134 } 1210 1135 1211 /*#accordion-section-themes .accordion-section-title:after {*/1212 1136 .control-section-themes .accordion-section-title:after, 1213 1137 .customize-themes-panel .accordion-section-title:after { 1214 1138 display: none; 1215 1139 } 1216 1140 1217 /*#customize-theme-controls .control-section-themes.current-panel > h3.accordion-section-title {1218 left: 0;1219 }*/1220 1221 1141 .customize-themes-panel.control-panel-content { 1222 /* position: absolute;1223 left: -100%;1224 top: 0;1225 width: 100%;*/1226 1142 border-top: 1px solid #ddd; 1227 1143 } 1228 1144 1229 /*.in-themes-panel #customize-info,1230 .in-themes-panel #customize-theme-controls > ul > .accordion-section {1231 left: 100%;1232 }*/1233 1234 1145 /* Details View */ 1235 1146 .wp-customizer .theme-overlay { 1236 1147 display: none; -
src/wp-admin/js/customize-controls.js
diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 39de2d2..bec58c5 100644
a b 718 718 parent = overlay.find( '.customize-pane-parent' ), 719 719 backBtn = content.find( '.customize-section-back' ), 720 720 sectionTitle = section.container.find( '.accordion-section-title' ).first(), 721 expand; 721 expand, handleTransition; 722 723 /** 724 * Handle transitions if they are supported by the browser. 725 * 726 * @param {object} args 727 * @param {object} args.focusElement Object gaining focus on after transition. 728 */ 729 handleTransition = function ( args ) { 730 var focus; 731 732 focus = function () { 733 if ( ! _.isUndefined( args.focusElement ) ) { 734 args.focusElement.focus(); 735 } 736 }; 737 738 container.scrollTop( 0 ); 739 if ( normalizedTransitionendEventName ) { 740 _.each( [ content, overlay ], function ( el ) { 741 el.addClass( 'transitioning' ); 742 } ); 743 744 if ( ! overlay.hasClass( 'in-sub-panel' ) ) { 745 _.each( [ info, parent ], function ( el ) { 746 el.addClass( 'transitioning' ); 747 } ); 748 } 749 750 content.on( normalizedTransitionendEventName, function ( event ) { 751 if ( ! content.is( event.target ) || 'transform' !== event.originalEvent.propertyName ) { 752 return this; 753 } 754 content.off( normalizedTransitionendEventName ); 755 756 _.each( [ content, overlay ], function ( el ) { 757 el.removeClass( 'transitioning' ); 758 } ); 759 760 if ( info.hasClass( 'transitioning' ) ) { 761 _.each( [ info, parent ], function ( el ) { 762 el.removeClass( 'transitioning' ); 763 } ); 764 } 765 766 focus(); 767 return this; 768 } ); 769 } else { 770 focus(); 771 } 772 }; 722 773 723 774 if ( expanded && ! content.hasClass( 'open' ) ) { 724 775 725 776 if ( args.unchanged ) { 726 777 expand = args.completeCallback; 727 778 } else { 728 container.scrollTop( 0 );729 779 expand = function() { 730 content.one( normalizedTransitionendEventName, function () { 731 info.removeClass( 'closing' ); 732 parent.removeClass( 'closing' ); 733 overlay.removeClass( 'transitioning' ); 734 backBtn.focus(); 735 } ); 736 780 handleTransition( { focusElement: backBtn } ); 737 781 content.addClass( 'open' ); 738 info.addClass( 'closing' ); 739 parent.addClass( 'closing' ); 740 overlay.addClass( 'section-open transitioning' ); 782 overlay.addClass( 'section-open' ); 741 783 742 784 sectionTitle.attr( 'tabindex', '-1' ); 743 785 backBtn.attr( 'tabindex', '0' ); … … 770 812 771 813 } else if ( ! expanded && content.hasClass( 'open' ) ) { 772 814 773 content.one( normalizedTransitionendEventName, function () { 774 content.removeClass( 'closing' ); 775 info.removeClass( 'closing' ); 776 parent.removeClass( 'closing' ); 777 overlay.removeClass( 'transitioning' ); 778 sectionTitle.focus(); 779 } ); 780 781 content.removeClass( 'open' ).addClass( 'closing' ); 782 info.addClass( 'closing' ); 783 parent.addClass( 'closing' ); 784 overlay.removeClass( 'section-open transitioning' ); 815 handleTransition( { focusElement: sectionTitle } ); 816 content.removeClass( 'open' ); 817 overlay.removeClass( 'section-open' ); 785 818 786 819 backBtn.attr( 'tabindex', '-1' ); 787 820 sectionTitle.attr( 'tabindex', '0' ); … … 984 1017 info = overlay.find( '#customize-info' ), 985 1018 parent = overlay.find( '.customize-pane-parent' ), 986 1019 customizeBtn = section.find( '.customize-theme' ), 987 changeBtn = panel.container.find( '.change-theme' ); 1020 changeBtn = panel.container.find( '.change-theme' ), 1021 handleTransition; 1022 1023 /** 1024 * Handle transitions if they are supported by the browser. 1025 * 1026 * @param {object} args 1027 * @param {object} args.focusElement Object gaining focus on after transition. 1028 */ 1029 handleTransition = function ( args ) { 1030 var focus, transitionedElements = [ section, info, parent, overlay ]; 1031 1032 focus = function () { 1033 if ( ! _.isUndefined( args.focusElement ) ) { 1034 args.focusElement.focus(); 1035 } 1036 }; 1037 1038 container.scrollTop( 0 ); 1039 if ( normalizedTransitionendEventName ) { 1040 _.each( transitionedElements, function ( el ) { 1041 el.addClass( 'transitioning' ); 1042 } ); 1043 1044 section.on( normalizedTransitionendEventName, function ( event ) { 1045 if ( ! section.is( event.target ) || 'transform' !== event.originalEvent.propertyName ) { 1046 return this; 1047 } 1048 section.off( normalizedTransitionendEventName ); 1049 1050 _.each( transitionedElements, function ( el ) { 1051 el.removeClass( 'transitioning' ); 1052 } ); 1053 1054 focus(); 1055 _.delay( panel.renderScreenshots, 10 ); 1056 return this; 1057 } ); 1058 } else { 1059 focus(); 1060 } 1061 }; 988 1062 989 1063 if ( expanded && ! section.hasClass( 'current-panel' ) ) { 1064 990 1065 // Collapse any sibling sections/panels 991 1066 api.section.each( function ( otherSection ) { 992 1067 if ( otherSection !== panel ) { … … 997 1072 otherPanel.collapse( { duration: 0 } ); 998 1073 }); 999 1074 1000 section.one( normalizedTransitionendEventName, function () { 1001 info.removeClass( 'closing' ); 1002 parent.removeClass( 'closing' ); 1003 overlay.removeClass( 'transitioning' ); 1004 customizeBtn.focus(); 1005 _.delay( panel.renderScreenshots, 10 ); 1006 } ); 1007 1075 handleTransition( { focusElement: customizeBtn } ); 1008 1076 section.addClass( 'current-panel' ); 1009 info.addClass( 'closing' ); 1010 parent.addClass( 'closing' ); 1011 overlay.addClass( 'in-themes-panel transitioning' ); 1077 overlay.addClass( 'in-themes-panel' ); 1012 1078 1013 container.scrollTop( 0 );1014 1079 panel.$customizeSidebar.on( 'scroll.customize-themes-section', _.throttle( panel.renderScreenshots, 300 ) ); 1015 1080 1016 1081 if ( args.completeCallback ) { 1017 1082 args.completeCallback(); 1018 1083 } 1019 1084 } else if ( ! expanded && section.hasClass( 'current-panel' ) ) { 1020 section.one( normalizedTransitionendEventName, function () {1021 section.removeClass( 'closing' );1022 info.removeClass( 'closing' );1023 parent.removeClass( 'closing' );1024 overlay.removeClass( 'transitioning' );1025 changeBtn.focus();1026 } );1027 1085 1028 section.removeClass( 'current-panel' ).addClass( 'closing');1029 info.addClass( 'closing' );1030 parent.addClass( 'closing' );1031 overlay.removeClass( 'in-themes-panel' ).addClass( 'transitioning' ); 1086 handleTransition( { focusElement: changeBtn } ); 1087 section.removeClass( 'current-panel' ); 1088 overlay.removeClass( 'in-themes-panel' ); 1089 1032 1090 panel.$customizeSidebar.off( 'scroll.customize-themes-section' ); 1033 1091 1034 1092 customizeBtn.attr( 'tabindex', '0' ); 1035 container.scrollTop( 0 );1036 1093 1037 1094 if ( args.completeCallback ) { 1038 1095 args.completeCallback(); … … 1393 1450 info = overlay.find( '#customize-info' ), 1394 1451 parent = overlay.find( '.customize-pane-parent' ), 1395 1452 topPanel = panel.container.find( '.accordion-section-title' ), 1396 backBtn = accordionSection.find( '.customize-panel-back' ); 1453 backBtn = accordionSection.find( '.customize-panel-back' ), 1454 handleTransition; 1455 1456 /** 1457 * Handle transitions if they are supported by the browser. 1458 * 1459 * @param {object} args 1460 * @param {object} args.focusElement Object gaining focus on after transition. 1461 */ 1462 handleTransition = function ( args ) { 1463 var focus, transitionedElements = [ accordionSection, info, parent, overlay ]; 1464 1465 focus = function () { 1466 if ( ! _.isUndefined( args.focusElement ) ) { 1467 args.focusElement.focus(); 1468 } 1469 }; 1470 1471 container.scrollTop( 0 ); 1472 if ( normalizedTransitionendEventName ) { 1473 _.each( transitionedElements, function ( el ) { 1474 el.addClass( 'transitioning' ); 1475 } ); 1476 1477 accordionSection.on( normalizedTransitionendEventName, function ( event ) { 1478 if ( ! accordionSection.is( event.target ) || 'transform' !== event.originalEvent.propertyName ) { 1479 return this; 1480 } 1481 accordionSection.off( normalizedTransitionendEventName ); 1482 1483 _.each( transitionedElements, function ( el ) { 1484 el.removeClass( 'transitioning' ); 1485 } ); 1486 1487 focus(); 1488 return this; 1489 } ); 1490 } else { 1491 focus(); 1492 } 1493 }; 1397 1494 1398 1495 if ( expanded && ! accordionSection.hasClass( 'current-panel' ) ) { 1399 1496 … … 1409 1506 } 1410 1507 }); 1411 1508 1412 accordionSection.one( normalizedTransitionendEventName, function () { 1413 info.removeClass( 'closing' ); 1414 parent.removeClass( 'closing' ); 1415 overlay.removeClass( 'transitioning' ); 1416 backBtn.focus(); 1417 } ); 1418 1509 handleTransition( { focusElement: backBtn } ); 1510 overlay.addClass( 'in-sub-panel' ); 1419 1511 accordionSection.addClass( 'current-panel' ); 1420 info.addClass( 'closing' );1421 parent.addClass( 'closing' );1422 overlay.addClass( 'in-sub-panel transitioning' );1423 1424 container.scrollTop( 0 );1425 if ( args.completeCallback ) {1426 args.completeCallback();1427 }1428 1512 1429 1513 topPanel.attr( 'tabindex', '-1' ); 1430 1514 backBtn.attr( 'tabindex', '0' ); 1431 1515 1432 } else if ( ! expanded && accordionSection.hasClass( 'current-panel' ) ) {1433 accordionSection.one( normalizedTransitionendEventName, function () {1434 accordionSection.removeClass( 'closing' );1435 info.removeClass( 'closing' );1436 parent.removeClass( 'closing' );1437 overlay.removeClass( 'transitioning' );1438 topPanel.focus();1439 } );1440 1441 accordionSection.removeClass( 'current-panel' ).addClass( 'closing' );1442 info.addClass( 'closing' );1443 parent.addClass( 'closing' );1444 overlay.removeClass( 'in-sub-panel' ).addClass( 'transitioning' );1445 1446 1516 if ( args.completeCallback ) { 1447 1517 args.completeCallback(); 1448 1518 } 1449 1519 1520 } else if ( ! expanded && accordionSection.hasClass( 'current-panel' ) ) { 1521 1522 handleTransition( { focusElement: topPanel } ); 1523 overlay.removeClass( 'in-sub-panel' ); 1524 accordionSection.removeClass( 'current-panel' ); 1525 1450 1526 topPanel.attr( 'tabindex', '0' ); 1451 1527 backBtn.attr( 'tabindex', '-1' ); 1452 1528 1453 container.scrollTop( 0 ); 1529 if ( args.completeCallback ) { 1530 args.completeCallback(); 1531 } 1454 1532 } 1455 1533 }, 1456 1534