diff --git a/art/measuring-stick-off.svg b/art/measuring-stick-off.svg index 7d1a630776e..2e47a2fbc5b 100644 --- a/art/measuring-stick-off.svg +++ b/art/measuring-stick-off.svg @@ -1,36 +1,36 @@ - - - - - - - - - - - - -]> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + diff --git a/art/measuring-stick-on.svg b/art/measuring-stick-on.svg index 75f037e45a0..ca0c18c7519 100644 --- a/art/measuring-stick-on.svg +++ b/art/measuring-stick-on.svg @@ -1,36 +1,36 @@ - - - - - - - - - - - - -]> - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + diff --git a/art/panning-hand-off.svg b/art/panning-hand-off.svg index 6ec048dd56f..bf2e40b1028 100644 --- a/art/panning-hand-off.svg +++ b/art/panning-hand-off.svg @@ -1,44 +1,44 @@ - - - - - - - - - - - - -]> - - - - - - - - - - - - - - - + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + diff --git a/art/panning-hand-on.svg b/art/panning-hand-on.svg index 279c9b609c8..139ce972183 100644 --- a/art/panning-hand-on.svg +++ b/art/panning-hand-on.svg @@ -1,44 +1,44 @@ - - - - - - - - - - - - -]> - - - - - - - - - - - - - - - + + + + + + + + + + + + +]> + + + + + + + + + + + + + + + diff --git a/examples/openstreetmap.html b/examples/openstreetmap.html index cd60ebd69cf..662597bca3c 100644 --- a/examples/openstreetmap.html +++ b/examples/openstreetmap.html @@ -1,36 +1,36 @@ - - - - - - - - -
- - + + + + + + + + +
+ + diff --git a/examples/wms.html b/examples/wms.html index d803fd656ea..f0c2b2e75a7 100644 --- a/examples/wms.html +++ b/examples/wms.html @@ -1,35 +1,35 @@ - - - - - - - - -
- - + + + + + + + + +
+ + diff --git a/examples/yahoo.html b/examples/yahoo.html index 2a1051fc1df..e1fec2f5546 100644 --- a/examples/yahoo.html +++ b/examples/yahoo.html @@ -1,39 +1,39 @@ - - - - - - - - - -

OpenLayers Example

-
- - + + + + + + + + + +

OpenLayers Example

+
+ + diff --git a/examples/zoomLevels.html b/examples/zoomLevels.html index 6bee6aabc43..a66d5fc452a 100644 --- a/examples/zoomLevels.html +++ b/examples/zoomLevels.html @@ -1,54 +1,54 @@ - - - - - - - - -
- - + + + + + + + + +
+ + diff --git a/lib/OpenLayers/Feature/WFS.js b/lib/OpenLayers/Feature/WFS.js index 7255e616362..efd573b1722 100644 --- a/lib/OpenLayers/Feature/WFS.js +++ b/lib/OpenLayers/Feature/WFS.js @@ -2,51 +2,51 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * text of the license. */ -/** +/** * @class - * + * * @requires OpenLayers/Feature.js - */ -OpenLayers.Feature.WFS = Class.create(); -OpenLayers.Feature.WFS.prototype = - Object.extend( new OpenLayers.Feature(), { - - /** - * @constructor - * - * @param {OpenLayers.Layer} layer - * @param {XMLNode} xmlNode - */ - initialize: function(layer, xmlNode) { - var newArguments = arguments; - if (arguments.length > 0) { - var data = this.processXMLNode(xmlNode); - newArguments = new Array(layer, data.lonlat, data) - } - OpenLayers.Feature.prototype.initialize.apply(this, newArguments); - - if (arguments.length > 0) { - this.createMarker(); - this.layer.addMarker(this.marker); - } - }, - - destroy: function() { - if (this.marker != null) { - this.layer.removeMarker(this.marker); - } - OpenLayers.Feature.prototype.destroy.apply(this, arguments); - }, - - /** - * @param {XMLNode} xmlNode - * - * @returns Data Object with 'id', 'lonlat', and private properties set - * @type Object - */ - processXMLNode: function(xmlNode) { - //this should be overridden by subclasses - // must return an Object with 'id' and 'lonlat' values set + */ +OpenLayers.Feature.WFS = Class.create(); +OpenLayers.Feature.WFS.prototype = + Object.extend( new OpenLayers.Feature(), { + + /** + * @constructor + * + * @param {OpenLayers.Layer} layer + * @param {XMLNode} xmlNode + */ + initialize: function(layer, xmlNode) { + var newArguments = arguments; + if (arguments.length > 0) { + var data = this.processXMLNode(xmlNode); + newArguments = new Array(layer, data.lonlat, data) + } + OpenLayers.Feature.prototype.initialize.apply(this, newArguments); + + if (arguments.length > 0) { + this.createMarker(); + this.layer.addMarker(this.marker); + } + }, + + destroy: function() { + if (this.marker != null) { + this.layer.removeMarker(this.marker); + } + OpenLayers.Feature.prototype.destroy.apply(this, arguments); + }, + + /** + * @param {XMLNode} xmlNode + * + * @returns Data Object with 'id', 'lonlat', and private properties set + * @type Object + */ + processXMLNode: function(xmlNode) { + //this should be overridden by subclasses + // must return an Object with 'id' and 'lonlat' values set var point = xmlNode.getElementsByTagName("Point"); var text = OpenLayers.Util.getXmlNodeValue(point[0].getElementsByTagName("coordinates")[0]); var floats = text.split(","); @@ -54,13 +54,13 @@ OpenLayers.Feature.WFS.prototype = parseFloat(floats[1])), id: null}; - }, - - /** @final @type String */ - CLASS_NAME: "OpenLayers.Feature.WFS" -}); - - - - - + }, + + /** @final @type String */ + CLASS_NAME: "OpenLayers.Feature.WFS" +}); + + + + + diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 3a77023dc7d..9afeb8a7615 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -2,234 +2,234 @@ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full * text of the license. */ -/** - * @class - */ -OpenLayers.Popup = Class.create(); - -OpenLayers.Popup.WIDTH = 200; -OpenLayers.Popup.HEIGHT = 200; -OpenLayers.Popup.COLOR = "white"; -OpenLayers.Popup.OPACITY = 1; -OpenLayers.Popup.BORDER = "0px"; - -OpenLayers.Popup.prototype = { - - /** @type OpenLayers.Events*/ - events: null, - - /** @type String */ - id: "", - - /** @type OpenLayers.LonLat */ - lonlat: null, - - /** @type DOMElement */ - div: null, - - /** @type OpenLayers.Size*/ - size: null, - - /** @type String */ - contentHTML: "", - - /** @type String */ - backgroundColor: "", - - /** @type float */ - opacity: "", - - /** @type String */ - border: "", - - /** this gets set in Map.js when the popup is added to the map - * @type OpenLayers.Map */ - map: null, - - /** - * @constructor - * - * @param {String} id - * @param {OpenLayers.LonLat} lonlat - * @param {OpenLayers.Size} size - * @param {String} contentHTML - */ - initialize:function(id, lonlat, size, contentHTML) { +/** + * @class + */ +OpenLayers.Popup = Class.create(); + +OpenLayers.Popup.WIDTH = 200; +OpenLayers.Popup.HEIGHT = 200; +OpenLayers.Popup.COLOR = "white"; +OpenLayers.Popup.OPACITY = 1; +OpenLayers.Popup.BORDER = "0px"; + +OpenLayers.Popup.prototype = { + + /** @type OpenLayers.Events*/ + events: null, + + /** @type String */ + id: "", + + /** @type OpenLayers.LonLat */ + lonlat: null, + + /** @type DOMElement */ + div: null, + + /** @type OpenLayers.Size*/ + size: null, + + /** @type String */ + contentHTML: "", + + /** @type String */ + backgroundColor: "", + + /** @type float */ + opacity: "", + + /** @type String */ + border: "", + + /** this gets set in Map.js when the popup is added to the map + * @type OpenLayers.Map */ + map: null, + + /** + * @constructor + * + * @param {String} id + * @param {OpenLayers.LonLat} lonlat + * @param {OpenLayers.Size} size + * @param {String} contentHTML + */ + initialize:function(id, lonlat, size, contentHTML) { if (id == null) { id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_"); } this.id = id; - this.lonlat = lonlat; - this.size = (size != null) ? size - : new OpenLayers.Size( - OpenLayers.Popup.WIDTH, - OpenLayers.Popup.HEIGHT); - if (contentHTML != null) { - this.contentHTML = contentHTML; - } - this.backgroundColor = OpenLayers.Popup.COLOR; - this.opacity = OpenLayers.Popup.OPACITY; - this.border = OpenLayers.Popup.BORDER; - - this.div = OpenLayers.Util.createDiv(this.id, null, null, - null, null, null, "hidden"); - - this.events = new OpenLayers.Events(this, this.div, null); - }, - - /** - */ - destroy: function() { - if (this.map != null) { - this.map.removePopup(this); - } - this.div = null; - this.map = null; - }, - - /** - * @param {OpenLayers.Pixel} px - * - * @returns Reference to a div that contains the drawn popup - * @type DOMElement - */ - draw: function(px) { - if (px == null) { - if ((this.lonlat != null) && (this.map != null)) { - px = this.map.getLayerPxFromLonLat(this.lonlat); - } - } - - this.setSize(); - this.setBackgroundColor(); - this.setOpacity(); - this.setBorder(); - this.setContentHTML(); - this.moveTo(px); - - return this.div; - }, - - /** - * if the popup has a lonlat and its map members set, - * then have it move itself to its proper position - */ - updatePosition: function() { - if ((this.lonlat) && (this.map)) { - var px = this.map.getLayerPxFromLonLat(this.lonlat); - this.moveTo(px); - } - }, - - /** - * @param {OpenLayers.Pixel} px - */ - moveTo: function(px) { - if ((px != null) && (this.div != null)) { - this.div.style.left = px.x + "px"; - this.div.style.top = px.y + "px"; - } - }, - - /** - * @returns Boolean indicating whether or not the popup is visible - * @type Boolean - */ - visible: function() { - return Element.visible(this.div); - }, - - /** - * - */ - toggle: function() { - Element.toggle(this.div); - }, - - /** - * - */ - show: function() { - Element.show(this.div); - }, - - /** - * - */ - hide: function() { - Element.hide(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 + "px"; - this.div.style.height = this.size.h + "px"; - } - }, - - /** - * @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" -}; + this.lonlat = lonlat; + this.size = (size != null) ? size + : new OpenLayers.Size( + OpenLayers.Popup.WIDTH, + OpenLayers.Popup.HEIGHT); + if (contentHTML != null) { + this.contentHTML = contentHTML; + } + this.backgroundColor = OpenLayers.Popup.COLOR; + this.opacity = OpenLayers.Popup.OPACITY; + this.border = OpenLayers.Popup.BORDER; + + this.div = OpenLayers.Util.createDiv(this.id, null, null, + null, null, null, "hidden"); + + this.events = new OpenLayers.Events(this, this.div, null); + }, + + /** + */ + destroy: function() { + if (this.map != null) { + this.map.removePopup(this); + } + this.div = null; + this.map = null; + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns Reference to a div that contains the drawn popup + * @type DOMElement + */ + draw: function(px) { + if (px == null) { + if ((this.lonlat != null) && (this.map != null)) { + px = this.map.getLayerPxFromLonLat(this.lonlat); + } + } + + this.setSize(); + this.setBackgroundColor(); + this.setOpacity(); + this.setBorder(); + this.setContentHTML(); + this.moveTo(px); + + return this.div; + }, + + /** + * if the popup has a lonlat and its map members set, + * then have it move itself to its proper position + */ + updatePosition: function() { + if ((this.lonlat) && (this.map)) { + var px = this.map.getLayerPxFromLonLat(this.lonlat); + this.moveTo(px); + } + }, + + /** + * @param {OpenLayers.Pixel} px + */ + moveTo: function(px) { + if ((px != null) && (this.div != null)) { + this.div.style.left = px.x + "px"; + this.div.style.top = px.y + "px"; + } + }, + + /** + * @returns Boolean indicating whether or not the popup is visible + * @type Boolean + */ + visible: function() { + return Element.visible(this.div); + }, + + /** + * + */ + toggle: function() { + Element.toggle(this.div); + }, + + /** + * + */ + show: function() { + Element.show(this.div); + }, + + /** + * + */ + hide: function() { + Element.hide(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 + "px"; + this.div.style.height = this.size.h + "px"; + } + }, + + /** + * @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" +}; diff --git a/lib/OpenLayers/Popup/Anchored.js b/lib/OpenLayers/Popup/Anchored.js index f98345f605b..e6fc1abb4cb 100644 --- a/lib/OpenLayers/Popup/Anchored.js +++ b/lib/OpenLayers/Popup/Anchored.js @@ -1,126 +1,126 @@ /* 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. */ - -/** + +/** * @class * * @requires OpenLayers/Popup.js - */ -OpenLayers.Popup.Anchored = Class.create(); -OpenLayers.Popup.Anchored.prototype = - Object.extend( new OpenLayers.Popup(), { - - /** "lr", "ll", "tr", "tl" - relative position of the popup. - * @type String */ - relativePosition: null, - - /** Object which must have expose a 'size' (OpenLayers.Size) and - * 'offset' (OpenLayers.Pixel) - * @type Object */ - anchor: null, - - /** - * @constructor - * - * @param {String} id - * @param {OpenLayers.LonLat} lonlat - * @param {OpenLayers.Size} size - * @param {String} contentHTML - * @param {Object} anchor Object which must expose a - * - 'size' (OpenLayers.Size) and - * - 'offset' (OpenLayers.Pixel) - * (this is generally an OpenLayers.Icon) - */ - initialize:function(id, lonlat, size, contentHTML, anchor) { - var newArguments = new Array(id, lonlat, size, contentHTML); - OpenLayers.Popup.prototype.initialize.apply(this, newArguments); - - this.anchor = (anchor != null) ? anchor - : { size: new OpenLayers.Size(0,0), - offset: new OpenLayers.Pixel(0,0)}; - }, - - /** - * @param {OpenLayers.Pixel} px - * - * @returns Reference to a div that contains the drawn popup - * @type DOMElement - */ - draw: function(px) { - if (px == null) { - if ((this.lonlat != null) && (this.map != null)) { - px = this.map.getLayerPxFromLonLat(this.lonlat); - } - } - - //calculate relative position - this.relativePosition = this.calculateRelativePosition(px); - - return OpenLayers.Popup.prototype.draw.apply(this, arguments); - }, - - /** - * @private - * - * @param {OpenLayers.Pixel} px - * - * @returns The relative position ("br" "tr" "tl "bl") at which the popup - * should be placed - * @type String - */ - calculateRelativePosition:function(px) { - var lonlat = this.map.getLonLatFromLayerPx(px); - - var extent = this.map.getExtent(); - var quadrant = extent.determineQuadrant(lonlat); - - return OpenLayers.Bounds.oppositeQuadrant(quadrant); - }, - - /** - * @param {OpenLayers.Pixel} px - */ - moveTo: function(px) { - - var newPx = this.calculateNewPx(px); - - var newArguments = new Array(newPx); - OpenLayers.Popup.prototype.moveTo.apply(this, newArguments); - }, - - /** - * @param {OpenLayers.Size} size - */ - setSize:function(size) { - OpenLayers.Popup.prototype.setSize.apply(this, arguments); - - if ((this.lonlat) && (this.map)) { - var px = this.map.getLayerPxFromLonLat(this.lonlat); - this.moveTo(px); - } - }, - - /** - * @private - * - * @param {OpenLayers.Pixel} px - * - * @returns The the new px position of the popup on the screen - * relative to the passed-in px - * @type OpenLayers.Pixel - */ - calculateNewPx:function(px) { - var newPx = px.offset(this.anchor.offset); - - var top = (this.relativePosition.charAt(0) == 't'); - newPx.y += (top) ? -this.size.h : this.anchor.size.h; - - var left = (this.relativePosition.charAt(1) == 'l'); - newPx.x += (left) ? -this.size.w : this.anchor.size.w; - - return newPx; - }, - - CLASS_NAME: "OpenLayers.Popup.Anchored" -}); + */ +OpenLayers.Popup.Anchored = Class.create(); +OpenLayers.Popup.Anchored.prototype = + Object.extend( new OpenLayers.Popup(), { + + /** "lr", "ll", "tr", "tl" - relative position of the popup. + * @type String */ + relativePosition: null, + + /** Object which must have expose a 'size' (OpenLayers.Size) and + * 'offset' (OpenLayers.Pixel) + * @type Object */ + anchor: null, + + /** + * @constructor + * + * @param {String} id + * @param {OpenLayers.LonLat} lonlat + * @param {OpenLayers.Size} size + * @param {String} contentHTML + * @param {Object} anchor Object which must expose a + * - 'size' (OpenLayers.Size) and + * - 'offset' (OpenLayers.Pixel) + * (this is generally an OpenLayers.Icon) + */ + initialize:function(id, lonlat, size, contentHTML, anchor) { + var newArguments = new Array(id, lonlat, size, contentHTML); + OpenLayers.Popup.prototype.initialize.apply(this, newArguments); + + this.anchor = (anchor != null) ? anchor + : { size: new OpenLayers.Size(0,0), + offset: new OpenLayers.Pixel(0,0)}; + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns Reference to a div that contains the drawn popup + * @type DOMElement + */ + draw: function(px) { + if (px == null) { + if ((this.lonlat != null) && (this.map != null)) { + px = this.map.getLayerPxFromLonLat(this.lonlat); + } + } + + //calculate relative position + this.relativePosition = this.calculateRelativePosition(px); + + return OpenLayers.Popup.prototype.draw.apply(this, arguments); + }, + + /** + * @private + * + * @param {OpenLayers.Pixel} px + * + * @returns The relative position ("br" "tr" "tl "bl") at which the popup + * should be placed + * @type String + */ + calculateRelativePosition:function(px) { + var lonlat = this.map.getLonLatFromLayerPx(px); + + var extent = this.map.getExtent(); + var quadrant = extent.determineQuadrant(lonlat); + + return OpenLayers.Bounds.oppositeQuadrant(quadrant); + }, + + /** + * @param {OpenLayers.Pixel} px + */ + moveTo: function(px) { + + var newPx = this.calculateNewPx(px); + + var newArguments = new Array(newPx); + OpenLayers.Popup.prototype.moveTo.apply(this, newArguments); + }, + + /** + * @param {OpenLayers.Size} size + */ + setSize:function(size) { + OpenLayers.Popup.prototype.setSize.apply(this, arguments); + + if ((this.lonlat) && (this.map)) { + var px = this.map.getLayerPxFromLonLat(this.lonlat); + this.moveTo(px); + } + }, + + /** + * @private + * + * @param {OpenLayers.Pixel} px + * + * @returns The the new px position of the popup on the screen + * relative to the passed-in px + * @type OpenLayers.Pixel + */ + calculateNewPx:function(px) { + var newPx = px.offset(this.anchor.offset); + + var top = (this.relativePosition.charAt(0) == 't'); + newPx.y += (top) ? -this.size.h : this.anchor.size.h; + + var left = (this.relativePosition.charAt(1) == 'l'); + newPx.x += (left) ? -this.size.w : this.anchor.size.w; + + return newPx; + }, + + CLASS_NAME: "OpenLayers.Popup.Anchored" +}); diff --git a/lib/OpenLayers/Popup/AnchoredBubble.js b/lib/OpenLayers/Popup/AnchoredBubble.js index 83cc46e84a3..fa32c161da8 100644 --- a/lib/OpenLayers/Popup/AnchoredBubble.js +++ b/lib/OpenLayers/Popup/AnchoredBubble.js @@ -1,184 +1,184 @@ /* 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. */ - -/** + +/** * @class * * @requires OpenLayers/Popup/Anchored.js - */ -OpenLayers.Popup.AnchoredBubble = Class.create(); - -//Border space for the rico corners -OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5; - -OpenLayers.Popup.AnchoredBubble.prototype = - Object.extend( new OpenLayers.Popup.Anchored(), { - - /** @type DOMElement */ - contentDiv:null, - - - /** - * @constructor - * - * @param {String} id - * @param {OpenLayers.LonLat} lonlat - * @param {OpenLayers.Size} size - * @param {String} contentHTML - * @param {Object} anchor Object which must expose a - * - 'size' (OpenLayers.Size) and - * - 'offset' (OpenLayers.Pixel) - * (this is generally an OpenLayers.Icon) - */ - initialize:function(id, lonlat, size, contentHTML, anchor) { - OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); - }, - - /** - * @param {OpenLayers.Pixel} px - * - * @returns Reference to a div that contains the drawn popup - * @type DOMElement - */ - draw: function(px) { - - OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments); - - // make the content Div - var contentSize = this.size.clone(); - contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); - - var id = this.div.id + "_contentDiv"; - this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, - null, "relative", null, - "hidden"); - this.div.appendChild(this.contentDiv); - this.setContentHTML(); - - this.setRicoCorners(true); - - //set the popup color and opacity - this.setBackgroundColor(); - this.setOpacity(); - - return this.div; - }, - - /** - * @param {OpenLayers.Size} size - */ - setSize:function(size) { - OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); - - if (this.contentDiv != null) { - - var contentSize = this.size.clone(); - contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); - - this.contentDiv.style.height = contentSize.h + "px"; - - //size has changed - must redo corners - this.setRicoCorners(false); - } - }, - - /** - * @param {String} color - */ - setBackgroundColor:function(color) { - if (color != undefined) { - this.backgroundColor = color; - } - - if (this.div != null) { - if (this.contentDiv != null) { - this.div.style.background = "transparent"; - Rico.Corner.changeColor(this.contentDiv, this.backgroundColor); - } - } - }, - - /** - * @param {float} opacity - */ - setOpacity:function(opacity) { - if (opacity != undefined) { - this.opacity = opacity; - } - - if (this.div != null) { - if (this.contentDiv != null) { - Rico.Corner.changeOpacity(this.contentDiv, this.opacity); - } - } - }, - - /** Bubble Popups can not have a border - * - * @param {int} border - */ - setBorder:function(border) { - this.border = 0; - }, - - /** - * @param {String} contentHTML - */ - setContentHTML:function(contentHTML) { - if (contentHTML != null) { - this.contentHTML = contentHTML; - } - - if (this.contentDiv != null) { - this.contentDiv.innerHTML = this.contentHTML; - } - }, - - /** - * @private - * - * @param {Boolean} firstTime Is this the first time the corners are being - * rounded? - * - * update the rico corners according to the popup's - * current relative postion - */ - setRicoCorners:function(firstTime) { - - var corners = this.getCornersToRound(this.relativePosition); - var options = {corners: corners, - color: this.backgroundColor, - bgColor: "transparent", - blend: false}; - - if (firstTime) { - Rico.Corner.round(this.div, options); - } else { - Rico.Corner.reRound(this.contentDiv, options); - //set the popup color and opacity - this.setBackgroundColor(); - this.setOpacity(); - } - }, - - /** - * @private - * - * @returns The proper corners string ("tr tl bl br") for rico - * to round - * @type String - */ - getCornersToRound:function() { - - var corners = ['tl', 'tr', 'bl', 'br']; - - //we want to round all the corners _except_ the opposite one. - var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition); - corners.remove(corner); - - return corners.join(" "); - }, - - CLASS_NAME: "OpenLayers.Popup.AnchoredBubble" -}); + */ +OpenLayers.Popup.AnchoredBubble = Class.create(); + +//Border space for the rico corners +OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5; + +OpenLayers.Popup.AnchoredBubble.prototype = + Object.extend( new OpenLayers.Popup.Anchored(), { + + /** @type DOMElement */ + contentDiv:null, + + + /** + * @constructor + * + * @param {String} id + * @param {OpenLayers.LonLat} lonlat + * @param {OpenLayers.Size} size + * @param {String} contentHTML + * @param {Object} anchor Object which must expose a + * - 'size' (OpenLayers.Size) and + * - 'offset' (OpenLayers.Pixel) + * (this is generally an OpenLayers.Icon) + */ + initialize:function(id, lonlat, size, contentHTML, anchor) { + OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments); + }, + + /** + * @param {OpenLayers.Pixel} px + * + * @returns Reference to a div that contains the drawn popup + * @type DOMElement + */ + draw: function(px) { + + OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments); + + // make the content Div + var contentSize = this.size.clone(); + contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); + + var id = this.div.id + "_contentDiv"; + this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, + null, "relative", null, + "hidden"); + this.div.appendChild(this.contentDiv); + this.setContentHTML(); + + this.setRicoCorners(true); + + //set the popup color and opacity + this.setBackgroundColor(); + this.setOpacity(); + + return this.div; + }, + + /** + * @param {OpenLayers.Size} size + */ + setSize:function(size) { + OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); + + if (this.contentDiv != null) { + + var contentSize = this.size.clone(); + contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE); + + this.contentDiv.style.height = contentSize.h + "px"; + + //size has changed - must redo corners + this.setRicoCorners(false); + } + }, + + /** + * @param {String} color + */ + setBackgroundColor:function(color) { + if (color != undefined) { + this.backgroundColor = color; + } + + if (this.div != null) { + if (this.contentDiv != null) { + this.div.style.background = "transparent"; + Rico.Corner.changeColor(this.contentDiv, this.backgroundColor); + } + } + }, + + /** + * @param {float} opacity + */ + setOpacity:function(opacity) { + if (opacity != undefined) { + this.opacity = opacity; + } + + if (this.div != null) { + if (this.contentDiv != null) { + Rico.Corner.changeOpacity(this.contentDiv, this.opacity); + } + } + }, + + /** Bubble Popups can not have a border + * + * @param {int} border + */ + setBorder:function(border) { + this.border = 0; + }, + + /** + * @param {String} contentHTML + */ + setContentHTML:function(contentHTML) { + if (contentHTML != null) { + this.contentHTML = contentHTML; + } + + if (this.contentDiv != null) { + this.contentDiv.innerHTML = this.contentHTML; + } + }, + + /** + * @private + * + * @param {Boolean} firstTime Is this the first time the corners are being + * rounded? + * + * update the rico corners according to the popup's + * current relative postion + */ + setRicoCorners:function(firstTime) { + + var corners = this.getCornersToRound(this.relativePosition); + var options = {corners: corners, + color: this.backgroundColor, + bgColor: "transparent", + blend: false}; + + if (firstTime) { + Rico.Corner.round(this.div, options); + } else { + Rico.Corner.reRound(this.contentDiv, options); + //set the popup color and opacity + this.setBackgroundColor(); + this.setOpacity(); + } + }, + + /** + * @private + * + * @returns The proper corners string ("tr tl bl br") for rico + * to round + * @type String + */ + getCornersToRound:function() { + + var corners = ['tl', 'tr', 'bl', 'br']; + + //we want to round all the corners _except_ the opposite one. + var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition); + corners.remove(corner); + + return corners.join(" "); + }, + + CLASS_NAME: "OpenLayers.Popup.AnchoredBubble" +}); diff --git a/tests/test_Popup.html b/tests/test_Popup.html index 4dd69326b5f..8551f4cd741 100644 --- a/tests/test_Popup.html +++ b/tests/test_Popup.html @@ -1,105 +1,105 @@ - - - - - - - - + + + + + + + +