| javascript_components

# Class: Bs_ColorPicker Source Location: /components/colorpicker/Bs_ColorPicker.class.js.php
### Class Overview
Color Picker class. #### Author(s): andrej at blueshoes dot org #### Copyright: blueshoes.org | ### Variables Bs_ColorPicker:: $bsImgDir $button $colorizeBackground $jsBaseDir $windowType $_constructor $_elementId $_elm | ### Methods attachEvent cleanHexCode draw fireEvent getColorAsHex hasEventAttached onBlur openWindow prepareSettings setColorByHex setColorByPickerWindow updateColorByField
### Inherited Variables | ### Inherited Methods
### Class Details [line 32] Color Picker class. #### Tags:
copyright: | blueshoes.org
author: | andrej at blueshoes dot org
[ Top ] ### Class Variables #### = arguments [line 35]
Type: | mixed
[ Top ] #### $bsImgDir = '/_bsImages/' [line 81] the blueshoes image directory. if you don't use the framework you should change it, see the examples. #### Tags:
var: | bsImgDir
access: | public
Type: | string
[ Top ] #### $button = new Bs_Button() [line 106] instance of Bs_Button. the button that opens the color picker. you can access it directly and modify values. example: myColorPicker.button.imgName = 'bs_fgColor'; see http://www.blueshoes.org/en/javascript/toolbar/ #### Tags:
access: | public
Type: | object button
[ Top ] #### $colorizeBackground = false [line 57] if the "background feature" should be used. it makes the background of the input field the selected color. and the text color of the input field is black or white, depending of the background color (dark or light). #### Tags:
var: | colorizeBackground
access: | public
Type: | bool
[ Top ] #### $jsBaseDir = '/_bsJavascript/' [line 73] the base dir to the blueshoes javascript directory. if you don't use the framework you should change it, see the examples. #### Tags:
var: | jsBaseDir
access: | public
Type: | string
[ Top ] #### $windowType = 'dialog' [line 93] what technology to use for the color window. dialog => window.showModalDialog(). that is the default, and works great in ie. popup => window.open() works in mozilla, has its drawbacks. note: mozilla falls back to popup anyway. #### Tags:
var: | windowType
access: | public
Type: | string
[ Top ] #### $_constructor = [line 382]
Type: | mixed
[ Top ] #### $_elementId = (a.length>1) ? a[1] : a[0] [line 36]
Type: | mixed
[ Top ] #### $_elm = document.getElementById(this._elementId) [line 37]
Type: | mixed
[ Top ] ### Class Methods ### method attachEvent [line 337]
`void attachEvent( string trigger, mixed yourEvent)`
attaches an event. the following triggers can be used: 'onBeforeChange' 'onAfterChange' the onXXXChange events fire when the value changes by the user, not when you do it using an api method like setColorByHex() because then you already know what's happening. the events will be executed in the order they were registered. if an onBeforeXXX event you've attached returns bool FALSE, it will stop executing any other attached events in that queue, and it will quit. example: if you attach an onBeforeChange event, and your code returns FALSE, the change won't be done at all. examples: myObj.attachEvent('onBeforeChange', myFunction); then your function myFunction() receives one param, it is a reference to this object (myObj). myObj.attachEvent('onBeforeChange', "if (true) return false;"); this is an example with code attached that will be evaluated. #### Tags:
see: | var this._attachedEvents
access: | public
#### Parameters:
string | trigger | trigger
mixed | yourEvent | yourEvent (string (of code) or function)
[ Top ] ### method cleanHexCode [line 232]
`string cleanHexCode( string hex)`
removes the trailing '#', converts to uppercase. #### Tags:
throws: | bool false (if not a valid hex code)
access: | public
#### Parameters:
string | hex | hex
[ Top ] ### method draw [line 165]
`void draw( )`
draws the open-picker button. #### Tags:
access: | public
[ Top ] ### method fireEvent [line 365]
`void fireEvent( string trigger)`
fires the events for the trigger specified. #### Parameters:
string | trigger | trigger
[ Top ] ### method getColorAsHex [line 277]
`string getColorAsHex( )`
returns the hex color code. #### Tags:
return: | (6 digit hex code)
access: | public
[ Top ] ### method hasEventAttached [line 355]
`bool hasEventAttached( string trigger)`
tells if any event is attached for the trigger specified. #### Tags:
access: | public
#### Parameters:
string | trigger | trigger
[ Top ] ### method onBlur [line 243]
`void onBlur( )`
[ Top ] ### method openWindow [line 184]
`void openWindow( )`
opens the colorpicker window. [ Top ] ### method prepareSettings [line 294]
`object (with prepareSettings( )`
#### Tags:
return: | settings)
[ Top ] ### method setColorByHex [line 213]
`void setColorByHex( string hex)`
#### Tags:
access: | public
#### Parameters:
string | hex | hex (6 digit hex code, it's ok to have a leading # (=7 digits).)
[ Top ] ### method setColorByPickerWindow [line 202]
`void setColorByPickerWindow( string hex)`
#### Parameters:
string | hex | hex (6 digit hex code)
[ Top ] ### method updateColorByField [line 286]
`void updateColorByField( )`
updates the color by the input field (hex value). #### Tags:
access: | public
[ Top ] Documentation generated on Mon, 29 Dec 2003 22:18:17 +0100 by phpDocumentor 1.2.3