-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.d.ts
1647 lines (1435 loc) · 73.5 KB
/
jquery.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
/* *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
// Typing for the jQuery library, version 1.10.x / 2.0.x
// Project: http://jquery.com/
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Christian Hoffmeister <https://github.com/choffmeister>, Steve Fenton, Diullei Gomes <https://github.com/Diullei>, Tass Iliopoulos <https://github.com/tasoili>, Jason Swearingen, Sean Hill <https://github.com/seanski>, Guus Goossens <https://github.com/Guuz>, Kelly Summerlin <https://github.com/ksummerlin>, Basarat Ali Syed <https://github.com/basarat>, Nicholas Wolverson <https://github.com/nwolverson>, Derek Cicerone <https://github.com/derekcicerone>, Andrew Gaspar <https://github.com/AndrewGaspar>, James Harrison Fisher <https://github.com/jameshfisher>, Seikichi Kondo <https://github.com/seikichi>, Benjamin Jackman <https://github.com/benjaminjackman>, Poul Sorensen <https://github.com/s093294>, Josh Strobl <https://github.com/JoshStrobl>, John Reilly <https://github.com/johnnyreilly/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/*
Interface for the AJAX setting that will configure the AJAX request
*/
interface JQueryAjaxSettings {
/**
* The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method.
*/
accepts?: any;
/**
* By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().
*/
async?: boolean;
/**
* A pre-request callback function that can be used to modify the jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object before it is sent. Use this to set custom headers, etc. The jqXHR and settings objects are passed as arguments. This is an Ajax Event. Returning false in the beforeSend function will cancel the request. As of jQuery 1.5, the beforeSend option will be called regardless of the type of request.
*/
beforeSend? (jqXHR: JQueryXHR, settings: JQueryAjaxSettings): any;
/**
* If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.
*/
cache?: boolean;
/**
* A function to be called when the request finishes (after success and error callbacks are executed). The function gets passed two arguments: The jqXHR (in jQuery 1.4.x, XMLHTTPRequest) object and a string categorizing the status of the request ("success", "notmodified", "error", "timeout", "abort", or "parsererror"). As of jQuery 1.5, the complete setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
*/
complete? (jqXHR: JQueryXHR, textStatus: string): any;
/**
* An object of string/regular-expression pairs that determine how jQuery will parse the response, given its content type. (version added: 1.5)
*/
contents?: { [key: string]: any; };
//According to jQuery.ajax source code, ajax's option actually allows contentType to set to "false"
// https://github.com/borisyankov/DefinitelyTyped/issues/742
/**
* When sending data to the server, use this content type. Default is "application/x-www-form-urlencoded; charset=UTF-8", which is fine for most cases. If you explicitly pass in a content-type to $.ajax(), then it is always sent to the server (even if no data is sent). The W3C XMLHttpRequest specification dictates that the charset is always UTF-8; specifying another charset will not force the browser to change the encoding.
*/
contentType?: any;
/**
* This object will be made the context of all Ajax-related callbacks. By default, the context is an object that represents the ajax settings used in the call ($.ajaxSettings merged with the settings passed to $.ajax).
*/
context?: any;
/**
* An object containing dataType-to-dataType converters. Each converter's value is a function that returns the transformed value of the response. (version added: 1.5)
*/
converters?: { [key: string]: any; };
/**
* If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. (version added: 1.5)
*/
crossDomain?: boolean;
/**
* Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing. Object must be Key/Value pairs. If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).
*/
data?: any;
/**
* A function to be used to handle the raw response data of XMLHttpRequest.This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the 'dataType' parameter.
*/
dataFilter? (data: any, ty: any): any;
/**
* The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string).
*/
dataType?: string;
/**
* A function to be called if the request fails. The function receives three arguments: The jqXHR (in jQuery 1.4.x, XMLHttpRequest) object, a string describing the type of error that occurred and an optional exception object, if one occurred. Possible values for the second argument (besides null) are "timeout", "error", "abort", and "parsererror". When an HTTP error occurs, errorThrown receives the textual portion of the HTTP status, such as "Not Found" or "Internal Server Error." As of jQuery 1.5, the error setting can accept an array of functions. Each function will be called in turn. Note: This handler is not called for cross-domain script and cross-domain JSONP requests. This is an Ajax Event.
*/
error? (jqXHR: JQueryXHR, textStatus: string, errorThrow: string): any;
/**
* Whether to trigger global Ajax event handlers for this request. The default is true. Set to false to prevent the global handlers like ajaxStart or ajaxStop from being triggered. This can be used to control various Ajax Events.
*/
global?: boolean;
/**
* An object of additional header key/value pairs to send along with requests using the XMLHttpRequest transport. The header X-Requested-With: XMLHttpRequest is always added, but its default XMLHttpRequest value can be changed here. Values in the headers setting can also be overwritten from within the beforeSend function. (version added: 1.5)
*/
headers?: { [key: string]: any; };
/**
* Allow the request to be successful only if the response has changed since the last request. This is done by checking the Last-Modified header. Default value is false, ignoring the header. In jQuery 1.4 this technique also checks the 'etag' specified by the server to catch unmodified data.
*/
ifModified?: boolean;
/**
* Allow the current environment to be recognized as "local," (e.g. the filesystem), even if jQuery does not recognize it as such by default. The following protocols are currently recognized as local: file, *-extension, and widget. If the isLocal setting needs modification, it is recommended to do so once in the $.ajaxSetup() method. (version added: 1.5.1)
*/
isLocal?: boolean;
/**
* Override the callback function name in a jsonp request. This value will be used instead of 'callback' in the 'callback=?' part of the query string in the url. So {jsonp:'onJSONPLoad'} would result in 'onJSONPLoad=?' passed to the server. As of jQuery 1.5, setting the jsonp option to false prevents jQuery from adding the "?callback" string to the URL or attempting to use "=?" for transformation. In this case, you should also explicitly set the jsonpCallback setting. For example, { jsonp: false, jsonpCallback: "callbackName" }
*/
jsonp?: string;
/**
* Specify the callback function name for a JSONP request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests. As of jQuery 1.5, you can also use a function for this setting, in which case the value of jsonpCallback is set to the return value of that function.
*/
jsonpCallback?: any;
/**
* A mime type to override the XHR mime type. (version added: 1.5.1)
*/
mimeType?: string;
/**
* A password to be used with XMLHttpRequest in response to an HTTP access authentication request.
*/
password?: string;
/**
* By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.
*/
processData?: boolean;
/**
* Only applies when the "script" transport is used (e.g., cross-domain requests with "jsonp" or "script" dataType and "GET" type). Sets the charset attribute on the script tag used in the request. Used when the character set on the local page is not the same as the one on the remote script.
*/
scriptCharset?: string;
/**
* An object of numeric HTTP codes and functions to be called when the response has the corresponding code. f the request is successful, the status code functions take the same parameters as the success callback; if it results in an error (including 3xx redirect), they take the same parameters as the error callback. (version added: 1.5)
*/
statusCode?: { [key: string]: any; };
/**
* A function to be called if the request succeeds. The function gets passed three arguments: The data returned from the server, formatted according to the dataType parameter; a string describing the status; and the jqXHR (in jQuery 1.4.x, XMLHttpRequest) object. As of jQuery 1.5, the success setting can accept an array of functions. Each function will be called in turn. This is an Ajax Event.
*/
success? (data: any, textStatus: string, jqXHR: JQueryXHR): any;
/**
* Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.
*/
timeout?: number;
/**
* Set this to true if you wish to use the traditional style of param serialization.
*/
traditional?: boolean;
/**
* The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
*/
type?: string;
/**
* A string containing the URL to which the request is sent.
*/
url?: string;
/**
* A username to be used with XMLHttpRequest in response to an HTTP access authentication request.
*/
username?: string;
/**
* Callback for creating the XMLHttpRequest object. Defaults to the ActiveXObject when available (IE), the XMLHttpRequest otherwise. Override to provide your own implementation for XMLHttpRequest or enhancements to the factory.
*/
xhr?: any;
/**
* An object of fieldName-fieldValue pairs to set on the native XHR object. For example, you can use it to set withCredentials to true for cross-domain requests if needed. In jQuery 1.5, the withCredentials property was not propagated to the native XHR and thus CORS requests requiring it would ignore this flag. For this reason, we recommend using jQuery 1.5.1+ should you require the use of it. (version added: 1.5.1)
*/
xhrFields?: { [key: string]: any; };
}
/*
Interface for the jqXHR object
*/
interface JQueryXHR extends XMLHttpRequest, JQueryPromise<any> {
overrideMimeType(mimeType: string): any;
abort(statusText?: string): void;
}
/*
Interface for the JQuery callback
*/
interface JQueryCallback {
add(...callbacks: any[]): any;
disable(): any;
empty(): any;
fire(...arguments: any[]): any;
fired(): boolean;
fireWith(context: any, ...args: any[]): any;
has(callback: any): boolean;
lock(): any;
locked(): boolean;
remove(...callbacks: any[]): any;
}
/*
Allows jQuery Promises to interop with non-jQuery promises
*/
interface JQueryGenericPromise<T> {
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => U): JQueryGenericPromise<U>;
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (reason: any) => U): JQueryGenericPromise<U>;
then<U>(onFulfill: (value: T) => U, onReject?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (reason: any) => JQueryGenericPromise<U>): JQueryGenericPromise<U>;
}
/*
Interface for the JQuery promise, part of callbacks
*/
interface JQueryPromise<T> {
// Generic versions of callbacks
always(...alwaysCallbacks: T[]): JQueryPromise<T>;
done(...doneCallbacks: T[]): JQueryPromise<T>;
fail(...failCallbacks: T[]): JQueryPromise<T>;
progress(...progressCallbacks: T[]): JQueryPromise<T>;
always(...alwaysCallbacks: any[]): JQueryPromise<T>;
done(...doneCallbacks: any[]): JQueryPromise<T>;
fail(...failCallbacks: any[]): JQueryPromise<T>;
progress(...progressCallbacks: any[]): JQueryPromise<T>;
// Deprecated - given no typings
pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise<any>;
then<U>(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (value: T) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (value: T) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
// Because JQuery Promises Suck
then<U>(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (...values: any[]) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => U, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (...values: any[]) => U, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
then<U>(onFulfill: (...values: any[]) => JQueryGenericPromise<U>, onReject?: (...reasons: any[]) => JQueryGenericPromise<U>, onProgress?: (...progression: any[]) => any): JQueryPromise<U>;
}
/*
Interface for the JQuery deferred, part of callbacks
*/
interface JQueryDeferred<T> extends JQueryPromise<T> {
// Generic versions of callbacks
always(...alwaysCallbacks: T[]): JQueryDeferred<T>;
done(...doneCallbacks: T[]): JQueryDeferred<T>;
fail(...failCallbacks: T[]): JQueryDeferred<T>;
progress(...progressCallbacks: T[]): JQueryDeferred<T>;
always(...alwaysCallbacks: any[]): JQueryDeferred<T>;
done(...doneCallbacks: any[]): JQueryDeferred<T>;
fail(...failCallbacks: any[]): JQueryDeferred<T>;
progress(...progressCallbacks: any[]): JQueryDeferred<T>;
notify(...args: any[]): JQueryDeferred<T>;
notifyWith(context: any, ...args: any[]): JQueryDeferred<T>;
reject(...args: any[]): JQueryDeferred<T>;
rejectWith(context: any, ...args: any[]): JQueryDeferred<T>;
resolve(val: T): JQueryDeferred<T>;
resolve(...args: any[]): JQueryDeferred<T>;
resolveWith(context: any, ...args: any[]): JQueryDeferred<T>;
state(): string;
promise(target?: any): JQueryPromise<T>;
}
/*
Interface of the JQuery extension of the W3C event object
*/
interface BaseJQueryEventObject extends Event {
data: any;
delegateTarget: Element;
isDefaultPrevented(): boolean;
isImmediatePropogationStopped(): boolean;
isPropagationStopped(): boolean;
namespace: string;
preventDefault(): any;
relatedTarget: Element;
result: any;
stopImmediatePropagation(): void;
stopPropagation(): void;
pageX: number;
pageY: number;
which: number;
metaKey: boolean;
}
interface JQueryInputEventObject extends BaseJQueryEventObject {
altKey: boolean;
ctrlKey: boolean;
metaKey: boolean;
shiftKey: boolean;
}
interface JQueryMouseEventObject extends JQueryInputEventObject {
button: number;
clientX: number;
clientY: number;
offsetX: number;
offsetY: number;
pageX: number;
pageY: number;
screenX: number;
screenY: number;
}
interface JQueryKeyEventObject extends JQueryInputEventObject {
char: any;
charCode: number;
key: any;
keyCode: number;
}
interface JQueryPopStateEventObject extends BaseJQueryEventObject {
originalEvent: PopStateEvent;
}
interface JQueryEventObject extends BaseJQueryEventObject, JQueryInputEventObject, JQueryMouseEventObject, JQueryKeyEventObject, JQueryPopStateEventObject {
}
/*
Collection of properties of the current browser
*/
interface JQuerySupport {
ajax?: boolean;
boxModel?: boolean;
changeBubbles?: boolean;
checkClone?: boolean;
checkOn?: boolean;
cors?: boolean;
cssFloat?: boolean;
hrefNormalized?: boolean;
htmlSerialize?: boolean;
leadingWhitespace?: boolean;
noCloneChecked?: boolean;
noCloneEvent?: boolean;
opacity?: boolean;
optDisabled?: boolean;
optSelected?: boolean;
scriptEval? (): boolean;
style?: boolean;
submitBubbles?: boolean;
tbody?: boolean;
}
interface JQueryParam {
(obj: any): string;
(obj: any, traditional: boolean): string;
}
/**
* The interface used to construct jQuery events (with $.Event). It is
* defined separately instead of inline in JQueryStatic to allow
* overriding the construction function with specific strings
* returning specific event objects.
*/
interface JQueryEventConstructor {
(name: string, eventProperties?: any): JQueryEventObject;
new (name: string, eventProperties?: any): JQueryEventObject;
}
/**
* The interface used to specify easing functions.
*/
interface JQueryEasing {
linear(p: number): number;
swing(p: number): number;
}
/*
Static members of jQuery (those on $ and jQuery themselves)
*/
interface JQueryStatic {
/**
* Perform an asynchronous HTTP (Ajax) request.
*
* @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
*/
ajax(settings: JQueryAjaxSettings): JQueryXHR;
/**
* Perform an asynchronous HTTP (Ajax) request.
*
* @param url A string containing the URL to which the request is sent.
* @param settings A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with $.ajaxSetup().
*/
ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
/**
* Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
*
* @param dataTypes An optional string containing one or more space-separated dataTypes
* @param handler A handler to set default values for future Ajax requests.
*/
ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
/**
* Handle custom Ajax options or modify existing options before each request is sent and before they are processed by $.ajax().
*
* @param handler A handler to set default values for future Ajax requests.
*/
ajaxPrefilter(handler: (opts: any, originalOpts: JQueryAjaxSettings, jqXHR: JQueryXHR) => any): void;
ajaxSettings: JQueryAjaxSettings;
/**
* Set default values for future Ajax requests. Its use is not recommended.
*
* @param options A set of key/value pairs that configure the default Ajax request. All options are optional.
*/
ajaxSetup(options: JQueryAjaxSettings): void;
/**
* Load data from the server using a HTTP GET request.
*
* @param url A string containing the URL to which the request is sent.
* @param success A callback function that is executed if the request succeeds.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
*/
get(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* Load data from the server using a HTTP GET request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
*/
get(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* Load data from the server using a HTTP GET request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
*/
get(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* Load JSON-encoded data from the server using a GET HTTP request.
*
* @param url A string containing the URL to which the request is sent.
* @param success A callback function that is executed if the request succeeds.
*/
getJSON(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
/**
* Load JSON-encoded data from the server using a GET HTTP request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds.
*/
getJSON(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
/**
* Load JSON-encoded data from the server using a GET HTTP request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds.
*/
getJSON(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
/**
* Load a JavaScript file from the server using a GET HTTP request, then execute it.
*
* @param url A string containing the URL to which the request is sent.
* @param success A callback function that is executed if the request succeeds.
*/
getScript(url: string, success?: (script: string, textStatus: string, jqXHR: JQueryXHR) => any): JQueryXHR;
param: JQueryParam;
/**
* Load data from the server using a HTTP POST request.
*
* @param url A string containing the URL to which the request is sent.
* @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
*/
post(url: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* Load data from the server using a HTTP POST request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
*/
post(url: string, data?: Object, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* Load data from the server using a HTTP POST request.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param success A callback function that is executed if the request succeeds. Required if dataType is provided, but can be null in that case.
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
*/
post(url: string, data?: string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
/**
* A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
*
* @param flags An optional list of space-separated flags that change how the callback list behaves.
*/
Callbacks(flags?: string): JQueryCallback;
/**
* Holds or releases the execution of jQuery's ready event.
*
* @param hold Indicates whether the ready hold is being requested or released
*/
holdReady(hold: boolean): void;
(selector: string, context?: any): JQuery;
(element: Element): JQuery;
(object: {}): JQuery;
(elementArray: Element[]): JQuery;
(object: JQuery): JQuery;
(func: Function): JQuery;
(array: any[]): JQuery;
(): JQuery;
/**
* Relinquish jQuery's control of the $ variable.
*
* @param removeAll A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself).
*/
noConflict(removeAll?: boolean): Object;
/**
* Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
*
* @param deferreds One or more Deferred objects, or plain JavaScript objects.
*/
when<T>(...deferreds: JQueryGenericPromise<T>[]): JQueryPromise<T>;
/**
* Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
*
* @param deferreds One or more Deferred objects, or plain JavaScript objects.
*/
when<T>(...deferreds: T[]): JQueryPromise<T>;
/**
* Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.
*
* @param deferreds One or more Deferred objects, or plain JavaScript objects.
*/
when<T>(...deferreds: any[]): JQueryPromise<T>;
cssHooks: { [key: string]: any; };
cssNumber: any;
/**
* Store arbitrary data associated with the specified element. Returns the value that was set.
*
* @param element The DOM element to associate with the data.
* @param key A string naming the piece of data to set.
* @param value The new data value.
*/
data<T>(element: Element, key: string, value: T): T;
/**
* Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
*
* @param element The DOM element to associate with the data.
* @param key A string naming the piece of data to set.
*/
data(element: Element, key: string): any;
/**
* Returns value at named data store for the element, as set by jQuery.data(element, name, value), or the full data store for the element.
*
* @param element The DOM element to associate with the data.
*/
data(element: Element): any;
dequeue(element: Element, queueName?: string): any;
hasData(element: Element): boolean;
queue(element: Element, queueName?: string): any[];
queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery;
removeData(element: Element, name?: string): JQuery;
// Deferred
Deferred<T>(beforeStart?: (deferred: JQueryDeferred<T>) => any): JQueryDeferred<T>;
// Effects
fx: { tick: () => void; interval: number; stop: () => void; speeds: { slow: number; fast: number; }; off: boolean; step: any; };
// Events
proxy(fn: (...args: any[]) => any, context: any, ...args: any[]): any;
proxy(context: any, name: string, ...args: any[]): any;
Event: JQueryEventConstructor;
// Internals
error(message: any): JQuery;
// Miscellaneous
expr: any;
fn: any; //TODO: Decide how we want to type this
isReady: boolean;
// Properties
support: JQuerySupport;
// Utilities
contains(container: Element, contained: Element): boolean;
each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any;
each(collection: JQuery, callback: (indexInArray: number, valueOfElement: HTMLElement) => any): any;
each<T>(collection: T[], callback: (indexInArray: number, valueOfElement: T) => any): any;
extend(target: any, ...objs: any[]): any;
extend(deep: boolean, target: any, ...objs: any[]): any;
globalEval(code: string): any;
grep<T>(array: T[], func: (elementOfArray: T, indexInArray: number) => boolean, invert?: boolean): T[];
inArray<T>(value: T, array: T[], fromIndex?: number): number;
isArray(obj: any): boolean;
isEmptyObject(obj: any): boolean;
isFunction(obj: any): boolean;
isNumeric(value: any): boolean;
isPlainObject(obj: any): boolean;
isWindow(obj: any): boolean;
isXMLDoc(node: Node): boolean;
makeArray(obj: any): any[];
map<T, U>(array: T[], callback: (elementOfArray: T, indexInArray: number) => U): U[];
map(array: any, callback: (elementOfArray: any, indexInArray: any) => any): any;
merge<T>(first: T[], second: T[]): T[];
merge<T,U>(first: T[], second: U[]): any[];
noop(): any;
now(): number;
parseJSON(json: string): any;
/**
* Parses a string into an XML document.
*
* @param dataa well-formed XML string to be parsed
*/
parseXML(data: string): XMLDocument;
queue(element: Element, queueName: string, newQueue: any[]): JQuery;
trim(str: string): string;
type(obj: any): string;
unique(arr: any[]): any[];
/**
* Parses a string into an array of DOM nodes.
*
* @param data HTML string to be parsed
* @param context DOM element to serve as the context in which the HTML fragment will be created
* @param keepScripts A Boolean indicating whether to include scripts passed in the HTML string
*/
parseHTML(data: string, context?: HTMLElement, keepScripts?: boolean): any[];
Animation(elem: any, properties: any, options: any): any;
easing: JQueryEasing;
}
/**
* The jQuery instance members
*/
interface JQuery {
/**
* Register a handler to be called when Ajax requests complete. This is an AjaxEvent.
*
* @param handler The function to be invoked.
*/
ajaxComplete(handler: (event: any, XMLHttpRequest: XMLHttpRequest, ajaxOptions: any) => any): JQuery;
ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
ajaxStart(handler: () => any): JQuery;
ajaxStop(handler: () => any): JQuery;
ajaxSuccess(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
/**
* Load data from the server and place the returned HTML into the matched element.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param complete A callback function that is executed when the request completes.
*/
load(url: string, data?: string, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery;
/**
* Load data from the server and place the returned HTML into the matched element.
*
* @param url A string containing the URL to which the request is sent.
* @param data A plain object or string that is sent to the server with the request.
* @param complete A callback function that is executed when the request completes.
*/
load(url: string, data?: Object, complete?: (responseText: string, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any): JQuery;
/**
* Encode a set of form elements as a string for submission.
*/
serialize(): string;
/**
* Encode a set of form elements as an array of names and values.
*/
serializeArray(): Object[];
/**
* Adds the specified class(es) to each of the set of matched elements.
*
* @param className One or more space-separated classes to be added to the class attribute of each matched element.
*/
addClass(className: string): JQuery;
/**
* Adds the specified class(es) to each of the set of matched elements.
*
* @param function A function returning one or more space-separated class names to be added to the existing class name(s). Receives the index position of the element in the set and the existing class name(s) as arguments. Within the function, this refers to the current element in the set.
*/
addClass(func: (index: number, className: string) => string): JQuery;
/**
* Add the previous set of elements on the stack to the current set, optionally filtered by a selector.
*/
addBack(selector?: string): JQuery;
/**
* Get the value of an attribute for the first element in the set of matched elements.
*
* @param attributeName The name of the attribute to get.
*/
attr(attributeName: string): string;
/**
* Set one or more attributes for the set of matched elements.
*
* @param attributeName The name of the attribute to set.
* @param value A value to set for the attribute.
*/
attr(attributeName: string, value: string): JQuery;
/**
* Set one or more attributes for the set of matched elements.
*
* @param attributeName The name of the attribute to set.
* @param value A value to set for the attribute.
*/
attr(attributeName: string, value: number): JQuery;
/**
* Set one or more attributes for the set of matched elements.
*
* @param attributeName The name of the attribute to set.
* @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old attribute value as arguments.
*/
attr(attributeName: string, func: (index: number, attr: any) => any): JQuery;
/**
* Set one or more attributes for the set of matched elements.
*
* @param attributes An object of attribute-value pairs to set.
*/
attr(attributes: Object): JQuery;
/**
* Determine whether any of the matched elements are assigned the given class.
*
* @param className The class name to search for.
*/
hasClass(className: string): boolean;
html(): string;
html(htmlString: string): JQuery;
html(htmlContent: (index: number, oldhtml: string) => string): JQuery;
html(obj: JQuery): JQuery;
prop(propertyName: string): any;
prop(propertyName: string, value: any): JQuery;
prop(map: any): JQuery;
prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery;
/**
* Remove an attribute from each element in the set of matched elements.
*
* @param attributeName An attribute to remove; as of version 1.7, it can be a space-separated list of attributes.
*/
removeAttr(attributeName: string): JQuery;
/**
* Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
*
* @param className One or more space-separated classes to be removed from the class attribute of each matched element.
*/
removeClass(className?: string): JQuery;
/**
* Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
*
* @param function A function returning one or more space-separated class names to be removed. Receives the index position of the element in the set and the old class value as arguments.
*/
removeClass(func: (index: number, className: string) => string): JQuery;
removeProp(propertyName: string): JQuery;
/**
* Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
*
* @param className One or more class names (separated by spaces) to be toggled for each element in the matched set.
* @param swtch A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.
*/
toggleClass(className: string, swtch?: boolean): JQuery;
/**
* Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
*
* @param swtch A boolean value to determine whether the class should be added or removed.
*/
toggleClass(swtch?: boolean): JQuery;
/**
* Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the switch argument.
*
* @param func A function that returns class names to be toggled in the class attribute of each element in the matched set. Receives the index position of the element in the set, the old class value, and the switch as arguments.
* @param swtch A boolean value to determine whether the class should be added or removed.
*/
toggleClass(func: (index: number, className: string, swtch: boolean) => string, swtch?: boolean): JQuery;
val(): any;
val(value: string[]): JQuery;
val(value: string): JQuery;
val(value: number): JQuery;
val(func: (index: any, value: any) => any): JQuery;
/**
* Get the value of style properties for the first element in the set of matched elements.
*
* @param propertyName A CSS property.
*/
css(propertyName: string): string;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A value to set for the property.
*/
css(propertyName: string, value: string): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A value to set for the property.
*/
css(propertyName: string, value: number): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A value to set for the property.
*/
css(propertyName: string, value: string[]): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A value to set for the property.
*/
css(propertyName: string, value: number[]): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
*/
css(propertyName: string, value: (index: number, value: string) => string): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param propertyName A CSS property name.
* @param value A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments.
*/
css(propertyName: string, value: (index: number, value: number) => number): JQuery;
/**
* Set one or more CSS properties for the set of matched elements.
*
* @param properties An object of property-value pairs to set.
*/
css(properties: Object): JQuery;
height(): number;
height(value: number): JQuery;
height(value: string): JQuery;
height(func: (index: any, height: any) => any): JQuery;
innerHeight(): number;
innerHeight(value: number): JQuery;
innerWidth(): number;
innerWidth(value: number): JQuery;
offset(): { left: number; top: number; };
offset(coordinates: any): JQuery;
offset(func: (index: any, coords: any) => any): JQuery;
outerHeight(includeMargin?: boolean): number;
outerHeight(value: number, includeMargin?: boolean): JQuery;
outerWidth(includeMargin?: boolean): number;
outerWidth(value: number, includeMargin?: boolean): JQuery;
position(): { top: number; left: number; };
scrollLeft(): number;
scrollLeft(value: number): JQuery;
scrollTop(): number;
scrollTop(value: number): JQuery;
width(): number;
width(value: number): JQuery;
width(value: string): JQuery;
width(func: (index: any, height: any) => any): JQuery;
// Data
clearQueue(queueName?: string): JQuery;
data(key: string, value: any): JQuery;
data(obj: { [key: string]: any; }): JQuery;
data(key?: string): any;
dequeue(queueName?: string): JQuery;
removeData(nameOrList?: any): JQuery;
// Deferred
promise(type?: any, target?: any): JQueryPromise<any>;
// Effects
animate(properties: any, duration?: any, complete?: Function): JQuery;
animate(properties: any, duration?: any, easing?: string, complete?: Function): JQuery;
animate(properties: any, options: { duration?: any; easing?: string; complete?: Function; step?: Function; queue?: boolean; specialEasing?: any; }): JQuery;
delay(duration: number, queueName?: string): JQuery;
fadeIn(duration?: any, callback?: any): JQuery;
fadeIn(duration?: any, easing?: string, callback?: any): JQuery;
fadeOut(duration?: any, callback?: any): JQuery;
fadeOut(duration?: any, easing?: string, callback?: any): JQuery;
fadeTo(duration: any, opacity: number, callback?: any): JQuery;
fadeTo(duration: any, opacity: number, easing?: string, callback?: any): JQuery;
fadeToggle(duration?: any, callback?: any): JQuery;
fadeToggle(duration?: any, easing?: string, callback?: any): JQuery;
finish(): JQuery;
hide(duration?: any, callback?: any): JQuery;
hide(duration?: any, easing?: string, callback?: any): JQuery;
show(duration?: any, callback?: any): JQuery;
show(duration?: any, easing?: string, callback?: any): JQuery;
slideDown(duration?: any, callback?: any): JQuery;
slideDown(duration?: any, easing?: string, callback?: any): JQuery;
slideToggle(duration?: any, callback?: any): JQuery;
slideToggle(duration?: any, easing?: string, callback?: any): JQuery;
slideUp(duration?: any, callback?: any): JQuery;
slideUp(duration?: any, easing?: string, callback?: any): JQuery;
stop(clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
stop(queue?: any, clearQueue?: boolean, jumpToEnd?: boolean): JQuery;
toggle(duration?: any, callback?: any): JQuery;
toggle(duration?: any, easing?: string, callback?: any): JQuery;
toggle(showOrHide: boolean): JQuery;
// Events
bind(eventType: string, eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
bind(eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
bind(eventType: string, eventData: any, preventBubble: boolean): JQuery;
bind(eventType: string, preventBubble: boolean): JQuery;
bind(...events: any[]): JQuery;
blur(handler: (eventObject: JQueryEventObject) => any): JQuery;
blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Trigger the "change" event on an element.
*/
change(): JQuery;
/**
* Bind an event handler to the "change" JavaScript event
*
* @param handler A function to execute each time the event is triggered.
*/
change(handler: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Bind an event handler to the "change" JavaScript event
*
* @param eventData An object containing data that will be passed to the event handler.
* @param handler A function to execute each time the event is triggered.
*/
change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
/**
* Trigger the "click" event on an element.
*/
click(): JQuery;
/**
* Bind an event handler to the "click" JavaScript event
*