Changeset 2181
- Timestamp:
- 01/22/07 18:26:32 (2 years ago)
- Files:
-
- branches/openlayers/2.3/build/build.py (modified) (1 diff)
- branches/openlayers/2.3/lib/OpenLayers/Control/OverviewMap.js (modified) (4 diffs)
- branches/openlayers/2.3/lib/OpenLayers/Events.js (modified) (1 diff)
- branches/openlayers/2.3/lib/OpenLayers/Map.js (modified) (4 diffs)
- branches/openlayers/2.3/lib/OpenLayers/Marker.js (modified) (1 diff)
- branches/openlayers/2.3/lib/OpenLayers/Tile/Image.js (modified) (2 diffs)
- branches/openlayers/2.3/lib/OpenLayers/Util.js (modified) (4 diffs)
- branches/openlayers/2.3/tests/test_Icon.html (modified) (1 diff)
- branches/openlayers/2.3/tests/test_Layer_EventPane.html (modified) (2 diffs)
- branches/openlayers/2.3/tests/test_Layer_WMS.html (modified) (1 diff)
- branches/openlayers/2.3/tests/test_Marker.html (modified) (2 diffs)
- branches/openlayers/2.3/tests/test_Popup.html (modified) (2 diffs)
- branches/openlayers/2.3/tests/test_Util.html (modified) (14 diffs)
- branches/openlayers/2.3/theme/default/style.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/openlayers/2.3/build/build.py
r2097 r2181 15 15 outputFilename = sys.argv[2] 16 16 17 print "Adding license file."18 merged = file("license.txt").read()19 17 print "Merging libraries." 20 merged += mergejs.run(sourceDirectory, None, configFilename)18 merged = mergejs.run(sourceDirectory, None, configFilename) 21 19 print "Compressing." 22 20 minimized = jsmin.jsmin(merged) 21 print "Adding license file." 22 minimized = file("license.txt").read() + minimized 23 23 24 24 print "Writing to %s." % outputFilename branches/openlayers/2.3/lib/OpenLayers/Control/OverviewMap.js
r2089 r2181 134 134 }); 135 135 this.rectEvents = new OpenLayers.Events(this, this.extentRectangle); 136 this.rectEvents.register('mouseover', this, this.rectMouseOver);137 136 this.rectEvents.register('mouseout', this, this.rectMouseOut); 138 137 this.rectEvents.register('mousedown', this, this.rectMouseDown); … … 148 147 // Optionally add min/max buttons if the control will go in the 149 148 // map viewport. 150 if(!this.div.parentNode || 151 (this.div.parentNode.className == 'olMapViewport')) { 149 if(!this.outsideViewport) { 152 150 this.div.className = 'olControlOverviewMapContainer'; 153 151 var imgLocation = OpenLayers.Util.getImagesLocation(); … … 188 186 this.element.style.display = ''; 189 187 } 190 188 if(this.map.getExtent()) { 189 this.update(); 190 } 191 191 return this.div; 192 192 }, … … 200 200 * @param {OpenLayers.Event} evt 201 201 */ 202 rectMouseOver: function (evt) {203 this.extentRectangle.style.cursor = 'move';204 },205 206 /**207 * @param {OpenLayers.Event} evt208 */209 202 rectMouseOut: function (evt) { 210 this.extentRectangle.style.cursor = 'default';211 203 if(this.rectDragStart != null) { 212 204 if(this.performedRectDrag) { 213 this.updateMapToRect(); 214 } 205 this.rectMouseMove(evt); 206 var rectPxBounds = this.getRectPxBounds(); 207 // if we're off of the overview map, update the main map 208 // otherwise, keep moving the rect 209 if((rectPxBounds.top <= 0) || (rectPxBounds.left <= 0) || 210 (rectPxBounds.bottom >= this.size.h - this.hComp) || 211 (rectPxBounds.right >= this.size.w - this.wComp)) { 212 this.updateMapToRect(); 213 } else { 214 return; 215 } 216 } 215 217 document.onselectstart = null; 216 218 this.rectDragStart = null; branches/openlayers/2.3/lib/OpenLayers/Events.js
r2024 r2181 273 273 274 274 // execute all callbacks registered for specified type 275 var listeners = this.listeners[type]; 275 // get a clone of the listeners array to 276 // allow for splicing during callbacks 277 var listeners = (this.listeners[type]) ? 278 this.listeners[type].slice() : null; 276 279 if ((listeners != null) && (listeners.length > 0)) { 277 280 for (var i = 0; i < listeners.length; i++) { branches/openlayers/2.3/lib/OpenLayers/Map.js
r2087 r2181 432 432 */ 433 433 setBaseLayer: function(newBaseLayer, noEvent) { 434 var oldBaseLayer = this.baseLayer; 435 436 if (newBaseLayer != oldBaseLayer) { 434 var oldExtent = null; 435 if(this.baseLayer) { 436 oldExtent = this.baseLayer.getExtent(); 437 } 438 439 if (newBaseLayer != this.baseLayer) { 437 440 438 441 // is newBaseLayer an already loaded layer? … … 440 443 441 444 // make the old base layer invisible 442 if ( oldBaseLayer != null) {443 oldBaseLayer.setVisibility(false, noEvent);445 if (this.baseLayer != null) { 446 this.baseLayer.setVisibility(false, noEvent); 444 447 } 445 448 … … 451 454 var center = this.getCenter(); 452 455 if (center != null) { 453 if (old BaseLayer== null) {456 if (oldExtent == null) { 454 457 this.setCenter(center); 455 458 } else { 456 this.zoomToExtent(old BaseLayer.getExtent());459 this.zoomToExtent(oldExtent); 457 460 } 458 461 } … … 481 484 */ 482 485 addControlToMap: function (control, px) { 486 // If a control doesn't have a div at this point, it belongs in the 487 // viewport. 488 control.outsideViewport = (control.div != null); 483 489 control.setMap(this); 484 490 var div = control.draw(px); 485 491 if (div) { 486 // only elements without parents should be appended to the viewport 487 if(!div.parentNode) { 492 if(!control.outsideViewport) { 488 493 div.style.zIndex = this.Z_INDEX_BASE['Control'] + 489 494 this.controls.length; branches/openlayers/2.3/lib/OpenLayers/Marker.js
r1721 r2181 127 127 var url = OpenLayers.Util.getImagesLocation() + "marker.png"; 128 128 var size = new OpenLayers.Size(21, 25); 129 return new OpenLayers.Icon(url, size); 129 var calculateOffset = function(size) { 130 return new OpenLayers.Pixel(-(size.w/2), -size.h); 131 }; 132 133 return new OpenLayers.Icon(url, size, null, calculateOffset); 130 134 }; 131 135 branches/openlayers/2.3/lib/OpenLayers/Tile/Image.js
r2093 r2181 118 118 this.imgDiv.className = 'olTileImage'; 119 119 120 /* checkImgURL *should* pretty predictably get called after the 121 createImage / createAlphaImageDiv onLoad handler */ 120 /* checkImgURL used to be used to called as a work around, but it 121 ended up hiding problems instead of solving them and broke things 122 like relative URLs. See discussion on the dev list: 123 http://openlayers.org/pipermail/dev/2007-January/000205.html 122 124 123 125 OpenLayers.Event.observe( this.imgDiv, "load", 124 126 this.checkImgURL.bindAsEventListener(this) ); 125 127 */ 126 128 this.layer.div.appendChild(this.imgDiv); 127 129 if(this.layer.opacity != null) { … … 140 142 * when the new URL loads in the image, or (b) we don't want to display 141 143 * this tile after all because its new bounds are outside our maxExtent. 144 * 145 * This function should no longer be neccesary with the improvements to 146 * Grid.js in OpenLayers 2.3. The lack of a good isEquivilantURL function 147 * caused problems in 2.2, but it's possible that with the improved 148 * isEquivilant URL function, this might be neccesary at some point. 149 * 150 * See discussion in the thread at 151 * http://openlayers.org/pipermail/dev/2007-January/000205.html 142 152 * 143 153 * @private branches/openlayers/2.3/lib/OpenLayers/Util.js
r2093 r2181 569 569 OpenLayers.Util.getArgs = function(url) { 570 570 if(url == null) { 571 var query = window.location.search.substring(1); 572 } else { 573 var query = (url.indexOf('?') == -1) ? 574 '' : url.substring(url.indexOf('?') + 1); 575 } 571 url = window.location.href; 572 } 573 var query = (url.indexOf('?') != -1) ? url.substring(url.indexOf('?') + 1) : ''; 574 576 575 var args = new Object(); 577 576 pairs = query.split(/[&;]/); … … 748 747 urlObj2 = OpenLayers.Util.createUrlObject(url2, options); 749 748 750 //compare keys (host, port, etc)749 //compare all keys (host, port, etc) 751 750 for(var key in urlObj1) { 752 if ( (key != "args") && (urlObj1[key] != urlObj2[key]) ) { 753 return false; 754 } 751 if (options.test) { 752 alert(key + "\n1:" + urlObj1[key] + "\n2:" + urlObj2[key]); 753 } 754 var val1 = urlObj1[key]; 755 var val2 = urlObj2[key]; 756 757 switch(key) { 758 case "args": 759 //do nothing, they'll be treated below 760 break; 761 case "host": 762 case "port": 763 case "protocol": 764 if ((val1 == "") || (val2 == "")) { 765 //these will be blank for relative urls, so no need to 766 // compare them here -- call break. 767 // 768 break; 769 } 770 // otherwise continue with default compare 771 // 772 default: 773 if ( (key != "args") && (urlObj1[key] != urlObj2[key]) ) { 774 return false; 775 } 776 break; 777 } 778 755 779 } 756 780 … … 790 814 791 815 var a = document.createElement('a'); 792 793 816 a.href = url; 794 795 //protocol796 urlObject.protocol = a.protocol;797 798 //pathname (this part allows for relative <-> absolute comparison)799 urlObject.pathname = a.pathname;800 801 //hash802 urlObject.hash = (options.ignoreHash) ? "" : a.hash;803 817 804 818 //host (without port) … … 809 823 urlObject.host = urlObject.host.substring(0, newHostLength); 810 824 } 811 825 826 //protocol 827 urlObject.protocol = a.protocol; 828 812 829 //port 813 830 urlObject.port = ((port == "80") && (options.ignorePort80)) ? "" : port; 814 831 832 //hash 833 urlObject.hash = (options.ignoreHash) ? "" : a.hash; 834 815 835 //args 816 urlObject.args = OpenLayers.Util.getArgs(a.search); 836 var queryString = a.search; 837 if (!queryString) { 838 var qMark = url.indexOf("?"); 839 queryString = (qMark != -1) ? url.substr(qMark) : ""; 840 } 841 urlObject.args = OpenLayers.Util.getArgs(queryString); 842 843 844 //pathname (this part allows for relative <-> absolute comparison) 845 if ( ((urlObject.protocol == "file:") && (url.indexOf("file:") != -1)) || 846 ((urlObject.protocol != "file:") && (urlObject.host != "")) ) { 847 848 urlObject.pathname = a.pathname; 849 850 //Test to see if the pathname includes the arguments (Opera) 851 var qIndex = urlObject.pathname.indexOf("?"); 852 if (qIndex != -1) { 853 urlObject.pathname = urlObject.pathname.substring(0, qIndex); 854 } 855 856 } else { 857 var relStr = OpenLayers.Util.removeTail(url); 858 859 var backs = 0; 860 do { 861 var index = relStr.indexOf("../"); 862 863 if (index == 0) { 864 backs++ 865 relStr = relStr.substr(3); 866 } else if (index >= 0) { 867 var prevChunk = relStr.substr(0,index - 1); 868 869 var slash = prevChunk.indexOf("/"); 870 prevChunk = (slash != -1) ? prevChunk.substr(0, slash +1) 871 : ""; 872 873 var postChunk = relStr.substr(index + 3); 874 relStr = prevChunk + postChunk; 875 } 876 } while(index != -1) 877 878 var windowAnchor = document.createElement("a"); 879 var windowUrl = window.location.href; 880 if (options.ignoreCase) { 881 windowUrl = windowUrl.toLowerCase(); 882 } 883 windowAnchor.href = windowUrl; 884 885 //set protocol of window 886 urlObject.protocol = windowAnchor.protocol; 887 888 var splitter = (windowAnchor.pathname.indexOf("/") != -1) ? "/" : "\\"; 889 var dirs = windowAnchor.pathname.split(splitter); 890 dirs.pop(); //remove filename 891 while ((backs > 0) && (dirs.length > 0)) { 892 dirs.pop(); 893 backs--; 894 } 895 relStr = dirs.join("/") + "/"+ relStr; 896 urlObject.pathname = relStr; 897 } 898 899 if ((urlObject.protocol == "file:") || (urlObject.protocol == "")) { 900 urlObject.host = "localhost"; 901 } 817 902 818 903 return urlObject; 819 904 }; 820 905 906 /** 907 * @param {String} url 908 * 909 * @returns The string with all queryString and Hash removed 910 * @type String 911 */ 912 OpenLayers.Util.removeTail = function(url) { 913 var head = null; 914 915 var qMark = url.indexOf("?"); 916 var hashMark = url.indexOf("#"); 917 918 if (qMark == -1) { 919 head = (hashMark != -1) ? url.substr(0,hashMark) : url; 920 } else { 921 head = (hashMark != -1) ? url.substr(0,Math.min(qMark, hashMark)) 922 : url.substr(0, qMark); 923 } 924 return head; 925 }; branches/openlayers/2.3/tests/test_Icon.html
r1541 r2181 25 25 } 26 26 27 function test_0 2_Marker_setOpacity(t) {27 function test_03_Marker_setOpacity(t) { 28 28 t.plan( 2 ); 29 29 30 30 icon = new OpenLayers.Icon("a",new OpenLayers.Size(5,6)); 31 32 31 t.ok(!icon.imageDiv.style.opacity, "default icon has no opacity"); 33 32 34 33 icon.setOpacity(0.5); 35 36 t.eq(icon.imageDiv.style.opacity + "", "0.5", "icon.setOpacity() works"); 34 t.eq(parseFloat(icon.imageDiv.style.opacity), 0.5, "icon.setOpacity() works"); 37 35 } 38 36 branches/openlayers/2.3/tests/test_Layer_EventPane.html
r1782 r2181 4 4 <script type="text/javascript"><!-- 5 5 var isMozilla = (navigator.userAgent.indexOf("compatible") == -1); 6 var isOpera = (navigator.userAgent.indexOf("Opera") != -1); 6 7 var layer; 7 8 … … 57 58 // t.plan( 2 ); 58 59 59 if ( document.createEventObject) {60 if (!isMozilla || isOpera) { 60 61 t.plan(4); 61 62 } else { branches/openlayers/2.3/tests/test_Layer_WMS.html
r1908 r2181 182 182 map.zoomToMaxExtent(); 183 183 t.eq(tLayer.opacity, "0.5", "Opacity is set correctly"); 184 t.eq( tLayer.div.firstChild.style.opacity, "0.5", "Opacity on tile is correct");184 t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.5, "Opacity on tile is correct"); 185 185 tLayer.setOpacity("0.6"); 186 186 t.eq(tLayer.opacity, "0.6", "setOpacity works properly"); 187 t.eq( tLayer.div.firstChild.style.opacity, "0.6", "Opacity on tile is changed correctly");187 t.eq(parseFloat(tLayer.div.firstChild.style.opacity), 0.6, "Opacity on tile is changed correctly"); 188 188 var pixel = new OpenLayers.Pixel(5,6); 189 189 var tile = tLayer.addTile(new OpenLayers.Bounds(1,2,3,4), pixel); 190 190 tile.draw(); 191 t.eq( tile.imgDiv.style.opacity, "0.6", "Tile opacity is set correctly");191 t.eq(parseFloat(tile.imgDiv.style.opacity), 0.6, "Tile opacity is set correctly"); 192 192 193 193 } branches/openlayers/2.3/tests/test_Marker.html
r1541 r2181 46 46 } 47 47 48 function test_0 2_Marker_setOpacity(t) {48 function test_03_Marker_setOpacity(t) { 49 49 t.plan( 2 ); 50 50 … … 70 70 marker.setOpacity(0.5); 71 71 72 t.eq( marker.icon.imageDiv.style.opacity + "", "0.5", "marker.setOpacity() works");72 t.eq(parseFloat(marker.icon.imageDiv.style.opacity), 0.5, "marker.setOpacity() works"); 73 73 } 74 74 branches/openlayers/2.3/tests/test_Popup.html
r1949 r2181 62 62 var content = "charlie"; 63 63 var color = "red"; 64 var hexColor = "#ff0000"; 64 65 var opacity = 0.5; 65 66 var border = "1px solid"; … … 90 91 t.eq(contentDiv.innerHTML, content, "correct content div content"); 91 92 92 t.eq(popup.div.style.backgroundColor, color, "good default popup.backgroundColor"); 93 var bColor = popup.div.style.backgroundColor; 94 var goodColor = ( (bColor == color) || (bColor == hexColor)); 95 t.ok(goodColor, "good default popup.backgroundColor"); 93 96 94 97 if (navigator.appName.indexOf("Microsoft") == -1) { branches/openlayers/2.3/tests/test_Util.html
r2101 r2181 68 68 t.eq( div.style.height, sz.h + "px", "div.style.height set correctly"); 69 69 70 t.eq( div.style.backgroundImage, "url(" + img + ")", "div.style.backgroundImage correctly"); 70 bImg = div.style.backgroundImage; 71 imgCorrect = ( (bImg == "url(" + img + ")") || 72 (bImg == "url(\"" + img + "\")") ); 73 t.ok(imgCorrect, "div.style.backgroundImage correctly"); 71 74 72 75 t.eq( div.style.position, position, "div.style.positionset correctly"); 73 76 t.ok( (div.style.border.indexOf(border) != -1), "div.style.border set correctly"); 74 77 t.eq( div.style.overflow, overflow, "div.style.overflow set correctly"); 75 t.eq( div.style.opacity + "", opacity + "", "elemnt.style.opacity set correctly");78 t.eq( parseFloat(div.style.opacity), opacity, "element.style.opacity set correctly"); 76 79 var filterString = 'alpha(opacity=' + (opacity * 100) + ')'; 77 80 t.eq( div.style.filter, filterString, "element.style.filter set correctly"); … … 96 99 t.eq( div.style.border, "", "div.style.border set correctly"); 97 100 t.eq(div.style.overflow, "", "div.style.overflow set correctly"); 98 t.ok( !div.style.opacity, "elem nt.style.opacity set correctly");101 t.ok( !div.style.opacity, "element.style.opacity set correctly"); 99 102 t.ok( !div.style.filter, "element.style.filter set correctly"); 100 103 … … 117 120 t.ok( true, "skipping element test outside of Mozilla"); 118 121 else 119 t.ok( image instanceof HTMLImageElement, "createImage creates a valid HTMLImageElement" );122 t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" ); 120 123 t.eq( image.id, id, "image.id set correctly"); 121 124 t.eq( image.style.left, xy.x + "px", "image.style.left set correctly"); … … 128 131 t.eq( image.src, img, "image.style.backgroundImage correctly"); 129 132 t.eq( image.style.position, position, "image.style.position set correctly"); 130 t.eq( image.style.opacity+"", opacity + "", "image.style.opacity set correctly");133 t.eq( parseFloat(image.style.opacity), opacity, "image.style.opacity set correctly"); 131 134 var filterString = 'alpha(opacity=' + (opacity * 100) + ')'; 132 135 t.eq( image.style.filter, filterString, "element.style.filter set correctly"); … … 138 141 t.ok( true, "skipping element test outside of Mozilla"); 139 142 else 140 t.ok( image instanceof HTMLImageElement, "createDiv creates a valid HTMLDivElement" );143 t.ok( image.nodeName == "IMG", "createDiv creates a valid HTMLDivElement" ); 141 144 t.ok( (image.id != ""), "image.id set to something"); 142 145 t.eq( image.style.left, "", "image.style.left set correctly"); … … 149 152 t.eq(image.src, "", "image.style.backgroundImage correctly"); 150 153 t.eq( image.style.position, "relative", "image.style.positionset correctly"); 151 t.ok( !image.style.opacity, "elem nt.style.opacity default unset");154 t.ok( !image.style.opacity, "element.style.opacity default unset"); 152 155 t.ok( !image.style.filter, "element.style.filter default unset"); 153 156 … … 212 215 213 216 t.eq( imageDiv.style.position, position, "image.style.positionset correctly"); 214 t.eq( imageDiv.style.opacity+"", opacity + "", "elemnt.style.opacity set correctly");217 t.eq( parseFloat(imageDiv.style.opacity), opacity, "element.style.opacity set correctly"); 215 218 216 219 var filterString; … … 224 227 225 228 image = imageDiv.firstChild; 226 227 229 if (!isMozilla) 228 230 t.ok( true, "skipping element test outside of Mozilla"); 229 231 else 230 t.ok( image instanceof HTMLImageElement, "createImage creates a valid HTMLImageElement" );232 t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" ); 231 233 t.eq( image.id, id + "_innerImage", "image.id set correctly"); 232 234 … … 294 296 t.ok( (element.style.border.indexOf(border) != -1), "element.style.border set correctly"); 295 297 t.eq( element.style.overflow, overflow, "element.style.overflow set correctly"); 296 t.eq( element.style.opacity+"", opacity + "", "elemnt.style.opacity set correctly");298 t.eq( parseFloat(element.style.opacity), opacity, "element.style.opacity set correctly"); 297 299 var filterString = 'alpha(opacity=' + (opacity * 100) + ')'; 298 300 t.eq( element.style.filter, filterString, "element.style.filter set correctly"); … … 314 316 315 317 OpenLayers.Util.modifyAlphaImageDiv(imageDiv, id, xy, sz, img, position, border, sizing, opacity); 316 317 318 if (OpenLayers.Util.alphaHack()) 318 319 t.ok( true, "skipping element test outside of Mozilla"); 319 320 else 320 t.ok( imageDiv instanceof HTMLDivElement, "createDiv creates a valid HTMLDivElement" );321 t.ok( imageDiv.nodeName == "DIV", "createDiv creates a valid HTMLDivElement" ); 321 322 322 323 t.eq( imageDiv.id, id, "image.id set correctly"); … … 328 329 329 330 t.eq( imageDiv.style.position, position, "image.style.position set correctly"); 330 t.eq( imageDiv.style.opacity+"", opacity + "", "elemnt.style.opacity set correctly");331 t.eq( parseFloat(imageDiv.style.opacity), opacity, "element.style.opacity set correctly"); 331 332 332 333 … … 340 341 } else { 341 342 var filterString = 'alpha(opacity=' + (opacity * 100) + ')'; 342 t.ok( image instanceof HTMLImageElement, "createImage creates a valid HTMLImageElement" );343 t.ok( image.nodeName == "IMG", "createImage creates a valid HTMLImageElement" ); 343 344 } 344 345 t.eq( imageDiv.style.filter, filterString, "element.style.filter set correctly"); … … 517 518 518 519 t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "default ignorePort80 works"); 520 519 521 options = { 520 522 'ignorePort80': false 521 523 } 522 523 524 url1 = "http://www.openlayers.org:80"; 524 525 url2 = "http://www.openlayers.org:50"; 525 526 526 t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2 ), "port check works");527 t.ok(!OpenLayers.Util.isEquivalentUrl(url1, url2, options), "port check works"); 527 528 528 529 … … 547 548 548 549 //PATHNAME 549 url1 = "foo.html ";550 url2 = "../tests/ foo.html";550 url1 = "foo.html?bar=now#go"; 551 url2 = "../tests/../tests/foo.html?bar=now#go"; 551 552 552 553 t.ok(OpenLayers.Util.isEquivalentUrl(url1, url2), "relative vs. absolute paths works"); branches/openlayers/2.3/theme/default/style.css
r1695 r2181 57 57 58 58 .olControlOverviewMapExtentRectangle { 59 cursor: move; 59 60 border: 2px dotted red; 60 61 }
