b569d8a245b8b8815fb459ce421d11d845d60283
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
7 * Contains UI features related to an editor instance.
9 * @param {CKEDITOR.editor} editor The editor instance.
12 CKEDITOR
.ui = function( editor
)
18 * Object used to hold private stuff.
31 // PACKAGER_RENAME( CKEDITOR.ui )
33 CKEDITOR
.ui
.prototype =
36 * Adds a UI item to the items collection. These items can be later used in
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.
43 * // Add a new button named "MyBold".
44 * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON,
50 add : function( name
, type
, definition
)
52 this._
.items
[ name
] =
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 )
63 * @param {String} name The UI item hame.
66 create : function( name
)
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 // Allow overrides from skin ui definitions..
75 item
&& ( result
= CKEDITOR
.tools
.extend( result
, this._
.editor
.skin
[ item
.type
], true ) );
77 // Add reference inside command object.
79 command
.uiItems
.push( result
);
85 * Adds a handler for a UI item type. The handler is responsible for
86 * transforming UI item definitions in UI objects.
87 * @param {Object} type The item type.
88 * @param {Object} handler The handler definition.
91 addHandler : function( type
, handler
)
93 this._
.handlers
[ type
] = handler
;
97 CKEDITOR
.event
.implementOn( CKEDITOR
.ui
);
100 * (Virtual Class) Do not call this constructor. This class is not really part
101 * of the API. It just illustrates the features of hanlder objects to be
102 * passed to the {@link CKEDITOR.ui.prototype.addHandler} function.
103 * @name CKEDITOR.ui.handlerDefinition
109 * Transforms an item definition into an UI item object.
110 * @name CKEDITOR.handlerDefinition.prototype.create
112 * @param {Object} definition The item definition.
114 * editorInstance.ui.addHandler( CKEDITOR.UI_BUTTON,
116 * create : function( definition )
118 * return new CKEDITOR.ui.button( definition );
124 * Internal event fired when a new UI element is ready
125 * @name CKEDITOR.ui#ready
127 * @param {Object} element The new element