Make WordPress Core

Ticket #42682: 42682.patch

File 42682.patch, 1.9 KB (added by nikeo, 9 years ago)
  • src/wp-includes/js/customize-base.js

    diff --git a/src/wp-includes/js/customize-base.js b/src/wp-includes/js/customize-base.js
    index 628d267456..0115071c14 100644
    a b window.wp = window.wp || {};  
    845845                 * @param {Function} [params.template] - Function for rendering template. If not provided, this will come from templateId.
    846846                 * @param {string}   [params.templateId] - ID for template to render the notification.
    847847                 * @param {string}   [params.containerClasses] - Additional class names to add to the notification container.
    848                  * @param {boolean}  [params.dismissible] - Whether the notification can be dismissed.
     848                 * @param {boolean|number}  [params.dismissible] - Whether the notification can be dismissed or the delay in milliseconds before it is auto dismissed.
    849849                 */
    850850                initialize: function( code, params ) {
    851851                        var _params;
    … … window.wp = window.wp || {};  
    875875                 * @returns {jQuery} Notification container element.
    876876                 */
    877877                render: function() {
     878
    878879                        var notification = this, container, data;
    879880                        if ( ! notification.template ) {
    880881                                notification.template = wp.template( notification.templateId );
    … … window.wp = window.wp || {};  
    889890                                        if ( 'keydown' === event.type && 13 !== event.which ) {
    890891                                                return;
    891892                                        }
     893                                        removeNotification();
     894                                });
    892895
     896                                var removeNotification = function() {
    893897                                        if ( notification.parent ) {
    894898                                                notification.parent.remove( notification.code );
    895899                                        } else {
    896900                                                container.remove();
    897901                                        }
    898                                 });
     902                                };
     903
     904                                // if the 'dismissible' param is a number, remove the notification after a delay defined by this number in milliseconds
     905                                // make sure the delay is > 500 ms.
     906                                if ( _.isNumber( notification.dismissible ) ) {
     907                                        _.delay( removeNotification, Math.max( 500, notification.dismissible ) );
     908                                }
     909
    899910                        }
    900911
    901912                        return container;