Changeset 4047
- Timestamp:
- 08/27/07 08:46:29 (1 year ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Control/Permalink.js (modified) (2 diffs)
- trunk/openlayers/tests/Control/test_Permalink.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/Permalink.js
r3984 r4047 36 36 OpenLayers.Control.prototype.initialize.apply(this, arguments); 37 37 this.element = OpenLayers.Util.getElement(element); 38 if (base) { 39 this.base = base; 40 } 38 this.base = base || document.location.href; 41 39 }, 42 40 … … 117 115 } 118 116 } 119 var href = this.base + "?" + lat + "&" + lon + "&" + zoom + 120 "&" + layers; 117 118 var href = this.base; 119 var paramsString = lat + "&" + lon + "&" + zoom + "&" + layers; 120 121 var lastServerChar = href.charAt(href.length - 1); 122 if ((lastServerChar == "&") || (lastServerChar == "?")) { 123 href += paramsString; 124 } else { 125 if (href.indexOf('?') == -1) { 126 //serverPath has no ? -- add one 127 href += '?' + paramsString; 128 } else { 129 //serverPath contains ?, so must already have paramsString at the end 130 href += '&' + paramsString; 131 } 132 } 121 133 this.element.href = href; 122 134 }, trunk/openlayers/tests/Control/test_Permalink.html
r3534 r4047 50 50 t.eq(map.controls[3].div.firstChild.nodeName, "A", "Permalink control creates div with 'a' inside." ); 51 51 } 52 function test_05_Control_Permalink_base_with_query (t) { 53 t.plan( 3 ); 54 55 control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar" ); 56 map = new OpenLayers.Map('map'); 57 layer = new OpenLayers.Layer.WMS('Test Layer', "http://example.com" ); 58 map.addLayer(layer); 59 if (!map.getCenter()) map.zoomToMaxExtent(); 60 map.addControl(control); 61 map.pan(5, 0); 62 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?foo=bar&lat=0&lon=1.75781&zoom=2&layers=B'; 63 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring"); 64 65 control = new OpenLayers.Control.Permalink('permalink', "./edit.html?foo=bar&" ); 66 map.addControl(control); 67 map.pan(0, 0); 68 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '&'"); 69 70 control = new OpenLayers.Control.Permalink('permalink', "./edit.html?" ); 71 OpenLayers.Util.getElement('edit_permalink').href = './edit.html?lat=0&lon=1.75781&zoom=2&layers=B'; 72 map.addControl(control); 73 map.pan(5, 0); 74 map.pan(-5, 0); 75 t.eq(OpenLayers.Util.getElement('permalink').href, OpenLayers.Util.getElement('edit_permalink').href, "Panning sets permalink with base and querystring ending with '?'"); 76 77 } 52 78 // --> 53 79 </script>
