OpenLayers OpenLayers

Changeset 4226

Show
Ignore:
Timestamp:
09/11/07 22:18:33 (1 year ago)
Author:
crschmidt
Message:

Add useFeedTitle option to georss layer -- defaults to true -- to determine
whether to use the remote title or the local name. (Closes #731)

Files:

Legend:

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

    r4041 r4226  
    4848     */ 
    4949    popupSize: null,  
     50     
     51    /**  
     52     * APIProperty: useFeedTitle  
     53     * {Boolean} Set layer.name to the first <title> element in the feed. Default is true.  
     54     */ 
     55    useFeedTitle: true, 
    5056     
    5157    /** 
     
    8793        } 
    8894         
    89         this.name = null; 
    90         try { 
    91             this.name = doc.getElementsByTagNameNS('*', 'title')[0].firstChild.nodeValue; 
    92         } 
    93         catch (e) { 
    94             this.name = doc.getElementsByTagName('title')[0].firstChild.nodeValue; 
     95        if (this.useFeedTitle) { 
     96            var name = null; 
     97            try { 
     98                name = doc.getElementsByTagNameNS('*', 'title')[0].firstChild.nodeValue; 
     99            } 
     100            catch (e) { 
     101                name = doc.getElementsByTagName('title')[0].firstChild.nodeValue; 
     102            } 
     103            if (name) { 
     104                this.setName(name); 
     105            }     
    95106        } 
    96107        
  • trunk/openlayers/tests/Layer/test_GeoRSS.html

    r4059 r4226  
    2929        } ); 
    3030    } 
     31     
     32    function test_Layer_GeoRSS_dontUseFeedTitle (t) { 
     33        t.plan( 1 ); 
     34        layer = new OpenLayers.Layer.GeoRSS('Test Layer', georss_txt, {'useFeedTitle': false} ); 
     35        t.delay_call( 1, function() {   
     36            t.eq( layer.name, "Test Layer", "Layer name is correct when not used from feed." ); 
     37        } ); 
     38    } 
     39     
    3140    function test_01_Layer_GeoRSS_AtomParsing (t) { 
    3241        t.plan( 6 );