summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/colorpicker/colorpicker.js
diff options
context:
space:
mode:
authorwei <>2006-04-25 00:27:44 +0000
committerwei <>2006-04-25 00:27:44 +0000
commitfd019bf034ef4dbedfc305c77fed0dbd83a732c4 (patch)
treeafc59b99826308924725074ee34e4f541a1d399a /framework/Web/Javascripts/colorpicker/colorpicker.js
parent72a75d7d0f5681df3fd98c684ab6f22baefb365c (diff)
Add TListControlValidator. Update client-side validators, datepicker.js, colorpicker.js. Merge to 3.0 if necessary.
Diffstat (limited to 'framework/Web/Javascripts/colorpicker/colorpicker.js')
-rw-r--r--framework/Web/Javascripts/colorpicker/colorpicker.js59
1 files changed, 42 insertions, 17 deletions
diff --git a/framework/Web/Javascripts/colorpicker/colorpicker.js b/framework/Web/Javascripts/colorpicker/colorpicker.js
index cc4587ff..dc80f0c7 100644
--- a/framework/Web/Javascripts/colorpicker/colorpicker.js
+++ b/framework/Web/Javascripts/colorpicker/colorpicker.js
@@ -83,7 +83,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
if(mode == "Full")
this.initializeFullPicker();
}
- this.show();
+ this.show(mode);
},
show : function(type)
@@ -108,6 +108,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
if(type == "Full")
{
+ this.observeMouseMovement();
var color = Rico.Color.createFromHex(this.input.value);
this.inputs.oldColor.style.backgroundColor = color.asHex();
this.setColor(color,true);
@@ -124,8 +125,14 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.element.style.display = "none";
this.showing = false;
- Event.stopObserving(document.body, "click", this._documentClickEvent);
+ Event.stopObserving(document.body, "click", this._documentClickEvent);
Event.stopObserving(document,"keydown", this._documentKeyDownEvent);
+
+ if(this._observingMouseMove)
+ {
+ Event.stopObserving(document.body, "mousemove", this._onMouseMove);
+ this._observingMouseMove = false;
+ }
}
},
@@ -208,7 +215,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
{
this.input.value = color.toString().toUpperCase();
this.button.style.backgroundColor = color.toString();
- if(isFunction(this.onChange))
+ if(typeof(this.onChange) == "function")
this.onChange(color);
},
@@ -246,7 +253,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
TR(null,
TD(null,'H:'),
- TD(null,this.inputs['H'], '°')),
+ TD(null,this.inputs['H'], '??')),
TR(null,
TD(null,'S:'),
@@ -333,34 +340,46 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this._onMouseMove = this.onMouseMove.bind(this);
Event.observe(this.inputs.background, "mousedown", this._onColorMouseDown);
+ Event.observe(this.inputs.selector, "mousedown", this._onColorMouseDown);
Event.observe(this.inputs.hue, "mousedown", this._onHueMouseDown);
+ Event.observe(this.inputs.slider, "mousedown", this._onHueMouseDown);
Event.observe(document.body, "mouseup", this._onMouseUp);
-
- //Because of using the CSS filter, IE can't do colour change quickly
- //if(!Prado.Browser().ie)
- Event.observe(document.body, "mousemove", this._onMouseMove);
+
+ this.observeMouseMovement();
Event.observe(this.buttons.Cancel, "click", this.hide.bindEvent(this,this.options['Mode']));
Event.observe(this.buttons.OK, "click", this.onOKClicked.bind(this));
},
+ observeMouseMovement : function()
+ {
+ if(!this._observingMouseMove)
+ {
+ Event.observe(document.body, "mousemove", this._onMouseMove);
+ this._observingMouseMove = true;
+ }
+ },
+
onColorMouseDown : function(ev)
{
this.isMouseDownOnColor = true;
this.onMouseMove(ev);
+ Event.stop(ev);
},
onHueMouseDown : function(ev)
{
this.isMouseDownOnHue = true;
this.onMouseMove(ev);
+ Event.stop(ev);
},
onMouseUp : function(ev)
{
this.isMouseDownOnColor = false;
this.isMouseDownOnHue = false;
+ Event.stop(ev);
},
onMouseMove : function(ev)
@@ -369,6 +388,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.changeSV(ev);
if(this.isMouseDownOnHue)
this.changeH(ev);
+ Event.stop(ev);
},
changeSV : function(ev)
@@ -376,18 +396,25 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var px = Event.pointerX(ev);
var py = Event.pointerY(ev);
var pos = Position.cumulativeOffset(this.inputs.background);
+
var x = this.truncate(px - pos[0],0,255);
var y = this.truncate(py - pos[1],0,255);
- var h = this.truncate(this.inputs.H.value,0,360)/360;
var s = x/255;
var b = (255-y)/255;
+ var current_s = parseInt(this.inputs.S.value);
+ var current_b = parseInt(this.inputs.V.value);
+
+ if(current_s == parseInt(s*100) && current_b == parseInt(b*100)) return;
+
+ var h = this.truncate(this.inputs.H.value,0,360)/360;
var color = new Rico.Color();
color.rgb = Rico.Color.HSBtoRGB(h,s,b);
+
this.inputs.selector.style.left = x+"px";
this.inputs.selector.style.top = y+"px";
@@ -403,6 +430,10 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var y = this.truncate(py - pos[1],0,255);
var h = (255-y)/255;
+ var current_h = this.truncate(this.inputs.H.value,0,360);
+ current_h = current_h == 0 ? 360 : current_h;
+ if(current_h == parseInt(h*360)) return;
+
var s = parseInt(this.inputs.S.value)/100;
var b = parseInt(this.inputs.V.value)/100;
var color = new Rico.Color();
@@ -472,14 +503,8 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var images = Prado.WebUI.TColorPicker.UIImages;
var changeCss = color.isBright() ? 'removeClassName' : 'addClassName';
- Element[changeCss](this.inputs.selector, 'target_white');
-/* if(color.isBright())
- Element.removeCssClass(this.inputs.selector, 'target_white');
- //this.inputs.selector.src = images['target_black.gif'];
- else
- Element.addCssClass(this.inputs.selector, 'target_white');
- //this.inputs.selector.src = images['target_white.gif'];
-*/
+ Element[changeCss](this.inputs.selector, 'target_white');
+
if(update)
this.updateSelectors(color);
},