1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
7 * @requires OpenLayers/Popup/Anchored.js
11 * Class: OpenLayers.Popup.AnchoredBubble
14 * - <OpenLayers.Popup.Anchored>
16 OpenLayers.Popup.AnchoredBubble =
17 OpenLayers.Class(OpenLayers.Popup.Anchored, {
21 * {Boolean} Has the popup been rounded yet?
26 * Constructor: OpenLayers.Popup.AnchoredBubble
30 * lonlat - {<OpenLayers.LonLat>}
31 * contentSize - {<OpenLayers.Size>}
32 * contentHTML - {String}
33 * anchor - {Object} Object to which we'll anchor the popup. Must expose
34 * a 'size' (<OpenLayers.Size>) and 'offset' (<OpenLayers.Pixel>)
35 * (Note that this is generally an <OpenLayers.Icon>).
36 * closeBox - {Boolean}
37 * closeBoxCallback - {Function} Function to be called on closeBox click.
39 initialize:function(id, lonlat, contentSize, contentHTML, anchor, closeBox,
42 this.padding = new OpenLayers.Bounds(
43 0, OpenLayers.Popup.AnchoredBubble.CORNER_SIZE,
44 0, OpenLayers.Popup.AnchoredBubble.CORNER_SIZE
46 OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
53 * px - {<OpenLayers.Pixel>}
56 * {DOMElement} Reference to a div that contains the drawn popup.
60 OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);
62 this.setContentHTML();
64 //set the popup color and opacity
65 this.setBackgroundColor();
72 * Method: updateRelativePosition
73 * The popup has been moved to a new relative location, in which case
74 * we will want to re-do the rico corners.
76 updateRelativePosition: function() {
77 this.setRicoCorners();
84 * contentSize - {<OpenLayers.Size>} the new size for the popup's
85 * contents div (in pixels).
87 setSize:function(contentSize) {
88 OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);
90 this.setRicoCorners();
94 * APIMethod: setBackgroundColor
99 setBackgroundColor:function(color) {
100 if (color != undefined) {
101 this.backgroundColor = color;
104 if (this.div != null) {
105 if (this.contentDiv != null) {
106 this.div.style.background = "transparent";
107 OpenLayers.Rico.Corner.changeColor(this.groupDiv,
108 this.backgroundColor);
114 * APIMethod: setOpacity
119 setOpacity:function(opacity) {
120 OpenLayers.Popup.Anchored.prototype.setOpacity.call(this, opacity);
122 if (this.div != null) {
123 if (this.groupDiv != null) {
124 OpenLayers.Rico.Corner.changeOpacity(this.groupDiv,
132 * Always sets border to 0. Bubble Popups can not have a border.
137 setBorder:function(border) {
142 * Method: setRicoCorners
143 * Update RICO corners according to the popup's current relative postion.
145 setRicoCorners:function() {
147 var corners = this.getCornersToRound(this.relativePosition);
148 var options = {corners: corners,
149 color: this.backgroundColor,
150 bgColor: "transparent",
154 OpenLayers.Rico.Corner.round(this.div, options);
157 OpenLayers.Rico.Corner.reRound(this.groupDiv, options);
158 //set the popup color and opacity
159 this.setBackgroundColor();
165 * Method: getCornersToRound
168 * {String} The proper corners string ("tr tl bl br") for rico to round.
170 getCornersToRound:function() {
172 var corners = ['tl', 'tr', 'bl', 'br'];
174 //we want to round all the corners _except_ the opposite one.
175 var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);
176 OpenLayers.Util.removeItem(corners, corner);
178 return corners.join(" ");
181 CLASS_NAME: "OpenLayers.Popup.AnchoredBubble"
185 * Constant: CORNER_SIZE
186 * {Integer} 5. Border space for the RICO corners.
188 OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;