git-svn-id: http://svn.openlayers.org/trunk/openlayers@236 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
179 lines
4.2 KiB
JavaScript
179 lines
4.2 KiB
JavaScript
/**
|
|
* @class
|
|
*/
|
|
OpenLayers.Popup = Class.create();
|
|
|
|
OpenLayers.Popup.count = 0;
|
|
OpenLayers.Popup.PX = new OpenLayers.Pixel(0, 0);
|
|
OpenLayers.Popup.SIZE = new OpenLayers.Size(200, 200);
|
|
OpenLayers.Popup.COLOR = "white";
|
|
OpenLayers.Popup.OPACITY = 1;
|
|
OpenLayers.Popup.BORDER = "0px";
|
|
|
|
OpenLayers.Popup.prototype = {
|
|
|
|
/** @type String */
|
|
id: "",
|
|
|
|
/** reference to the parent DIV to which this popup is @type DOMElement */
|
|
parent: null,
|
|
|
|
/** @type DOMElement */
|
|
div: null,
|
|
|
|
/** @type OpenLayers.Pixel */
|
|
px: null,
|
|
|
|
/** @type OpenLayers.Size*/
|
|
size: null,
|
|
|
|
/** @type String */
|
|
contentHTML: "",
|
|
|
|
/** @type String */
|
|
backgroundColor: "",
|
|
|
|
/** @type float */
|
|
opacity: "",
|
|
|
|
/** @type String */
|
|
border: "",
|
|
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @param {String} id
|
|
* @param {OpenLayers.Pixel} px
|
|
* @param {OpenLayers.Size} size
|
|
* @param {String} contentHTML
|
|
*/
|
|
initialize:function(id, px, size, contentHTML) {
|
|
OpenLayers.Popup.count += 1;
|
|
|
|
this.id = (id != null) ? id : "Popup" + OpenLayers.Popup.count;
|
|
this.px = (px != null) ? px : OpenLayers.Popup.PX;
|
|
this.size = (size != null) ? size : OpenLayers.Popup.SIZE;
|
|
if (contentHTML != null) {
|
|
this.contentHTML = contentHTML;
|
|
}
|
|
this.backgroundColor = OpenLayers.Popup.COLOR;
|
|
this.opacity = OpenLayers.Popup.OPACITY;
|
|
this.border = OpenLayers.Popup.BORDER;
|
|
},
|
|
|
|
/**
|
|
*/
|
|
destroy: function() {
|
|
if ((this.div) && (this.div.parentNode)) {
|
|
this.div.parentNode.removeChild(this.div);
|
|
}
|
|
this.div = null;
|
|
},
|
|
|
|
/**
|
|
*/
|
|
draw: function() {
|
|
if (this.div == null) {
|
|
this.div = OpenLayers.Util.createDiv(this.id + "_div",
|
|
null,
|
|
null,
|
|
"hidden");
|
|
}
|
|
this.setPx();
|
|
this.setSize();
|
|
this.setBackgroundColor();
|
|
this.setOpacity();
|
|
this.setBorder();
|
|
this.setContentHTML();
|
|
|
|
return this.div;
|
|
},
|
|
|
|
/**
|
|
* @param {OpenLayers.Size} size
|
|
*/
|
|
setSize:function(size) {
|
|
if (size != undefined) {
|
|
this.size = size;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
this.div.style.width = this.size.w;
|
|
this.div.style.height = this.size.h;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {OpenLayers.Pixel} px
|
|
*/
|
|
setPx:function(px) {
|
|
if (px != undefined) {
|
|
this.px = px;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
this.div.style.left = this.px.x;
|
|
this.div.style.top = this.px.y;
|
|
}
|
|
},
|
|
|
|
|
|
/**
|
|
* @param {String} color
|
|
*/
|
|
setBackgroundColor:function(color) {
|
|
if (color != undefined) {
|
|
this.backgroundColor = color;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
this.div.style.backgroundColor = this.backgroundColor;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {float} opacity
|
|
*/
|
|
setOpacity:function(opacity) {
|
|
if (opacity != undefined) {
|
|
this.opacity = opacity;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
// for Mozilla and Safari
|
|
this.div.style.opacity = this.opacity;
|
|
|
|
// for IE
|
|
this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')';
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {int} border
|
|
*/
|
|
setBorder:function(border) {
|
|
if (border != undefined) {
|
|
this.border = border;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
this.div.style.border = this.border;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* @param {String} contentHTML
|
|
*/
|
|
setContentHTML:function(contentHTML) {
|
|
if (contentHTML != null) {
|
|
this.contentHTML = contentHTML;
|
|
}
|
|
|
|
if (this.div != null) {
|
|
this.div.innerHTML = this.contentHTML;
|
|
}
|
|
},
|
|
|
|
CLASS_NAME: "OpenLayers.Popup"
|
|
}; |