/dev/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/trunk

« back to all changes in this revision

Viewing changes to js/history.js

  • Committer: Suren A. Chilingaryan
  • Date: 2008-04-02 10:23:22 UTC
  • Revision ID: csa@dside.dyndns.org-20080402102322-okib92sicg2dx3o3
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function HISTORY(callback) {
 
2
    window.dhtmlHistory.create({
 
3
        toJSON: function(o) {
 
4
                return Object.toJSON(o);
 
5
        },
 
6
        fromJSON: function(s) {
 
7
                return s.evalJSON();
 
8
        }
 
9
    });
 
10
    
 
11
    dhtmlHistory.initialize();
 
12
//    dhtmlHistory.addListener(callback);
 
13
 
 
14
    this.started = false;
 
15
    this.callback = callback;
 
16
    dhtmlHistory.addListener(this.onHistoryEvent(this));
 
17
}
 
18
 
 
19
HISTORY.prototype.onHistoryEvent = function(self) {
 
20
    return function(newLocation, historyData) {
 
21
        if (newLocation == "__startup__") {
 
22
            history.forward();
 
23
            adeiReportError(translate("History is exhausted"));
 
24
        }
 
25
        
 
26
        return self.callback(newLocation, historyData);
 
27
    }
 
28
}
 
29
 
 
30
HISTORY.prototype.GetProps = function() {
 
31
    return dhtmlHistory.getCurrentLocation();
 
32
}
 
33
 
 
34
HISTORY.prototype.Add = function(page, cfg) {
 
35
    if (!this.started) {
 
36
        dhtmlHistory.add("__startup__", cfg);
 
37
        this.started = true;
 
38
    }
 
39
        
 
40
    dhtmlHistory.add(page, cfg);
 
41
}
 
42
 
 
43
HISTORY.prototype.AddSynonim = function(old_page, new_page) {
 
44
    var cfg = historyStorage.get(old_page);
 
45
    
 
46
    if (cfg) {    
 
47
        if (historyStorage.hasKey(new_page))
 
48
            historyStorage.remove(new_page);
 
49
 
 
50
        historyStorage.put(new_page, cfg);
 
51
    }
 
52
}