From 1705358159d7ebafa3d7aaaa224ce3998d8ccd95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Tue, 8 Jul 2014 20:22:15 +0000 Subject: [PATCH] accordion.js: * Remove remnants from when some corners were rounded. * Docs. props celloexpressions. see #27406. Built from https://develop.svn.wordpress.org/trunk@29036 git-svn-id: http://core.svn.wordpress.org/trunk@28824 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/accordion.js | 71 ++++++++++++++++++++++++++---------- wp-admin/js/accordion.min.js | 2 +- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/wp-admin/js/accordion.js b/wp-admin/js/accordion.js index ca866f8c1c..d174ffe814 100644 --- a/wp-admin/js/accordion.js +++ b/wp-admin/js/accordion.js @@ -1,8 +1,41 @@ +/** + * Accordion-folding functionality. + * + * Markup with the appropriate classes will be automatically hidden, + * with one section opening at a time when its title is clicked. + * Use the following markup structure for accordion behavior: + * + *
+ *
+ *

+ *
+ *
+ *
+ *
+ *

+ *
+ *
+ *
+ *
+ *

+ *
+ *
+ *
+ *
+ * + * Note that any appropriate tags may be used, as long as the above classes are present. + * + * In addition to the standard accordion behavior, this file includes JS for the + * Customizer's "Panel" functionality. + * + * @since 3.6.0. + */ + ( function( $ ){ $( document ).ready( function () { - // Expand/Collapse on click + // Expand/Collapse accordion sections on click. $( '.accordion-container' ).on( 'click keydown', '.accordion-section-title', function( e ) { if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key return; @@ -13,7 +46,7 @@ accordionSwitch( $( this ) ); }); - // Back to top level + // Go back to the top-level Customizer accordion. $( '.accordion-container' ).on( 'click keydown', '.control-panel-back', function( e ) { if ( e.type === 'keydown' && 13 !== e.which ) { // "return" key return; @@ -23,33 +56,28 @@ panelSwitch( $( this ) ); }); - - // Re-initialize accordion when screen options are toggled - $( '.hide-postbox-tog' ).click( function () { - accordionInit(); - }); - }); var accordionOptions = $( '.accordion-container li.accordion-section' ), sectionContent = $( '.accordion-section-content' ); - function accordionInit () { - // Rounded corners - accordionOptions.removeClass( 'top bottom' ); - accordionOptions.filter( ':visible' ).first().addClass( 'top' ); - accordionOptions.filter( ':visible' ).last().addClass( 'bottom' ).find( sectionContent ).addClass( 'bottom' ); - } - + /** + * Close the current accordion section and open a new one. + * + * @param {Object} el Title element of the accordion section to toggle. + * @since 3.6.0 + */ function accordionSwitch ( el ) { var section = el.closest( '.accordion-section' ), siblings = section.closest( '.accordion-container' ).find( '.open' ), content = section.find( sectionContent ); + // This section has no content and cannot be expanded. if ( section.hasClass( 'cannot-expand' ) ) { return; } + // Slide into a sub-panel instead of accordioning (Customizer-specific). if ( section.hasClass( 'control-panel' ) ) { panelSwitch( section ); return; @@ -64,10 +92,16 @@ content.toggle( false ).slideToggle( 150 ); section.toggleClass( 'open' ); } - - accordionInit(); } + /** + * Slide into an accordion sub-panel. + * + * For the Customizer-specific panel functionality + * + * @param {Object} panel Title element or back button of the accordion panel to toggle. + * @since 4.0.0 + */ function panelSwitch( panel ) { var position, scroll, section = panel.closest( '.accordion-section' ), @@ -107,7 +141,4 @@ } } - // Initialize the accordion (currently just corner fixes) - accordionInit(); - })(jQuery); diff --git a/wp-admin/js/accordion.min.js b/wp-admin/js/accordion.min.js index 2023d6139f..5a5632d114 100644 --- a/wp-admin/js/accordion.min.js +++ b/wp-admin/js/accordion.min.js @@ -1 +1 @@ -!function(a){function b(){e.removeClass("top bottom"),e.filter(":visible").first().addClass("top"),e.filter(":visible").last().addClass("bottom").find(f).addClass("bottom")}function c(a){var c=a.closest(".accordion-section"),e=c.closest(".accordion-container").find(".open"),g=c.find(f);if(!c.hasClass("cannot-expand")){if(c.hasClass("control-panel"))return void d(c);c.hasClass("open")?(c.toggleClass("open"),g.toggle(!0).slideToggle(150)):(e.removeClass("open"),e.find(f).show().slideUp(150),g.toggle(!1).slideToggle(150),c.toggleClass("open")),b()}}function d(a){var b,c,d=a.closest(".accordion-section"),e=d.closest(".wp-full-overlay"),g=d.closest(".accordion-container"),h=g.find(".open"),i=e.find("#customize-theme-controls > ul > .accordion-section > .accordion-section-title").add("#customize-info > .accordion-section-title"),j=d.find(".control-panel-back"),k=d.find(".accordion-section-title").first(),l=d.find(".control-panel-content");d.hasClass("current-panel")?(d.toggleClass("current-panel"),e.toggleClass("in-sub-panel"),l.delay(180).hide(0,function(){l.css("margin-top","inherit")}),i.attr("tabindex","0"),j.attr("tabindex","-1"),k.focus(),g.scrollTop(0)):(h.removeClass("open"),h.find(f).show().slideUp(0),l.show(0,function(){b=l.offset().top,c=g.scrollTop(),l.css("margin-top",45-b-c),d.toggleClass("current-panel"),e.toggleClass("in-sub-panel"),g.scrollTop(0)}),i.attr("tabindex","-1"),j.attr("tabindex","0"),j.focus())}a(document).ready(function(){a(".accordion-container").on("click keydown",".accordion-section-title",function(b){("keydown"!==b.type||13===b.which)&&(b.preventDefault(),c(a(this)))}),a(".accordion-container").on("click keydown",".control-panel-back",function(b){("keydown"!==b.type||13===b.which)&&(b.preventDefault(),d(a(this)))}),a(".hide-postbox-tog").click(function(){b()})});var e=a(".accordion-container li.accordion-section"),f=a(".accordion-section-content");b()}(jQuery); \ No newline at end of file +!function(a){function b(a){var b=a.closest(".accordion-section"),e=b.closest(".accordion-container").find(".open"),f=b.find(d);if(!b.hasClass("cannot-expand"))return b.hasClass("control-panel")?void c(b):void(b.hasClass("open")?(b.toggleClass("open"),f.toggle(!0).slideToggle(150)):(e.removeClass("open"),e.find(d).show().slideUp(150),f.toggle(!1).slideToggle(150),b.toggleClass("open")))}function c(a){var b,c,e=a.closest(".accordion-section"),f=e.closest(".wp-full-overlay"),g=e.closest(".accordion-container"),h=g.find(".open"),i=f.find("#customize-theme-controls > ul > .accordion-section > .accordion-section-title").add("#customize-info > .accordion-section-title"),j=e.find(".control-panel-back"),k=e.find(".accordion-section-title").first(),l=e.find(".control-panel-content");e.hasClass("current-panel")?(e.toggleClass("current-panel"),f.toggleClass("in-sub-panel"),l.delay(180).hide(0,function(){l.css("margin-top","inherit")}),i.attr("tabindex","0"),j.attr("tabindex","-1"),k.focus(),g.scrollTop(0)):(h.removeClass("open"),h.find(d).show().slideUp(0),l.show(0,function(){b=l.offset().top,c=g.scrollTop(),l.css("margin-top",45-b-c),e.toggleClass("current-panel"),f.toggleClass("in-sub-panel"),g.scrollTop(0)}),i.attr("tabindex","-1"),j.attr("tabindex","0"),j.focus())}a(document).ready(function(){a(".accordion-container").on("click keydown",".accordion-section-title",function(c){("keydown"!==c.type||13===c.which)&&(c.preventDefault(),b(a(this)))}),a(".accordion-container").on("click keydown",".control-panel-back",function(b){("keydown"!==b.type||13===b.which)&&(b.preventDefault(),c(a(this)))})});var d=(a(".accordion-container li.accordion-section"),a(".accordion-section-content"))}(jQuery); \ No newline at end of file