Changeset 2813
- Timestamp:
- 03/17/07 17:49:59 (2 years ago)
- Files:
-
- sandbox/elemoine/openlayers/examples/history.html (added)
- sandbox/elemoine/openlayers/lib/OpenLayers.js (modified) (2 diffs)
- sandbox/elemoine/openlayers/lib/OpenLayers/History.js (modified) (5 diffs)
- sandbox/elemoine/openlayers/lib/OpenLayers/Memento.js (modified) (2 diffs)
- sandbox/elemoine/openlayers/lib/OpenLayers/Memento/Map.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/elemoine/openlayers/lib/OpenLayers.js
r2803 r2813 93 93 "OpenLayers/Popup/Anchored.js", 94 94 "OpenLayers/Popup/AnchoredBubble.js", 95 "OpenLayers/History.js", 96 "OpenLayers/Memento.js", 97 "OpenLayers/Memento/Map.js", 95 98 "OpenLayers/Handler.js", 96 99 "OpenLayers/Handler/Point.js", … … 120 123 "OpenLayers/Control/Panel.js", 121 124 "OpenLayers/Control/SelectFeature.js", 125 "OpenLayers/Control/History.js", 122 126 "OpenLayers/Geometry.js", 123 127 "OpenLayers/Geometry/Rectangle.js", sandbox/elemoine/openlayers/lib/OpenLayers/History.js
r2810 r2813 25 25 mementos: null, 26 26 27 /** @type {int} pos */ 28 pos: -1, 29 27 30 /** 28 31 * @constructor … … 41 44 */ 42 45 activate: function() { 46 if (this.active == true) 47 return; 48 43 49 this.mementos = new Array(); 50 this.pos = -1; 44 51 this.active = true; 45 52 }, … … 49 56 */ 50 57 deactivate: function() { 58 if (this.active == false) 59 return; 60 51 61 this.active = false; 52 62 this.mementos = null; … … 57 67 */ 58 68 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); 61 99 }, 62 100 … … 64 102 CLASS_NAME: "OpenLayers.History" 65 103 }; 66 67 sandbox/elemoine/openlayers/lib/OpenLayers/Memento.js
r2810 r2813 9 9 OpenLayers.Memento.prototype = { 10 10 11 /** @type {Object} object */ 12 obj: null, 13 11 14 /** 12 15 * @constructor 13 16 */ 14 initialize: function() { 17 initialize: function(_obj) { 18 this.obj = _obj; 15 19 }, 16 20 … … 19 23 */ 20 24 destroy: function() { 25 this.obj = null; 21 26 }, 27 28 getObject: function() { 29 return this.obj; 30 }, 22 31 23 32 /** @final @type String */ sandbox/elemoine/openlayers/lib/OpenLayers/Memento/Map.js
r2810 r2813 12 12 OpenLayers.Class.inherit(OpenLayers.Memento, { 13 13 14 /** @type OpenLayers.Map */15 map: null,16 17 14 /** @type OpenLayers.Bound */ 18 15 bounds: null, … … 24 21 * @param {OpenLayers.Bounds} bounds 25 22 */ 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; 30 28 }, 31 29 32 30 destroy: function() { 33 31 this.bounds = null; 34 this.map = null;35 32 OpenLayers.Memento.prototype.destroy.apply(this); 36 33 },
