OpenLayers OpenLayers

Changeset 2813

Show
Ignore:
Timestamp:
03/17/07 17:49:59 (2 years ago)
Author:
elemoine
Message:

history is working (undo at least), history control object still missing

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sandbox/elemoine/openlayers/lib/OpenLayers.js

    r2803 r2813  
    9393        "OpenLayers/Popup/Anchored.js", 
    9494        "OpenLayers/Popup/AnchoredBubble.js", 
     95        "OpenLayers/History.js", 
     96        "OpenLayers/Memento.js", 
     97        "OpenLayers/Memento/Map.js", 
    9598        "OpenLayers/Handler.js", 
    9699        "OpenLayers/Handler/Point.js", 
     
    120123        "OpenLayers/Control/Panel.js", 
    121124        "OpenLayers/Control/SelectFeature.js", 
     125        "OpenLayers/Control/History.js", 
    122126        "OpenLayers/Geometry.js", 
    123127        "OpenLayers/Geometry/Rectangle.js", 
  • sandbox/elemoine/openlayers/lib/OpenLayers/History.js

    r2810 r2813  
    2525    mementos: null, 
    2626 
     27    /** @type {int} pos */ 
     28    pos: -1, 
     29 
    2730    /** 
    2831     * @constructor 
     
    4144     */ 
    4245    activate: function() { 
     46        if (this.active == true) 
     47            return; 
     48 
    4349        this.mementos = new Array(); 
     50        this.pos = -1; 
    4451        this.active = true; 
    4552    }, 
     
    4956     */ 
    5057    deactivate: function() { 
     58        if (this.active == false) 
     59            return; 
     60 
    5161        this.active = false; 
    5262        this.mementos = null; 
     
    5767     */ 
    5868    addMemento: function(memento) { 
    59         if (this.active) 
    60             this.mementos.push(memento); 
     69        if (this.active == false) 
     70            return; 
     71 
     72        // TODO use HISTSIZE 
     73 
     74        this.pos++; 
     75        this.mementos.splice(this.pos); 
     76        this.mementos.push(memento); 
     77    }, 
     78 
     79    /** 
     80     * 
     81     */ 
     82    undo: function() { 
     83        if (this.active == false || this.pos == -1) 
     84            return; 
     85 
     86        var memento = this.mementos[this.pos--]; 
     87        memento.getObject().setMemento(memento); 
     88    }, 
     89 
     90    /** 
     91     * 
     92     */ 
     93    redo: function() { 
     94        if (this.active == false || this.pos == this.mementos.length - 1) 
     95            return; 
     96 
     97        var memento = this.mementos[++this.pos]; 
     98        memento.getObject().setMemento(memento); 
    6199    }, 
    62100 
     
    64102    CLASS_NAME: "OpenLayers.History" 
    65103}; 
    66  
    67  
  • sandbox/elemoine/openlayers/lib/OpenLayers/Memento.js

    r2810 r2813  
    99OpenLayers.Memento.prototype = { 
    1010 
     11    /** @type {Object} object */ 
     12    obj: null, 
     13 
    1114    /** 
    1215     * @constructor 
    1316     */ 
    14     initialize: function() { 
     17    initialize: function(_obj) { 
     18        this.obj = _obj; 
    1519    }, 
    1620     
     
    1923     */ 
    2024    destroy: function() { 
     25        this.obj = null; 
    2126    }, 
     27 
     28    getObject: function() { 
     29        return this.obj; 
     30    }, 
    2231 
    2332    /** @final @type String */ 
  • sandbox/elemoine/openlayers/lib/OpenLayers/Memento/Map.js

    r2810 r2813  
    1212    OpenLayers.Class.inherit(OpenLayers.Memento, { 
    1313 
    14     /** @type OpenLayers.Map */ 
    15     map: null, 
    16  
    1714    /** @type OpenLayers.Bound */ 
    1815    bounds: null, 
     
    2421     * @param {OpenLayers.Bounds} bounds 
    2522     */ 
    26     initialize: function(_map, _bounds) { 
    27         OpenLayers.Memento.prototype.initialize.apply(this); 
    28         this.map = _map; 
    29         this.bounds = _bounds; 
     23    initialize: function(map, bounds) { 
     24        var args = new Array(); 
     25        args.push(map); 
     26        OpenLayers.Memento.prototype.initialize.apply(this, args); 
     27        this.bounds = bounds; 
    3028    }, 
    3129 
    3230    destroy: function() { 
    3331        this.bounds = null; 
    34         this.map = null; 
    3532        OpenLayers.Memento.prototype.destroy.apply(this); 
    3633    },