[Commits] r1704 - in trunk/openlayers: examples img lib/OpenLayers lib/OpenLayers/Popup

commits at openlayers.org commits at openlayers.org
Wed Oct 18 12:50:09 EDT 2006


Author: crschmidt
Date: 2006-10-18 12:50:07 -0400 (Wed, 18 Oct 2006)
New Revision: 1704

Added:
   trunk/openlayers/img/close.gif
Modified:
   trunk/openlayers/examples/popups.html
   trunk/openlayers/lib/OpenLayers/Popup.js
   trunk/openlayers/lib/OpenLayers/Popup/Anchored.js
   trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js
Log:
Add the ability to add a close button to popups via a final param to the 
constructor of a popup. 


Modified: trunk/openlayers/examples/popups.html
===================================================================
--- trunk/openlayers/examples/popups.html	2006-10-18 14:47:39 UTC (rev 1703)
+++ trunk/openlayers/examples/popups.html	2006-10-18 16:50:07 UTC (rev 1704)
@@ -37,7 +37,8 @@
             popup = new OpenLayers.Popup("chicken", 
                                          new OpenLayers.LonLat(5,40),
                                          new OpenLayers.Size(200,200),
-                                         "example popup");
+                                         "example popup",
+                                         true);
         
             map.addPopup(popup);
         }        

Added: trunk/openlayers/img/close.gif
===================================================================
(Binary files differ)


Property changes on: trunk/openlayers/img/close.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/openlayers/lib/OpenLayers/Popup/Anchored.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Popup/Anchored.js	2006-10-18 14:47:39 UTC (rev 1703)
+++ trunk/openlayers/lib/OpenLayers/Popup/Anchored.js	2006-10-18 16:50:07 UTC (rev 1704)
@@ -31,9 +31,10 @@
     *                         - 'size' (OpenLayers.Size) and 
     *                         - 'offset' (OpenLayers.Pixel) 
     *                         (this is generally an OpenLayers.Icon)
+    * @param {Boolean} closeBox
     */
-    initialize:function(id, lonlat, size, contentHTML, anchor) {
-        var newArguments = new Array(id, lonlat, size, contentHTML);
+    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
+        var newArguments = new Array(id, lonlat, size, contentHTML, closeBox);
         OpenLayers.Popup.prototype.initialize.apply(this, newArguments);
 
         this.anchor = (anchor != null) ? anchor 

Modified: trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js	2006-10-18 14:47:39 UTC (rev 1703)
+++ trunk/openlayers/lib/OpenLayers/Popup/AnchoredBubble.js	2006-10-18 16:50:07 UTC (rev 1704)
@@ -28,8 +28,9 @@
     *                         - 'size' (OpenLayers.Size) and 
     *                         - 'offset' (OpenLayers.Pixel) 
     *                         (this is generally an OpenLayers.Icon)
+    * @param {Boolean} closeBox
     */
-    initialize:function(id, lonlat, size, contentHTML, anchor) {
+    initialize:function(id, lonlat, size, contentHTML, anchor, closeBox) {
         OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);
     },
 

Modified: trunk/openlayers/lib/OpenLayers/Popup.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Popup.js	2006-10-18 14:47:39 UTC (rev 1703)
+++ trunk/openlayers/lib/OpenLayers/Popup.js	2006-10-18 16:50:07 UTC (rev 1704)
@@ -60,8 +60,9 @@
     * @param {OpenLayers.LonLat} lonlat
     * @param {OpenLayers.Size} size
     * @param {String} contentHTML
+    * @param {Boolean} closeBox
     */
-    initialize:function(id, lonlat, size, contentHTML) {
+    initialize:function(id, lonlat, size, contentHTML, closeBox) {
         if (id == null) {
             id = OpenLayers.Util.createUniqueID(this.CLASS_NAME + "_");
         }
@@ -90,6 +91,23 @@
         this.contentDiv.className = 'olPopupContent';                                            
         this.div.appendChild(this.contentDiv);
 
+        if (closeBox == true) {
+           // close icon
+            var closeSize = new OpenLayers.Size(17,17);
+            var img = OpenLayers.Util.getImagesLocation() + "close.gif";
+            var closeImg = OpenLayers.Util.createAlphaImageDiv(this.id + "_close", 
+                                                                null, 
+                                                                closeSize, 
+                                                                img);
+            closeImg.style.right = this.padding + "px";
+            closeImg.style.top = this.padding + "px";
+            this.div.appendChild(closeImg);
+
+            var closeEvents = new OpenLayers.Events(this, closeImg);
+            closeEvents.register("mousedown", this, this.hide);
+
+        }
+
         this.registerEvents();
     },
 



More information about the Commits mailing list