[wp-trac] [WordPress Trac] #30850: Audio/video previews for media controls in the Customizer

WordPress Trac noreply at wordpress.org
Mon Feb 16 16:06:48 UTC 2015


#30850: Audio/video previews for media controls in the Customizer
-------------------------------------+-------------------------
 Reporter:  celloexpressions         |       Owner:
     Type:  enhancement              |      Status:  new
 Priority:  normal                   |   Milestone:  4.2
Component:  Customize                |     Version:  4.1
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-refresh  |     Focuses:  javascript
-------------------------------------+-------------------------

Comment (by westonruter):

 Yes, having an `expanded` (and `collapsed`) event for Sections would align
 with what widget form controls in the Customizer are
 [https://github.com/xwp/wordpress-
 develop/blob/b52cb0346e3f5be022b5cf1962103b5c51de07a2/src/wp-admin/js
 /customize-widgets.js#L1251 doing]. But in the mean time of not having it
 in Core, ''by the power of JavaScript'' you can have it now, by adding the
 following to some plugin code that gets enqueued after `customize-
 controls.js`:

 {{{#!js
 var oldToggleExpanded = wp.customize.Section.prototype._toggleExpanded;
 wp.customize.Section.prototype._toggleExpanded = function ( expanded,
 params ) {
         params = params || {};
         var section = this, previousCompleteCallback =
 params.completeCallback;
         params.completeCallback = function () {
                 if ( previousCompleteCallback ) {
                         previousCompleteCallback.apply( section, arguments
 );
                 }
                 if ( expanded ) {
                         section.container.trigger( 'expanded' );
                 } else {
                         section.container.trigger( 'collapsed' );
                 }
         }
         oldToggleExpanded.call( this, expanded, params );
 };
 }}}

 Note that as with widget form controls, the event is triggered on the DOM
 element itself, so that's what you listen on.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30850#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list