Type.registerNamespace("Telerik.Web.UI.Editor.DialogControls");
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog=function(_1){
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog.initializeBase(this,[_1]);
this._clientParameters=null;
this._imageCaller=null;
};
var CIRCLESHAPE_BCKG_COLOR_NOT_SELECTED="#33CCFF";
var CIRCLESHAPE_BCKG_COLOR_SELECTED="#33FFFF";
var AREA_SHAPE_CONSTANTS={DEFAULT_SHAPE_TYPE:"RECT",RECTANGLE_TYPE:"RECT",CIRCLE_TYPE:"CIRCLE",POLYGON_TYPE:"POLY"};
var IMAGE_MAP_DIALOG_CONTROL=null;
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog.prototype={clientInit:function(_2){
this._clientParameters=_2;
var _3=this._getChildElement("ImageMap_ImageMapFrame");
this._window=_3.contentWindow;
this._document=_3.contentWindow.document;
IMAGE_MAP_DIALOG_CONTROL=this;
var _4=this._getChildElement("ImageMap_ImageMapHtml");
this._document.open();
this._document.write("<html><head></head><body style = \"margin:0px 0px 0px 0px;font:11px Arial; color:red;background-color:white;\" oncontextmenu=\"return false\" unselectable=\"on\">"+_4.value+"</body></html>");
this._document.close();
this.initializeImageMap(_2,this);
},initializeImageMap:function(_5){
this.initializeImageDialogCaller(_5);
if(_5.ImageSrc){
var _6=this.insertImageForMap();
_6.src=_5.ImageSrc;
if(_5.ImageWidth){
_6.style.width=_5.ImageWidth;
}
if(_5.ImageHeight){
_6.style.height=_5.ImageHeight;
}
this._imageCaller.set_value(_5.ImageSrc);
this.setDummyLayerOverImage(_6);
imageMap=new ImageMap(_6);
if(_5.ImageMapHTML){
imageMap.Initialize(_5.ImageMapHTML);
}
this.showAreaControls();
}else{
var _7=this._document.createElement("CENTER");
_7.id="mappedImageText";
_7.innerHTML=this.get_string("SelectImage");
this._document.body.appendChild(_7);
}
RectangleShape.prototype.ContainerTitle=this.get_string("ShapeAlt");
CircleShape.prototype.ContainerTitle=this.get_string("ShapeAlt");
if(imageMap&&imageMap.GetAreasNumber()>0){
this.ShowMapProps();
}
},CloseAreaPropsDlg:function(){
this._removeAreaButton.disabled=true;
this._removeAllAreasButton.disabled=true;
this._updateAreaButton.disabled=true;
this.Area_Fields.area_link.disabled=true;
this.Area_Fields.area_link.value="";
this.Area_Fields.area_target.disabled=true;
this.Area_Fields.area_target.value="";
this.Area_Fields.area_comment.disabled=true;
this.Area_Fields.area_comment.value="";
this.Rect_Fields.rect_x.disabled=true;
this.Rect_Fields.rect_x.value="";
this.Rect_Fields.rect_y.disabled=true;
this.Rect_Fields.rect_y.value="";
this.Rect_Fields.rect_width.disabled=true;
this.Rect_Fields.rect_width.value="";
this.Rect_Fields.rect_height.disabled=true;
this.Rect_Fields.rect_height.value="";
if(CurrentArea){
CurrentArea.DeSelect();
}
},ShowRectPropsDlg:function(_8){
this.Rect_Fields.rect_x.disabled=false;
this.Rect_Fields.rect_x.value=_8.x;
this.Rect_Fields.rect_y.disabled=false;
this.Rect_Fields.rect_y.value=_8.y;
this.Rect_Fields.rect_width.disabled=false;
this.Rect_Fields.rect_width.value=_8.width;
if(CurrentArea.Shape.Type==AREA_SHAPE_CONSTANTS.RECTANGLE_TYPE){
this.Rect_Fields.rect_height.disabled=false;
this.Rect_Fields.rect_height.value=_8.height;
}else{
if(CurrentArea.Shape.Type==AREA_SHAPE_CONSTANTS.CIRCLE_TYPE){
this.Rect_Fields.rect_height.disabled=true;
this.Rect_Fields.rect_height.value=_8.width;
}
}
},ShowAreaPropsDlg:function(_9){
this._removeAreaButton.disabled=false;
this._removeAllAreasButton.disabled=false;
this._updateAreaButton.disabled=false;
this.Area_Fields.area_link.disabled=false;
this.Area_Fields.area_link.value=_9.Link?_9.Link:"http://";
this.Area_Fields.area_target.disabled=false;
this.Area_Fields.area_target.value=_9.Target;
this.Area_Fields.area_comment.disabled=false;
this.Area_Fields.area_comment.value=_9.Comment;
this.ShowMapProps();
},getSelectedShapeType:function(){
for(var i=0;i<this._shapeTypeRadioButtons.length;i++){
if(this._shapeTypeRadioButtons[i].checked){
return this._shapeTypeRadioButtons[i].value;
}
}
return AREA_SHAPE_CONSTANTS.DEFAULT_SHAPE_TYPE;
},insertNewMapArea:function(x,y,_d,_e){
var _f=this.getSelectedShapeType();
if(_f!=AREA_SHAPE_CONSTANTS.CIRCLE_TYPE&&_f!=AREA_SHAPE_CONSTANTS.RECTANGLE_TYPE){
_f=AREA_SHAPE_CONSTANTS.DEFAULT_TYPE;
}
if(typeof (x)==="undefined"){
var _10=this._document.getElementById("mappedImage");
if(_10.offsetWidth<40||_10.offsetHeight<40){
x=0;
y=0;
_d=1;
_e=1;
}else{
x=10;
y=10;
_d=20;
_e=20;
}
}
this._document.body.scrollLeft=0;
this._document.body.scrollTop=0;
this.focusImageMap();
var _11=imageMap.AddNewArea(_f,x,y,_d,_e);
if(_11!=null){
_11.Shape.OnSelect();
}
return _11;
},focusImageMap:function(){
try{
this._document.body.focus();
}
catch(e){
}
},_addAreaButtonClickHandler:function(){
this.insertNewMapArea();
},_removeAreaButtonClickHandler:function(){
if(!window.confirm(this.get_string("AlertDeleteArea"))){
return;
}
RemoveArea();
},_removeAllAreasButtonClickHandler:function(){
if(!window.confirm(this.get_string("AlertDeleteAllAreas"))){
return;
}
RemoveAllAreas();
},_updateAreaButtonClickHandler:function(){
if(this._updateAreaButton.disabled){
return true;
}
if(!this.UpdateRectPropsDlg()){
return;
}
var _12={Link:this.Area_Fields.area_link.value,Comment:this.Area_Fields.area_comment.value,Target:this.Area_Fields.area_target.value};
UpdateAreaProps(_12);
},_okButtonClickHandler:function(){
this.returnNewImageMap();
},_cancelButtonClickHandler:function(){
this.closeDialog();
},initializeChildElements:function(){
this._addAreaButton=this._getChildElement("ImageMap_NewArea");
$addHandlers(this._addAreaButton,{"click":this._addAreaButtonClickHandler},this);
this._removeAreaButton=this._getChildElement("ImageMap_RemoveArea");
$addHandlers(this._removeAreaButton,{"click":this._removeAreaButtonClickHandler},this);
this._removeAllAreasButton=this._getChildElement("ImageMap_RemoveAllAreas");
$addHandlers(this._removeAllAreasButton,{"click":this._removeAllAreasButtonClickHandler},this);
this._updateAreaButton=this._getChildElement("ImageMap_UpdateArea");
$addHandlers(this._updateAreaButton,{"click":this._updateAreaButtonClickHandler},this);
this._okButton=this._getChildElement("ImageMap_OK");
$addHandlers(this._okButton,{"click":this._okButtonClickHandler},this);
this._cancelButton=this._getChildElement("ImageMap_Cancel");
$addHandlers(this._cancelButton,{"click":this._cancelButtonClickHandler},this);
this.Area_Fields={};
this.Area_Fields.area_link=this._getChildElement("ImageMap_AreaURL");
this.Area_Fields.area_target=this._getChildElement("ImageMap_AreaTarget");
this.Area_Fields.area_comment=this._getChildElement("ImageMap_AreaComment");
this.Rect_Fields={};
this.Rect_Fields.rect_x=this._getChildElement("ImageMap_AreaLeft");
this.Rect_Fields.rect_y=this._getChildElement("ImageMap_AreaTop");
this.Rect_Fields.rect_width=this._getChildElement("ImageMap_AreaWidth");
this.Rect_Fields.rect_height=this._getChildElement("ImageMap_AreaHeight");
this._shapeTypeRadioButtons=[];
this._shapeTypeRadioButtons[0]=this._getChildElement("ImageMap_Rect");
this._shapeTypeRadioButtons[0].value=AREA_SHAPE_CONSTANTS.RECTANGLE_TYPE;
this._shapeTypeRadioButtons[1]=this._getChildElement("ImageMap_Circle");
this._shapeTypeRadioButtons[1].value=AREA_SHAPE_CONSTANTS.CIRCLE_TYPE;
this._shapeTypeRadioButtons[1].disabled=!this.circleShapeSupported();
this._shapeTypeRadioButtons[2]=this._getChildElement("ImageMap_Polygon");
this._shapeTypeRadioButtons[2].value=AREA_SHAPE_CONSTANTS.POLYGON_TYPE;
this._shapeTypeRadioButtons[2].disabled=true;
},initialize:function(){
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog.callBaseMethod(this,"initialize");
this.initializeChildElements();
},dispose:function(){
this._imageCaller=null;
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog.callBaseMethod(this,"dispose");
$clearHandlers(this._addAreaButton);
$clearHandlers(this._removeAreaButton);
$clearHandlers(this._removeAllAreasButton);
$clearHandlers(this._updateAreaButton);
},get_string:function(key){
return key;
},initializeImageDialogCaller:function(_14){
var _15=function(_16){
var src=_16.get_value();
if(src){
var _18=IMAGE_MAP_DIALOG_CONTROL._document.getElementById("mappedImageText");
if(_18!=null){
_18.parentNode.removeChild(_18);
}
var _19=IMAGE_MAP_DIALOG_CONTROL._document.getElementById("mappedImage");
if(_19==null){
_19=IMAGE_MAP_DIALOG_CONTROL.insertImageForMap();
imageMap=new ImageMap(_19);
}
_19.src=src;
IMAGE_MAP_DIALOG_CONTROL.setDummyLayerOverImage(_19);
IMAGE_MAP_DIALOG_CONTROL.showAreaControls();
}
};
this._imageCaller=this._findChildControl("ImageCaller");
this._imageCaller.set_editor(_14._editor);
this._imageCaller.add_valueSelected(_15);
},showAreaControls:function(){
this._getChildElement("ImageMap_area_controls").style.display="block";
},insertImageForMap:function(){
var _1a=this._document.createElement("IMG");
_1a.id="mappedImage";
_1a.setAttribute("unselectable","on");
this._document.body.appendChild(_1a);
return _1a;
},setDummyLayerOverImage:function(_1b){
var _1c=RadEditorNamespace.Utils.GetRect(_1b);
var _1d=this._document.getElementById("dummy");
_1d.style.left=_1c.left;
_1d.style.top=_1c.top;
_1d.style.width=_1c.width;
_1d.style.height=_1c.height;
RadEditorNamespace.Utils.AttachEventEx(this._document,"keydown",CheckKeyDown);
RadEditorNamespace.Utils.AttachEventEx(_1d,"mousedown",ImageMapper_OnMouseDown);
},HideMapProps:function(){
this._getChildElement("ImageMap_map_props").style.display="none";
},ShowMapProps:function(){
this._getChildElement("ImageMap_map_props").style.display="";
},createAreaShapeByType:function(_1e){
var _1f={};
_1f[AREA_SHAPE_CONSTANTS.RECTANGLE_TYPE]=RectangleShape;
_1f[AREA_SHAPE_CONSTANTS.POLYGON_TYPE]=PolygonShape;
_1f[AREA_SHAPE_CONSTANTS.CIRCLE_TYPE]=CircleShape;
if(!_1f[_1e]){
_1e=AREA_SHAPE_CONSTANTS.DEFAULT_SHAPE_TYPE;
}
if(_1e==AREA_SHAPE_CONSTANTS.CIRCLE_TYPE&&!this.circleShapeSupported()){
return null;
}
return new _1f[_1e]();
},circleShapeSupported:function(){
if(!document.all){
var _20=document.createElement("canvas");
if(!_20.getContext){
return false;
}
}
return true;
},UpdateRectPropsDlg:function(){
var _21={x:this.Rect_Fields.rect_x.value,y:this.Rect_Fields.rect_y.value,width:this.Rect_Fields.rect_width.value,height:this.Rect_Fields.rect_height.value};
var _22=!UpdateRectProps(_21);
if(_22){
alert(this.get_string("AlertInvalidProperties"));
ShowRectProps();
return false;
}
return true;
},UpdateAreaPropsDlg:function(){
if(this._updateAreaButton.getAttribute("disabled",2)){
return true;
}
if(!this.UpdateRectPropsDlg()){
return false;
}
var _23={Link:this.Area_Fields.area_link.value,Comment:this.Area_Fields.area_comment.value,Target:this.Area_Fields.area_target.value};
UpdateAreaProps(_23);
return true;
},returnNewImageMap:function(){
var _24=this.getMapImageSrc();
if(_24){
if(this.UpdateAreaPropsDlg()){
var _25={"MapHtml":imageMap.GetHTML(),"ImageSrc":_24};
this.closeDialog(_25);
}
}else{
this.closeDialog();
}
},closeDialog:function(_26){
Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(_26);
},getMapImageSrc:function(){
var _27=this._document.getElementById("mappedImage");
if(_27!=null){
return _27.getAttribute("src",2);
}
return null;
}};
Telerik.Web.UI.Editor.DialogControls.ImageMapDialog.registerClass("Telerik.Web.UI.Editor.DialogControls.ImageMapDialog",Telerik.Web.UI.RadWebControl,Telerik.Web.IParameterConsumer);;;function ImageMap(_1){
this.AreaCollection=[];
this.AreaIDCnt=0;
this.Name="ImageMap1";
this.Image=_1;
}
ImageMap.prototype.Initialize=function(_2){
if(_2){
if(!this._InitFromHTMLString(_2)){
return false;
}
}
return true;
};
ImageMap.prototype._InitFromHTMLString=function(_3){
var _4=IMAGE_MAP_DIALOG_CONTROL._document.createElement("SPAN");
_4.innerHTML=_3;
var _5=_4.getElementsByTagName("MAP");
if(_5.length!=1){
return false;
}
var _6=_5[0];
this.Name=_6.getAttribute("name");
var _7=_6.getElementsByTagName("area");
for(var i=0;i<_7.length;i++){
var _9=new MapArea(this.Image);
_9.ID=this.AreaIDCnt;
if(!_9.Initialize(_7[i])){
continue;
}
if(this.AddArea(_9)){
_9.Draw();
}
}
_4=null;
return true;
};
ImageMap.prototype.AddArea=function(_a){
if(!this.IsAreaValid(_a)){
return false;
}
this.AreaCollection.push(_a);
this.AreaIDCnt++;
return true;
};
ImageMap.prototype.AddNewArea=function(_b,x,y,_e,_f){
var _10=new MapArea(this.Image);
_10.ID=this.AreaIDCnt;
if(!_10.CreateDefaultShape(_b,x,y,_e,_f)){
return null;
}
this.AddArea(_10);
_10.Draw();
return _10;
};
ImageMap.prototype.GetAreaById=function(_11){
return this.AreaCollection[_11];
};
ImageMap.prototype.RemoveArea=function(_12){
var _13=this.GetAreaById(_12);
if(_13!=null){
_13.Dispose();
}
this.AreaCollection[_12]=null;
};
ImageMap.prototype.IsAreaOverlaps=function(_14){
return false;
};
ImageMap.prototype.IsAreaValid=function(_15){
return !this.IsAreaOverlaps(_15);
};
ImageMap.prototype.GetHTML=function(){
var _16="";
_16+="<map";
_16+=" name=\"#"+this.Name.replace("\"","&#34;")+"\"";
_16+=">";
for(var i=0;i<this.AreaCollection.length;i++){
if(this.AreaCollection[i]!=null){
_16+=this.AreaCollection[i].GetHTML();
}
}
_16+="</map>";
return _16;
};
ImageMap.prototype.GetAreasNumber=function(){
var nr=0;
for(var i=0;i<this.AreaCollection.length;i++){
if(this.AreaCollection[i]!=null){
nr++;
}
}
return nr;
};
function MapArea(_1a){
this.Comment="";
this.Link="";
this.Target="";
this.Image=_1a;
}
MapArea.prototype.GetHTML=function(){
var _1b="";
_1b+="<area";
_1b+=" shape=\""+this.Shape.Type+"\"";
_1b+=" coords=\""+this.Shape.GetCoords()+"\"";
if(this.Link){
if(this.Link.indexOf("about:blank")==0){
this.Link=this.Link.substr("about:blank".length);
}else{
if(this.Link.indexOf("about:")==0){
this.Link=this.Link.substr("about:".length);
}
}
_1b+=" href=\""+this.Link.replace("\"","&#34;")+"\"";
}
if(this.Target){
_1b+=" target=\""+this.Target.replace("\"","&#34;")+"\"";
}
if(this.Comment){
_1b+=" alt=\""+this.Comment.replace("\"","&#34;")+"\"";
}
_1b+="/>";
return _1b;
};
MapArea.prototype.Initialize=function(_1c){
var _1d=_1c.getAttribute("shape");
if(!_1d){
_1d=AREA_SHAPE_CONSTANTS.DEFAULT_SHAPE_TYPE;
}
this.Shape=IMAGE_MAP_DIALOG_CONTROL.createAreaShapeByType(_1d);
this.Shape.SetImage(this.Image);
this.Shape.SetAreaId(this.ID);
var _1e=_1c.getAttribute("coords");
if(!this.Shape.AreCoordsValid(_1e)){
return false;
}
this.Shape.SetCoords(_1e);
this.Comment=_1c.getAttribute("alt");
this.Link=_1c.getAttribute("href");
if(this.Link){
if(this.Link.indexOf("about:blank")==0){
this.Link=this.Link.substr("about:blank".length);
}else{
if(this.Link.indexOf("about:")==0){
this.Link=this.Link.substr("about:".length);
}
}
}
this.Target=_1c.getAttribute("target");
return true;
};
MapArea.prototype.Draw=function(){
this.Shape.Draw();
};
MapArea.prototype.Move=function(_1f){
var _20=this.Shape.GetShapeProperties();
if(_1f.x){
_20.x+=_1f.x;
}
if(_1f.y){
_20.y+=_1f.y;
}
var _21=this.Shape.ShapePropsToCoords(_20);
if(!this.Shape.AreCoordsValid(_21)){
return false;
}
this.Shape.SetCoords(_21);
this.Shape.Draw();
return true;
};
MapArea.prototype.SetSize=function(_22){
var _23=this.Shape.GetShapeProperties();
if(_22.width){
_23.width=_22.width;
}
if(_22.height){
_23.height=_22.height;
}
var _24=this.Shape.ShapePropsToCoords(_23);
if(!this.Shape.AreCoordsValid(_24)){
return false;
}
this.Shape.SetCoords(_24);
this.Shape.Resize(_22);
return true;
};
MapArea.prototype.CreateDefaultShape=function(_25,x,y,_28,_29){
this.Shape=IMAGE_MAP_DIALOG_CONTROL.createAreaShapeByType(_25);
this.Shape.SetImage(this.Image);
this.Shape.SetAreaId(this.ID);
var _2a=this.Shape.ShapePropsToCoords({x:x,y:y,width:_28,height:_29});
if(!this.Shape.AreCoordsValid(_2a)){
return null;
}
return this.Shape.SetCoords(_2a);
};
MapArea.prototype.GetProperties=function(){
return {Comment:this.Comment,Link:this.Link,Target:this.Target};
};
MapArea.prototype.SetProperties=function(_2b){
this.Comment=_2b.Comment;
this.Link=_2b.Link;
this.Target=_2b.Target;
};
MapArea.prototype.SetSelected=function(){
this.Shape.SetSelected();
};
MapArea.prototype.DeSelect=function(){
this.Shape.DeSelect();
};
MapArea.prototype.Dispose=function(){
this.Shape.Dispose();
this.Image=null;
};
function AreaShape(){
this.Coords="";
this.Type="";
this.ResizeElementClassName="circ_shape_resizer";
}
AreaShape.prototype.GetType=function(){
return this.Type;
};
AreaShape.prototype.GetCoords=function(){
return this.Coords;
};
AreaShape.prototype.AreCoordsValid=function(_2c){
return false;
};
AreaShape.prototype.SetCoords=function(_2d){
if(!this.AreCoordsValid(_2d)){
return false;
}
this.Coords=_2d;
return true;
};
AreaShape.prototype.SetImage=function(_2e){
this.Image=_2e;
};
AreaShape.prototype.Resize=function(_2f){
};
AreaShape.prototype.SetAreaId=function(_30){
this.AreaID=_30;
};
AreaShape.prototype.CreateResizerElement=function(){
var _31=IMAGE_MAP_DIALOG_CONTROL._document.createElement("DIV");
_31.id="res_"+this.AreaID;
_31.className=this.ResizeElementClassName;
_31.style.width=5;
_31.style.height=5;
_31.style.position="absolute";
_31.style.display="none";
return IMAGE_MAP_DIALOG_CONTROL._document.body.appendChild(_31);
};
AreaShape.prototype.GetShapeProperties=function(){
return this.ShapeCoordsToProps(this.Coords);
};
AreaShape.prototype.SetSelected=function(){
};
AreaShape.prototype.DeSelect=function(){
};
AreaShape.prototype.Draw=function(){
};
AreaShape.prototype.OnSelect=function(){
};
AreaShape.prototype.Dispose=function(){
};
function RectangleShape(){
this.Type=AREA_SHAPE_CONSTANTS.RECTANGLE_TYPE;
this.VisualFillElement=null;
this.VisualBorderElement=null;
this.ResizeElement=null;
this.ResizeElementClassName="rect_shape_resizer";
this.SelectedClassName="rect_shape_selected";
this.NotSelectedClassName="rect_shape_not_selected";
this.BorderElementClass="rect_shape_border";
}
RectangleShape.prototype=new AreaShape();
RectangleShape.prototype.ContainerTitle="";
RectangleShape.prototype.Resize=function(_32){
if(_32.width){
var _33=Math.abs(_32.width);
this.VisualFillElement.style.width=_33-1;
this.VisualBorderElement.style.width=_33;
}
if(_32.height){
var _34=Math.abs(_32.height);
this.VisualFillElement.style.height=_34-1;
this.VisualBorderElement.style.height=_34;
}
this.SetResizeElementPosition();
};
RectangleShape.prototype.Draw=function(){
var _35=RadEditorNamespace.Utils.GetRect(this.Image);
if(this.VisualBorderElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.VisualBorderElement);
}
if(this.ResizeElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.ResizeElement);
}
var _36=IMAGE_MAP_DIALOG_CONTROL._document.createElement("DIV");
var _37=IMAGE_MAP_DIALOG_CONTROL._document.createElement("DIV");
_36.style.position="absolute";
_36.className=this.BorderElementClass;
_36.title=this.ContainerTitle;
var _38=this.GetShapeProperties();
_36.style.top=_35.top+_38.y;
_36.style.left=_35.left+_38.x;
_36.style.width=_38.width;
_36.style.height=_38.height;
_37.className=this.NotSelectedClassName;
_37.style.width=_38.width-1;
_37.style.height=_38.height-1;
_36.id="rect_"+this.AreaID;
_36.ShapeObj=this;
_36.onclick=this.HandleClick;
_36.appendChild(_37);
IMAGE_MAP_DIALOG_CONTROL._document.body.appendChild(_36);
var _39=this.CreateResizerElement();
this.VisualFillElement=_37;
this.VisualBorderElement=_36;
this.ResizeElement=_39;
this.SetResizeElementPosition();
var _3a=this;
var _3b=function(){
var _3c=RadEditorNamespace.Utils.GetRect(_3a.VisualBorderElement);
var _3d=RadEditorNamespace.Utils.GetRect(_3a.Image);
_3a.SetResizeElementPosition();
var _3e=_3a.ShapePropsToCoords({x:_3c.left-_3d.left,y:_3c.top-_3d.top,width:_3c.width,height:_3c.height});
if(_3a.AreCoordsValid(_3e)){
_3a.SetCoords(_3e);
}else{
_3a.Draw();
}
_3a.OnSelect();
};
var _3f=function(){
_3a.SetResizeElementPosition();
};
var _40=function(fff,x,y){
_36.style.cursor="SE-resize";
var _44=RadEditorNamespace.Utils.GetRect(_36);
var _45=_44.left+_44.width+parseInt(_3a.ResizeElement.style.width);
var _46=_44.top+_44.height+parseInt(_3a.ResizeElement.style.height);
var _47=(_44.height+y-_46);
var _48=(_44.width+x-_45);
var _49={width:_48,height:_47};
_3a.Resize(_49);
};
var _4a=function(){
_36.style.cursor="move";
_3b();
};
var _t=new Draggable(_36,_36,null,_3f,_3b);
var _t2=new Draggable(_39,_39,null,_40,_4a);
};
RectangleShape.prototype.SetResizeElementPosition=function(){
var _4d=this.VisualBorderElement.style;
this.ResizeElement.style.top=parseInt(_4d.top)+parseInt(_4d.height);
this.ResizeElement.style.left=parseInt(_4d.left)+parseInt(_4d.width);
this.ResizeElement.style.display="block";
};
RectangleShape.prototype.HandleClick=function(){
this.ShapeObj.OnSelect();
};
RectangleShape.prototype.SetSelected=function(){
this.VisualFillElement.className=this.SelectedClassName;
this.ResizeElement.style.display="block";
this.VisualBorderElement.style.zIndex=2;
this.ResizeElement.style.zIndex=2;
};
RectangleShape.prototype.DeSelect=function(){
this.VisualFillElement.className=this.NotSelectedClassName;
this.ResizeElement.style.display="none";
this.VisualBorderElement.style.zIndex=1;
this.ResizeElement.style.zIndex=1;
};
RectangleShape.prototype.ShapePropsToCoords=function(_4e){
return _4e.x+","+_4e.y+","+(parseInt(_4e.x)+parseInt(_4e.width))+","+(parseInt(_4e.y)+parseInt(_4e.height));
};
RectangleShape.prototype.ShapeCoordsToProps=function(_4f){
var _50=_4f.split(",");
var _51=_50[0];
var _52=_50[1];
var _53=_50[2];
var _54=_50[3];
return {x:parseInt(_51),y:parseInt(_52),width:parseInt((_53-_51)),height:parseInt((_54-_52))};
};
RectangleShape.prototype.AreCoordsValid=function(_55){
var _56=_55.split(",");
if(_56.length!=4){
return false;
}
for(var i=0;i<_56.length;i++){
if(_56[i]<0){
return false;
}
}
var _58=this.ShapeCoordsToProps(_55);
if(_58.width<=0){
return false;
}
if(_58.height<=0){
return false;
}
if((_58.x+_58.width)>this.Image.offsetWidth){
return false;
}
if((_58.y+_58.height)>this.Image.offsetHeight){
return false;
}
return true;
};
RectangleShape.prototype.Dispose=function(){
this.VisualFillElement=null;
if(this.VisualBorderElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.VisualBorderElement);
this.VisualBorderElement=null;
}
if(this.ResizeElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.ResizeElement);
this.ResizeElement=null;
}
};
function CircleShape(){
this.Type=AREA_SHAPE_CONSTANTS.CIRCLE_TYPE;
this.VisualElement=null;
this.ResizeElement=null;
this.SelectedClassName="circ_shape_selected";
this.NotSelectedClassName="circ_shape_not_selected";
}
CircleShape.prototype=new AreaShape();
CircleShape.prototype.ContainerTitle="";
CircleShape.prototype.Resize=function(_59){
if(document.all){
if(_59.width){
this.VisualElement.style.width=Math.abs(_59.width);
this.VisualElement.style.height=Math.abs(_59.width);
}
this.SetResizeElementPosition();
}else{
this.Draw();
}
};
CircleShape.prototype.Draw=function(_5a){
if(this.VisualElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.VisualElement);
}
if(this.ResizeElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.ResizeElement);
}
var _5b=RadEditorNamespace.Utils.GetRect(this.Image);
var _5c=this.GetShapeProperties();
var _5d=IMAGE_MAP_DIALOG_CONTROL._document.createElement("DIV");
if(document.all){
_5d.innerHTML="<"+"v:oval fillcolor=\""+CIRCLESHAPE_BCKG_COLOR_NOT_SELECTED+"\" style=\"position:absolute;\" ></v:oval>";
}else{
_5d.innerHTML="<canvas width=\""+_5c.width+"\" height=\""+_5c.width+"\"></canvas>";
}
_5d=_5d.childNodes[0];
_5d.style.position="absolute";
_5d.title=this.ContainerTitle;
_5d.style.top=_5b.top+_5c.y;
_5d.style.left=_5b.left+_5c.x;
if(!document.all){
var ctx=_5d.getContext("2d");
ctx.beginPath();
var _5f=parseInt(_5c.width/2);
var x=_5f;
var y=_5f;
var _62=0;
var _63=360;
ctx.arc(x,y,_5f,_62,_63,false);
if(!_5a){
_5a=CIRCLESHAPE_BCKG_COLOR_NOT_SELECTED;
}
ctx.fillStyle=_5a;
ctx.fill();
ctx.stroke();
}else{
}
_5d.style.width=_5c.width;
_5d.style.height=_5c.width;
_5d.className=this.NotSelectedClassName;
_5d.id="circ_"+this.AreaID;
_5d.ShapeObj=this;
_5d.onclick=this.HandleClick;
IMAGE_MAP_DIALOG_CONTROL._document.body.appendChild(_5d);
var _64=this.CreateResizerElement();
this.VisualElement=_5d;
this.ResizeElement=_64;
this.SetResizeElementPosition();
var _65=this;
var _66=function(){
var _67=RadEditorNamespace.Utils.GetRect(_65.VisualElement);
var _68=RadEditorNamespace.Utils.GetRect(_65.Image);
_65.SetResizeElementPosition();
var _69=_65.ShapePropsToCoords({x:_67.left-_68.left,y:_67.top-_68.top,width:_67.width});
if(_65.AreCoordsValid(_69)){
_65.SetCoords(_69);
}else{
_65.Draw();
}
_65.OnSelect();
};
var _6a=function(){
_65.SetResizeElementPosition();
};
var _6b=function(fff,x,y){
_5d.style.cursor="W-resize";
var _6f=RadEditorNamespace.Utils.GetRect(_5d);
var _70=_6f.left+_6f.width+parseInt(_65.ResizeElement.style.width);
var _71=(_6f.width+(x-_70));
_5d.style.width=(_71>0?_71:0)+"px";
_5d.style.height=_5d.style.width;
_65.SetResizeElementPosition();
};
var _72=function(){
_5d.style.cursor="move";
_66();
};
var _t=new Draggable(_5d,_5d,null,_6a,_66);
var _t2=new Draggable(_64,_64,null,_6b,_72);
};
CircleShape.prototype.SetResizeElementPosition=function(){
var _75=this.VisualElement.style;
var _76=parseInt(_75.width)/2;
var _77=parseInt(_75.width);
var _78=parseInt(_75.top)+_76;
var _79=parseInt(_75.left)+_77;
this.ResizeElement.style.top=_78;
this.ResizeElement.style.left=_79;
this.ResizeElement.style.display="block";
};
CircleShape.prototype.HandleClick=function(){
this.ShapeObj.OnSelect();
};
CircleShape.prototype.SetSelected=function(){
if(document.all){
this.VisualElement.fillColor=CIRCLESHAPE_BCKG_COLOR_SELECTED;
}else{
this.Draw(CIRCLESHAPE_BCKG_COLOR_SELECTED);
}
this.VisualElement.className=this.SelectedClassName;
this.ResizeElement.style.display="block";
this.VisualElement.style.zIndex=2;
this.ResizeElement.style.zIndex=2;
};
CircleShape.prototype.DeSelect=function(){
if(document.all){
this.VisualElement.fillColor=CIRCLESHAPE_BCKG_COLOR_NOT_SELECTED;
}else{
this.Draw(CIRCLESHAPE_BCKG_COLOR_NOT_SELECTED);
}
this.VisualElement.className=this.NotSelectedClassName;
this.ResizeElement.style.display="none";
this.VisualElement.style.zIndex=1;
this.ResizeElement.style.zIndex=1;
};
CircleShape.prototype.ShapePropsToCoords=function(_7a){
var _7b=parseInt(_7a.width)/2;
return (parseInt(_7a.x)+_7b)+","+(parseInt(_7a.y)+_7b)+","+_7b;
};
CircleShape.prototype.ShapeCoordsToProps=function(_7c){
var _7d=_7c.split(",");
var _7e=parseInt(_7d[0]);
var _7f=parseInt(_7d[1]);
var _80=parseInt(_7d[2]);
return {x:_7e-_80,y:_7f-_80,width:(_80*2)};
};
CircleShape.prototype.AreCoordsValid=function(_81){
var _82=_81.split(",");
if(_82.length!=3){
return false;
}
for(var i=0;i<_82.length;i++){
if(_82[i]<0){
return false;
}
}
var _84=this.ShapeCoordsToProps(_81);
if(_84.x<0){
return false;
}
if(_84.y<0){
return false;
}
if(_84.width<=0){
return false;
}
if((_84.x+_84.width)>this.Image.offsetWidth){
return false;
}
if((_84.y+_84.width)>this.Image.offsetHeight){
return false;
}
return true;
};
CircleShape.prototype.Dispose=function(){
if(this.VisualElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.VisualElement);
this.VisualElement=null;
}
if(this.ResizeElement){
IMAGE_MAP_DIALOG_CONTROL._document.body.removeChild(this.ResizeElement);
this.ResizeElement=null;
}
};
function PolygonShape(){
this.Type=AREA_SHAPE_CONSTANTS.POLYGON_TYPE;
}
PolygonShape.prototype=new AreaShape();
PolygonShape.prototype.Draw=function(){
alert("draw polygon");
};
if(typeof (RadEditorNamespace)=="undefined"){
RadEditorNamespace={};
}
RadEditorNamespace.Utils={GetRect:function(_85){
if(!_85){
_85=this;
}
var _86=0;
var top=0;
var _88=_85.offsetWidth;
var _89=_85.offsetHeight;
while(_85.offsetParent){
_86+=_85.offsetLeft;
top+=_85.offsetTop;
_85=_85.offsetParent;
}
if(_85.x){
_86=_85.x;
}
if(_85.y){
top=_85.y;
}
_86=RadEditorNamespace.Utils.GetIntValue(_86,0);
top=RadEditorNamespace.Utils.GetIntValue(top,0);
_88=RadEditorNamespace.Utils.GetIntValue(_88,0);
_89=RadEditorNamespace.Utils.GetIntValue(_89,0);
return new RadEditorNamespace.Utils.Rectangle(_86,top,_88,_89);
},Rectangle:function(_8a,top,_8c,_8d){
this.left=(null!=_8a?_8a:0);
this.top=(null!=top?top:0);
this.width=(null!=_8c?_8c:0);
this.height=(null!=_8d?_8d:0);
this.right=_8a+_8c;
this.bottom=top+_8d;
},AttachEventEx:function(_8e,_8f,_90){
_8f=RadEditorNamespace.Utils.FixEventName(_8f);
if(_8e.attachEvent){
_8e.attachEvent(_8f,_90);
}else{
if(_8e.addEventListener){
_8e.addEventListener(_8f,_90,true);
}
}
},DetachEventEx:function(_91,_92,_93){
_92=RadEditorNamespace.Utils.FixEventName(_92);
if(_91.detachEvent){
_91.detachEvent(_92,_93);
}else{
if(_91.addEventListener){
_91.removeEventListener(_92,_93,true);
}
}
},FixEventName:function(_94){
_94=_94.toLowerCase();
if(document.addEventListener&&RadEditorNamespace.Utils.StartsWith(_94,"on")){
return _94.substr(2);
}else{
if(document.attachEvent&&!RadEditorNamespace.Utils.StartsWith(_94,"on")){
return "on"+_94;
}else{
return _94;
}
}
},CancelEvent:function(_95){
if(!_95){
_95=IMAGE_MAP_DIALOG_CONTROL._window.event;
}
if(!_95){
return false;
}
_95.returnValue=false;
_95.cancelBubble=true;
if(_95.stopPropagation){
_95.stopPropagation();
}
return false;
},GetIntValue:function(_96,_97){
if(!_97){
_97=0;
}
var _98=parseInt(_96);
return (isNaN(_98)?_97:_98);
},StartsWith:function(_99,_9a){
if(typeof (_9a)!="string"){
return false;
}
return (0==_99.indexOf(_9a));
},GetEventSource:function(e){
if(null==e){
return null;
}
if(e.srcElement){
return e.srcElement;
}else{
if(e.target){
return e.target;
}else{
return null;
}
}
}};
function Draggable(obj,_9d,_9e,_9f,_a0){
var _9d=_9d!=null?_9d:obj;
this.obj=obj;
this.objToMove=_9d;
this.onDragStart=_9e;
this.onDrag=_9f;
this.onDragEnd=_a0;
this.zIndex=0;
var _a1=this;
obj.onmousedown=function(e){
if(_a1.onDragStart){
_a1.onDragStart(_9d);
}
_a1.elNode=_9d;
var _a3=GetCursorPos(e);
x=_a3[0];
y=_a3[1];
_a1.cursorStartX=x;
_a1.cursorStartY=y;
var _a4=RadEditorNamespace.Utils.GetRect(_9d);
_a1.elStartLeft=_a4.left;
_a1.elStartTop=_a4.top;
if(isNaN(_a1.elStartLeft)){
_a1.elStartLeft=0;
}
if(isNaN(_a1.elStartTop)){
_a1.elStartTop=0;
}
_9d.style.position="absolute";
_a1.elNode.style.zIndex=++_a1.zIndex;
RadEditorNamespace.Utils.AttachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"onmousemove",_a1.DragGo);
RadEditorNamespace.Utils.AttachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"onmouseup",_a1.DragStop);
RadEditorNamespace.Utils.CancelEvent(e?e:IMAGE_MAP_DIALOG_CONTROL._window.event);
};
this.DragGo=function(e){
var _a6=GetCursorPos(e);
x=_a6[0];
y=_a6[1];
var _a7=(_a1.elStartLeft+x-_a1.cursorStartX);
var _a8=(_a1.elStartTop+y-_a1.cursorStartY);
_a1.elNode.style.left=_a7+"px";
_a1.elNode.style.top=_a8+"px";
RadEditorNamespace.Utils.CancelEvent(e?e:IMAGE_MAP_DIALOG_CONTROL._window.event);
if(_a1.onDrag){
_a1.onDrag(_9d,x,y);
}
};
this.DragStop=function(_a9){
RadEditorNamespace.Utils.DetachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"onmousemove",_a1.DragGo);
RadEditorNamespace.Utils.DetachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"onmouseup",_a1.DragStop);
if(_a1.onDragEnd){
_a1.onDragEnd(_9d);
}
};
function GetCursorPos(e){
if(document.all){
x=IMAGE_MAP_DIALOG_CONTROL._window.event.clientX+IMAGE_MAP_DIALOG_CONTROL._document.documentElement.scrollLeft+IMAGE_MAP_DIALOG_CONTROL._document.body.scrollLeft;
y=IMAGE_MAP_DIALOG_CONTROL._window.event.clientY+IMAGE_MAP_DIALOG_CONTROL._document.documentElement.scrollTop+IMAGE_MAP_DIALOG_CONTROL._document.body.scrollTop;
}else{
x=e.clientX+IMAGE_MAP_DIALOG_CONTROL._window.scrollX;
y=e.clientY+IMAGE_MAP_DIALOG_CONTROL._window.scrollY;
}
return [x,y];
}
}
function ShowRectProps(){
var _ab=CurrentArea.Shape.GetShapeProperties();
IMAGE_MAP_DIALOG_CONTROL.ShowRectPropsDlg(_ab);
}
var CurrentArea=null;
RectangleShape.prototype.OnSelect=function(){
if(CurrentArea){
CurrentArea.DeSelect();
}
CurrentArea=imageMap.GetAreaById(this.AreaID);
var _ac=CurrentArea.GetProperties();
IMAGE_MAP_DIALOG_CONTROL.ShowAreaPropsDlg(_ac);
ShowRectProps();
CurrentArea.SetSelected();
};
CircleShape.prototype.OnSelect=function(){
if(CurrentArea){
CurrentArea.DeSelect();
}
CurrentArea=imageMap.GetAreaById(this.AreaID);
var _ad=CurrentArea.GetProperties();
IMAGE_MAP_DIALOG_CONTROL.ShowAreaPropsDlg(_ad);
ShowRectProps();
CurrentArea.SetSelected();
};
function UpdateAreaProps(_ae){
CurrentArea.SetProperties(_ae);
CurrentArea.Shape.OnSelect();
}
function RemoveArea(){
if(!imageMap||!CurrentArea){
return;
}
imageMap.RemoveArea(CurrentArea.ID);
CurrentArea=null;
IMAGE_MAP_DIALOG_CONTROL.CloseAreaPropsDlg();
if(imageMap.GetAreasNumber()==0){
IMAGE_MAP_DIALOG_CONTROL.HideMapProps();
}
}
function RemoveAllAreas(){
for(var i=0;i<imageMap.AreaCollection.length;i++){
if(imageMap.AreaCollection[i]!=null){
imageMap.RemoveArea(imageMap.AreaCollection[i].ID);
}
}
CurrentArea=null;
IMAGE_MAP_DIALOG_CONTROL.CloseAreaPropsDlg();
IMAGE_MAP_DIALOG_CONTROL.HideMapProps();
}
function CheckKeyDown(e){
if(!CurrentArea){
return;
}
if(e.keyCode==46){
RemoveArea();
}else{
if(e.keyCode==37){
CurrentArea.Move({x:-1,y:0});
CurrentArea.Shape.OnSelect();
}else{
if(e.keyCode==40){
CurrentArea.Move({x:0,y:1});
CurrentArea.Shape.OnSelect();
}else{
if(e.keyCode==38){
CurrentArea.Move({x:0,y:-1});
CurrentArea.Shape.OnSelect();
}else{
if(e.keyCode==39){
CurrentArea.Move({x:1,y:0});
CurrentArea.Shape.OnSelect();
}
}
}
}
}
}
var imageMap;
var InitialOffsetX=0;
var InitialOffsetY=0;
function ImageMapper_OnMouseDown(e){
var _b2=(document.all)?IMAGE_MAP_DIALOG_CONTROL._window.event:e;
var _b3=RadEditorNamespace.Utils.GetRect(IMAGE_MAP_DIALOG_CONTROL._document.getElementById("mappedImage"));
var _b4=_b3.left;
var _b5=_b3.top;
InitialOffsetX=_b2.clientX-_b4;
InitialOffsetY=_b2.clientY-_b5;
IsMouseMoved=false;
if(CurrentArea){
IMAGE_MAP_DIALOG_CONTROL.CloseAreaPropsDlg();
CurrentArea=null;
}
RadEditorNamespace.Utils.AttachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"mousemove",ImageMapper_OnMouseMove);
RadEditorNamespace.Utils.AttachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"mouseup",ImageMapper_OnMouseUp);
RadEditorNamespace.Utils.CancelEvent(_b2);
}
function ImageMapper_OnMouseMove(e){
var _b7=(document.all)?IMAGE_MAP_DIALOG_CONTROL._window.event:e;
if(!CurrentArea){
var _b8=2;
var _b9=2;
CurrentArea=IMAGE_MAP_DIALOG_CONTROL.insertNewMapArea(InitialOffsetX,InitialOffsetY,_b8,_b9);
if(!CurrentArea){
return;
}
}
IsMouseMoved=true;
var _ba=RadEditorNamespace.Utils.GetRect(IMAGE_MAP_DIALOG_CONTROL._document.getElementById("mappedImage"));
var _bb=_ba.left;
var _bc=_ba.top;
var _bd=_b7.clientX-_bb;
var _be=_b7.clientY-_bc;
var _bf={width:Math.abs(_bd-InitialOffsetX),height:Math.abs(_be-InitialOffsetY)};
CurrentArea.SetSize(_bf);
RadEditorNamespace.Utils.CancelEvent(_b7);
}
function ImageMapper_OnMouseUp(){
if(IsMouseMoved){
if(CurrentArea){
CurrentArea.Shape.OnSelect();
}
}
RadEditorNamespace.Utils.DetachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"mousemove",ImageMapper_OnMouseMove);
RadEditorNamespace.Utils.DetachEventEx(IMAGE_MAP_DIALOG_CONTROL._document,"mouseup",ImageMapper_OnMouseUp);
IsMouseMoved=false;
}
function UpdateRectProps(_c0){
if(!CurrentArea){
return;
}
var _c1=CurrentArea.Shape.ShapePropsToCoords(_c0);
if(!CurrentArea.Shape.AreCoordsValid(_c1)){
return false;
}
CurrentArea.Shape.SetCoords(_c1);
CurrentArea.Shape.Draw();
return true;
};