forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.ajaxFile.d.ts
120 lines (94 loc) · 2.95 KB
/
jquery.ajaxFile.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
// Type definitions for jquery.ajaxfile v0.2.0
// Project: https://github.com/fpellet/jquery.ajaxFile
// Definitions by: Florent PELLET <https://github.com/fpellet/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="../knockout/knockout.d.ts" />
declare namespace JQueryAjaxFile {
export enum DataType {
Json,
Xml,
Text
}
interface IFileData {
name: string;
element: HTMLInputElement;
}
interface IOption {
method?: string;
url?: string;
data?: any;
files?: IFileData[];
desiredResponseDataType?: DataType;
timeoutInSeconds?: number;
}
interface IResponseStatus {
code: number;
text: string;
isSuccess: boolean;
}
interface IAjaxFileResult<T> {
error?: any;
data?: any;
status?: IResponseStatus;
}
interface IAjaxFileResultCallback<T> {
(result: IAjaxFileResult<T>): void;
}
interface IAjaxFilePromise<T> {
then(success: IAjaxFileResultCallback<T>, error?: IAjaxFileResultCallback<T>): IAjaxFilePromise<T>;
done(success: IAjaxFileResultCallback<T>): IAjaxFilePromise<T>;
fail(error: IAjaxFileResultCallback<T>): IAjaxFilePromise<T>;
always(error: IAjaxFileResultCallback<T>): IAjaxFilePromise<T>;
abord(): void;
}
interface IAjaxFileStatic {
DataType: typeof DataType;
send<T>(option: IOption): IAjaxFilePromise<T>;
}
interface IJQueryXHR {
readyState: any;
status: number;
statusText: string;
responseXML: Document;
responseText: string;
statusCode?: { [key: string]: any; };
abort(statusText?: string): void;
setRequestHeader(header: string, value: string): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string;
beforeSend?(jqXHR: IJQueryXHR, settings: JQueryAjaxSettings): any;
dataFilter?(data: any, ty: any): any;
success?(data: any, textStatus: string, jqXHR: IJQueryXHR): any;
error?(jqXHR: IJQueryXHR, textStatus: string, errorThrown: string): any;
complete?(jqXHR: IJQueryXHR, textStatus: string): any;
}
interface IJQueryOption {
type?: string;
url?: string;
data?: any;
files?: IFileData[];
dataType?: string;
timeout?: number;
global?: boolean;
error?(jqXHR: IJQueryXHR, textStatus: string, errorThrown: string): any;
success?(data: any, textStatus: string, jqXHR: IJQueryXHR): any;
complete?(jqXHR: IJQueryXHR, textStatus: string): any;
}
interface IAjaxFileJQueryExtension {
ajaxWithFile<T>(jqueryOption: IJQueryOption): JQueryDeferred<T>;
}
}
declare var AjaxFile: JQueryAjaxFile.IAjaxFileStatic;
declare module 'ajaxfile' {
export = AjaxFile;
}
declare namespace AjaxFileKnockout {
interface IFileInputWrapper {
getElement(): HTMLInputElement;
fileSelected(): boolean;
}
}
interface KnockoutBindingHandlers {
file: KnockoutBindingHandler;
}