+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup = Class.create();\r
-\r
-OpenLayers.Popup.count = 0;\r
-OpenLayers.Popup.WIDTH = 200;\r
-OpenLayers.Popup.HEIGHT = 200;\r
-OpenLayers.Popup.COLOR = "white";\r
-OpenLayers.Popup.OPACITY = 1;\r
-OpenLayers.Popup.BORDER = "0px";\r
-\r
-OpenLayers.Popup.prototype = {\r
-\r
- /** @type OpenLayers.Events*/\r
- events: null,\r
- \r
- /** @type String */\r
- id: "",\r
-\r
- /** @type OpenLayers.LonLat */\r
- lonlat: null,\r
-\r
- /** @type DOMElement */\r
- div: null,\r
-\r
- /** @type OpenLayers.Size*/\r
- size: null, \r
-\r
- /** @type String */\r
- contentHTML: "",\r
- \r
- /** @type String */\r
- backgroundColor: "",\r
- \r
- /** @type float */\r
- opacity: "",\r
-\r
- /** @type String */\r
- border: "",\r
-\r
- /** this gets set in Map.js when the popup is added to the map\r
- * @type OpenLayers.Map */\r
- map: null,\r
-\r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- */\r
- initialize:function(id, lonlat, size, contentHTML) {\r
- OpenLayers.Popup.count += 1;\r
- this.id = (id != null) ? id : "Popup" + OpenLayers.Popup.count;\r
- this.lonlat = lonlat;\r
- this.size = (size != null) ? size \r
- : new OpenLayers.Size(\r
- OpenLayers.Popup.WIDTH,\r
- OpenLayers.Popup.HEIGHT);\r
- if (contentHTML != null) { \r
- this.contentHTML = contentHTML;\r
- }\r
- this.backgroundColor = OpenLayers.Popup.COLOR;\r
- this.opacity = OpenLayers.Popup.OPACITY;\r
- this.border = OpenLayers.Popup.BORDER;\r
-\r
- this.div = OpenLayers.Util.createDiv(this.id + "_div", null, null, \r
- null, null, null, "hidden");\r
-\r
- this.events = new OpenLayers.Events(this, this.div, null);\r
- },\r
-\r
- /** \r
- */\r
- destroy: function() {\r
- if (this.map != null) {\r
- this.map.removePopup(this);\r
- }\r
- this.div = null;\r
- this.map = null;\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns Reference to a div that contains the drawn popup\r
- * @type DOMElement\r
- */\r
- draw: function(px) {\r
- if (px == null) {\r
- if ((this.lonlat != null) && (this.map != null)) {\r
- px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- }\r
- }\r
- \r
- this.setSize();\r
- this.setBackgroundColor();\r
- this.setOpacity();\r
- this.setBorder();\r
- this.setContentHTML();\r
- this.moveTo(px);\r
-\r
- return this.div;\r
- },\r
-\r
- /** \r
- * if the popup has a lonlat and its map members set, \r
- * then have it move itself to its proper position\r
- */\r
- updatePosition: function() {\r
- if ((this.lonlat) && (this.map)) {\r
- var px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- this.moveTo(px); \r
- }\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Pixel} px\r
- */\r
- moveTo: function(px) {\r
- if ((px != null) && (this.div != null)) {\r
- this.div.style.left = px.x + "px";\r
- this.div.style.top = px.y + "px";\r
- }\r
- },\r
-\r
- /**\r
- * @returns Boolean indicating whether or not the popup is visible\r
- * @type Boolean\r
- */\r
- visible: function() {\r
- return Element.visible(this.div);\r
- },\r
-\r
- /**\r
- * \r
- */\r
- toggle: function() {\r
- Element.toggle(this.div);\r
- },\r
-\r
- /**\r
- *\r
- */\r
- show: function() {\r
- Element.show(this.div);\r
- },\r
-\r
- /**\r
- *\r
- */\r
- hide: function() {\r
- Element.hide(this.div);\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- if (size != undefined) {\r
- this.size = size; \r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.width = this.size.w;\r
- this.div.style.height = this.size.h;\r
- }\r
- }, \r
-\r
- /**\r
- * @param {String} color\r
- */\r
- setBackgroundColor:function(color) { \r
- if (color != undefined) {\r
- this.backgroundColor = color; \r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.backgroundColor = this.backgroundColor;\r
- }\r
- }, \r
- \r
- /**\r
- * @param {float} opacity\r
- */\r
- setOpacity:function(opacity) { \r
- if (opacity != undefined) {\r
- this.opacity = opacity; \r
- }\r
- \r
- if (this.div != null) {\r
- // for Mozilla and Safari\r
- this.div.style.opacity = this.opacity;\r
-\r
- // for IE\r
- this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')';\r
- }\r
- }, \r
- \r
- /**\r
- * @param {int} border\r
- */\r
- setBorder:function(border) { \r
- if (border != undefined) {\r
- this.border = border;\r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.border = this.border;\r
- }\r
- }, \r
- \r
- /**\r
- * @param {String} contentHTML\r
- */\r
- setContentHTML:function(contentHTML) {\r
- if (contentHTML != null) {\r
- this.contentHTML = contentHTML;\r
- }\r
- \r
- if (this.div != null) {\r
- this.div.innerHTML = this.contentHTML;\r
- } \r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup"\r
-};\r