X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fckeditor.js;h=548fd4424800487cdeb6763454b07d8c1324e393;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=5e0369367998dfc958326f7ca1fe357e5065a3d2;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6;p=ckeditor.git diff --git a/_source/core/ckeditor.js b/_source/core/ckeditor.js index 5e03693..548fd44 100644 --- a/_source/core/ckeditor.js +++ b/_source/core/ckeditor.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -59,9 +59,10 @@ CKEDITOR.add = function( editor ) }; /** - * Removes and editor instance from the global {@link CKEDITOR} object. his function - * is available for internal use mainly. - * @param {CKEDITOR.editor} editor The editor instance to be added. + * Removes an editor instance from the global {@link CKEDITOR} object. This function + * is available for internal use only. External code must use {@link CKEDITOR.editor.prototype.destroy} + * to avoid memory leaks. + * @param {CKEDITOR.editor} editor The editor instance to be removed. * @example */ CKEDITOR.remove = function( editor ) @@ -69,6 +70,16 @@ CKEDITOR.remove = function( editor ) delete CKEDITOR.instances[ editor.name ]; }; +/** + * Perform global clean up to free as much memory as possible + * when there are no instances left + */ +CKEDITOR.on( 'instanceDestroyed', function () + { + if ( CKEDITOR.tools.isEmpty( this.instances ) ) + CKEDITOR.fire( 'reset' ); + }); + // Load the bootstrap script. CKEDITOR.loader.load( 'core/_bootstrap' ); // @Packager.RemoveLine @@ -94,3 +105,37 @@ CKEDITOR.TRISTATE_OFF = 2; * @example */ CKEDITOR.TRISTATE_DISABLED = 0; + +/** + * The editor which is currently active (have user focus). + * @name CKEDITOR.currentInstance + * @type CKEDITOR.editor + * @see CKEDITOR#currentInstance + * @example + * function showCurrentEditorName() + * { + * if ( CKEDITOR.currentInstance ) + * alert( CKEDITOR.currentInstance.name ); + * else + * alert( 'Please focus an editor first.' ); + * } + */ + +/** + * Fired when the CKEDITOR.currentInstance object reference changes. This may + * happen when setting the focus on different editor instances in the page. + * @name CKEDITOR#currentInstance + * @event + * var editor; // Variable to hold a reference to the current editor. + * CKEDITOR.on( 'currentInstance' , function( e ) + * { + * editor = CKEDITOR.currentInstance; + * }); + */ + +/** + * Fired when the last instance has been destroyed. This event is used to perform + * global memory clean up. + * @name CKEDITOR#reset + * @event + */