X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Fui.js;h=005dc1377d99f15750d36c34bd2295a4fb301d41;hb=a272c66d841421f8bf933c16535bdcde1c4649fc;hp=1d152e24d38f7be5341207690a05e84a054b3dc7;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git diff --git a/_source/core/ui.js b/_source/core/ui.js index 1d152e2..005dc13 100644 --- a/_source/core/ui.js +++ b/_source/core/ui.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -21,7 +21,8 @@ CKEDITOR.ui = function( editor ) this._ = { handlers : {}, - items : {} + items : {}, + editor : editor }; return this; @@ -51,6 +52,8 @@ CKEDITOR.ui.prototype = this._.items[ name ] = { type : type, + // The name of {@link CKEDITOR.command} which associate with this UI. + command : definition.command || null, args : Array.prototype.slice.call( arguments, 2 ) }; }, @@ -63,9 +66,19 @@ CKEDITOR.ui.prototype = create : function( name ) { var item = this._.items[ name ], - handler = item && this._.handlers[ item.type ]; + handler = item && this._.handlers[ item.type ], + command = item && item.command && this._.editor.getCommand( item.command ); - return handler && handler.create.apply( this, item.args ); + var result = handler && handler.create.apply( this, item.args ); + + // Allow overrides from skin ui definitions.. + item && ( result = CKEDITOR.tools.extend( result, this._.editor.skin[ item.type ], true ) ); + + // Add reference inside command object. + if ( command ) + command.uiItems.push( result ); + + return result; }, /** @@ -81,6 +94,8 @@ CKEDITOR.ui.prototype = } }; +CKEDITOR.event.implementOn( CKEDITOR.ui ); + /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. It just illustrates the features of hanlder objects to be @@ -104,3 +119,10 @@ CKEDITOR.ui.prototype = * } * }); */ + +/** + * Internal event fired when a new UI element is ready + * @name CKEDITOR.ui#ready + * @event + * @param {Object} element The new element + */