﻿//----------------------------------------------------------
// Copyright (C) ESRI. All rights reserved.
//----------------------------------------------------------
Type.registerNamespace('ESRI.ADF.UI');ESRI.ADF.UI.MapCopyrightText = function(element) { 
ESRI.ADF.UI.MapCopyrightText.initializeBase(this, [element]);this._copyrightText = null;this._calloutWindowTitleText = '';this._calloutReference = null;var isRTL = (document.dir === 'rtl')
this._calloutTemplate = '<div style="width:300px;background-color:#fff;border: solid 1px #ddd;padding: 0px; margin:0;" ><div style="background:#eee; margin:0; height: 22px;"><span style="float: '+(isRTL?'right':'left')+';"><b>{@title}</b></span><span style="float: '+(isRTL?'left':'right')+'; cursor: pointer;" onclick="ESRI.ADF.UI.MapCopyrightText.closeClick(\''+this.get_id()+'\');">X</span></div><div style="padding:0;">{@content}</div></div>';};ESRI.ADF.UI.MapCopyrightText.prototype = {
initialize : function() {
ESRI.ADF.UI.MapCopyrightText.callBaseMethod(this, 'initialize');this._createCallout();$addHandler(this.get_element(), 'click', Function.createDelegate(this, this._doMouseClick));},
dispose : function() {
if(this._calloutReference !== null) {
this._calloutReference.dispose();}
$clearHandlers(this.get_element());ESRI.ADF.UI.MapCopyrightText.callBaseMethod(this, 'dispose');},
_createCallout : function() {
if(this._calloutReference === null) {
this._calloutReference = $create(ESRI.ADF.UI.Callout, { "parent":document.body,"animate":true, "template":this._calloutTemplate, "autoHide":false }, null);this._calloutReference.setContent({"content":this._copyrightText,"title":this._calloutWindowTitleText});}
},
get_map : function () {
return this._map;},
set_map : function(value) {
if (this._map != value) {
this._map = value;this.raisePropertyChanged('map');}
},
get_copyrightText : function () {
return this._copyrightText;},
set_copyrightText : function (value) {
if (this._copyrightText !== value) {
this._copyrightText = value;if(!value) {
this.get_element().style.display = 'none';}
else {
this.get_element().style.display = '';}
this.raisePropertyChanged('copyrightText');}
}, 
get_calloutWindowTitleText : function() {
return this._calloutWindowTitleText;},
set_calloutWindowTitleText : function(value) {
this._calloutWindowTitleText = value;},
get_callout : function() {
if(this._calloutReference===null) {
this._createCallout();}
return this._calloutReference;},
_doMouseClick : function (e) {
var alignment = this._getAlignmentToMap();var xy = this._computeXYAndAnchorForCallout(alignment);this._calloutReference.setPosition(xy.xCoOrd,xy.yCoOrd);this._calloutReference.set_anchorPoint(xy.aPoint);if(this._calloutReference.get_isOpen()) {
this._calloutReference.hide();}
else {
this._calloutReference.show();}
}, 
_getAlignmentToMap : function() {
var list = this.get_element()._behaviors;for(var j=0;list && j < list.length;j++) {
var behav = this.get_element()._behaviors[j];if(ESRI.ADF.Extenders.Dock.isInstanceOfType(behav)) {
return behav.get_alignment();}
}
var ctlBounds = Sys.UI.DomElement.getBounds(this.get_element());if(ctlBounds.x+ctlBounds.width/2>parseInt(document.body.offsetWidth,10)/2)
return ESRI.ADF.System.ContentAlignment.BottomRight;else
return ESRI.ADF.System.ContentAlignment.BottomLeft;},
_computeXYAndAnchorForCallout : function(alignment) {
var ctlBounds = Sys.UI.DomElement.getBounds(this.get_element());var x = ctlBounds.x;var y = ctlBounds.y;var width = ctlBounds.width;var height = ctlBounds.height;var spacing = 3;switch (alignment) {
case ESRI.ADF.System.ContentAlignment.TopCenter:
case ESRI.ADF.System.ContentAlignment.TopRight:
case ESRI.ADF.System.ContentAlignment.TopLeft:
y += (height + spacing);break;case ESRI.ADF.System.ContentAlignment.BottomLeft:
case ESRI.ADF.System.ContentAlignment.BottomCenter:
case ESRI.ADF.System.ContentAlignment.BottomRight:
y -= (spacing);break;}
x += spacing + width/2;var anchorPoint = ESRI.ADF.UI.AnchorPoint.BottomLeft;switch(alignment) {
case ESRI.ADF.System.ContentAlignment.TopLeft:
case ESRI.ADF.System.ContentAlignment.TopCenter:
case ESRI.ADF.System.ContentAlignment.MiddleCenter:
anchorPoint = ESRI.ADF.UI.AnchorPoint.TopLeft;break;case ESRI.ADF.System.ContentAlignment.MiddleLeft:
case ESRI.ADF.System.ContentAlignment.BottomCenter:
case ESRI.ADF.System.ContentAlignment.BottomLeft:
anchorPoint = ESRI.ADF.UI.AnchorPoint.BottomLeft;break;case ESRI.ADF.System.ContentAlignment.TopRight:
case ESRI.ADF.System.ContentAlignment.MiddleRight:
anchorPoint = ESRI.ADF.UI.AnchorPoint.TopRight;break;case ESRI.ADF.System.ContentAlignment.BottomRight:
anchorPoint = ESRI.ADF.UI.AnchorPoint.BottomRight;break;}
return {"xCoOrd":x,"yCoOrd":y,"aPoint":anchorPoint};}
};ESRI.ADF.UI.MapCopyrightText.closeClick = function(id) {
var component = $find(id);if(component) { component._doMouseClick();}
};ESRI.ADF.UI.MapCopyrightText.registerClass('ESRI.ADF.UI.MapCopyrightText', Sys.UI.Control);if (typeof(Sys) !== 'undefined') { Sys.Application.notifyScriptLoaded();}

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();