Class Ext.ColorPalette
Simple color palette class for choosing colors. The palette can be rendered to any container.
Here's an example of typical usage:
var cp = new Ext.ColorPalette({value:'993300'}); // initial selected color
cp.render('my-div');
cp.on('select', function(palette, selColor){
// do something with selColor
});
Properties
-
Methods
-
Events
-
Config Options
Public Properties
|
colors : Array |
ColorPalette |
An array of 6-digit color hex code strings (without the # symbol). This array can contain any number
of colors, and ... |
|
disabled : Object |
Component |
true if this component is disabled. Read-only. |
|
disabledClass : Object |
Component |
CSS class added to the component when it is disabled. |
|
hidden : Object |
Component |
true if this component is hidden. Read-only. |
|
rendered : Object |
Component |
true if this component has been rendered. Read-only. |
Public Methods
|
ColorPalette(Object config ) |
ColorPalette |
Create a new ColorPalette |
|
addEvents(Object object ) : void |
Observable |
Copies any events from the passed object onto this object if they do not already exist. The passed object
must also ... |
|
addListener(String eventName , Function handler , [Object options ]) : void |
Observable |
Appends an event handler to this component |
|
disable() : void |
Component |
Disable this component |
|
enable() : void |
Component |
Enable this component |
|
fireEvent(String eventName , Object... args ) : Boolean |
Observable |
Fires the specified event with the passed parameters (minus the event name). |
|
focus(Boolean selectText ) : void |
Component |
Try to focus this component |
|
getEl() : Ext.Element |
Component |
Returns the underlying Ext.Element |
|
hasListener(String eventName ) : Boolean |
Observable |
Checks to see if this object is currently listening for a specified event |
|
hide() : void |
Component |
Hide this component |
|
on(String eventName , Function handler , [Object options ]) : void |
Observable |
Appends an event handler to this element (shorthand for addListener) |
|
purgeListeners() : void |
Observable |
Removes all listeners for this object |
|
removeListener(String eventName , Function handler , [Object scope ]) : void |
Observable |
Removes a listener |
|
render(String/HTMLElement/Element container ) : void |
Component |
If this is a lazy rendering component, render it to it's container element |
|
select(String color ) : void |
ColorPalette |
Selects the specified color in the palette (fires the select event) |
|
setDisabled(Boolean disabled ) : void |
Component |
Convenience function for setting disabled/enabled by boolean |
|
setVisible(Boolean visible ) : void |
Component |
Convenience function to hide or show this component by boolean |
|
show() : void |
Component |
Show this component |
|
un(String eventName , Function handler , [Object scope ]) : void |
Observable |
Removes a listener (shorthand for removeListener) |
Public Events
|
beforedestroy : (Ext.Component this ) |
Component |
Fires before the component is destroyed |
|
beforehide : (Ext.Component this ) |
Component |
Fires before the component is hidden |
|
beforerender : (Ext.Component this ) |
Component |
Fires before the component is rendered |
|
beforeshow : (Ext.Component this ) |
Component |
Fires before the component is shown |
|
destroy : (Ext.Component this ) |
Component |
Fires after the component is destroyed |
|
disable : (Ext.Component this ) |
Component |
Fires after the component is disabled |
|
enable : (Ext.Component this ) |
Component |
Fires after the component is enabled |
|
hide : (Ext.Component this ) |
Component |
Fires after the component is hidden |
|
render : (Ext.Component this ) |
Component |
Fires after the component is rendered |
|
select : (ColorPalette this , String color ) |
ColorPalette |
Fires when a color is selected |
|
show : (Ext.Component this ) |
Component |
Fires after the component is shown |
Config Options
|
itemCls : String |
ColorPalette |
The CSS class to apply to the containing element (defaults to "x-color-palette") |
|
value : String |
ColorPalette |
The initial color to highlight (should be a valid 6-digit color hex code without the # symbol). Note that the hex cod... |
Property Details
colors
public Array colors
An array of 6-digit color hex code strings (without the # symbol). This array can contain any number
of colors, and each hex code should be unique. The width of the palette is controlled via CSS by adjusting
the width property of the 'x-color-palette' class (or assigning a custom class), so you can balance the number
of colors with the width setting until the box is symmetrical.
You can override individual colors if needed:
var cp = new Ext.ColorPalette();
cp.colors[0] = "FF0000"; // change the first box to red
Or you can provide a custom array of your own for complete control:
var cp = new Ext.ColorPalette();
cp.colors = ["000000", "993300", "333300"];
This property is defined by ColorPalette.
disabled
public Object disabled
true if this component is disabled. Read-only.
disabledClass
public Object disabledClass
CSS class added to the component when it is disabled.
hidden
public Object hidden
true if this component is hidden. Read-only.
rendered
public Object rendered
true if this component has been rendered. Read-only.
Constructor Details
ColorPalette
public function ColorPalette(Object config
)
Create a new ColorPalette
Parameters:
config
: ObjectThe config object
Method Details
addEvents
public function addEvents(Object object
)
Copies any events from the passed object onto this object if they do not already exist. The passed object
must also inherit from Observable for this method to have any effect.
addListener
public function addListener(String eventName
, Function handler
, [Object options
])
Appends an event handler to this component
disable
public function disable()
enable
public function enable()
fireEvent
public function fireEvent(String eventName
, Object... args
)
Fires the specified event with the passed parameters (minus the event name).
focus
public function focus(Boolean selectText
)
Try to focus this component
getEl
public function getEl()
hasListener
public function hasListener(String eventName
)
Checks to see if this object is currently listening for a specified event
hide
public function hide()
on
public function on(String eventName
, Function handler
, [Object options
])
Appends an event handler to this element (shorthand for addListener)
purgeListeners
public function purgeListeners()
Removes all listeners for this object
removeListener
public function removeListener(String eventName
, Function handler
, [Object scope
])
render
public function render(String/HTMLElement/Element container
)
If this is a lazy rendering component, render it to it's container element
select
public function select(String color
)
Selects the specified color in the palette (fires the select event)
This method is defined by ColorPalette.
setDisabled
public function setDisabled(Boolean disabled
)
Convenience function for setting disabled/enabled by boolean
setVisible
public function setVisible(Boolean visible
)
Convenience function to hide or show this component by boolean
show
public function show()
un
public function un(String eventName
, Function handler
, [Object scope
])
Removes a listener (shorthand for removeListener)
Event Details
beforedestroy
public event beforedestroy
Fires before the component is destroyed
Subscribers will be called with the following parameters:
beforehide
public event beforehide
Fires before the component is hidden
Subscribers will be called with the following parameters:
beforerender
public event beforerender
Fires before the component is rendered
Subscribers will be called with the following parameters:
beforeshow
public event beforeshow
Fires before the component is shown
Subscribers will be called with the following parameters:
destroy
public event destroy
Fires after the component is destroyed
Subscribers will be called with the following parameters:
disable
public event disable
Fires after the component is disabled
Subscribers will be called with the following parameters:
enable
public event enable
Fires after the component is enabled
Subscribers will be called with the following parameters:
hide
public event hide
Fires after the component is hidden
Subscribers will be called with the following parameters:
render
public event render
Fires after the component is rendered
Subscribers will be called with the following parameters:
select
public event select
Fires when a color is selected
Subscribers will be called with the following parameters:
This event is defined by ColorPalette.
show
public event show
Fires after the component is shown
Subscribers will be called with the following parameters:
Config Details
itemCls
itemCls : String
The CSS class to apply to the containing element (defaults to "x-color-palette")
This config option is defined by ColorPalette.
value
value : String
The initial color to highlight (should be a valid 6-digit color hex code without the # symbol). Note that the hex codes are case-sensitive.
This config option is defined by ColorPalette.