Skip to content
Permalink
Browse files

Merge branch 't/10103' into major

  • Loading branch information...
Reinmar committed Feb 21, 2013
2 parents 1974bda + 497f1d4 commit ca6b17de0ceebdb732df351c4f98af9d2c7f5673
Showing with 57 additions and 16 deletions.
  1. +1 −3 core/creators/inline.js
  2. +1 −3 core/creators/themedui.js
  3. +55 −10 core/editor.js
@@ -36,9 +36,6 @@
// data retrieval possible immediately after the editor creation.
editor.setData( element.getHtml(), null, true );

// Clean during initialization.
editor.resetDirty();

// Once the editor is loaded, start the UI.
editor.on( 'loaded', function() {
editor.fire( 'uiReady' );
@@ -62,6 +59,7 @@
editor.fire( 'mode' );

// The editor is completely loaded for interaction.
editor.status = 'ready';
editor.fireOnce( 'instanceReady' );
CKEDITOR.fire( 'instanceReady', null, editor );

@@ -252,9 +252,6 @@ CKEDITOR.replaceClass = 'ckeditor';

data && editor.setData( data, null, true );

// Clean during initialization.
editor.resetDirty();

// Once the editor is loaded, start the UI.
editor.on( 'loaded', function() {
loadTheme( editor );
@@ -267,6 +264,7 @@ CKEDITOR.replaceClass = 'ckeditor';
editor.resetDirty();

// Editor is completely loaded for interaction.
editor.status = 'ready';
editor.fireOnce( 'instanceReady' );
CKEDITOR.fire( 'instanceReady', null, editor );
});
@@ -103,6 +103,19 @@
*/
this.id = CKEDITOR.tools.getNextId();

/**
* Indicates editor initialization status. The following statuses are available:
*
* * **unloaded**: the initial state - editor's instance has been initialized,
* but its components (config, plugins, language files) are not loaded yet.
* * **loaded**: editor's components have been loaded - see {@link CKEDITOR.editor#loaded} event.
* * **ready**: editor is fully initialized and ready - see {@link CKEDITOR.editor#instanceReady} event.
* * **destroyed**: the editor has been destroyed - see {@link CKEDITOR.editor#method-destroy} method.
*
* @property {String}
*/
this.status = 'unloaded';

/**
* The configurations for this editor instance. It inherits all
* settings defined in {@link CKEDITOR.config}, combined with settings
@@ -140,14 +153,18 @@
this.keystrokeHandler = new CKEDITOR.keystrokeHandler( this );

// Make the editor update its command states on mode change.
this.on( 'mode', updateCommands );
this.on( 'readOnly', updateCommands );
this.on( 'selectionChange', updateCommandsContext );

// Handle startup focus.
this.on( 'instanceReady', function() {
updateCommands.call( this );
// First 'mode' event is fired before this 'instanceReady',
// so to avoid updating commands twice, add this listener here.
this.on( 'mode', updateCommands );

this.config.startupFocus && this.focus();
});
} );

CKEDITOR.fire( 'instanceCreated', null, this );

@@ -172,17 +189,18 @@
}

function updateCommands() {
var command,
commands = this.commands,
var commands = this.commands,
mode = this.mode;

if ( !mode )
return;

for ( var name in commands ) {
command = commands[ name ];
command[ command.startDisabled ? 'disable' : this.readOnly && !command.readOnly ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ]();
}
for ( var name in commands )
updateCommand( this, commands[ name ] );
}

function updateCommand( editor, cmd ) {
cmd[ cmd.startDisabled ? 'disable' : editor.readOnly && !cmd.readOnly ? 'disable' : cmd.modes[ editor.mode ] ? 'enable' : 'disable' ]();
}

function updateCommandsContext( ev ) {
@@ -526,6 +544,7 @@
for ( i = 0; i < editor.config.blockedKeystrokes.length; i++ )
editor.keystrokeHandler.blockedKeystrokes[ editor.config.blockedKeystrokes[ i ] ] = 1;

editor.status = 'loaded';
editor.fireOnce( 'loaded' );
CKEDITOR.fire( 'instanceLoaded', null, editor );
});
@@ -571,6 +590,11 @@
addCommand: function( commandName, commandDefinition ) {
commandDefinition.name = commandName.toLowerCase();
var cmd = new CKEDITOR.command( this, commandDefinition );

// Update command when added after editor has been already initialized.
if ( this.status == 'ready' && this.mode )
updateCommand( this, cmd );

return this.commands[ commandName ] = cmd;
},

@@ -593,6 +617,8 @@

this.editable( null );

this.status = 'destroyed';

this.fire( 'destroy' );

// Plug off all listeners to prevent any further events firing.
@@ -865,7 +891,7 @@
*
* function beforeUnload( evt ) {
* if ( CKEDITOR.instances.editor1.checkDirty() )
* return e.returnValue = "You will lose the changes made in the editor.";
* return evt.returnValue = "You will lose the changes made in the editor.";
* }
*
* if ( window.addEventListener )
@@ -876,7 +902,7 @@
* @returns {Boolean} `true` if the contents contain changes.
*/
checkDirty: function() {
return this._.previousValue !== this.getSnapshot();
return this.status == 'ready' && this._.previousValue !== this.getSnapshot();
},

/**
@@ -1080,6 +1106,16 @@ CKEDITOR.ELEMENT_MODE_INLINE = 3;
* @param {CKEDITOR.editor} editor The editor instance that has been created.
*/

/**
* Fired when CKEDITOR instance's components (config, languages and plugins) are fully
* loaded and initialized. However, the editor will be fully ready to for interaction
* on {@link CKEDITOR#instanceReady}.
*
* @event instanceLoaded
* @member CKEDITOR
* @param {CKEDITOR.editor} editor This editor instance that has been loaded.
*/

/**
* Fired when a CKEDITOR instance is destroyed.
*
@@ -1230,6 +1266,15 @@ CKEDITOR.ELEMENT_MODE_INLINE = 3;
* @param {CKEDITOR.editor} editor This editor instance.
*/

/**
* Fired when editor's components (config, languages and plugins) are fully
* loaded and initialized. However, the editor will be fully ready to for interaction
* on {@link #instanceReady}.
*
* @event loaded
* @param {CKEDITOR.editor} editor This editor instance.
*/

/**
* Internal event to perform the {@link #method-insertHtml} call.
*

0 comments on commit ca6b17d

Please sign in to comment.
You can’t perform that action at this time.