mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
History.js definitions and tests added
This commit is contained in:
parent
716a5a0c49
commit
9f07758e11
25
Definitions/history.d.ts
vendored
Normal file
25
Definitions/history.d.ts
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Type definitions for History.js
|
||||
// Project: https://github.com/balupton/History.js
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface HistoryAdapter {
|
||||
bind(element, event, callback);
|
||||
trigger(element, event);
|
||||
onDomLoad(callback);
|
||||
}
|
||||
|
||||
interface HistoryStatic {
|
||||
enabled: bool;
|
||||
pushState(data, title, url);
|
||||
replaceState(data, title, url);
|
||||
getState();
|
||||
getHash();
|
||||
Adapter: HistoryAdapter;
|
||||
back();
|
||||
forward();
|
||||
go(X);
|
||||
log(...messages: any[]);
|
||||
debug(...messages: any[]);
|
||||
}
|
||||
|
||||
declare var History: HistoryStatic;
|
||||
17
Tests/history-tests.ts
Normal file
17
Tests/history-tests.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path="../Definitions/history.d.ts" />
|
||||
|
||||
if (!History.enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
History.Adapter.bind(window, 'statechange', () => {
|
||||
var State = History.getState();
|
||||
History.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);
|
||||
Loading…
Reference in New Issue
Block a user