Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / core / ui.js
blob52a0e6e38da1cb255a57cff1dc211035ec0d1f53
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 /**
7  * Contains UI features related to an editor instance.
8  * @constructor
9  * @param {CKEDITOR.editor} editor The editor instance.
10  * @example
11  */
12 CKEDITOR.ui = function( editor )
14         if ( editor.ui )
15                 return editor.ui;
17         /**
18          * Object used to hold private stuff.
19          * @private
20          */
21         this._ =
22         {
23                 handlers : {},
24                 items : {},
25                 editor : editor
26         };
28         return this;
31 // PACKAGER_RENAME( CKEDITOR.ui )
33 CKEDITOR.ui.prototype =
35         /**
36          * Adds a UI item to the items collection. These items can be later used in
37          * the interface.
38          * @param {String} name The UI item name.
39          * @param {Object} type The item type.
40          * @param {Object} definition The item definition. The properties of this
41          *              object depend on the item type.
42          * @example
43          * // Add a new button named "MyBold".
44          * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON,
45          *     {
46          *         label : 'My Bold',
47          *         command : 'bold'
48          *     });
49          */
50         add : function( name, type, definition )
51         {
52                 this._.items[ name ] =
53                 {
54                         type : type,
55                         // The name of {@link CKEDITOR.command} which associate with this UI.
56                         command : definition.command || null,
57                         args : Array.prototype.slice.call( arguments, 2 )
58                 };
59         },
61         /**
62          * Gets a UI object.
63          * @param {String} name The UI item hame.
64          * @example
65          */
66         create : function( name )
67         {
68                 var item        = this._.items[ name ],
69                         handler = item && this._.handlers[ item.type ],
70                         command = item && item.command && this._.editor.getCommand( item.command );
72                 var result = handler && handler.create.apply( this, item.args );
74                 // Add reference inside command object.
75                 if ( command )
76                         command.uiItems.push( result );
78                 return result;
79         },
81         /**
82          * Adds a handler for a UI item type. The handler is responsible for
83          * transforming UI item definitions in UI objects.
84          * @param {Object} type The item type.
85          * @param {Object} handler The handler definition.
86          * @example
87          */
88         addHandler : function( type, handler )
89         {
90                 this._.handlers[ type ] = handler;
91         }
94 CKEDITOR.event.implementOn( CKEDITOR.ui );
96 /**
97  * (Virtual Class) Do not call this constructor. This class is not really part
98  *              of the API. It just illustrates the features of hanlder objects to be
99  *              passed to the {@link CKEDITOR.ui.prototype.addHandler} function.
100  * @name CKEDITOR.ui.handlerDefinition
101  * @constructor
102  * @example
103  */
105  /**
106  * Transforms an item definition into an UI item object.
107  * @name CKEDITOR.handlerDefinition.prototype.create
108  * @function
109  * @param {Object} definition The item definition.
110  * @example
111  * editorInstance.ui.addHandler( CKEDITOR.UI_BUTTON,
112  *     {
113  *         create : function( definition )
114  *         {
115  *             return new CKEDITOR.ui.button( definition );
116  *         }
117  *     });
118  */
121  * Internal event fired when a new UI element is ready
122  * @name CKEDITOR.ui#ready
123  * @event
124  * @param {Object} element The new element
125  */