CKEditor 4 Documentation

CKEDITOR.plugins.notificationAggregator

Mixins

Files

An aggregator of multiple tasks (progresses) which should be displayed using one notification.

Once all the tasks are done, it means that the whole process is finished and the finished event will be fired.

New tasks can be created after the previous set of tasks is finished. This will continue the process and fire the finished event again when it is done.

Simple usage example:

// Declare one aggregator that will be used for all tasks.
var aggregator;

// ...

// Create a new aggregator if the previous one finished all tasks.
if ( !aggregator || aggregator.isFinished() ) {
    // Create a new notification aggregator instance.
    aggregator = new CKEDITOR.plugins.notificationAggregator( editor, 'Loading process, step {current} of {max}...' );

    // Change the notification type to 'success' on finish.
    aggregator.on( 'finished', function() {
        aggregator.notification.update( { message: 'Done', type: 'success' } );
    } );
}

// Create 3 tasks.
var taskA = aggregator.createTask(),
    taskB = aggregator.createTask(),
    taskC = aggregator.createTask();

// At this point the notification contains a message: "Loading process, step 0 of 3...".

// Let's close the first one immediately.
taskA.done(); // "Loading process, step 1 of 3...".

// One second later the message will be: "Loading process, step 2 of 3...".
setTimeout( function() {
    taskB.done();
}, 1000 );

// Two seconds after the previous message the last task will be completed, meaning that
// the notification will be closed.
setTimeout( function() {
    taskC.done();
}, 3000 );

Available since: 4.5

Defined By

Properties

CKEDITOR.plugins.notificationAggregator
view source
: Numberprivate

Stores the count of tasks done.

Stores the count of tasks done.

CKEDITOR.plugins.notificationAggregator
view source
: Numberprivate

Stores the sum of done weights for all contained tasks.

Stores the sum of done weights for all contained tasks.

CKEDITOR.plugins.notificationAggregator
view source
: CKEDITOR.templateprivate
A template for the notification message. ...

A template for the notification message.

The template can use the following variables:

  • {current} – The number of completed tasks.
  • {max} – The number of tasks.
  • {percentage} – The progress (number 0-100).
CKEDITOR.plugins.notificationAggregator
view source
: CKEDITOR.template/nullprivate
A template for the notification message used when only one task is loading. ...

A template for the notification message used when only one task is loading.

Sometimes there might be a need to specify a special message when there is only one task loading, and to display standard messages in other cases.

For example, you might want to show a message "Translating a widget" rather than "Translating widgets (1 of 1)", but still you would want to have a message "Translating widgets (2 of 3)" if more widgets are being translated at the same time.

Template variables are the same as in _message.

CKEDITOR.plugins.notificationAggregator
view source
: CKEDITOR.plugins.notificationAggregator.task[]private

Array of tasks tracked by the aggregator.

Array of tasks tracked by the aggregator.

CKEDITOR.plugins.notificationAggregator
view source
: Numberprivate

Stores the sum of declared weights for all contained tasks.

Stores the sum of declared weights for all contained tasks.

CKEDITOR.plugins.notificationAggregator
view source
: CKEDITOR.editorreadonly
CKEDITOR.plugins.notificationAggregator
view source
: CKEDITOR.plugins.notification/nullreadonly
Notification created by the aggregator. ...

Notification created by the aggregator.

The notification object is modified as aggregator tasks are being closed.

Defined By

Methods

CKEDITOR.plugins.notificationAggregator
view source
new( editor, message, [singularMessage] ) : CKEDITOR.plugins.notificationAggregator
Creates a notification aggregator instance. ...

Creates a notification aggregator instance.

Parameters

  • editor : CKEDITOR.editor
  • message : String

    The template for the message to be displayed in the notification. The template can use the following variables:

    • {current} – The number of completed tasks.
    • {max} – The number of tasks.
    • {percentage} – The progress (number 0-100).
  • singularMessage : String/null (optional)

    An optional template for the message to be displayed in the notification when there is only one task remaining. This template can use the same variables as the message template. If null, then the message template will be used.

    Defaults to: null

Returns

Overrides: CKEDITOR.event.constructor

CKEDITOR.plugins.notificationAggregator
view source
( options ) : CKEDITOR.plugins.notificationAggregator.taskprivate
Creates a CKEDITOR.plugins.notificationAggregator.task instance based on options, and adds it to the task list. ...

Creates a CKEDITOR.plugins.notificationAggregator.task instance based on options, and adds it to the task list.

Parameters

  • options : Object

    Options object coming from the createTask method.

Returns

CKEDITOR.plugins.notificationAggregator
view source
( ) : CKEDITOR.plugins.notificationprivate
Creates a notification object. ...

Creates a notification object.

Returns

CKEDITOR.plugins.notificationAggregator
view source
( ) : Stringprivate
Returns a message used in the notification. ...

Returns a message used in the notification.

Returns

  • String
CKEDITOR.plugins.notificationAggregator
view source
( evt )private
A listener called on the CKEDITOR.plugins.notificationAggregator.task.done event. ...
CKEDITOR.plugins.notificationAggregator
view source
( evt )private
A listener called on the CKEDITOR.plugins.notificationAggregator.task.update event. ...
CKEDITOR.plugins.notificationAggregator
view source
( task )private
Removes a given task from the _tasks array and updates the UI. ...

Removes a given task from the _tasks array and updates the UI.

Parameters

CKEDITOR.plugins.notificationAggregator
view source
( )private
Updates the notification content. ...

Updates the notification content.

Register event handler under the capturing stage on supported target. ...

Register event handler under the capturing stage on supported target.

CKEDITOR.plugins.notificationAggregator
view source
( [options] ) : CKEDITOR.plugins.notificationAggregator.task
Creates a new task that can be updated to indicate the progress. ...

Creates a new task that can be updated to indicate the progress.

Parameters

Returns

Predefine some intrinsic properties on a specific event name. ...

Predefine some intrinsic properties on a specific event name.

Parameters

  • name : String

    The event name

  • meta : Object
    • errorProof : (optional)

      Whether the event firing should catch error thrown from a per listener call.

      Defaults to: false

( eventName, [data], [editor] ) : Boolean/Object
Fires an specific event in the object. ...

Fires an specific event in the object. All registered listeners are called at this point.

someObject.on( 'someEvent', function() { ... } );
someObject.on( 'someEvent', function() { ... } );
someObject.fire( 'someEvent' );             // Both listeners are called.

someObject.on( 'someEvent', function( event ) {
    alert( event.data );                    // 'Example'
} );
someObject.fire( 'someEvent', 'Example' );

Parameters

Returns

  • Boolean/Object

    A boolean indicating that the event is to be canceled, or data returned by one of the listeners.

( eventName, [data], [editor] ) : Boolean/Object
Fires an specific event in the object, releasing all listeners registered to that event. ...

Fires an specific event in the object, releasing all listeners registered to that event. The same listeners are not called again on successive calls of it or of fire.

someObject.on( 'someEvent', function() { ... } );
someObject.fire( 'someEvent' );         // Above listener called.
someObject.fireOnce( 'someEvent' );     // Above listener called.
someObject.fire( 'someEvent' );         // No listeners called.

Parameters

Returns

  • Boolean/Object

    A booloan indicating that the event is to be canceled, or data returned by one of the listeners.

CKEDITOR.plugins.notificationAggregator
view source
( ) : Number
...

Returns

  • Number

    Returns the number of tasks done.

CKEDITOR.plugins.notificationAggregator
view source
( ) : Number
Returns a number from 0 to 1 representing the done weights to total weights ratio (showing how many of the tasks are ...

Returns a number from 0 to 1 representing the done weights to total weights ratio (showing how many of the tasks are done).

Note: For an empty aggregator (without any tasks created) it will return 1.

Returns

  • Number

    Returns the percentage of tasks done as a number ranging from 0 to 1.

CKEDITOR.plugins.notificationAggregator
view source
( ) : Number
...

Returns

  • Number

    Returns a total tasks count.

Checks if there is any listener registered to a given event. ...

Checks if there is any listener registered to a given event.

var myListener = function() { ... };
someObject.on( 'someEvent', myListener );
alert( someObject.hasListeners( 'someEvent' ) );    // true
alert( someObject.hasListeners( 'noEvent' ) );      // false

Parameters

  • eventName : String

    The event name.

Returns

  • Boolean
CKEDITOR.plugins.notificationAggregator
view source
( ) : Boolean
...

Returns

  • Boolean

    Returns true if all notification tasks are done (or there are no tasks at all).

( eventName, listenerFunction, [scopeObj], [listenerData], [priority] ) : Object
Registers a listener to a specific event in the current object. ...

Registers a listener to a specific event in the current object.

someObject.on( 'someEvent', function() {
    alert( this == someObject );        // true
} );

someObject.on( 'someEvent', function() {
    alert( this == anotherObject );     // true
}, anotherObject );

someObject.on( 'someEvent', function( event ) {
    alert( event.listenerData );        // 'Example'
}, null, 'Example' );

someObject.on( 'someEvent', function() { ... } );                       // 2nd called
someObject.on( 'someEvent', function() { ... }, null, null, 100 );      // 3rd called
someObject.on( 'someEvent', function() { ... }, null, null, 1 );        // 1st called

Parameters

  • eventName : String

    The event name to which listen.

  • listenerFunction : Function

    The function listening to the event. A single CKEDITOR.eventInfo object instanced is passed to this function containing all the event data.

  • scopeObj : Object (optional)

    The object used to scope the listener call (the this object). If omitted, the current object is used.

  • listenerData : Object (optional)

    Data to be sent as the CKEDITOR.eventInfo.listenerData when calling the listener.

  • priority : Number (optional)

    The listener priority. Lower priority listeners are called first. Listeners with the same priority value are called in registration order.

    Defaults to: 10

Returns

  • Object

    An object containing the removeListener function, which can be used to remove the listener at any time.

Similiar with on but the listener will be called only once upon the next event firing. ...

Similiar with on but the listener will be called only once upon the next event firing.

CKEDITOR.event.on

Remove all existing listeners on this object, for cleanup purpose. ...

Remove all existing listeners on this object, for cleanup purpose.

( eventName, listenerFunction )
Unregisters a listener function from being called at the specified event. ...

Unregisters a listener function from being called at the specified event. No errors are thrown if the listener has not been registered previously.

var myListener = function() { ... };
someObject.on( 'someEvent', myListener );
someObject.fire( 'someEvent' );                 // myListener called.
someObject.removeListener( 'someEvent', myListener );
someObject.fire( 'someEvent' );                 // myListener not called.

Parameters

  • eventName : String

    The event name.

  • listenerFunction : Function

    The listener function to unregister.

CKEDITOR.plugins.notificationAggregator
view source
( )
Triggers an update on the aggregator, meaning that its UI will be refreshed. ...

Triggers an update on the aggregator, meaning that its UI will be refreshed.

When all the tasks are done, the finished event is fired.

Defined By

Events

CKEDITOR.plugins.notificationAggregator
view source
( evt )
Fired when all tasks are done. ...

Fired when all tasks are done. When this event occurs, the notification may change its type to success or be hidden:

aggregator.on( 'finished', function() {
    if ( aggregator.getTaskCount() == 0 ) {
        aggregator.notification.hide();
    } else {
        aggregator.notification.update( { message: 'Done', type: 'success' } );
    }
} );

Parameters