Class: Notifications

wp.customize. Notifications


new Notifications(options)

A collection of observable notifications.
Parameters:
Name Type Description
options object Options.
Properties
Name Type Argument Description
container jQuery <optional>
Container element for notifications. This can be injected later.
alt boolean <optional>
Whether alternative style should be used when rendering notifications.
Since:
  • 4.9.0
Source:
Returns:
Type
void

Extends

Members


alt :boolean

Whether the alternative style should be used.
Type:
  • boolean
Since:
  • 4.9.0
Source:

defaultConstructor :object

The default constructor for items of the collection.
Type:
  • object
Since:
  • 4.9.0
Overrides:
Source:

Methods


_change()

A helper function to propagate a 'change' event from an item to the collection itself.
Inherited From:
Source:

add(notification [, notificationObject])

Add notification to the collection.
Parameters:
Name Type Argument Description
notification string | wp.customize.Notification Notification object to add. Alternatively code may be supplied, and in that case the second notificationObject argument must be supplied.
notificationObject wp.customize.Notification <optional>
Notification to add when first argument is the code string.
Since:
  • 4.9.0
Overrides:
Source:
Returns:
Added notification (or existing instance if it was already added).
Type
wp.customize.Notification

constrainFocus(event)

Constrain focus on focus container.
Parameters:
Name Type Description
event jQuery.Event Event.
Since:
  • 4.9.0
Source:
Returns:
Type
void

count()

Get the number of notifications added.
Since:
  • 4.9.0
Source:
Returns:
Count of notifications.
Type
number

create(id, value)

Create a new item of the collection using the collection's default constructor and store it in the collection.
Parameters:
Name Type Description
id string The ID of the item.
value mixed Any extra arguments are passed into the item's initialize method.
Inherited From:
Source:
Returns:
The new item's instance.
Type
mixed

each(callback, context)

Iterate over all items in the collection invoking the provided callback.
Parameters:
Name Type Description
callback function Function to invoke.
context object Object context to invoke the function with. Optional.
Inherited From:
Source:

get(args)

Get list of notifications. Notifications may be sorted by type followed by added time.
Parameters:
Name Type Description
args object Args.
Properties
Name Type Argument Default Description
sort boolean <optional>
false Whether to return the notifications sorted.
Since:
  • 4.9.0
Source:
Returns:
Notifications.
Type
Array:.<wp.customize.Notification:>

has(id)

Whether the collection has an item with the given ID.
Parameters:
Name Type Description
id string The ID of the item to look for.
Inherited From:
Source:
Returns:
Type
Boolean

instance(id)

Get the instance of an item from the collection if only ID is specified. If more than one argument is supplied, all are expected to be IDs and the last to be a function callback that will be invoked when the requested items are available.
Parameters:
Name Type Description
id string ID of the item.
Inherited From:
Source:
See:
  • {api.Values.when:}
Returns:
The item instance if only one ID was supplied. A Deferred Promise object if a callback function is supplied.
Type
mixed

remove(code)

Add notification to the collection.
Parameters:
Name Type Description
code string Notification code to remove.
Since:
  • 4.9.0
Overrides:
Source:
Returns:
Added instance (or existing instance if it was already added).
Type
api.Notification

render()

Render notifications area.
Since:
  • 4.9.0
Source:
Returns:
Type
void

value(id)

Get the instance of an item.
Parameters:
Name Type Description
id string The ID of the item.
Inherited From:
Source:
Returns:

when()

Runs a callback once all requested values exist. when( ids*, [callback] ); For example: when( id1, id2, id3, function( value1, value2, value3 ) {} );
Inherited From:
Source:
Returns:
$.Deferred.promise();