Revision 4307
Added by ben leinfelder over 15 years ago
History.js | ||
---|---|---|
1 | 1 |
/* |
2 | 2 |
Author: Steven Ottens AT geodan.nl |
3 | 3 |
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html |
4 |
$Id$ |
|
4 |
$Id: History.js 2956 2007-07-09 12:17:52Z steven $
|
|
5 | 5 |
*/ |
6 | 6 |
|
7 | 7 |
// Ensure this object's dependancies are loaded. |
... | ... | |
19 | 19 |
function History(toolNode, model) { |
20 | 20 |
ToolBase.apply(this, new Array(toolNode, model)); |
21 | 21 |
|
22 |
|
|
23 |
var doAdd = new Boolean(); |
|
24 |
|
|
25 | 22 |
/** |
26 |
* Inititialising the history and setting start parameters
|
|
27 |
* @param objRef pointer to this object.
|
|
28 |
*/
|
|
23 |
* Inititialising the history and setting start parameters |
|
24 |
* @param objRef pointer to this object. |
|
25 |
*/ |
|
29 | 26 |
|
30 | 27 |
this.init = function(objRef) { |
31 |
place = -1; |
|
32 |
list = new Array(); |
|
33 |
|
|
34 |
var bbox = objRef.targetModel.getBoundingBox(); |
|
35 |
newExtent = new Array(); |
|
36 |
newExtent[0] = new Array(bbox[0],bbox[3]); |
|
37 |
newExtent[1] = new Array(bbox[2],bbox[1]); |
|
38 |
list.push(newExtent); |
|
39 |
|
|
40 |
place = place+1; |
|
41 |
|
|
42 |
objRef.model.active = place; |
|
43 |
objRef.model.historyList = list; |
|
44 |
|
|
28 |
objRef.model.active = -1; |
|
29 |
objRef.model.historyList = new Array(); |
|
30 |
objRef.add(objRef); |
|
45 | 31 |
} |
46 | 32 |
|
47 | 33 |
/** |
... | ... | |
52 | 38 |
if (objRef.model.active!=null) { |
53 | 39 |
var place = objRef.model.active; |
54 | 40 |
var list = objRef.model.historyList; |
55 |
newExtent = new Array(); |
|
56 |
newExtent[0] = objRef.model.extent.ul; |
|
57 |
newExtent[1] = objRef.model.extent.lr; |
|
41 |
var center = objRef.targetModel.map.getExtent().getCenterLonLat(); |
|
42 |
// take the current scale -1, otherwise we get troubles when |
|
43 |
// fixed scales are defined |
|
44 |
var scale = objRef.targetModel.map.getScale()-1; |
|
45 |
if (place > -1) { |
|
46 |
// check if current and previous history entry would result |
|
47 |
// in same center point and zoom level. If this is the case, |
|
48 |
// we do not want a new entry in the list |
|
49 |
if (center.toString() == list[place].center.toString() && |
|
50 |
scale == list[place].scale) { |
|
51 |
return; |
|
52 |
} |
|
53 |
} |
|
54 |
var newExtent = new Object({center:center, scale:scale}); |
|
58 | 55 |
|
59 | 56 |
if( place==(list.length-1)) { //If we are already at the end of the list add a new item |
60 | 57 |
list.push(newExtent); |
... | ... | |
76 | 73 |
*/ |
77 | 74 |
|
78 | 75 |
this.back = function(objRef){ |
79 |
place = objRef.model.active; |
|
76 |
var place = objRef.model.active;
|
|
80 | 77 |
if(place<1) { |
81 | 78 |
objRef.model.previousExtent = null; |
82 |
alert("You can't go further back");
|
|
79 |
alert(mbGetMessage("cantGoBack"));
|
|
83 | 80 |
} |
84 | 81 |
else { |
85 | 82 |
place = place -1; |
... | ... | |
93 | 90 |
* @param objRef pointer to this object. |
94 | 91 |
*/ |
95 | 92 |
this.forward = function(objRef) { |
96 |
place = objRef.model.active; |
|
93 |
var place = objRef.model.active;
|
|
97 | 94 |
if(place<(objRef.model.historyList.length-1)) { |
98 | 95 |
place = place +1; |
99 | 96 |
objRef.model.active = place; |
... | ... | |
101 | 98 |
} |
102 | 99 |
else { |
103 | 100 |
objRef.model.nextExtent = null; |
104 |
alert("You can't go further forward");
|
|
101 |
alert(mbGetMessage("cantGoForward"));
|
|
105 | 102 |
} |
106 | 103 |
} |
107 | 104 |
|
... | ... | |
134 | 131 |
this.model.addListener("historyStart", this.start, this); |
135 | 132 |
this.model.addListener("historyStop", this.stop, this); |
136 | 133 |
this.model.addListener("init", this.initReset, this); |
137 |
} |
|
138 |
|
|
139 |
|
|
140 |
|
|
134 |
} |
Also available in: Unified diff
upgrade to MapBuilder 1.5rc2 - includes support for Firefox 3 compatibility (yes, it is also EOLed)