OpenLayers OpenLayers

Changeset 6629

Show
Ignore:
Timestamp:
03/27/08 02:56:37 (10 months ago)
Author:
euzuro
Message:

turns out that we're going to have to cache this value

Files:

Legend:

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

    r6628 r6629  
    639639    getContentDivPadding: function() { 
    640640 
    641         //make the div invisible and add it to the page         
    642         this.div.style.display = "none"; 
    643         document.body.appendChild(this.div); 
    644  
    645         //read the padding settings from css, put them in an OL.Bounds         
    646         var contentDivPadding = new OpenLayers.Bounds( 
    647             OpenLayers.Element.getStyle(this.contentDiv, "padding-left"), 
    648             OpenLayers.Element.getStyle(this.contentDiv, "padding-bottom"), 
    649             OpenLayers.Element.getStyle(this.contentDiv, "padding-right"), 
    650             OpenLayers.Element.getStyle(this.contentDiv, "padding-top") 
    651         ); 
    652  
    653         //remove the div from the page and make it visible again 
    654         document.body.removeChild(this.div); 
    655         this.div.style.display = ""; 
    656  
     641        //use cached value if we have it 
     642        var contentDivPadding = this._contentDivPadding; 
     643        if (!contentDivPadding) { 
     644            //make the div invisible and add it to the page         
     645            this.div.style.display = "none"; 
     646            document.body.appendChild(this.div); 
     647     
     648            //read the padding settings from css, put them in an OL.Bounds         
     649            contentDivPadding = new OpenLayers.Bounds( 
     650                OpenLayers.Element.getStyle(this.contentDiv, "padding-left"), 
     651                OpenLayers.Element.getStyle(this.contentDiv, "padding-bottom"), 
     652                OpenLayers.Element.getStyle(this.contentDiv, "padding-right"), 
     653                OpenLayers.Element.getStyle(this.contentDiv, "padding-top") 
     654            ); 
     655     
     656            //cache the value 
     657            this._contentDivPadding = contentDivPadding; 
     658     
     659            //remove the div from the page and make it visible again 
     660            document.body.removeChild(this.div); 
     661            this.div.style.display = ""; 
     662        } 
    657663        return contentDivPadding; 
    658664    },