Type.registerNamespace("Telerik.Web");
Telerik.Web.UI.ColorPickerColorChangeEventArgs=function(_1){
Telerik.Web.UI.ColorPickerColorChangeEventArgs.initializeBase(this);
this._oldColor=_1;
};
Telerik.Web.UI.ColorPickerColorChangeEventArgs.prototype={get_oldColor:function(){
return this._oldColor;
}};
$telerik.makeCompatible(Telerik.Web.UI.ColorPickerColorChangeEventArgs);
Telerik.Web.UI.ColorPickerColorChangeEventArgs.registerClass("Telerik.Web.UI.ColorPickerColorChangeEventArgs",Sys.EventArgs);
Telerik.Web.UI.ColorPickerColorSelectingEventArgs=function(_2){
Telerik.Web.UI.ColorPickerColorSelectingEventArgs.initializeBase(this);
this._color=_2;
};
Telerik.Web.UI.ColorPickerColorSelectingEventArgs.prototype={get_color:function(){
return this._color;
}};
$telerik.makeCompatible(Telerik.Web.UI.ColorPickerColorSelectingEventArgs);
Telerik.Web.UI.ColorPickerColorSelectingEventArgs.registerClass("Telerik.Web.UI.ColorPickerColorSelectingEventArgs",Sys.EventArgs);
Telerik.Web.UI.RadColorPicker=function(_3){
Telerik.Web.UI.RadColorPicker.initializeBase(this,[_3]);
this._selectedColor=null;
this._autoPostBack=false;
this._previewColor=true;
this._showIcon=false;
this._showEmptyColor=true;
this._lastPreviewColor="";
this._elementsByColor=[];
this._mouseUpHandler=null;
this._pickColorText="";
this._currentColorText="";
this._noColorText="";
this._popupBehavior=null;
this._paletteDisplayed=false;
this._realWidthIE6=0;
this._realWidthIE7=0;
this._realWidthColorBoxOpera=0;
this._uniqueID=null;
};
Telerik.Web.UI.RadColorPicker.prototype={initialize:function(){
Telerik.Web.UI.RadColorPicker.callBaseMethod(this,"initialize");
this._wrapperElement=$get(this.get_id());
this._previewElement=$get(this.get_id()+"_preview");
this._emptyColorElement=$get(this.get_id()+"_emptycolor");
this._iconElement=$get(this.get_id()+"_icon");
this._iconWrapperElement=$get(this.get_id()+"_label");
this._paletteWrapperElement=$get(this.get_id()+"_palette");
if(!this._showIcon){
this._paletteDisplayed=true;
}else{
if(!this._popupBehavior){
this._popupBehavior=$create(Telerik.Web.PopupBehavior,{"id":this.get_id()+"PopupBehavior","parentElement":this._iconWrapperElement},null,null,this._paletteWrapperElement);
}
}
var _4=this._paletteWrapperElement.getElementsByTagName("A");
for(var i=0;i<_4.length;i++){
if(this._getColorBoxElement(_4[i])==null){
continue;
}
this._elementsByColor[this._getElementColor(_4[i])]=_4[i];
}
if(Sys.Browser.agent==Sys.Browser.Opera){
var _6=this._paletteWrapperElement.getElementsByTagName("LI");
for(var i=0;i<_6.length;i++){
_6[i].style.width=this._realWidthColorBoxOpera+"px";
}
}
this._initializeEventHandlers();
this.set_selectedColor(this._selectedColor);
this.raiseEvent("loaded");
},dispose:function(){
if(this._popupBehavior){
this._popupBehavior.dispose();
this._popupBehavior=null;
}
this._disposeHandlers();
Telerik.Web.UI.RadColorPicker.callBaseMethod(this,"dispose");
},showPalette:function(){
var _7=$telerik.getBounds(this._iconWrapperElement);
this._popupBehavior.set_x(0);
this._popupBehavior.set_y(_7.height);
if(Sys.Browser.agent==Sys.Browser.InternetExplorer&&Sys.Browser.version==6){
this._paletteWrapperElement.style.width=this._realWidthIE6+"px";
}else{
if(Sys.Browser.agent==Sys.Browser.InternetExplorer&&Sys.Browser.version==7){
this._paletteWrapperElement.style.width=this._realWidthIE7+"px";
}else{
this._paletteWrapperElement.style.width=this._realWidthIE7+"px";
}
}
this._popupBehavior.show();
this._paletteDisplayed=true;
},hidePalette:function(){
this._popupBehavior.hide();
this._paletteDisplayed=false;
},getIconContainer:function(){
return this._iconWrapperElement;
},getPaletteContainer:function(){
return this._paletteWrapperElement;
},ShowPalette:function(){
this.showPalette();
},HidePalette:function(){
this.hidePalette();
},GetIconContainer:function(){
this.getIconContainer();
},GetPaletteContainer:function(){
this.getPaletteContainer();
},saveClientState:function(){
var _8=["selectedColor"];
var _9={};
for(var i=0;i<_8.length;i++){
_9[_8[i]]=this["get_"+_8[i]]();
}
return Sys.Serialization.JavaScriptSerializer.serialize(_9);
},add_loaded:function(_b){
this.get_events().addHandler("loaded",_b);
},remove_loaded:function(_c){
this.get_events().removeHandler("loaded",_c);
},add_colorSelecting:function(_d){
this.get_events().addHandler("colorSelecting",_d);
},remove_colorSelecting:function(_e){
this.get_events().removeHandler("colorSelecting",_e);
},add_colorChange:function(_f){
this.get_events().addHandler("colorChange",_f);
},remove_colorChange:function(_10){
this.get_events().removeHandler("colorChange",_10);
},get_selectedColor:function(){
return this._selectedColor;
},set_selectedColor:function(_11){
if(!_11){
_11=null;
}
var _12=this._selectedColor;
if(!_12){
_12=null;
}
if(_11!=null){
_11=_11.toUpperCase();
}
this._selectedColor=_11;
var _13=this._getMarkedElement();
if(_13!=null){
if(_13==this._emptyColorElement){
_13.className="emptycolor";
}else{
_13.className="colorbox";
}
}
var _14=this._getBoxElementByColor(_11);
if(_14!=null){
this._setMarkedElement(_14);
if(_14==this._emptyColorElement){
_14.className="emptycolor selectedcolor";
}else{
_14.className="selectedcolor";
}
}
this._previewCurrentColor(_11);
if(this._showIcon){
this._setIconColor(_11);
}
this.updateClientState();
if(this._selectedColor!=_12){
var _15=new Telerik.Web.UI.ColorPickerColorChangeEventArgs(_12);
this.raiseEvent("colorChange",_15);
if(this._autoPostBack){
this._raiseColorChangedServerEvent();
}
}
},get_selectedColorTitle:function(){
var _16=this._getBoxElementByColor(this._selectedColor);
if(_16!=null){
return _16.getAttribute("title");
}
return this._selectedColor;
},_initializeEventHandlers:function(){
$addHandlers(this._paletteWrapperElement,{"mouseover":this._onBoxMouseOver,"mouseup":this._onBoxClick,"selectstart":this._onSelectStart},this);
if(this._showEmptyColor){
$addHandlers(this._emptyColorElement,{"click":this._onEmptyColorClick},this);
}
if(this._showIcon){
$addHandlers(this._iconWrapperElement,{"mousedown":this._onIconMouseDown,"mouseup":this._onIconMouseUp},this);
this._mouseUpHandler=Function.createDelegate(this,this._onMouseUp);
$addHandler(document,"mouseup",this._mouseUpHandler);
}
},_disposeHandlers:function(){
$clearHandlers(this._paletteWrapperElement);
if(this._showEmptyColor){
$clearHandlers(this._emptyColorElement);
}
if(this._showIcon){
$clearHandlers(this._iconWrapperElement);
$removeHandler(document,"mouseup",this._mouseUpHandler);
}
this._mouseUpHandler=null;
},_raiseColorChangedServerEvent:function(){
__doPostBack(this._uniqueID);
},_onMouseUp:function(){
this.hidePalette();
},_onBoxMouseOver:function(evt){
var _18=this._getColorBoxElement(evt.target);
if(_18==null){
return;
}
var _19=this._getElementColor(_18);
if(_19!=this._lastPreviewColor){
var _1a=new Telerik.Web.UI.ColorPickerColorSelectingEventArgs(_19);
this.raiseEvent("colorSelecting",_1a);
}
this._previewCurrentColor(_19,_18.title);
},_onEmptyColorClick:function(evt){
this.set_selectedColor(null);
if(this._showIcon){
this.hidePalette();
}
},_onIconMouseDown:function(evt){
evt.preventDefault();
evt.stopPropagation();
},_onIconMouseUp:function(evt){
if(this._paletteDisplayed){
this.hidePalette();
}else{
this.showPalette();
}
evt.preventDefault();
evt.stopPropagation();
},_getElementColor:function(_1e){
if(_1e==this._emptyColorElement){
return null;
}
return _1e.firstChild.innerHTML;
},_setIconColor:function(_1f){
if(_1f==null){
_1f="#FFFFFF";
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}","blank");
}else{
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}",_1f);
}
this._iconElement.style.backgroundColor=_1f;
},_onSelectStart:function(evt){
evt.stopPropagation();
evt.preventDefault();
},_onBoxClick:function(evt){
if(evt.button!=0){
return;
}
evt.stopPropagation();
var _22=this._getColorBoxElement(evt.target);
if(_22==null){
return;
}
this.set_selectedColor(this._getElementColor(_22));
if(this._showIcon){
this.hidePalette();
}
},_getMarkedElement:function(){
if(this._markedElement){
return this._markedElement;
}
var _23=this._paletteWrapperElement.getElementsByTagName("A");
for(var i=0;i<_23.length;i++){
if(_23[i].className=="selectedcolor"){
return _23[i];
}
}
return null;
},_setMarkedElement:function(_25){
this._markedElement=_25;
},_getColorBoxElement:function(_26){
var _27=3;
var i=0;
while(i<_27){
if(_26.className=="colorbox"||_26.className=="selectedcolor"||_26.className.indexOf("emptycolor")>-1){
return _26;
}
i++;
_26=_26.parentNode;
}
return null;
},_getBoxElementByColor:function(_29){
if(!_29){
return this._emptyColorElement;
}
_29=_29.toUpperCase();
return this._elementsByColor[_29];
},_previewCurrentColor:function(_2a,_2b){
if(!this.get_isInitialized()){
return;
}
this._lastPreviewColor=_2a;
if(!this._previewColor){
return;
}
if(_2a==null){
_2a="#FFFFFF";
_2b=this._noColorText;
}
_2a=_2a.toUpperCase();
if(!_2b){
_2b=_2a;
}
this._previewElement.style.backgroundColor=_2a;
this._previewElement.getElementsByTagName("span")[0].innerHTML=_2b;
this._previewElement.getElementsByTagName("span")[1].innerHTML=_2b;
}};
$telerik.makeCompatible(Telerik.Web.UI.RadColorPicker);
Telerik.Web.UI.RadColorPicker.registerClass("Telerik.Web.UI.RadColorPicker",Telerik.Web.UI.RadWebControl);

