[wp-trac] [WordPress Trac] #28709: Improve/introduce Customizer JS models for Controls, Sections, and Panels

WordPress Trac noreply at wordpress.org
Tue Oct 21 07:45:34 UTC 2014


#28709: Improve/introduce Customizer JS models for Controls, Sections, and Panels
------------------------------------+-------------------------
 Reporter:  westonruter             |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  high                    |   Milestone:  4.1
Component:  Customize               |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  javascript
------------------------------------+-------------------------

Comment (by westonruter):

 In [attachment:28709.wip.5.diff] I tried to align the Sections and Panels
 more closely with Controls and the Widgets controls. Instead of the
 `toggle( active )` actually changing the `active` value (state), now this
 method is aligned with widgets where it is a handler to respond to an
 active state change. The name has also been renamed to `toggleActive`with
 `toggle` now being a deprecated alias. Sections and Panels now have
 `toggleExpanded` as well.

 I'm pretty happy with the `active` and `expanded` states, the shortcut
 methods that change them (`activate()`/`deactivate()`,
 `expand()`/`collapse()`), but what I'm not really happy about is the API
 for how controls respond to changes in state, and how the behavior is
 defined. Right now, the models have a `toggleActive( active )` and a
 `toggleExpanded( expanded )` methods. You might think that this would
 change the underlying `active` and `expanded` states, but this is not
 their purpose. Instead of changing their associated state, they are called
 when their associated state is changed. So they are event handlers. The
 naming `toggle*` implies that a state is going to be changed though.
 Perhaps it would be better to say `onToggleActive()` and
 `onToggleExpanded()`, and that these are the methods that subclasses would
 override to provide custom behaviors.

 Thoughts?

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


More information about the wp-trac mailing list