From 2670bdfb3f9b09f998750c48ee088959bc65cc13 Mon Sep 17 00:00:00 2001
From: Piotr Jasiun
Date: Mon, 9 Feb 2015 11:46:31 +0100
Subject: [PATCH] Notification timeout does not wait for the `change` event.
---
plugins/notification/plugin.js | 22 ++++++++----------
tests/plugins/notification/manual/classic.md | 2 +-
tests/plugins/notification/manual/inline.md | 2 +-
tests/plugins/notification/notification.js | 24 ++++----------------
4 files changed, 16 insertions(+), 34 deletions(-)
diff --git a/plugins/notification/plugin.js b/plugins/notification/plugin.js
index cba38db3b2f..32db78b8063 100644
--- a/plugins/notification/plugin.js
+++ b/plugins/notification/plugin.js
@@ -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 ) {
@@ -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.
@@ -389,7 +389,7 @@ Notification.prototype = {
},
/**
- * Hides notification after the timeout after the first change event.
+ * Hides notification after the timeout.
*
* @private
*/
@@ -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 );
}
}
};
@@ -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.
diff --git a/tests/plugins/notification/manual/classic.md b/tests/plugins/notification/manual/classic.md
index 71c51b73747..0327fb9ee6a 100644
--- a/tests/plugins/notification/manual/classic.md
+++ b/tests/plugins/notification/manual/classic.md
@@ -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.
\ No newline at end of file
diff --git a/tests/plugins/notification/manual/inline.md b/tests/plugins/notification/manual/inline.md
index 5d561522195..b42d949fd3c 100644
--- a/tests/plugins/notification/manual/inline.md
+++ b/tests/plugins/notification/manual/inline.md
@@ -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.
\ No newline at end of file
diff --git a/tests/plugins/notification/notification.js b/tests/plugins/notification/notification.js
index ed667f2b87a..9388bc20b6f 100644
--- a/tests/plugins/notification/notification.js
+++ b/tests/plugins/notification/notification.js
@@ -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 } );
@@ -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' } );
@@ -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( {
@@ -193,8 +181,6 @@ bender.test( {
notification.show();
- editor.fire( 'change' );
-
assertNotifications( editor, [ { message: 'Foo', type: 'info', alert: true } ] );
tc.clock.tick( 4900 );
@@ -215,8 +201,6 @@ bender.test( {
notification.show();
- editor.fire( 'change' );
-
notification.update( { type: 'warning' } );
this.clock.tick( 110 );
@@ -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, [] );