X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/c930e9176a5a85509c5b0230e2bff5c22a591432..6b044c28b5f26fb99c86c237ffad19741c0f7f3d:/docs/source/ColorPalette.html?ds=inline diff --git a/docs/source/ColorPalette.html b/docs/source/ColorPalette.html index 723fc9d4..70b1d700 100644 --- a/docs/source/ColorPalette.html +++ b/docs/source/ColorPalette.html @@ -1,11 +1,18 @@ - -
-/** + + + ++ \ No newline at end of fileThe source code + + + + +/*! + * Ext JS Library 3.3.1 + * Copyright(c) 2006-2010 Sencha Inc. + * licensing@sencha.com + * http://www.sencha.com/license + */ +/** * @class Ext.ColorPalette * @extends Ext.Component * Simple color palette class for choosing colors. The palette can be rendered to any container.- +Ext.reg('colorpalette', Ext.ColorPalette);
@@ -23,23 +30,7 @@ cp.on('select', function(palette, selColor){ * @param {Object} config The config object * @xtype colorpalette */ -Ext.ColorPalette = function(config){ - Ext.ColorPalette.superclass.constructor.call(this, config); - this.addEvents( - /** - * @event select - * Fires when a color is selected - * @param {ColorPalette} this - * @param {String} color The 6-digit color hex code (without the # symbol) - */ - 'select' - ); - - if(this.handler){ - this.on('select', this.handler, this.scope, true); - } -}; -Ext.extend(Ext.ColorPalette, Ext.Component, { +Ext.ColorPalette = Ext.extend(Ext.Component, { /** * @cfg {String} tpl An existing XTemplate instance to be used in place of the default template for rendering the component. */ @@ -54,6 +45,11 @@ Ext.extend(Ext.ColorPalette, Ext.Component, { * the hex codes are case-sensitive. */ value : null, + /** + * @cfg {String} clickEvent + * The DOM event that will cause a color to be selected. This can be any valid event name (dblclick, contextmenu). + * Defaults to 'click'. + */ clickEvent :'click', // private ctype : 'Ext.ColorPalette', @@ -102,18 +98,36 @@ cp.colors = ['000000', '993300', '333300']; * The scope (this reference) in which the{@link #handler}
* function will be called. Defaults to this ColorPalette instance. */ + + // private + initComponent : function(){ + Ext.ColorPalette.superclass.initComponent.call(this); + this.addEvents( + /** + * @event select + * Fires when a color is selected + * @param {ColorPalette} this + * @param {String} color The 6-digit color hex code (without the # symbol) + */ + 'select' + ); + + if(this.handler){ + this.on('select', this.handler, this.scope, true); + } + }, // private onRender : function(container, position){ + this.autoEl = { + tag: 'div', + cls: this.itemCls + }; + Ext.ColorPalette.superclass.onRender.call(this, container, position); var t = this.tpl || new Ext.XTemplate( '' ); - var el = document.createElement('div'); - el.id = this.getId(); - el.className = this.itemCls; - t.overwrite(el, this.colors); - container.dom.insertBefore(el, position); - this.el = Ext.get(el); + t.overwrite(this.el, this.colors); this.mon(this.el, this.clickEvent, this.handleClick, this, {delegate: 'a'}); if(this.clickEvent != 'click'){ this.mon(this.el, 'click', Ext.emptyFn, this, {delegate: 'a', preventDefault: true}); @@ -126,7 +140,7 @@ cp.colors = ['000000', '993300', '333300']; if(this.value){ var s = this.value; this.value = null; - this.select(s); + this.select(s, true); } }, @@ -142,8 +156,9 @@ cp.colors = ['000000', '993300', '333300']; /** * Selects the specified color in the palette (fires the {@link #select} event) * @param {String} color A valid 6-digit color hex code (# will be stripped if included) + * @param {Boolean} suppressEvent (optional) True to stop the select event from firing. Defaults to false. */ - select : function(color){ + select : function(color, suppressEvent){ color = color.replace('#', ''); if(color != this.value || this.allowReselect){ var el = this.el; @@ -152,7 +167,9 @@ cp.colors = ['000000', '993300', '333300']; } el.child('a.color-'+color).addClass('x-color-palette-sel'); this.value = color; - this.fireEvent('select', this, color); + if(suppressEvent !== true){ + this.fireEvent('select', this, color); + } } } @@ -160,7 +177,6 @@ cp.colors = ['000000', '993300', '333300']; * @cfg {String} autoEl @hide */ }); -Ext.reg('colorpalette', Ext.ColorPalette); -