Improve/introduce Customizer JavaScript models for Controls, Sections, and Panels.

* Introduce models for panels and sections.
* Introduce API to expand and focus a control, section or panel.
* Allow deep-linking to panels, sections, and controls inside of the Customizer.
* Clean up `accordion.js`, removing all Customizer-specific logic.
* Add initial unit tests for `wp.customize.Class` in `customize-base.js`.

https://make.wordpress.org/core/2014/10/27/toward-a-complete-javascript-api-for-the-customizer/ provides an overview of how to use the JavaScript API.

props westonruter, celloexpressions, ryankienstra.
see #28032, #28579, #28580, #28650, #28709, #29758.
fixes #29529.



git-svn-id: https://develop.svn.wordpress.org/trunk@30102 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90)
2014-10-29 22:50:21 +00:00
parent 037e00fb15
commit 90182015e7
12 changed files with 1470 additions and 294 deletions
+12 -4
View File
@@ -498,6 +498,8 @@ final class WP_Customize_Manager {
$settings = array(
'values' => array(),
'channel' => wp_unslash( $_POST['customize_messenger_channel'] ),
'activePanels' => array(),
'activeSections' => array(),
'activeControls' => array(),
);
@@ -511,6 +513,12 @@ final class WP_Customize_Manager {
foreach ( $this->settings as $id => $setting ) {
$settings['values'][ $id ] = $setting->js_value();
}
foreach ( $this->panels as $id => $panel ) {
$settings['activePanels'][ $id ] = $panel->active();
}
foreach ( $this->sections as $id => $section ) {
$settings['activeSections'][ $id ] = $section->active();
}
foreach ( $this->controls as $id => $control ) {
$settings['activeControls'][ $id ] = $control->active();
}
@@ -911,11 +919,11 @@ final class WP_Customize_Manager {
if ( ! $section->panel ) {
// Top-level section.
$sections[] = $section;
$sections[ $section->id ] = $section;
} else {
// This section belongs to a panel.
if ( isset( $this->panels [ $section->panel ] ) ) {
$this->panels[ $section->panel ]->sections[] = $section;
$this->panels[ $section->panel ]->sections[ $section->id ] = $section;
}
}
}
@@ -932,8 +940,8 @@ final class WP_Customize_Manager {
continue;
}
usort( $panel->sections, array( $this, '_cmp_priority' ) );
$panels[] = $panel;
uasort( $panel->sections, array( $this, '_cmp_priority' ) );
$panels[ $panel->id ] = $panel;
}
$this->panels = $panels;