OpenLayers OpenLayers

Changeset 6676

Show
Ignore:
Timestamp:
03/28/08 21:25:49 (10 months ago)
Author:
euzuro
Message:

tripatch. first, in anchoredbubble, it is foolish to pass firstTime as an argument. just use and set this.rounded in the actual function. second, do not update the relative position unless the relative position has changed. third, whenever the size changes, take the appropriate action (in bubble, we must reround the corners. in framed, we update the blocks). This patch nicelygets rid of a lot of repeated unnecessary function calls. slimmer slimmer slimmer.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/Anchored.js

    r6650 r6676  
    9393     */ 
    9494    moveTo: function(px) { 
     95        var oldRelativePosition = this.relativePosition; 
    9596        this.relativePosition = this.calculateRelativePosition(px); 
    9697         
     
    99100        var newArguments = new Array(newPx);         
    100101        OpenLayers.Popup.prototype.moveTo.apply(this, newArguments); 
     102         
     103        if (this.relativePosition != oldRelativePosition) { 
     104            this.updateRelativePosition(); 
     105        } 
     106    }, 
     107 
     108    /** 
     109     * Method: updateRelativePosition 
     110     * The popup has been moved to a new relative location, so we may want to  
     111     *     make some cosmetic adjustments to it.  
     112     *  
     113     *     Note that in the classic Anchored popup, there is nothing to do  
     114     *     here, since the popup looks exactly the same in all four positions. 
     115     *     Subclasses such as the AnchoredBubble and Framed, however, will  
     116     *     want to do something special here. 
     117     */ 
     118    updateRelativePosition: function() { 
     119        //to be overridden by subclasses 
    101120    }, 
    102121 
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/AnchoredBubble.js

    r6600 r6676  
    7070 
    7171    /** 
    72      * Method: moveTo 
    73      * The popup may have been moved to a new relative location, in which case 
     72     * Method: updateRelativePosition 
     73     * The popup has been moved to a new relative location, in which case 
    7474     *     we will want to re-do the rico corners. 
    75      *  
    76      * Parameters: 
    77      * px - {<OpenLayers.Pixel>} 
    7875     */ 
    79     moveTo: function(px) { 
    80         OpenLayers.Popup.Anchored.prototype.moveTo.apply(this, arguments); 
    81         this.setRicoCorners(!this.rounded); 
    82         this.rounded = true; 
     76    updateRelativePosition: function() { 
     77        this.setRicoCorners(); 
    8378    }, 
    8479 
     
    9085     */ 
    9186    setSize:function(size) {  
    92  
    9387        OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); 
    9488 
    95         //finally, we re-round the corners 
    96         if (this.map) { 
    97             this.setRicoCorners(!this.rounded); 
    98             this.rounded = true; 
    99         }     
    100  
     89        this.setRicoCorners(); 
    10190    },   
    10291 
     
    152141     * Method: setRicoCorners 
    153142     * Update RICO corners according to the popup's current relative postion. 
    154      *   
    155      * Parameters: 
    156      * firstTime - {Boolean} This the first time the corners are being rounded. 
    157143     */ 
    158     setRicoCorners:function(firstTime) { 
     144    setRicoCorners:function() { 
    159145     
    160146        var corners = this.getCornersToRound(this.relativePosition); 
     
    164150                         blend: false}; 
    165151 
    166         if (firstTime) { 
     152        if (!this.rounded) { 
    167153            OpenLayers.Rico.Corner.round(this.div, options); 
     154            this.rounded = true; 
    168155        } else { 
    169156            OpenLayers.Rico.Corner.reRound(this.groupDiv, options); 
  • sandbox/euzuro/pop/lib/OpenLayers/Popup/Framed.js

    r6671 r6676  
    149149 
    150150    /** 
    151      * APIMethod: moveTo 
    152      *  
    153      * Parameters: 
    154      * px - {<OpenLayers.Pixel>} 
    155      */ 
    156     moveTo: function(px) { 
    157         OpenLayers.Popup.Anchored.prototype.moveTo.apply(this, arguments); 
    158  
    159         this.updateRelativePosition(); 
     151     * Method: setSize 
     152     * Overridden here, because we need to update the blocks whenever the size 
     153     *     of the popup has changed. 
     154     *  
     155     * Parameters: 
     156     * size - {<OpenLayers.Size>} 
     157     */ 
     158    setSize:function(size) {  
     159        OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments); 
     160         
     161        this.updateBlocks(); 
    160162    }, 
    161163