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.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.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._selectedColorName="";
this._autoPostBack=false;
this._enabled=true;
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;
this._columns=18;
this._items=null;
this._width=null;
this._createdUI=false;
};
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;
this._initializeColorElementsArray();
}
if(this._enabled){
this._initializeEventHandlers();
}
this.set_selectedColor(this._selectedColor);
if(this._items){
this._items=eval(this._items);
}
this.raiseEvent("loaded");
},_initializeColorElementsArray:function(){
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";
}
}
},_createSpanEl:function(_7,_8){
var _9=document.createElement("span");
_9.className=_7;
_9.innerHTML=_8;
return _9;
},_createEmptyColor:function(){
var _a=this._selectedColor?" selectedcolor":"";
var _b=document.createElement("div");
_b.id=this.get_id()+"_emptycolor";
_b.className="emptycolor"+_a;
var _c=document.createElement("a");
_c.title=this._noColorText;
_c.href="javascript:void(0);";
var _d=this._createSpanEl("",this._noColorText);
_c.appendChild(_d);
_b.appendChild(_c);
return _b;
},_createPreviewColor:function(){
var _e=this._selectedColor;
var _f=this._selectedColorName;
if(!_e){
_e="white";
_f="none";
}
var div=document.createElement("div");
div.className="colorpreview";
div.id=this.get_id()+"_preview";
div.style.background=_e;
var _11=this._createSpanEl("colorvaluedark",_f);
var _12=this._createSpanEl("colorvaluelight",_f);
div.appendChild(_11);
div.appendChild(_12);
return div;
},_createColorElement:function(_13,_14){
var _15=(this._selectedColor==_13.value)?"selectedcolor":"colorbox";
var li=document.createElement("li");
var _17=document.createElement("a");
_17.title=_13.title;
_17.href="javascript:void(0);";
_17.className=_15;
_17.style.background=_13.value;
var _18=this._createSpanEl("",_13.value);
_18.style.width=_14+"px";
_18.style.height=_14+"px";
_17.appendChild(_18);
li.appendChild(_17);
return li;
},_calculateColorBoxSize:function(){
var _19=18;
var _1a=6;
var _1b=2;
var _1c=_19;
var _1d=this._columns;
if(this._width){
var _1e=parseInt(this._width)-_1b;
if(_1e<1){
_1e=1;
}
_1c=parseInt(_1e/_1d);
if(_1c<1){
_1c=1;
}
}
this._realWidthIE6=_1b+_1d*(_1c+2);
this._realWidthIE7=_1b+_1d*(_1c+2)-_1d*2;
this._realWidthColorBoxOpera=_1c;
_1c-=_1a;
if(_1c<1){
_1c=1;
}
return _1c;
},_createPalette:function(){
if(this._createdUI){
return;
}
var _1f=document.createElement("div");
_1f.id=this.get_id()+"_palette";
_1f.className="palette";
if(this._showEmptyColor){
var _20=this._createEmptyColor();
_1f.appendChild(_20);
}
var ul=document.createElement("ul");
var _22=0;
var _23=this._items;
var _24=this._calculateColorBoxSize();
for(var i in _23){
if(_22==this._columns){
_22=0;
var _26=document.createElement("li");
_26.className="breakline";
ul.appendChild(_26);
}
_22++;
var _27=this._createColorElement(_23[i],_24);
ul.appendChild(_27);
}
_1f.appendChild(ul);
if(this._previewColor){
var _28=this._createPreviewColor();
_1f.appendChild(_28);
}
var _29=this.get_element();
_29.rows[0].cells[0].appendChild(_1f);
this._previewElement=$get(this.get_id()+"_preview");
this._emptyColorElement=$get(this.get_id()+"_emptycolor");
this._paletteWrapperElement=$get(this.get_id()+"_palette");
if(!this._popupBehavior){
this._popupBehavior=$create(Telerik.Web.PopupBehavior,{"id":this.get_id()+"PopupBehavior","parentElement":this._iconWrapperElement},null,null,this._paletteWrapperElement);
}
this._initializeColorElementsArray();
this._initializePalleteEventHandlers();
this._createdUI=true;
},dispose:function(){
if(this._popupBehavior){
this._popupBehavior.dispose();
this._popupBehavior=null;
}
if(this._enabled){
this._disposeHandlers();
}
Telerik.Web.UI.RadColorPicker.callBaseMethod(this,"dispose");
},showPalette:function(){
this._createPalette();
var _2a=$telerik.getBounds(this._iconWrapperElement);
this._popupBehavior.set_x(0);
this._popupBehavior.set_y(_2a.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(){
if(this._popupBehavior){
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(){
return this.getIconContainer();
},GetPaletteContainer:function(){
return this.getPaletteContainer();
},saveClientState:function(){
var _2b=["selectedColor"];
var _2c={};
for(var i=0;i<_2b.length;i++){
_2c[_2b[i]]=this["get_"+_2b[i]]();
}
return Sys.Serialization.JavaScriptSerializer.serialize(_2c);
},add_loaded:function(_2e){
this.get_events().addHandler("loaded",_2e);
},remove_loaded:function(_2f){
this.get_events().removeHandler("loaded",_2f);
},add_colorSelecting:function(_30){
this.get_events().addHandler("colorSelecting",_30);
},remove_colorSelecting:function(_31){
this.get_events().removeHandler("colorSelecting",_31);
},add_colorChange:function(_32){
this.get_events().addHandler("colorChange",_32);
},remove_colorChange:function(_33){
this.get_events().removeHandler("colorChange",_33);
},get_selectedColor:function(){
return this._selectedColor;
},set_selectedColor:function(_34){
if(!_34){
_34=null;
}
var _35=this._selectedColor;
if(!_35){
_35=null;
}
if(_34!=null){
_34=_34.toUpperCase();
}
this._selectedColor=_34;
var _36=this._getMarkedElement();
if(_36!=null){
if(_36==this._emptyColorElement){
_36.className="emptycolor";
}else{
_36.className="colorbox";
}
}
var _37=this._getBoxElementByColor(_34);
if(_37!=null){
this._setMarkedElement(_37);
if(_37==this._emptyColorElement){
_37.className="emptycolor selectedcolor";
}else{
_37.className="selectedcolor";
}
}
this._previewCurrentColor(_34);
if(this._showIcon){
this._setIconColor(_34);
}
this.updateClientState();
if(this._selectedColor!=_35){
var _38=new Telerik.Web.UI.ColorPickerColorChangeEventArgs(_35);
this.raiseEvent("colorChange",_38);
if(this._autoPostBack){
this._raiseColorChangedServerEvent();
}
}
},get_selectedColorTitle:function(){
var _39=this._getBoxElementByColor(this._selectedColor);
if(_39!=null){
return _39.getAttribute("title");
}
return this._selectedColor;
},get_enabled:function(){
return this._enabled;
},set_enabled:function(_3a){
this._enabled=_3a;
},_initializeEventHandlers:function(){
this._initializePalleteEventHandlers();
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);
}
},_initializePalleteEventHandlers:function(){
if(this._paletteWrapperElement){
$addHandlers(this._paletteWrapperElement,{"mouseover":this._onBoxMouseOver,"mouseup":this._onBoxClick,"selectstart":this._onSelectStart},this);
}
if(this._emptyColorElement&&this._showEmptyColor){
$addHandlers(this._emptyColorElement,{"click":this._onEmptyColorClick},this);
}
},_disposeHandlers:function(){
if(this._paletteWrapperElement){
$clearHandlers(this._paletteWrapperElement);
}
if(this._emptyColorElement&&this._showEmptyColor){
$clearHandlers(this._emptyColorElement);
}
if(this._showIcon){
$clearHandlers(this._iconWrapperElement);
$removeHandler(document,"mouseup",this._mouseUpHandler);
}
this._mouseUpHandler=null;
},_raiseColorChangedServerEvent:function(){
setTimeout(Function.createDelegate(this,function(){
__doPostBack(this._uniqueID);
}),0);
},_onMouseUp:function(){
this.hidePalette();
},_onBoxMouseOver:function(evt){
var _3c=this._getColorBoxElement(evt.target);
if(_3c==null){
return;
}
var _3d=this._getElementColor(_3c);
if(_3d!=this._lastPreviewColor){
var _3e=new Telerik.Web.UI.ColorPickerColorSelectingEventArgs(_3d);
this.raiseEvent("colorSelecting",_3e);
}
this._previewCurrentColor(_3d,_3c.title);
},_onEmptyColorClick:function(evt){
this.set_selectedColor(null);
if(this._showIcon){
this.hidePalette();
}
},_onIconMouseDown:function(evt){
evt.preventDefault();
evt.stopPropagation();
},_onIconMouseUp:function(evt){
this._createPalette();
if(this._paletteDisplayed){
this.hidePalette();
}else{
this.showPalette();
}
evt.preventDefault();
evt.stopPropagation();
},_getElementColor:function(_42){
if(_42==this._emptyColorElement){
return null;
}
return _42.firstChild.innerHTML;
},_setIconColor:function(_43){
if(_43==null){
_43="#FFFFFF";
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}","blank");
}else{
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}",_43);
}
this._iconElement.style.backgroundColor=_43;
},_onSelectStart:function(evt){
evt.stopPropagation();
evt.preventDefault();
},_onBoxClick:function(evt){
if(evt.button!=0){
return;
}
evt.stopPropagation();
var _46=this._getColorBoxElement(evt.target);
if(_46==null){
return;
}
this.set_selectedColor(this._getElementColor(_46));
if(this._showIcon){
this.hidePalette();
}
},_getMarkedElement:function(){
if(this._markedElement){
return this._markedElement;
}
if(!this._paletteWrapperElement){
return null;
}
var _47=this._paletteWrapperElement.getElementsByTagName("A");
for(var i=0;i<_47.length;i++){
if(_47[i].className=="selectedcolor"){
return _47[i];
}
}
return null;
},_setMarkedElement:function(_49){
this._markedElement=_49;
},_getColorBoxElement:function(_4a){
var _4b=3;
var i=0;
while(i<_4b){
if(_4a.className=="colorbox"||_4a.className=="selectedcolor"||_4a.className.indexOf("emptycolor")>-1){
return _4a;
}
i++;
_4a=_4a.parentNode;
}
return null;
},_getBoxElementByColor:function(_4d){
if(!_4d){
return this._emptyColorElement;
}
_4d=_4d.toUpperCase();
return this._elementsByColor[_4d];
},_previewCurrentColor:function(_4e,_4f){
if(!this.get_isInitialized()){
return;
}
this._lastPreviewColor=_4e;
if(!this._previewColor){
return;
}
if(_4e==null){
_4e="#FFFFFF";
_4f=this._noColorText;
}
_4e=_4e.toUpperCase();
if(!_4f){
_4f=_4e;
}
if(this._previewElement){
this._previewElement.style.backgroundColor=_4e;
this._previewElement.getElementsByTagName("span")[0].innerHTML=_4f;
this._previewElement.getElementsByTagName("span")[1].innerHTML=_4f;
}
}};
Telerik.Web.UI.RadColorPicker.registerClass("Telerik.Web.UI.RadColorPicker",Telerik.Web.UI.RadWebControl);

