1 /*
  2  * CKEditor - The text editor for Internet - http://ckeditor.com
  3  * Copyright (C) 2003-2008 Frederico Caldeira Knabben
  4  *
  5  * == BEGIN LICENSE ==
  6  *
  7  * Licensed under the terms of any of the following licenses at your
  8  * choice:
  9  *
 10  *  - GNU General Public License Version 2 or later (the "GPL")
 11  *    http://www.gnu.org/licenses/gpl.html
 12  *
 13  *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 14  *    http://www.gnu.org/licenses/lgpl.html
 15  *
 16  *  - Mozilla Public License Version 1.1 or later (the "MPL")
 17  *    http://www.mozilla.org/MPL/MPL-1.1.html
 18  *
 19  * == END LICENSE ==
 20  */
 21 
 22  /**
 23  * Represents an editor instance.
 24  * @constructor
 25  * @param {CKEDITOR.dom.element} element The original element replaced by this
 26  *		editor instance.
 27  */
 28 CKEDITOR.editor = ( function()
 29 {
 30 	// The counter for automatic instance names.
 31 	var nameCounter = 0;
 32 
 33 	var getNewName = function()
 34 	{
 35 		var name = 'editor' + nameCounter++;
 36 		return CKEDITOR.instances[ name ] ? getNewName() : name;
 37 	};
 38 	
 39 	// Basic config class to inherit the default settings from CKEDITOR.config.
 40 	var config = function()
 41 	{}
 42 	config.prototype = CKEDITOR.config;
 43 	
 44 	return function( element )
 45 	{
 46 		// Call the base constructor.
 47 		CKEDITOR.event.call( this );
 48 
 49 		this.element = element;
 50 		this.name = element.getId() || element.getNameAtt() || getNewName();
 51 		
 52 		// Get the default settings.
 53 		this.config = new config();
 54 	};
 55 }());
 56 
 57 CKEDITOR.editor.prototype =
 58 {
 59 	// The CKEDITOR.editor.fire will always pass itself as the "editor"
 60 	// param in CKEDITOR.event.fire. So, we override it to do that
 61 	// automaticaly.
 62 	fire : function( eventName, data )
 63 	{
 64 		return CKEDITOR.event.prototype.fire.call( this, eventName, data, this );
 65 	},
 66 	
 67 	fireOnce : function( eventName, data )
 68 	{
 69 		return CKEDITOR.event.prototype.fireOnce.call( this, eventName, data, this );
 70 	}
 71 };
 72 
 73 // "Inherit" (copy actually) from CKEDITOR.event.
 74 CKEDITOR.tools.extend( CKEDITOR.editor.prototype, CKEDITOR.event.prototype );
 75