forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hasher.d.ts
116 lines (93 loc) · 4.36 KB
/
hasher.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Type definitions for Hasher.js
// Project: https://github.com/millermedeiros/hasher/
// Definitions by: flyfishMT <https://github.com/flyfishMT/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../js-signals/js-signals.d.ts" />
declare namespace HasherJs {
export interface HasherStatic {
// {string} hasher.appendHash
// String that should always be added to the end of Hash value.
appendHash(): string;
// default value: '';
// will be automatically removed from `hasher.getHash()`
// avoid conflicts with elements that contain ID equal to hash value;
// <static> {signals.Signal} hasher.changed
// Signal dispatched when hash value changes. - pass current hash as 1st parameter to listeners and previous hash value as 2nd parameter.
changed: Signal;
// <static> {signals.Signal} hasher.initialized
// Signal dispatched when hasher is initialized. - pass current hash as first parameter to listeners.
initialized: Signal;
// <static> {string} hasher.prependHash
// String that should always be added to the beginning of Hash value.
prependHash: string;
// default value: '/';
// will be automatically removed from `hasher.getHash()`
// avoid conflicts with elements that contain ID equal to hash value;
// <static> {string} hasher.separator
// String used to split hash paths; used by hasher.getHashAsArray() to split paths.
separator: string;
// default value: '/';
// <static> {signals.Signal} hasher.stopped
// Signal dispatched when hasher is stopped. - pass current hash as first parameter to listeners
stopped: Signal;
// <static> <constant> {string} hasher.VERSION
// hasher Version Number
VERSION: string;
// Method Detail
// <static> hasher.dispose()
// Removes all event listeners, stops hasher and destroy hasher object. - IMPORTANT: hasher won't work after calling this method, hasher Object will be deleted.
dispose(): void;
// <static> {string} hasher.getBaseURL()
// Returns:
// {string} Retrieve URL without query string and hash.
getBaseURL(): string;
// <static> {string} hasher.getHash()
// Returns:
// {string} Hash value without '#', `hasher.appendHash` and `hasher.prependHash`.
getHash(): string;
// <static> {Array.} hasher.getHashAsArray()
// Returns:
// {Array.} Hash value split into an Array.
getHashAsArray(): string[];
// <static> {string} hasher.getURL()
// Returns:
// {string} Full URL.
getURL(): string;
// <static> hasher.init()
// Start listening/dispatching changes in the hash/history.
init(): void;
// hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons before calling this method.
// <static> {boolean} hasher.isActive()
// Returns:
// {boolean} If hasher is listening to changes on the browser history and/or hash value.
isActive(): boolean;
// <static> hasher.replaceHash(path)
// Set Hash value without keeping previous hash on the history record. Similar to calling window.location.replace("#/hash") but will also work on IE6-7.
// hasher.replaceHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'
// Parameters:
// {...string} path
// Hash value without '#'. Hasher will join path segments using `hasher.separator` and prepend/append hash value with `hasher.appendHash` and `hasher.prependHash`
replaceHash(...path: string[]): void;
// <static> hasher.setHash(path)
// Set Hash value, generating a new history record.
// hasher.setHash('lorem', 'ipsum', 'dolor') -> '#/lorem/ipsum/dolor'
// Parameters:
// {...string} path
// Hash value without '#'. Hasher will join path segments using `hasher.separator` and prepend/append hash value with `hasher.appendHash` and `hasher.prependHash`
setHash(...path: string[]): void;
// <static> hasher.stop()
// Stop listening/dispatching changes in the hash/history.
// hasher won't dispatch CHANGE events by manually typing a new value or pressing the back/forward buttons after calling this method, unless you call hasher.init() again.
// hasher will still dispatch changes made programatically by calling hasher.setHash();
stop(): void;
// <static> {string} hasher.toString()
// Returns:
// {string} A string representation of the object.
toString(): string;
}
}
declare var hasher: HasherJs.HasherStatic;
// AMD
declare module 'hasher'{
export = hasher;
}