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=0,_26=_23.length;i<_26;i++){
if(_22==this._columns){
_22=0;
var _27=document.createElement("li");
_27.className="breakline";
ul.appendChild(_27);
}
_22++;
var _28=this._createColorElement(_23[i],_24);
ul.appendChild(_28);
}
_1f.appendChild(ul);
if(this._previewColor){
var _29=this._createPreviewColor();
_1f.appendChild(_29);
}
var _2a=this.get_element();
_2a.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 _2b=$telerik.getBounds(this._iconWrapperElement);
this._popupBehavior.set_x(0);
this._popupBehavior.set_y(_2b.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 _2c=["selectedColor"];
var _2d={};
for(var i=0;i<_2c.length;i++){
_2d[_2c[i]]=this["get_"+_2c[i]]();
}
return Sys.Serialization.JavaScriptSerializer.serialize(_2d);
},add_loaded:function(_2f){
this.get_events().addHandler("loaded",_2f);
},remove_loaded:function(_30){
this.get_events().removeHandler("loaded",_30);
},add_colorSelecting:function(_31){
this.get_events().addHandler("colorSelecting",_31);
},remove_colorSelecting:function(_32){
this.get_events().removeHandler("colorSelecting",_32);
},add_colorChange:function(_33){
this.get_events().addHandler("colorChange",_33);
},remove_colorChange:function(_34){
this.get_events().removeHandler("colorChange",_34);
},get_selectedColor:function(){
return this._selectedColor;
},set_selectedColor:function(_35){
if(!_35){
_35=null;
}
var _36=this._selectedColor;
if(!_36){
_36=null;
}
if(_35!=null){
_35=_35.toUpperCase();
}
this._selectedColor=_35;
var _37=this._getMarkedElement();
if(_37!=null){
if(_37==this._emptyColorElement){
_37.className="emptycolor";
}else{
_37.className="colorbox";
}
}
var _38=this._getBoxElementByColor(_35);
if(_38!=null){
this._setMarkedElement(_38);
if(_38==this._emptyColorElement){
_38.className="emptycolor selectedcolor";
}else{
_38.className="selectedcolor";
}
}
this._previewCurrentColor(_35);
if(this._showIcon){
this._setIconColor(_35);
}
this.updateClientState();
if(this._selectedColor!=_36){
var _39=new Telerik.Web.UI.ColorPickerColorChangeEventArgs(_36);
this.raiseEvent("colorChange",_39);
if(this._autoPostBack){
this._raiseColorChangedServerEvent();
}
}
},get_selectedColorTitle:function(){
var _3a=this._getBoxElementByColor(this._selectedColor);
if(_3a!=null){
return _3a.getAttribute("title");
}
return this._selectedColor;
},get_enabled:function(){
return this._enabled;
},set_enabled:function(_3b){
if(this._enabled==_3b){
return;
}
if(_3b){
this._initializeEventHandlers();
Sys.UI.DomElement.removeCssClass(this.get_element(),"cpDisabled");
}else{
this._disposeHandlers();
Sys.UI.DomElement.addCssClass(this.get_element(),"cpDisabled");
}
this._enabled=_3b;
},_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 _3d=this._getColorBoxElement(evt.target);
if(_3d==null){
return;
}
var _3e=this._getElementColor(_3d);
if(_3e!=this._lastPreviewColor){
var _3f=new Telerik.Web.UI.ColorPickerColorSelectingEventArgs(_3e);
this.raiseEvent("colorSelecting",_3f);
}
this._previewCurrentColor(_3e,_3d.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(_43){
if(_43==this._emptyColorElement){
return null;
}
return _43.firstChild.innerHTML;
},_setIconColor:function(_44){
if(_44==null){
_44="#FFFFFF";
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}","blank");
}else{
this._iconWrapperElement.title=this._pickColorText+" "+this._currentColorText.toString().replace("{0}",_44);
}
this._iconElement.style.backgroundColor=_44;
},_onSelectStart:function(evt){
evt.stopPropagation();
evt.preventDefault();
},_onBoxClick:function(evt){
if(evt.button!=0){
return;
}
evt.stopPropagation();
var _47=this._getColorBoxElement(evt.target);
if(_47==null){
return;
}
this.set_selectedColor(this._getElementColor(_47));
if(this._showIcon){
this.hidePalette();
}
},_getMarkedElement:function(){
if(this._markedElement){
return this._markedElement;
}
if(!this._paletteWrapperElement){
return null;
}
var _48=this._paletteWrapperElement.getElementsByTagName("A");
for(var i=0;i<_48.length;i++){
if(_48[i].className=="selectedcolor"){
return _48[i];
}
}
return null;
},_setMarkedElement:function(_4a){
this._markedElement=_4a;
},_getColorBoxElement:function(_4b){
var _4c=3;
var i=0;
while(i<_4c){
if(_4b.className=="colorbox"||_4b.className=="selectedcolor"||_4b.className.indexOf("emptycolor")>-1){
return _4b;
}
i++;
_4b=_4b.parentNode;
}
return null;
},_getBoxElementByColor:function(_4e){
if(!_4e){
return this._emptyColorElement;
}
_4e=_4e.toUpperCase();
return this._elementsByColor[_4e];
},_previewCurrentColor:function(_4f,_50){
if(!this.get_isInitialized()){
return;
}
this._lastPreviewColor=_4f;
if(!this._previewColor){
return;
}
if(_4f==null){
_4f="#FFFFFF";
_50=this._noColorText;
}
_4f=_4f.toUpperCase();
if(!_50){
_50=_4f;
}
if(this._previewElement){
this._previewElement.style.backgroundColor=_4f;
this._previewElement.getElementsByTagName("span")[0].innerHTML=_50;
this._previewElement.getElementsByTagName("span")[1].innerHTML=_50;
}
}};
Telerik.Web.UI.RadColorPicker.registerClass("Telerik.Web.UI.RadColorPicker",Telerik.Web.UI.RadWebControl);

