Report an issue
Class

CKEDITOR.plugins.notificationAggregator

classsince 4.5.0

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 );

Filtering

Properties

  • readonly

    editor : editor

  • readonly

    notification : notification | null

    Notification created by the aggregator.

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

  • private

    _doneTasks : Number

    Stores the count of tasks done.

  • private

    _doneWeights : Number

    Stores the sum of done weights for all contained tasks.

  • private

    _message : template

    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).
  • private

    _singularMessage : template | null

    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.

  • private

    _tasks : task[]

    Array of tasks tracked by the aggregator.

  • private

    _totalWeights : Number

    Stores the sum of declared weights for all contained tasks.

Static properties

Methods