JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.4.2
[ckeditor.git] / _source / core / ckeditor.js
1 /*\r
2 Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 /**\r
7  * @fileOverview Contains the third and last part of the {@link CKEDITOR} object\r
8  *              definition.\r
9  */\r
10 \r
11 // Remove the CKEDITOR.loadFullCore reference defined on ckeditor_basic.\r
12 delete CKEDITOR.loadFullCore;\r
13 \r
14 /**\r
15  * Holds references to all editor instances created. The name of the properties\r
16  * in this object correspond to instance names, and their values contains the\r
17  * {@link CKEDITOR.editor} object representing them.\r
18  * @type {Object}\r
19  * @example\r
20  * alert( <b>CKEDITOR.instances</b>.editor1.name );  // "editor1"\r
21  */\r
22 CKEDITOR.instances = {};\r
23 \r
24 /**\r
25  * The document of the window holding the CKEDITOR object.\r
26  * @type {CKEDITOR.dom.document}\r
27  * @example\r
28  * alert( <b>CKEDITOR.document</b>.getBody().getName() );  // "body"\r
29  */\r
30 CKEDITOR.document = new CKEDITOR.dom.document( document );\r
31 \r
32 /**\r
33  * Adds an editor instance to the global {@link CKEDITOR} object. This function\r
34  * is available for internal use mainly.\r
35  * @param {CKEDITOR.editor} editor The editor instance to be added.\r
36  * @example\r
37  */\r
38 CKEDITOR.add = function( editor )\r
39 {\r
40         CKEDITOR.instances[ editor.name ] = editor;\r
41 \r
42         editor.on( 'focus', function()\r
43                 {\r
44                         if ( CKEDITOR.currentInstance != editor )\r
45                         {\r
46                                 CKEDITOR.currentInstance = editor;\r
47                                 CKEDITOR.fire( 'currentInstance' );\r
48                         }\r
49                 });\r
50 \r
51         editor.on( 'blur', function()\r
52                 {\r
53                         if ( CKEDITOR.currentInstance == editor )\r
54                         {\r
55                                 CKEDITOR.currentInstance = null;\r
56                                 CKEDITOR.fire( 'currentInstance' );\r
57                         }\r
58                 });\r
59 };\r
60 \r
61 /**\r
62  * Removes and editor instance from the global {@link CKEDITOR} object. his function\r
63  * is available for internal use mainly.\r
64  * @param {CKEDITOR.editor} editor The editor instance to be added.\r
65  * @example\r
66  */\r
67 CKEDITOR.remove = function( editor )\r
68 {\r
69         delete CKEDITOR.instances[ editor.name ];\r
70 };\r
71 \r
72 /**\r
73  * Perform global clean up to free as much memory as possible\r
74  * when there are no instances left\r
75  */\r
76 CKEDITOR.on( 'instanceDestroyed', function ()\r
77         {\r
78                 if ( CKEDITOR.tools.isEmpty( this.instances ) )\r
79                         CKEDITOR.fire( 'reset' );\r
80         });\r
81 \r
82 // Load the bootstrap script.\r
83 CKEDITOR.loader.load( 'core/_bootstrap' );              // @Packager.RemoveLine\r
84 \r
85 // Tri-state constants.\r
86 \r
87 /**\r
88  * Used to indicate the ON or ACTIVE state.\r
89  * @constant\r
90  * @example\r
91  */\r
92 CKEDITOR.TRISTATE_ON = 1;\r
93 \r
94 /**\r
95  * Used to indicate the OFF or NON ACTIVE state.\r
96  * @constant\r
97  * @example\r
98  */\r
99 CKEDITOR.TRISTATE_OFF = 2;\r
100 \r
101 /**\r
102  * Used to indicate DISABLED state.\r
103  * @constant\r
104  * @example\r
105  */\r
106 CKEDITOR.TRISTATE_DISABLED = 0;\r
107 \r
108 /**\r
109  * The editor which is currently active (have user focus).\r
110  * @name CKEDITOR.currentInstance\r
111  * @type CKEDITOR.editor\r
112  * @see CKEDITOR#currentInstance\r
113  * @example\r
114  * function showCurrentEditorName()\r
115  * {\r
116  *     if ( CKEDITOR.currentInstance )\r
117  *         alert( CKEDITOR.currentInstance.name );\r
118  *     else\r
119  *         alert( 'Please focus an editor first.' );\r
120  * }\r
121  */\r
122 \r
123 /**\r
124  * Fired when the CKEDITOR.currentInstance object reference changes. This may\r
125  * happen when setting the focus on different editor instances in the page.\r
126  * @name CKEDITOR#currentInstance\r
127  * @event\r
128  * var editor;  // Variable to hold a reference to the current editor.\r
129  * CKEDITOR.on( 'currentInstance' , function( e )\r
130  *     {\r
131  *         editor = CKEDITOR.currentInstance;\r
132  *     });\r
133  */\r