From 594a41666b5956e23bffd68eef321b613dd65433 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 12 Sep 2017 07:02:49 +0000 Subject: [PATCH] Customize: Add global notifications area. * Displays an error notification in the global area when a save attempt is rejected due to invalid settings. An error notification is also displayed when saving fails due to a network error or server error. * Introduces `wp.customize.Notifications` subclass of `wp.customize.Values` to contain instances of `wp.customize.Notification` and manage their rendering into a container. * Exposes the global notification area as `wp.customize.notifications` collection instance. * Updates the `notifications` object on `Control` to use `Notifications` rather than `Values` and to re-use the rendering logic from the former. The old `Control#renderNotifications` method is deprecated. * Allows notifications to be dismissed by instantiating them with a `dismissible` property. * Allows `wp.customize.Notification` to be extended with custom templates and `render` functions. * Triggers a `removed` event on `wp.customize.Values` instances _after_ a value has been removed from the collection. Props delawski, westonruter, karmatosed, celloexpressions, Fab1en, melchoyce, Kelderic, afercia, adamsilverstein. See #34893, #39896. Fixes #35210, #31582, #37727, #37269. git-svn-id: https://develop.svn.wordpress.org/trunk@41374 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/css/customize-controls.css | 28 +- src/wp-admin/customize.php | 31 +- src/wp-admin/js/customize-controls.js | 344 ++++++++++++++++-- src/wp-admin/js/customize-widgets.js | 4 + .../class-wp-customize-manager.php | 18 +- src/wp-includes/js/customize-base.js | 83 ++++- src/wp-includes/script-loader.php | 1 + tests/qunit/index.html | 9 + tests/qunit/wp-admin/js/customize-base.js | 48 ++- tests/qunit/wp-admin/js/customize-controls.js | 50 ++- 10 files changed, 557 insertions(+), 59 deletions(-) diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css index eaaee146c4..82dd9abb10 100644 --- a/src/wp-admin/css/customize-controls.css +++ b/src/wp-admin/css/customize-controls.css @@ -766,7 +766,6 @@ p.customize-section-description { #customize-controls .customize-control-notifications-container { /* Scoped to #customize-controls for specificity over notification styles in common.css. */ margin: 4px 0 8px 0; padding: 0; - display: none; cursor: default; } @@ -798,6 +797,33 @@ p.customize-section-description { outline: 2px solid #dc3232; } +#customize-controls #customize-notifications-area { + position: absolute; + top: 46px; + width: 100%; + max-height: 210px; + overflow-x: hidden; + overflow-y: auto; + border-bottom: 1px solid #ddd; + display: block; + padding: 0; + margin: 0; +} + +#customize-controls #customize-notifications-area > ul, +#customize-controls #customize-notifications-area .notice { + margin: 0; +} +#customize-controls #customize-notifications-area .notice { + padding: 9px 14px; +} +#customize-controls #customize-notifications-area .notice.is-dismissible { + padding-right: 38px; +} +#customize-controls #customize-notifications-area .notice + .notice { + margin-top: 1px; +} + /* Style for custom settings */ /** diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php index f1bf8aa9a1..81a7ae2741 100644 --- a/src/wp-admin/customize.php +++ b/src/wp-admin/customize.php @@ -151,24 +151,27 @@ do_action( 'customize_controls_print_scripts' );
-
-
-
- ' . get_bloginfo( 'name', 'display' ) . '' ); - ?> - +
+
    +
    +
    +
    +
    + ' . get_bloginfo( 'name', 'display' ) . '' ); + ?> + +
    +
    -
    -
    -
    -
    +
    +
    +
    -