OpenLayers OpenLayers

Changeset 7684

Show
Ignore:
Timestamp:
08/03/08 14:47:52 (4 months ago)
Author:
crschmidt
Message:

Improve getRenderedDimensions to take into account a CSS class. Refactor some
popup code to take advantage of this, to provide a better hint to the
getRenderedDimensions call as to what is going on. Patch from sbenthall, r=me,
includes a manual acceptance test (only because the testing framework makes
these kinds of things hard). Manually confirmed to work with the sundials.html
example, tested with that and manual test in IE6, IE7, FF2-Win FF3-Mac FF2-Mac
Safari-Mac Opera-Win, and in all browsers it worked. (Hooray!) Nice one,
sbenthall. (Closes #1500)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers/Popup.js

    r7656 r7684  
    118118 
    119119    /**  
     120     * Property: displayClass 
     121     * {String} The CSS class of the popup. 
     122     */ 
     123    displayClass: "olPopup", 
     124 
     125    /**  
     126     * Property: contentDisplayClass 
     127     * {String} The CSS class of the popup content div. 
     128     */ 
     129    contentDisplayClass: "olPopupContent", 
     130 
     131    /**  
    120132     * Property: padding  
    121133     * {int or <OpenLayers.Bounds>} An extra opportunity to specify internal  
     
    199211        this.div = OpenLayers.Util.createDiv(this.id, null, null,  
    200212                                             null, null, null, "hidden"); 
    201         this.div.className = 'olPopup'
     213        this.div.className = this.displayClass
    202214         
    203215        var groupDivId = this.id + "_GroupDiv"; 
     
    209221        this.contentDiv = OpenLayers.Util.createDiv(id, null, this.size.clone(),  
    210222                                                    null, "relative"); 
    211         this.contentDiv.className = 'olPopupContent';                                             
     223        this.contentDiv.className = this.contentDisplayClass; 
    212224        this.groupDiv.appendChild(this.contentDiv); 
    213225        this.div.appendChild(this.groupDiv); 
     
    499511     */ 
    500512    setContentHTML:function(contentHTML) { 
     513 
     514        var preparedHTML; 
    501515        if (contentHTML != null) { 
    502516            this.contentHTML = contentHTML; 
    503517        } 
    504          
     518        
    505519        if (this.autoSize) { 
    506  
     520            //fake the contentDiv for the CSS context 
     521            preparedHTML = "<div class='" + this.contentDisplayClass+ "'>" + this.contentHTML + "<div>"; 
     522  
    507523            // determine actual render dimensions of the contents 
    508524            var realSize =  
    509                  OpenLayers.Util.getRenderedDimensions(this.contentHTML); 
     525                OpenLayers.Util.getRenderedDimensions(preparedHTML, null,  
     526                    { displayClass: this.displayClass }); 
    510527 
    511528            // is the "real" size of the div is safe to display in our map? 
     
    536553                    // run getRenderedDimensions() again with a fixed dimension 
    537554                    var clippedSize = OpenLayers.Util.getRenderedDimensions( 
    538                         this.contentHTML, fixedSize 
     555                        preparedHTML, fixedSize,  
     556                        { displayClass: this.contentDisplayClass } 
    539557                    ); 
    540558                     
  • trunk/openlayers/lib/OpenLayers/Popup/FramedCloud.js

    r6751 r7684  
    1616OpenLayers.Popup.FramedCloud =  
    1717  OpenLayers.Class(OpenLayers.Popup.Framed, { 
     18 
     19    /**  
     20     * Property: contentDisplayClass 
     21     * {String} The CSS class of the popup content div. 
     22     */ 
     23    contentDisplayClass: "olFramedCloudPopupContent", 
    1824 
    1925    /** 
     
    211217        this.imageSrc = OpenLayers.Util.getImagesLocation() + 'cloud-popup-relative.png'; 
    212218        OpenLayers.Popup.Framed.prototype.initialize.apply(this, arguments); 
    213         this.contentDiv.className = "olFramedCloudPopupContent"
     219        this.contentDiv.className = this.contentDisplayClass
    214220    }, 
    215221 
  • trunk/openlayers/lib/OpenLayers/Util.js

    r7675 r7684  
    13751375 *      
    13761376 * Parameters: 
     1377 * contentHTML 
    13771378 * size - {<OpenLayers.Size>} If either the 'w' or 'h' properties is  
    13781379 *     specified, we fix that dimension of the div to be measured. This is  
    13791380 *     useful in the case where we have a limit in one dimension and must  
    13801381 *     therefore meaure the flow in the other dimension. 
     1382 * options - {Object} 
     1383 *     displayClass - {String} Optional parameter.  A CSS class name(s) string 
     1384 *         to provide the CSS context of the rendered content. 
    13811385 *  
    13821386 * Returns: 
    13831387 * {OpenLayers.Size} 
    13841388 */ 
    1385 OpenLayers.Util.getRenderedDimensions = function(contentHTML, size) { 
     1389OpenLayers.Util.getRenderedDimensions = function(contentHTML, size, options) { 
    13861390     
    13871391    var w, h; 
     
    14031407        } 
    14041408    } 
     1409 
     1410    //add css classes, if specified 
     1411    if (options && options.displayClass) { 
     1412        container.className = options.displayClass; 
     1413    } 
    14051414     
    14061415    // create temp content div and assign content