+++ /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. */
-// @require: OpenLayers/Popup/Anchored.js\r
-\r
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup.AnchoredBubble = Class.create();\r
-\r
-//Border space for the rico corners\r
-OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;\r
-\r
-OpenLayers.Popup.AnchoredBubble.prototype =\r
- Object.extend( new OpenLayers.Popup.Anchored(), {\r
-\r
- /** @type DOMElement */\r
- contentDiv:null,\r
-\r
- \r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- * @param {Object} anchor Object which must expose a \r
- * - 'size' (OpenLayers.Size) and \r
- * - 'offset' (OpenLayers.Pixel) \r
- * (this is generally an OpenLayers.Icon)\r
- */\r
- initialize:function(id, lonlat, size, contentHTML, anchor) {\r
- OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);\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
- \r
- OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);\r
-\r
- // make the content Div\r
- var contentSize = this.size.copyOf();\r
- contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);\r
-\r
- var id = this.div.id + "-contentDiv";\r
- this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, \r
- null, "relative", null,\r
- "hidden");\r
- this.div.appendChild(this.contentDiv);\r
- this.setContentHTML();\r
- \r
- this.setRicoCorners(true);\r
- \r
- //set the popup color and opacity \r
- this.setBackgroundColor(); \r
- this.setOpacity();\r
-\r
- return this.div;\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);\r
- \r
- if (this.contentDiv != null) {\r
-\r
- var contentSize = this.size.copyOf();\r
- contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);\r
- \r
- this.contentDiv.style.height = contentSize.h + "px";\r
- \r
- //size has changed - must redo corners \r
- this.setRicoCorners(false);\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
- if (this.contentDiv != null) {\r
- this.div.style.background = "transparent";\r
- Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);\r
- }\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
- if (this.contentDiv != null) {\r
- Rico.Corner.changeOpacity(this.contentDiv, this.opacity);\r
- }\r
- }\r
- }, \r
- \r
- /** Bubble Popups can not have a border\r
- * \r
- * @param {int} border\r
- */\r
- setBorder:function(border) { \r
- this.border = 0;\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.contentDiv != null) {\r
- this.contentDiv.innerHTML = this.contentHTML;\r
- } \r
- },\r
- \r
- /** \r
- * @private\r
- * \r
- * @param {Boolean} firstTime Is this the first time the corners are being\r
- * rounded?\r
- * \r
- * update the rico corners according to the popup's\r
- * current relative postion \r
- */\r
- setRicoCorners:function(firstTime) {\r
- \r
- var corners = this.getCornersToRound(this.relativePosition);\r
- var options = {corners: corners,\r
- color: this.backgroundColor,\r
- bgColor: "transparent",\r
- blend: false};\r
-\r
- if (firstTime) {\r
- Rico.Corner.round(this.div, options);\r
- } else {\r
- Rico.Corner.reRound(this.contentDiv, options);\r
- //set the popup color and opacity\r
- this.setBackgroundColor(); \r
- this.setOpacity();\r
- }\r
- },\r
-\r
- /** \r
- * @private\r
- * \r
- * @returns The proper corners string ("tr tl bl br") for rico\r
- * to round\r
- * @type String\r
- */\r
- getCornersToRound:function() {\r
-\r
- var corners = ['tl', 'tr', 'bl', 'br'];\r
-\r
- //we want to round all the corners _except_ the opposite one. \r
- var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);\r
- corners.remove(corner);\r
-\r
- return corners.join(" ");\r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup.AnchoredBubble"\r
-});\r