Skip to content

Commit

Permalink
Merge branch 't/12866' into major
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Feb 12, 2015
2 parents 439339b + 2670bdf commit 969ec74
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
22 changes: 10 additions & 12 deletions plugins/notification/plugin.js
Expand Up @@ -22,9 +22,10 @@ CKEDITOR.plugins.add( 'notification', {
* @param {String} message Message displayed on the notification.
* @param {String} [type='info'] Type of the notification. Can be `'info'`, `'warning'`, `'success'` or `'progress'`.
* @param {Number} [progressOrDuration] If the type is `progress` the third parameter may be a progress from `0` to `1`
* (defaults to `0`). Otherwise the the third parameter may be a notification duration: how many milliseconds after the
* next change event notification should be closed automatically. `0` means that notification will not be closed
* automatically, user needs to close it manually. See {@link CKEDITOR.plugins.notification#duration}.
* (defaults to `0`). Otherwise the the third parameter may be a notification duration: after how many milliseconds
* notification should be closed automatically. `0` means that notification will not be closed automatically, user
* needs to close it manually. See {@link CKEDITOR.plugins.notification#duration}.
* Note that `warning` notifications will not be closed automatically.
* @returns {CKEDITOR.plugins.notification} Created and shown notification.
*/
editor.showNotification = function( message, type, progressOrDuration ) {
Expand Down Expand Up @@ -172,8 +173,7 @@ function Notification( editor, options ) {
*/

/**
* Notification duration. Determines how many milliseconds after the next {@link CKEDITOR.editor#change} event
* the notification should be closed automatically.
* Notification duration. Determines after how many milliseconds notification should be closed automatically.
* 0 means that notification will not be closed automatically, user needs to close it manually.
* By default it is 0 for `warning` and `progress`. For `info` and `success` value it is the of
* {@link CKEDITOR.config#notification_duration notification_duration} configuration option or 5000 if not set.
Expand Down Expand Up @@ -389,7 +389,7 @@ Notification.prototype = {
},

/**
* Hides notification after the timeout after the first change event.
* Hides notification after the timeout.
*
* @private
*/
Expand All @@ -410,11 +410,9 @@ Notification.prototype = {
}

if ( duration ) {
this.editor.once( 'change', function() {
notification._hideTimeoutId = setTimeout( function() {
notification.hide();
}, duration );
} );
notification._hideTimeoutId = setTimeout( function() {
notification.hide();
}, duration );
}
}
};
Expand Down Expand Up @@ -846,7 +844,7 @@ Area.prototype = {
CKEDITOR.plugins.notification = Notification;

/**
* How many milliseconds after the {@link CKEDITOR.editor#change} event notifications of the `info` and `success`
* After how many milliseconds the notification of the `info` and `success`
* {@link CKEDITOR.plugins.notification#type type} should be closed automatically.
* `0` means that notifications will not be closed automatically.
* Note that `warning` and `progress` notifications will not be closed automatically.
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/notification/manual/classic.md
Expand Up @@ -6,6 +6,6 @@
* Play with notification using buttons.
* Using scroll, check if position of notification is correct.

**Note:** `info` and `success` notifications should close automatically 5 sec after `change` event or on `ESC` key if editor is focused.
**Note:** `info` and `success` notifications should close automatically after 5 sec or on `ESC` key if editor is focused.

**Note:** if you close notification it will be shown again if update is important.
2 changes: 1 addition & 1 deletion tests/plugins/notification/manual/inline.md
Expand Up @@ -6,6 +6,6 @@
* Play with notification using buttons.
* Using scroll, check if position of notification is correct.

**Note:** `info` and `success` notifications should close automatically 5 sec after `change` event or on `ESC` key if editor is focused.
**Note:** `info` and `success` notifications should close automatically after 5 sec or on `ESC` key if editor is focused.

**Note:** if you close notification it will be shown again if update is important.
24 changes: 4 additions & 20 deletions tests/plugins/notification/notification.js
Expand Up @@ -129,7 +129,7 @@ bender.test( {
assert.isFalse( notification.isVisible(), 'After hide' );
},

'test close after change - info': function() {
'test close after timeout - info': function() {
var editor = this.editor,
notification = new CKEDITOR.plugins.notification( editor, { message: 'Foo', type: 'info', duration: 100 } );

Expand All @@ -143,16 +143,10 @@ bender.test( {

this.clock.tick( 110 );

assertNotifications( editor, [ { message: 'Foo', type: 'info', duration: 100 } ] );

editor.fire( 'change' );

this.clock.tick( 110 );

assertNotifications( editor, [] );
},

'test close after change - warning': function() {
'test close after timeout - warning': function() {
var editor = this.editor,
notification = new CKEDITOR.plugins.notification( editor, { message: 'Foo', type: 'warning' } );

Expand All @@ -167,15 +161,9 @@ bender.test( {
this.clock.tick( 110 );

assertNotifications( editor, [ { message: 'Foo', type: 'warning' } ] );

editor.fire( 'change' );

this.clock.tick( 110 );

assertNotifications( editor, [ { message: 'Foo', type: 'warning' } ] );
},

'test close after change - default value': function() {
'test close after timeout - default value': function() {
var tc = this;

bender.editorBot.create( {
Expand All @@ -193,8 +181,6 @@ bender.test( {

notification.show();

editor.fire( 'change' );

assertNotifications( editor, [ { message: 'Foo', type: 'info', alert: true } ] );

tc.clock.tick( 4900 );
Expand All @@ -215,8 +201,6 @@ bender.test( {

notification.show();

editor.fire( 'change' );

notification.update( { type: 'warning' } );

this.clock.tick( 110 );
Expand Down Expand Up @@ -249,7 +233,7 @@ bender.test( {

assertNotifications( editor, [ { message: 'Foo', type: 'warning' } ] );

editor.fire( 'key', { keyCode: 27 /* ESC */ } );
editor.fire( 'key', { keyCode: 27 } ); /* ESC */

assertNotifications( editor, [] );

Expand Down

0 comments on commit 969ec74

Please sign in to comment.