forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap-slider.d.ts
207 lines (199 loc) · 6.44 KB
/
bootstrap-slider.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Type definitions for bootstrap-slider.js 4.8.3
// Project: https://github.com/seiyria/bootstrap-slider
// Definitions by: Daniel Beckwith <https://github.com/dbeckwith>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///<reference path="../jquery/jquery.d.ts"/>
interface SliderOptions {
/**
* Default: ''
* set the id of the slider element when it's created
*/
id?: string;
/**
* Default: 0
* minimum possible value
*/
min?: number;
/**
* Default: 10
* maximum possible value
*/
max?: number;
/**
* Default: 1
* increment step
*/
step?: number;
/**
* Default: number of digits after the decimal of step value
* The number of digits shown after the decimal. Defaults to the number of digits after the decimal of step value.
*/
precision?: number;
/**
* Default: 'horizontal'
* set the orientation. Accepts 'vertical' or 'horizontal'
*/
orientation?: number;
/**
* Default: 5
* initial value. Use array to have a range slider.
*/
value?: number|number[];
/**
* Default: false
* make range slider. Optional if initial value is an array. If initial value is scalar, max will be used for second value.
*/
range?: boolean;
/**
* Default: 'before'
* selection placement. Accepts: 'before', 'after' or 'none'. In case of a range slider, the selection will be placed between the handles
*/
selection?: string;
/**
* Default: 'show'
* whether to show the tooltip on drag, hide the tooltip, or always show the tooltip. Accepts: 'show', 'hide', or 'always'
*/
tooltip?: string;
/**
* Default: false
* if false show one tootip if true show two tooltips one for each handler
*/
tooltip_split?: boolean;
/**
* Default: 'round'
* handle shape. Accepts: 'round', 'square', 'triangle' or 'custom'
*/
handle?: string;
/**
* Default: false
* whether or not the slider should be reversed
*/
reversed?: boolean;
/**
* Default: true
* whether or not the slider is initially enabled
*/
enabled?: boolean;
/**
* Default: returns the plain value
* formatter callback. Return the value wanted to be displayed in the tooltip
* @param val the current value to display
*/
formatter?(val:number): string;
/**
* Default: false
* The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not. By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.
*/
natural_arrow_keys?: boolean;
/**
* Default: [ ]
* Used to define the values of ticks. Tick marks are indicators to denote special values in the range. This option overwrites min and max options.
*/
ticks?: number[];
/**
* Default: [ ]
* Defines the positions of the tick values in percentages. The first value should alwasy be 0, the last value should always be 100 percent.
*/
ticks_positions?: number[];
/**
* Default: [ ]
* Defines the labels below the tick marks. Accepts HTML input.
*/
ticks_labels?: string[];
/**
* Default: 0
* Used to define the snap bounds of a tick. Snaps to the tick if value is within these bounds.
*/
ticks_snap_bounds?: number;
/**
* Default: 'linear'
* Set to 'logarithmic' to use a logarithmic scale.
*/
scale?: string;
/**
* Default: false
* Focus the appropriate slider handle after a value change.
*/
focus?: boolean;
}
interface JQuery {
/**
* Creates a slider from the current element.
* @param options
*/
slider(options?:SliderOptions): JQuery;
slider(methodName:string, ...args:any[]): JQuery;
}
interface ChangeValue {
oldValue: number;
newValue: number;
}
interface JQueryEventObject {
value: number|ChangeValue;
}
interface SliderStatics {
new (selector: string, opts: SliderOptions): Slider;
prototype: Slider;
}
declare var Slider: SliderStatics;
/**
* This class is actually not used when using the jQuery version of bootstrap-slider
* The method documentation is still here thouh.
* When using jQuery, slider methods like setValue(3, true) have to be called like $slider.slider('setValue', 3, true)
*/
interface Slider extends JQuery {
/**
* Get the current value from the slider
*/
getValue(): number;
/**
* Set a new value for the slider. If optional triggerSlideEvent parameter is true, 'slide' events will be triggered. If optional triggerChangeEvent parameter is true, 'change' events will be triggered.
* @param newValue
* @param triggerSlideEvent
* @param triggerChangeEvent
*/
setValue(newValue:number, triggerSlideEvent?:boolean, triggerChangeEvent?:boolean): void;
/**
* Properly clean up and remove the slider instance
*/
destroy(): void;
/**
* Disables the slider and prevents the user from changing the value
*/
disable(): void;
/**
* Enables the slider
*/
enable(): void;
/**
* Returns true if enabled, false if disabled
*/
isEnabled(): boolean;
/**
* Updates the slider's attributes
* @param attribute
* @param value
*/
setAttribute(attribute:string, value:any): void;
/**
* Get the slider's attributes
* @param attribute
*/
getAttribute(attribute:string): any;
/**
* Refreshes the current slider
*/
refresh(): void;
/**
* Renders the tooltip again, after initialization. Useful in situations when the slider and tooltip are initially hidden.
*/
relayout(): void;
on: {
(eventType:string, callback:(eventObject:JQueryEventObject, ...args:any[]) => any): Slider;
(eventType:string, data:any, callback:(eventObject:JQueryEventObject, ...args:any[]) => any): Slider;
(eventType:string, selector:string, callback:(eventObject:JQueryEventObject, ...eventData:any[]) => any): Slider;
(eventType:string, selector:string, data:any, callback:(eventObject:JQueryEventObject, ...eventData:any[]) => any): Slider;
(eventType:{ [key: string]: any; }, selector?:string, data?:any): Slider;
(eventType:{ [key: string]: any; }, data?:any): Slider;
}
}