WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/12/2017 07:02:49 AM (2 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/qunit/index.html

    r41206 r41374  
    210210                <# } ); #>
    211211            </ul>
     212        </script>
     213        <script type="text/html" id="tmpl-customize-notification">
     214            <li class="notice notice-{{ data.type || 'info' }} {{ data.altNotice ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
     215                {{{ data.message || data.code }}}
     216                <# if ( data.dismissible ) { #>
     217                    <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button>
     218                <# } #>
     219            </li>
    212220        </script>
    213221
     
    387395        <div hidden>
    388396            <div id="customize-preview"></div>
     397            <div id="customize-notifications-test"><ul></ul></div>
    389398        </div>
    390399
Note: See TracChangeset for help on using the changeset viewer.