Fix History.js definitions and tests

This commit is contained in:
Boris Yankov
2013-05-25 18:35:52 +03:00
parent 3f0b158c4c
commit 85f1e0c358
2 changed files with 19 additions and 15 deletions

View File

@@ -1,17 +1,19 @@
/// <reference path="history.d.ts" />
if (!History.enabled) {
return false;
}
function tests() {
if (!Historyjs.enabled) {
return false;
}
History.Adapter.bind(window, 'statechange', () => {
var State = History.getState();
History.log(State.data, State.title, State.url);
});
Historyjs.Adapter.bind(window, 'statechange', () => {
var State = Historyjs.getState();
Historyjs.log(State.data, State.title, State.url);
});
History.pushState({ state: 1 }, "State 1", "?state=1");
History.pushState({ state: 2 }, "State 2", "?state=2");
History.replaceState({ state: 3 }, "State 3", "?state=3");
History.pushState(null, null, "?state=4");
History.back();
History.go(2);
Historyjs.pushState({ state: 1 }, "State 1", "?state=1");
Historyjs.pushState({ state: 2 }, "State 2", "?state=2");
Historyjs.replaceState({ state: 3 }, "State 3", "?state=3");
Historyjs.pushState(null, null, "?state=4");
Historyjs.back();
Historyjs.go(2);
}

View File

@@ -10,7 +10,7 @@ interface HistoryAdapter {
onDomLoad(callback);
}
interface History {
interface Historyjs {
enabled: bool;
pushState(data, title, url);
replaceState(data, title, url);
@@ -22,4 +22,6 @@ interface History {
go(X);
log(...messages: any[]);
debug(...messages: any[]);
}
}
declare var Historyjs: Historyjs;