OpenLayers OpenLayers

Changeset 6182

Show
Ignore:
Timestamp:
02/10/08 15:47:13 (1 year ago)
Author:
tschaub
Message:

Adding eventsListener property for objects with events instances. Example demonstrates use.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/tschaub/events/examples/navigation-history.html

    r6160 r6182  
    3636            function init(){ 
    3737                map = new OpenLayers.Map('map'); 
    38                  
     38 
    3939                nav = new OpenLayers.Control.NavigationHistory(); 
    4040                // parent control must be added to the map 
     
    7070 
    7171        <div id="map"></div> 
    72         Map navigation history controls<div id="panel"><div> 
     72        Map navigation history controls<div id="panel"></div> 
    7373        <div id="docs"></div> 
    7474    </body> 
  • sandbox/tschaub/events/lib/OpenLayers/Control/NavigationHistory.js

    r6160 r6182  
    114114     */ 
    115115    restoring: false, 
    116  
     116     
    117117    /** 
    118118     * Constructor: OpenLayers.Control.NavigationHistory  
     
    140140            displayClass: this.displayClass + "Previous" 
    141141        }; 
    142         if(options) { 
    143             OpenLayers.Util.extend(previousOptions, options.previousOptions); 
    144         } 
     142        OpenLayers.Util.extend(previousOptions, this.previousOptions); 
    145143        this.previous = new OpenLayers.Control.Button(previousOptions); 
    146144         
     
    149147            displayClass: this.displayClass + "Next" 
    150148        }; 
    151         if(options) { 
    152             OpenLayers.Util.extend(nextOptions, options.nextOptions); 
    153         } 
     149        OpenLayers.Util.extend(nextOptions, this.nextOptions); 
    154150        this.next = new OpenLayers.Control.Button(nextOptions); 
    155151 
  • sandbox/tschaub/events/lib/OpenLayers/Events.js

    r6125 r6182  
    429429        if (this.element != null) { 
    430430            this.attachToElement(element); 
     431        } 
     432         
     433        /** 
     434         * If the object has an eventListeners property and it is an instance 
     435         * of an OpenLayers class, assume eventListeners is a hash of listeners 
     436         * to be registered with the on method. 
     437         */ 
     438        if(object && object.CLASS_NAME.indexOf("OpenLayers") == 0 && 
     439           typeof object.eventListeners == "object") { 
     440            this.on(object.eventListeners); 
    431441        } 
    432442    }, 
     
    652662        evt.object = this.object; 
    653663        evt.element = this.element; 
     664        if(!evt.type) { 
     665            evt.type = type; 
     666        } 
    654667     
    655668        // execute all callbacks registered for specified type