[wp-trac] [WordPress Trac] #42682: Allow customize notifications to be auto dismissed after a delay
WordPress Trac
noreply at wordpress.org
Thu Nov 23 16:37:09 UTC 2017
#42682: Allow customize notifications to be auto dismissed after a delay
-------------------------------+------------------------------
Reporter: nikeo | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Customize | Version: 4.9
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by nikeo):
My use case is that I want to notify a user with an information without
necessarily waiting for a manual dismiss. Simply displaying a contextual
information.
I thought this could be useful for developers to allow this flexibility
for the customizer notifications.
Typically, the following is an example of what I need to write to achieve
that right now :
{{{#!javascript
api.notifications.add( new wp.customize.Notification(
'widgets_are_sidewide', {
type: 'info',
message: serverControlParams.i18n['Widgets are created sitewide.'],
dismissible: true
} ) );
// Removed if not dismissed after 5 seconds
_.delay( function() {
if ( api.notifications.has( 'widgets_are_sidewide' ) ) {
var _notif_ = api.notifications( 'widgets_are_sidewide' );
if ( _notif_.parent ) {
_notif_.parent.remove( _notif_.code );
} else {
_notif_.container.remove();
}
}
}, 5000 );
}}}
While I would like to simply write :
{{{#!javascript
api.notifications.add( new wp.customize.Notification(
'widgets_are_sidewide', {
type: 'info',
message: serverControlParams.i18n['Widgets are created sitewide.'],
dismissible: 5000
} ) );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42682#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list