[fusion-commits] r1742 - in branches/fusion-1.1/widgets: . LinkToView

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Jan 22 16:01:39 EST 2009


Author: madair
Date: 2009-01-22 16:01:39 -0500 (Thu, 22 Jan 2009)
New Revision: 1742

Added:
   branches/fusion-1.1/widgets/LinkToView/
   branches/fusion-1.1/widgets/LinkToView/LinkToView.html
Modified:
   branches/fusion-1.1/widgets/LinkToView.js
Log:
re #34: allow link URL to be put in a dialog that pops up

Added: branches/fusion-1.1/widgets/LinkToView/LinkToView.html
===================================================================
--- branches/fusion-1.1/widgets/LinkToView/LinkToView.html	                        (rev 0)
+++ branches/fusion-1.1/widgets/LinkToView/LinkToView.html	2009-01-22 21:01:39 UTC (rev 1742)
@@ -0,0 +1,11 @@
+<html>
+<head>
+    <title>Link to the map view</title>
+</head>
+<body>
+  <div>
+    <p><a id='linkToMap' target='_blank'>Link</a> to this map view.  The full URL is provided below.</p>
+    <input type='text' id='linkField' size='60'/>
+  </div>
+</body>
+</html>
\ No newline at end of file

Modified: branches/fusion-1.1/widgets/LinkToView.js
===================================================================
--- branches/fusion-1.1/widgets/LinkToView.js	2009-01-22 20:59:44 UTC (rev 1741)
+++ branches/fusion-1.1/widgets/LinkToView.js	2009-01-22 21:01:39 UTC (rev 1742)
@@ -31,6 +31,8 @@
 
 
 Fusion.Widget.LinkToView = OpenLayers.Class(Fusion.Widget,  {
+    useDialog: true,
+    
     initialize: function(widgetTag) {
         //console.log('LinkToView.initialize');
 
@@ -38,6 +40,7 @@
         
         var json = widgetTag.extension;
         this.baseUrl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?';
+        this.dialogContent = Fusion.getFusionURL() + 'widgets/LinkToView/LinkToView.html';
 
         //remove any existing extent param
         var queryParams = Fusion.parseQueryString();
@@ -66,16 +69,47 @@
 
         this.anchor = document.createElement('a');
         this.anchor.className = 'anchorLinkToView';
-        this.anchor.href = this.baseUrl;
         this.anchor.innerHTML = this.anchorLabel;
         this.anchor.title = json.Tooltip ? json.Tooltip[0] : 'Right-click to copy or bookmark link to current view';
+        
         this.domObj.innerHTML = '';
         this.domObj.appendChild(this.anchor);
+        
+        if (this.useDialog) {
+          this.createDialog();
+          this.anchor.href = '#';
+          this.anchor.onclick = OpenLayers.Function.bind(this.dialog.open, this.dialog);
+        } else {
+          this.anchor.href = this.baseUrl;
+          this.getMap().oMapOL.events.register("addlayer", this, this.setListener);
+        }
 
-        this.getMap().oMapOL.events.register("addlayer", this, this.setListener);
         this.enable();                   
     },
     
+    createDialog: function() {
+        var o = {
+            id: 'linkDialog',
+            title: 'Link to the map view',
+            contentURL: this.dialogContent,
+            width: 360,
+            height: 100,
+            right: 0,
+            bottom: 20,
+            onOpen: this.onOpen.bind(this)
+        };
+        this.dialog = new Jx.Dialog( o );
+        this.dialog.domObj.style.lineHeight = '20px';
+    },
+    
+    onOpen: function() {
+      var linkField = document.getElementById('linkField');
+      var mapLink = this.getLink();
+      linkField.value = mapLink;
+      var linkToMap = document.getElementById('linkToMap');
+      linkToMap.href = mapLink;
+    },
+    
     setListener: function(evt) {
         var layer = evt.layer;
         //register on the OL loadend event to update the link because this event
@@ -83,9 +117,13 @@
         layer.events.register("loadend", this, this.updateLink);
     },
     
-    updateLink: function() {
+    getLink: function() {
         var join = (this.baseUrl.indexOf('?')==this.baseUrl.length-1)?'':'&';
         var queryStr = this.getMap().getLinkParams();
-        this.anchor.href = this.baseUrl + join + queryStr;
+        return this.baseUrl + join + queryStr;
+    },
+    
+    updateLink: function() {
+        this.anchor.href = this.getLink();
     }
 });



More information about the fusion-commits mailing list