2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
7 * Contains UI features related to an editor instance.
\r
9 * @param {CKEDITOR.editor} editor The editor instance.
\r
12 CKEDITOR.ui = function( editor )
\r
18 * Object used to hold private stuff.
\r
30 // PACKAGER_RENAME( CKEDITOR.ui )
\r
32 CKEDITOR.ui.prototype =
\r
35 * Adds a UI item to the items collection. These items can be later used in
\r
37 * @param {String} name The UI item name.
\r
38 * @param {Object} type The item type.
\r
39 * @param {Object} definition The item definition. The properties of this
\r
40 * object depend on the item type.
\r
42 * // Add a new button named "MyBold".
\r
43 * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON,
\r
45 * label : 'My Bold',
\r
49 add : function( name, type, definition )
\r
51 this._.items[ name ] =
\r
54 args : Array.prototype.slice.call( arguments, 2 )
\r
60 * @param {String} name The UI item hame.
\r
63 create : function( name )
\r
65 var item = this._.items[ name ],
\r
66 handler = item && this._.handlers[ item.type ];
\r
68 return handler && handler.create.apply( this, item.args );
\r
72 * Adds a handler for a UI item type. The handler is responsible for
\r
73 * transforming UI item definitions in UI objects.
\r
74 * @param {Object} type The item type.
\r
75 * @param {Object} handler The handler definition.
\r
78 addHandler : function( type, handler )
\r
80 this._.handlers[ type ] = handler;
\r
85 * (Virtual Class) Do not call this constructor. This class is not really part
\r
86 * of the API. It just illustrates the features of hanlder objects to be
\r
87 * passed to the {@link CKEDITOR.ui.prototype.addHandler} function.
\r
88 * @name CKEDITOR.ui.handlerDefinition
\r
94 * Transforms an item definition into an UI item object.
\r
95 * @name CKEDITOR.handlerDefinition.prototype.create
\r
97 * @param {Object} definition The item definition.
\r
99 * editorInstance.ui.addHandler( CKEDITOR.UI_BUTTON,
\r
101 * create : function( definition )
\r
103 * return new CKEDITOR.ui.button( definition );
\r