forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
typeahead.d.ts
1207 lines (1063 loc) · 61.9 KB
/
typeahead.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for typeahead.js 0.11.1
// Project: http://twitter.github.io/typeahead.js/
// Definitions by: Ivaylo Gochkov <https://github.com/igochkov/>, Gidon Junge <https://github.com/gjunge/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
interface JQuery {
/**
* For a given input[type="text"], enables typeahead functionality.
*
* @constructor
* @param options Options hash that's used for configuration
* @param datasets Array of datasets
*/
typeahead<T>(options: Twitter.Typeahead.Options, datasets: Twitter.Typeahead.Dataset<T>[]): JQuery;
/**
* For a given input[type="text"], enables typeahead functionality.
*
* @constructor
* @param options Options hash that's used for configuration
* @param dataset At least one dataset is required
* @param datasets Rest of the datasets.
*/
typeahead<T>(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset<T>, ...datasets: Twitter.Typeahead.Dataset<T>[]): JQuery;
/**
* Returns the current value of the typeahead.
* The value is the text the user has entered into the input element.
*
* @constructor
* @param methodName Method 'val'
*/
typeahead(methodName: 'val'): string;
/**
* Accommodates the val overload.
*
* @constructor
* @param methodName Method 'val'
*/
typeahead(methodName: string): string;
/**
* Sets the value of the typeahead. This should be used in place of jQuery#val.
*
* @constructor
* @param methodName Method 'val'
* @param val The value to be set
*/
typeahead(methodName: 'val', val: string): JQuery;
/**
* Accommodates the set val overload.
*
* @constructor
* @param methodName Method 'val'
* @param val The value to be set
*/
typeahead(methodName: string, val: string): JQuery;
/**
* Opens the suggestion menu.
*
* @constructor
* @param methodName Method 'open'
*/
typeahead(methodName: 'open'): JQuery;
/**
* Closes the suggestion menu.
*
* @constructor
* @param methodName Method 'close'
*/
typeahead(methodName: 'close'): JQuery;
/**
* Removes typeahead functionality and reverts the input element back to its original state.
*
* @constructor
* @param methodName Method 'destroy'
*/
typeahead(methodName: 'destroy'): JQuery;
/**
* Attach an event handler function for typeahead:active event to the selected elements.
*
* @param events typeahead:active event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:active", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:active event to the selected elements.
*
* @param events typeahead:active event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:active", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:active event to the selected elements.
*
* @param events typeahead:active event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:active", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:active event to the selected elements.
*
* @param events typeahead:active event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:active", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:idle event to the selected elements.
*
* @param events typeahead:idle event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:idle", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:idle event to the selected elements.
*
* @param events typeahead:idle event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:idle", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:idle event to the selected elements.
*
* @param events typeahead:idle event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:idle", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:idle event to the selected elements.
*
* @param events typeahead:idle event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:idle", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:open event to the selected elements.
*
* @param events typeahead:open event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:open", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:open event to the selected elements.
*
* @param events typeahead:open event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:open", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:open event to the selected elements.
*
* @param events typeahead:open event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:open", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:open event to the selected elements.
*
* @param events typeahead:open event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:open", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:close event to the selected elements.
*
* @param events typeahead:close event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:close", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:close event to the selected elements.
*
* @param events typeahead:close event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:close", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:close event to the selected elements.
*
* @param events typeahead:close event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:close", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:close event to the selected elements.
*
* @param events typeahead:close event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:close", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:change event to the selected elements.
*
* @param events typeahead:change event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:change", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:change event to the selected elements.
*
* @param events typeahead:change event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:change", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:change event to the selected elements.
*
* @param events typeahead:change event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:change", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:change event to the selected elements.
*
* @param events typeahead:change event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:change", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:render event to the selected elements.
*
* @param events typeahead:render event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:render", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:render event to the selected elements.
*
* @param events typeahead:render event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:render", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:render event to the selected elements.
*
* @param events typeahead:render event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:render", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:render event to the selected elements.
*
* @param events typeahead:render event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:render", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:select event to the selected elements.
*
* @param events typeahead:select event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:select", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:select event to the selected elements.
*
* @param events typeahead:select event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:select", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:select event to the selected elements.
*
* @param events typeahead:select event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:select", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:select event to the selected elements.
*
* @param events typeahead:select event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:select", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:autocomplete event to the selected elements.
*
* @param events typeahead:autocomplete event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:autocomplete", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:autocomplete event to the selected elements.
*
* @param events typeahead:autocomplete event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:autocomplete", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:autocomplete event to the selected elements.
*
* @param events typeahead:autocomplete event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:autocomplete", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:autocomplete event to the selected elements.
*
* @param events typeahead:autocomplete event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:autocomplete", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:cursorchange event to the selected elements.
*
* @param events typeahead:cursorchange event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:cursorchange", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:cursorchange event to the selected elements.
*
* @param events typeahead:cursorchange event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:cursorchange", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:cursorchange event to the selected elements.
*
* @param events typeahead:cursorchange event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:cursorchange", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:cursorchange event to the selected elements.
*
* @param events typeahead:cursorchange event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:cursorchange", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncrequest event to the selected elements.
*
* @param events typeahead:asyncrequest event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:asyncrequest", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncrequest event to the selected elements.
*
* @param events typeahead:asyncrequest event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncrequest", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncrequest event to the selected elements.
*
* @param events typeahead:asyncrequest event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncrequest", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncrequest event to the selected elements.
*
* @param events typeahead:asyncrequest event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncrequest", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asynccancel event to the selected elements.
*
* @param events typeahead:asynccancel event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:asynccancel", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asynccancel event to the selected elements.
*
* @param events typeahead:asynccancel event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asynccancel", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asynccancel event to the selected elements.
*
* @param events typeahead:asynccancel event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asynccancel", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asynccancel event to the selected elements.
*
* @param events typeahead:asynccancel event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asynccancel", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncreceive event to the selected elements.
*
* @param events typeahead:asyncreceive event fired when the typeahead moves to active state.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax).
*/
on(events: "typeahead:asyncreceive", handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncreceive event to the selected elements.
*
* @param events typeahead:asyncreceive event fired when the typeahead moves to active state.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncreceive", data: any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncreceive event to the selected elements.
*
* @param events typeahead:asyncreceive event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncreceive", selector: string, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Attach an event handler function for typeahead:asyncreceive event to the selected elements.
*
* @param events typeahead:asyncreceive event fired when the typeahead moves to active state.
* @param selector A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
* @param data Data to be passed to the handler in event.data when an event is triggered.
* @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
*/
on(events: "typeahead:asyncreceive", selector: string, data: any, handler: (eventObject: JQueryEventObject, ...eventData: any[]) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:active event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:active", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:active event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:active", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:idle event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:idle", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:idle event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:idle", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:open event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:open", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:open event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:open", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:close event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:close", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:close event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:close", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:change event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:change", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:change event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:change", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:render event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:render", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:render event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:render", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:select event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:select", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:select event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:select", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:autocomplete event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:autocomplete", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:autocomplete event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:autocomplete", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:cursorchange event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:cursorchange", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:cursorchange event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:cursorchange", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asyncrequest event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asyncrequest", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asyncrequest event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asyncrequest", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asynccancel event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asynccancel", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asynccancel event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asynccancel", handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asyncreceive event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asyncreceive", selector?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Remove an event handler.
*
* @param events typeahead:asyncreceive event.
* @param handler A handler function previously attached for the event(s), or the special value false.
*/
off(events: "typeahead:asyncreceive", handler: (eventObject: JQueryEventObject) => any): JQuery;
}
declare module Twitter.Typeahead {
interface Options {
/**
* If true, when suggestions are rendered, pattern matches for the current query in text nodes will be wrapped in a strong element with its class set to {{classNames.highlight}}.
* Defaults to false.
*/
highlight?: boolean;
/**
* If false, the typeahead will not show a hint.
* Defaults to true.
*/
hint?: boolean;
/**
* The minimum character length needed before suggestions start getting rendered.
* Defaults to 1.
*/
minLength?: number;
/**
* Used for overriding the default class names.
*/
classNames?: ClassNames;
}
/**
* A typeahead is composed of one or more datasets. When an end-user
* modifies the value of a typeahead, each dataset will attempt to render
* suggestions for the new value.
* For most use cases, one dataset should suffice. It's only in the scenario
* where you want rendered suggestions to be grouped based on some sort of
* categorical relationship that you'd need to use multiple datasets. For
* example, on twitter.com, the search typeahead groups results into recent
* searches, trends, and accounts that would be a great use case for using
* multiple datasets.
*/
interface Dataset<T> {
/**
* The backing data source for suggestions.
* Expected to be a function with the signature (query, syncResults, asyncResults).
* syncResults should be called with suggestions computed synchronously and
* asyncResults should be called with suggestions computed asynchronously
* (e.g. suggestions that come for an AJAX request).
* source can also be a Bloodhound instance.
*/
source: Bloodhound<T> | ((query: string, syncResults: (result: T[]) => void, asyncResults?: (result: T[]) => void) => void);
/**
* Lets the dataset know if async suggestions should be expected.
* If not set, this information is inferred from the signature of
* source i.e. if the source function expects 3 arguments, async will
* be set to true.
*/
async?: boolean;
/**
* The name of the dataset.
* This will be appended to {{classNames.dataset}} - to form the class name of the containing DOM element.
* Must only consist of underscores, dashes, letters (a-z), and numbers.
* Defaults to a random number.
*/
name?: string;
/**
* The max number of suggestions to be displayed. Defaults to 5.
*/
limit?: number;
/**
* For a given suggestion, determines the string representation of it.
* This will be used when setting the value of the input control after
* a suggestion is selected. Can be either a key string or a function
* that transforms a suggestion object into a string.
* Defaults to stringifying the suggestion.
*/
display?: string | ((obj: T) => string);
/**
* A hash of templates to be used when rendering the dataset. Note a
* precompiled template is a function that takes a JavaScript object as
* its first argument and returns a HTML string.
*/
templates?: Templates<T>;
}
/**
* A hash of templates to be used when rendering the dataset. Note a
* precompiled template is a function that takes a JavaScript object as
* its first argument and returns a HTML string.
*/
interface Templates<T> {
/**
* Rendered when 0 suggestions are available for the given query.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query.
*/
notFound?: string | ((query: string) => string);
/**
* Rendered when 0 synchronous suggestions are available but asynchronous suggestions are expected.
* Can be either a HTML string or a precompiled template.
* If it's a precompiled template, the passed in context will contain query.
*/
pending?: string | ((query: string) => string);
/**
* Rendered at the top of the dataset when suggestions are present. Can be either a HTML string or
* a precompiled template. If it's a precompiled template, the passed in context will contain
* query and suggestions.
*/
header?: string | ((query: string, suggestions: T[]) => string);
/**
* Rendered at the bottom of the dataset when suggestions are present. Can be either a HTML string or
* a precompiled template. If it's a precompiled template, the passed in context will contain
* query and suggestions.
*/
footer?: string | ((query: string, suggestions: T[]) => string);
/**
* Used to render a single suggestion. If set, this has to be a precompiled template.
* The associated suggestion object will serve as the context.
* Defaults to the value of display wrapped in a div tag i.e. <div>{{value}}</div>.
*/
suggestion?: (suggestion: T) => string;
}
/**
* Used for overriding the default class names.
*/
interface ClassNames {
/**
* Added to input that's initialized into a typeahead. Defaults to tt-input.
*/
input?: string;
/**
* Added to hint input.Defaults to tt- hint.
*/
hint?: string;
/**
* Added to menu element.Defaults to tt- menu.
*/
menu?: string;
/**
* Added to dataset elements.to Defaults to tt- dataset.
*/
dataset?: string;
/**
* Added to suggestion elements.Defaults to tt- suggestion.
*/
suggestion?: string;
/**
* Added to menu element when it contains no content.Defaults to tt- empty.
*/
empty?: string;
/**
* Added to menu element when it is opened.Defaults to tt- open.
*/
open?: string;
/**
* Added to suggestion element when menu cursor moves to said suggestion.Defaults to tt- cursor.
*/
cursor?: string;
/**
* Added to the element that wraps highlighted text.Defaults to tt- highlight.
*/
highlight?: string;
}
}
declare module Bloodhound {
interface BloodhoundOptions<T> {
/**
* Transforms a datum into an array of string tokens.
*
* @param datum Suggestion.
* @returns An array of string tokens.
*/
datumTokenizer: (datum: T) => string[];
/**
* Transforms a query into an array of string tokens.
*
* @param quiery Query.
* @returns An array of string tokens.
*/
queryTokenizer: (query: string) => string[];
/**
* If set to false, the Bloodhound instance will not be implicitly
* initialized by the constructor function. Defaults to true.
*/
initialize?: boolean;
/**
* Given a datum, returns a unique id for it.
* Defaults to JSON.stringify. Note that it is highly recommended
* to override this option.
*
* @param datum Suggestion.
* @returns Unique id for the suggestion.
*/
identify?: (datum: T) => number;
/**
* If the number of datums provided from the internal search index is
* less than sufficient, remote will be used to backfill search
* requests triggered by calling #search. Defaults to 5.
*/
sufficient?: number;
/**
* A compare function used to sort data returned from the internal search index.
*
* @param a First suggestion.
* @param b Second suggestion.
* @returns Comparison result.
*/
sorter?: (a: T, b: T) => number;
/**
* An array of data or a function that returns an array of data.
* The data will be added to the internal search index when #initialize is called.
*/
local?: T[] | (() => T[]);
/**
* Can be a URL to a JSON file containing an array of data or,
* if more configurability is needed, a prefetch options hash.
*/
prefetch?: string | PrefetchOptions<T>;
/**
* Can be a URL to fetch data from when the data provided by the internal
* search index is insufficient or, if more configurability is needed,
* a remote options hash.
*/
remote?: string | RemoteOptions<T>;
}
/**
* Prefetched data is fetched and processed on initialization. If the browser
* supports local storage, the processed data will be cached there to prevent
* additional network requests on subsequent page loads.
*
* WARNING: While it's possible to get away with it for smaller data sets,
* prefetched data isn't meant to contain entire sets of data. Rather, it should
* act as a first-level cache. Ignoring this warning means you'll run the risk
* of hitting local storage limits.
*/
interface PrefetchOptions<T> {
/**
* The URL prefetch data should be loaded from.
*/
url: string;
/**
* If false, will not attempt to read or write to local storage and
* will always load prefetch data from url on initialization. Defaults to true.
*/
cache?: boolean;
/**
* The time (in milliseconds) the prefetched data should be cached in
* local storage. Defaults to 86400000 (1 day).
*/
ttl?: number;
/**
* The key that data will be stored in local storage under.
* Defaults to value of url.
*/
cacheKey?: string;
/**
* A string used for thumbprinting prefetched data. If this doesn't
* match what's stored in local storage, the data will be refetched.
*/
thumbprint?: string;
/**