Changeset 9406


Ignore:
Timestamp:
May 22, 2009 7:03:17 AM (7 years ago)
Author:
crschmidt
Message:

Pullups for OL 2.8 RC3.

jQuery lib fix (Closes #1391)
getRenderedSize regression (Closes #1906)
element.scrolls error with panzoombar (Closes #2054)
createUrlObject bug (Closes #2060)
google layer in late rendered maps (Closes #2075)
IE6/Lang.nb bug (Closes #2093)
Layer.TMS/TileCache bugs (Closes #2099) (Closes #2100)
Graphic names issues (Closes #2101)

Location:
branches/openlayers/2.8
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/openlayers/2.8/lib/OpenLayers/Events.js

    r9142 r9406  
    437437
    438438    /**
     439     * Method: clearMouseListener
     440     * A version of <clearMouseCache> that is bound to this instance so that
     441     *     it can be used with <OpenLayers.Event.observe> and
     442     *     <OpenLayers.Event.stopObserving>.
     443     */
     444    clearMouseListener: null,
     445
     446    /**
    439447     * Constructor: OpenLayers.Events
    440448     * Construct an OpenLayers.Events object.
     
    459467            this.handleBrowserEvent, this
    460468        );
     469       
     470        // to be used with observe and stopObserving
     471        this.clearMouseListener = OpenLayers.Function.bind(
     472            this.clearMouseCache, this
     473        );
    461474
    462475        // if eventTypes is specified, create a listeners list for each
     
    482495        if (this.element) {
    483496            OpenLayers.Event.stopObservingElement(this.element);
     497            if(this.element.hasScrollEvent) {
     498                OpenLayers.Event.stopObserving(
     499                    window, "scroll", this.clearMouseListener
     500                );
     501            }
    484502        }
    485503        this.element = null;
     
    774792            this.clearMouseCache();
    775793        } else if (!this.element.hasScrollEvent) {
    776             OpenLayers.Event.observe(window, 'scroll',
    777                 OpenLayers.Function.bind(this.clearMouseCache, this));
     794            OpenLayers.Event.observe(window, "scroll", this.clearMouseListener);
    778795            this.element.hasScrollEvent = true;
    779796        }
  • branches/openlayers/2.8/lib/OpenLayers/Lang/nb.js

    r9038 r9406  
    9494        "visning av kartdata over kommersielle bakgrunnskart, men det " +
    9595        "bør nå gjøres med støtten for Spherical Mercator. Mer informasjon " +
    96         "finnes på " +
    97         "http://trac.openlayers.org/wiki/SphericalMercator.",
     96        "finnes på http://trac.openlayers.org/wiki/SphericalMercator.",
    9897
    9998    // console message
  • branches/openlayers/2.8/lib/OpenLayers/Layer/Google.js

    r9348 r9406  
    213213     */
    214214    onMapResize: function() {
    215         if(this.visibility) {
     215        // workaround for resizing of invisible or not yet fully loaded layers
     216        // where GMap2.checkResize() does not work. We need to load all tiles
     217        // for the old div size, then checkResize(), and then call
     218        // layer.moveTo() to trigger GMap.setCenter() (which will finish
     219        // the GMap initialization).
     220        if(this.visibility && this.mapObject.isLoaded()) {
    216221            this.mapObject.checkResize();
    217222        } else {
    218             // workaround for resizing of invisible layers where
    219             // GMap2.checkResize() does not work. We need to load all tiles
    220             // for the old div size, then checkResize(), and then call
    221             // layer.moveTo() to trigger GMap.setCenter() (which will finish
    222             // the GMap initialization).
    223223            if(!this._resized) {
    224224                var layer = this;
  • branches/openlayers/2.8/lib/OpenLayers/Layer/TMS.js

    r8932 r9406  
    106106        var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
    107107        var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
    108         var z = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
     108        var z = this.serverResolutions != null ?
     109            OpenLayers.Util.indexOf(this.serverResolutions, res) :
     110            this.map.getZoom();
    109111        var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type;
    110112        var url = this.url;
  • branches/openlayers/2.8/lib/OpenLayers/Layer/TileCache.js

    r8932 r9406  
    106106        var tileX = Math.round((bounds.left - bbox.left) / (res * size.w));
    107107        var tileY = Math.round((bounds.bottom - bbox.bottom) / (res * size.h));
    108         var tileZ = this.serverResolutions != null ? this.serverResolutions.indexOf(res) : this.map.getZoom();
     108        var tileZ = this.serverResolutions != null ?
     109            OpenLayers.Util.indexOf(this.serverResolutions, res) :
     110            this.map.getZoom();
    109111        /**
    110112         * Zero-pad a positive integer.
  • branches/openlayers/2.8/lib/OpenLayers/Map.js

    r9296 r9406  
    16621662           
    16631663            //send the move call to the baselayer and all the overlays   
    1664             this.baseLayer.moveTo(bounds, zoomChanged, dragging);
    1665             if(dragging) {
    1666                 this.baseLayer.events.triggerEvent("move");
    1667             } else {
    1668                 this.baseLayer.events.triggerEvent("moveend",
    1669                     {"zoomChanged": zoomChanged}
    1670                 );
     1664
     1665            if(this.baseLayer.visibility) {
     1666                this.baseLayer.moveTo(bounds, zoomChanged, dragging);
     1667                if(dragging) {
     1668                    this.baseLayer.events.triggerEvent("move");
     1669                } else {
     1670                    this.baseLayer.events.triggerEvent("moveend",
     1671                        {"zoomChanged": zoomChanged}
     1672                    );
     1673                }
    16711674            }
    16721675           
  • branches/openlayers/2.8/lib/OpenLayers/Popup.js

    r9221 r9406  
    507507        var preparedHTML = "<div class='" + this.contentDisplayClass+ "'>" +
    508508            this.contentDiv.innerHTML +
    509             "<div>";
     509            "</div>";
    510510 
    511511        var containerElement = (this.map) ? this.map.layerContainerDiv
  • branches/openlayers/2.8/lib/OpenLayers/Renderer/SVG.js

    r9278 r9406  
    292292                pos = this.getPosition(node);
    293293                widthFactor = this.symbolSize[id] / size;
    294                 // Only set the href if it is different from the current one.
    295                 // This is a workaround for strange rendering behavior in FF3.
    296                 if (node.getAttributeNS(this.xlinkns, "href") != href) {
    297                     node.setAttributeNS(this.xlinkns, "href", href);
    298                 } else if (size != parseFloat(node.getAttributeNS(null, "width"))) {
    299                     // hide the element (and force a reflow so it really gets
    300                     // hidden. This workaround is needed for Safari.
    301                     node.style.visibility = "hidden";
    302                     this.container.scrollLeft = this.container.scrollLeft;
     294               
     295                // remove the node from the dom before we modify it. This
     296                // prevents various rendering issues in Safari and FF
     297                var parent = node.parentNode;
     298                var nextSibling = node.nextSibling;
     299                if(parent) {
     300                    parent.removeChild(node);
    303301                }
     302               
     303                node.setAttributeNS(this.xlinkns, "href", href);
    304304                node.setAttributeNS(null, "width", size);
    305305                node.setAttributeNS(null, "height", size);
    306306                node.setAttributeNS(null, "x", pos.x - offset);
    307307                node.setAttributeNS(null, "y", pos.y - offset);
    308                 // set the visibility back to normal (after the Safari
    309                 // workaround above)
    310                 node.style.visibility = "";
     308               
     309                // now that the node has all its new properties, insert it
     310                // back into the dom where it was
     311                if(nextSibling) {
     312                    parent.insertBefore(node, nextSibling);
     313                } else if(parent) {
     314                    parent.appendChild(node);
     315                }
    311316            } else {
    312317                node.setAttributeNS(null, "r", style.pointRadius);
  • branches/openlayers/2.8/lib/OpenLayers/Util.js

    r9348 r9406  
    3333
    3434/**
    35  * Maintain $() from prototype
    36  */
    37 if ($ == null) {
    38     var $ = OpenLayers.Util.getElement;
     35 * Maintain existing definition of $.
     36 */
     37if(typeof window.$  === "undefined") {
     38    window.$ = OpenLayers.Util.getElement;
    3939}
    4040
     
    13471347    options = options || {};
    13481348
    1349     var urlObject = {};
     1349    // deal with relative urls first
     1350    if(!(/^\w+:\/\//).test(url)) {
     1351        var loc = window.location;
     1352        var port = loc.port ? ":" + loc.port : "";
     1353        var fullUrl = loc.protocol + "//" + loc.host + port;
     1354        if(url.indexOf("/") === 0) {
     1355            // full pathname
     1356            url = fullUrl + url;
     1357        } else {
     1358            // relative to current path
     1359            var parts = loc.pathname.split("/");
     1360            parts.pop();
     1361            url = fullUrl + parts.join("/") + "/" + url;
     1362        }
     1363    }
    13501364 
    13511365    if (options.ignoreCase) {
     
    13551369    var a = document.createElement('a');
    13561370    a.href = url;
     1371   
     1372    var urlObject = {};
    13571373   
    13581374  //host (without port)
     
    13621378    urlObject.host = a.host || window.location.host;
    13631379    var port = a.port;
    1364     if (port.length <= 0) {
     1380    if (port.length > 0) {
    13651381        var newHostLength = urlObject.host.length - (port.length);
    13661382        urlObject.host = urlObject.host.substring(0, newHostLength);
     
    15411557    // create temp container div with restricted size
    15421558    var container = document.createElement("div");
    1543     container.style.overflow= "";
    1544     container.style.position = "absolute";
    1545     container.style.left = "-9999px";
     1559    container.style.visibility = "hidden";
    15461560       
    15471561    var containerElement = (options && options.containerElement)
     
    15681582    content.innerHTML = contentHTML;
    15691583   
     1584    // we need overflow visible when calculating the size
     1585    content.style.overflow = "visible";
     1586    if (content.childNodes) {
     1587        for (var i=0, l=content.childNodes.length; i<l; i++) {
     1588            if (!content.childNodes[i].style) continue;
     1589            content.childNodes[i].style.overflow = "visible";
     1590        }
     1591    }
     1592   
    15701593    // add content to restricted container
    15711594    container.appendChild(content);
     
    15731596    // append container to body for rendering
    15741597    containerElement.appendChild(container);
     1598   
     1599    // Opera and IE7 can't handle a node with position:aboslute if it inherits
     1600    // position:absolute from a parent.
     1601    var parentHasPositionAbsolute = false;
     1602    var parent = container.parentNode;
     1603    while (parent && parent.tagName.toLowerCase()!="body") {
     1604        var parentPosition = OpenLayers.Element.getStyle(parent, "position");
     1605        if(parentPosition == "absolute") {
     1606            parentHasPositionAbsolute = true;
     1607            break;
     1608        } else if (parentPosition && parentPosition != "static") {
     1609            break;
     1610        }
     1611        parent = parent.parentNode;
     1612    }
     1613
     1614    if(!parentHasPositionAbsolute) {
     1615        container.style.position = "absolute";
     1616    }
    15751617   
    15761618    // calculate scroll width of content and add corners and shadow width
  • branches/openlayers/2.8/tests/Layer/TMS.html

    r8932 r9406  
    5252        var testBounds = new OpenLayers.Bounds(1,2,3,4);
    5353       
    54         t.ok( bounds.equals(testBounds), "getTMSBounds() returns correct bounds")
     54        t.ok( bounds.equals(testBounds), "getTMSBounds() returns correct bounds");
    5555       
    5656        layer.grid = null;
     
    137137                    "http://labs.metacarta.com/wms-c/Basic.py/", {layername: 'basic', type:'png', resolutions:[0.000634956337608418]} );
    138138            m.addLayer(layer);
    139             m.zoomToMaxExtent()
     139            m.zoomToMaxExtent();
    140140            t.eq(layer.getURL(layer.grid[3][3].bounds), "http://labs.metacarta.com/wms-c/Basic.py/1.0.0/basic/0/1/1.png", "TMS tiles around rounded properly.");
    141141        m.destroy();
     
    160160        tileurl = layer.getURL(new OpenLayers.Bounds(0,0,0,0));
    161161        level = parseInt(tileurl.split('/')[2]);
    162         t.eq(layer.serverResolutions.indexOf(map.getResolution()), level, "Tile zoom level is correct with serverResolutions");
     162        var res = map.getResolution();
     163        var gotLevel = OpenLayers.Util.indexOf(layer.serverResolutions, res);
     164        t.eq(gotLevel, level, "Tile zoom level is correct with serverResolutions");
    163165       
    164166        map.destroy();
     
    209211</head>
    210212<body>
    211 <div id="map" style="width:500px;height:550px"></div>
     213<div id="map" style="width:500px;height:550px;"></div>
    212214</body>
    213215</html>
  • branches/openlayers/2.8/tests/Layer/TileCache.html

    r8972 r9406  
    160160        tileurl = layer.getURL(new OpenLayers.Bounds(0,0,0,0));
    161161        level = parseInt(tileurl.split('/')[2]);
    162         t.eq(layer.serverResolutions.indexOf(map.getResolution()), level, "Tile zoom level is correct with serverResolutions");
     162        var gotLevel = OpenLayers.Util.indexOf(layer.serverResolutions, map.getResolution());
     163        t.eq(gotLevel, level, "Tile zoom level is correct with serverResolutions");
    163164       
    164165        map.destroy();
  • branches/openlayers/2.8/tests/Map.html

    r9259 r9406  
    12131213    function test_allOverlays(t) {
    12141214       
    1215         t.plan(14);
    1216        
     1215        t.plan(16);
     1216
    12171217        var map = new OpenLayers.Map({
    12181218            div: "map", allOverlays: true
    12191219        });
    12201220       
    1221         var a = new OpenLayers.Layer.Vector("a");
     1221        var a = new OpenLayers.Layer.Vector("a", {visibility: true});
     1222
    12221223        var b = new OpenLayers.Layer.Image(
    12231224            "b",
     
    12261227            new OpenLayers.Size(580, 288)
    12271228        );
     1229
    12281230        var c = new OpenLayers.Layer.WMS(
    12291231            "c",
     
    12311233            {layers: 'basic'}
    12321234        );
     1235
    12331236        var d = new OpenLayers.Layer.Vector("d");
    12341237       
     
    12441247        t.eq(moveCount, 1, "map.moveTo moves the base layer only once");
    12451248        t.eq(map.getCenter().toString(), "lon=0,lat=0", "a map with all overlays can have a center");
     1249
     1250        a.setVisibility(false);
     1251        var moveend = 0;
     1252        a.events.on({"moveend": function() { moveend++; }});
     1253        map.zoomToMaxExtent();
     1254        t.eq(moveCount, 1, "map.moveTo does not move the base layer if it is invisible");
     1255        t.eq(moveend, 0, "map.moveTo does not trigger \"moveend\" in the layer if the layer is invisible");
     1256        a.setVisibility(true);
    12461257       
    12471258        // a, b, c, d
     
    12821293        map.setLayerIndex(b, 0);
    12831294        t.eq(b.visibility, false, "changing layer order doesn't change visibility");
    1284        
     1295
     1296       
    12851297        map.destroy();
    12861298       
  • branches/openlayers/2.8/tests/Util.html

    r9348 r9406  
    11<html>
    22<head>
     3  <script>
     4    var custom$ = function() {};
     5    window.$ = custom$;
     6  </script>
    37  <script src="../lib/OpenLayers.js"></script>
    48  <script type="text/javascript">
    59    var isMozilla = (navigator.userAgent.indexOf("compatible") == -1);
    610    var map;
     11   
     12    function test_$(t) {
     13        t.plan(1);
     14        t.ok($ === custom$, "OpenLayers doesn't clobber existing definition of $.");
     15    }
    716   
    817    function test_Util_getImagesLocation (t) {
  • branches/openlayers/2.8/tests/manual/rendered-dimensions.html

    r7684 r9406  
    1212    var size = OpenLayers.Util.getRenderedDimensions("<p>Content</p>");
    1313    var bigger = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", null, {displayClass: 'testDims'});
     14    var overflow = OpenLayers.Util.getRenderedDimensions("<p style='overflow:auto'>Content</p>");
     15    var width = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(250, null));
     16    var height = OpenLayers.Util.getRenderedDimensions("<p>Content</p>", new OpenLayers.Size(null, 40));
    1417    if ((size.w + 40) == bigger.w && (size.h + 40) == bigger.h) {
    15         out.innerHTML = "Pass:  " + size + ", " + bigger;
     18        out.innerHTML = "bigger Pass:  " + size + ", " + bigger;
    1619    } else {
    17         out.innerHTML = "Fail:  " + size + ", " + bigger;
     20        out.innerHTML = "bigger Fail:  " + size + ", " + bigger;
     21    }
     22
     23    if (size.w == overflow.w && size.h == overflow.h) {
     24        out.innerHTML += "<br/>overflow Pass:  " + size + ", " + overflow;
     25    } else {
     26        out.innerHTML += "<br/>overflow Fail:  " + size + ", " + overflow;
     27    }
     28
     29    if (width.w == 250 && width.h == size.h) {
     30        out.innerHTML += "<br/>width Pass:  " + size + ", " + width;
     31    }
     32    else {
     33        out.innerHTML += "<br/>width Fail:  " + size + ", " + width;
     34    }
     35
     36    if (height.h == 40 && height.w == size.w) {
     37        out.innerHTML += "<br/>height Pass:  " + size + ", " + height;
     38    }
     39    else {
     40        out.innerHTML += "<br/>height Fail:  " + size + ", " + height;
    1841    }
    1942}
Note: See TracChangeset for help on using the changeset viewer.