Index: _samples/ui_usererror.html
===================================================================
--- _samples/ui_usererror.html (revision 0)
+++ _samples/ui_usererror.html (revision 0)
@@ -0,0 +1,77 @@
+
+
+
+
+ User Defined UI In Alerts - CKEditor Sample
+
+
+
+
+
+
+
+
+
+ CKEditor Sample
+
+
+
+
+
+
+
+
+
Index: _source/core/editor.js
===================================================================
--- _source/core/editor.js (revision 5248)
+++ _source/core/editor.js (working copy)
@@ -410,6 +410,16 @@
*/
this.focusManager = new CKEDITOR.focusManager( this );
+ // Set default handlers for alert and confirm
+ this.on( 'alert', function( evt )
+ {
+ window.alert( evt.data.errorString );
+ });
+ this.on( 'confirm', function( evt )
+ {
+ evt.data.status = window.confirm( evt.data.confirmString );
+ });
+
CKEDITOR.fire( 'instanceCreated', null, this );
this.on( 'mode', updateCommandsMode, null, null, 1 );
@@ -758,3 +768,15 @@
* @name CKEDITOR#pluginsLoaded
* @event
*/
+
+/**
+ * Fired when there is a message to display to the user.
+ * @name CKEDITOR#alert
+ * @event
+ */
+
+/**
+ * Fired when the user need to confirm something. the data object 'status' determines the result.
+ * @name CKEDITOR#confirm
+ * @event
+ */
\ No newline at end of file
Index: _source/core/event.js
===================================================================
--- _source/core/event.js (revision 5248)
+++ _source/core/event.js (working copy)
@@ -318,6 +318,24 @@
},
/**
+ * Unregisters all listeners of the specified event.
+ * @param {String} eventName The event name.
+ * @example
+ * var myListener = function() { ... };
+ * var myListener1 = function() { ... };
+ * someObject.on( 'someEvent', myListener );
+ * someObject.on( 'someEvent', myListener1 );
+ * someObject.fire( 'someEvent' ); // Both listeners are called
+ * someObject.removeListeners( 'someEvent' );
+ * someObject.fire( 'someEvent' ); // No listeners are called
+ */
+ removeListeners : function( eventName )
+ {
+ var event = getPrivate( this )[ eventName ] || {};
+ event.listeners && ( event.listeners = [] );
+ },
+
+ /**
* Checks if there is any listener registered to a given event.
* @param {String} eventName The event name.
* @example
Index: _source/plugins/dialog/plugin.js
===================================================================
--- _source/plugins/dialog/plugin.js (revision 5248)
+++ _source/plugins/dialog/plugin.js (working copy)
@@ -237,7 +237,12 @@
{
if ( item.isChanged() )
{
- if ( !confirm( editor.lang.common.confirmCancel ) )
+ var confirmation = editor.fire( 'confirm', {
+ confirmString : editor.lang.common.confirmCancel,
+ confirmAt : 'dialog_cancel',
+ status : true
+ }).status;
+ if ( !confirmation )
evt.data.hide = false;
return true;
}
Index: _source/plugins/find/dialogs/find.js
===================================================================
--- _source/plugins/find/dialogs/find.js (revision 5248)
+++ _source/plugins/find/dialogs/find.js (working copy)
@@ -604,8 +604,10 @@
dialog.getValueOf( 'find', 'txtFindCaseChk' ),
dialog.getValueOf( 'find', 'txtFindWordChk' ),
dialog.getValueOf( 'find', 'txtFindCyclic' ) ) )
- alert( editor.lang.findAndReplace
- .notFoundMsg );
+ editor.fire( 'alert', {
+ errorString : editor.lang.findAndReplace.notFoundMsg,
+ errorType : 'findandreplace_notfound'
+ });
}
}
]