forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backbone.paginator.d.ts
116 lines (84 loc) · 3.39 KB
/
backbone.paginator.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
// Type definitions for backbone.paginator 2.0.2
// Project: https://github.com/backbone-paginator/backbone.paginator
// Definitions by: Nyamazing <https://github.com/Nyamazing/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare namespace Backbone {
interface PageableState {
firstPage?: number;
lastPage?: number;
currentPage?: number;
pageSize?: number;
totalPages?: number;
totalRecords?: number;
sortKey?: string;
order?: number;
}
interface PageableQueryParams {
currentPage?: string;
pageSize?: string;
totalPages?: string;
totalRecords?: string;
sortKey?: string;
order?: string;
directions?: any;
}
interface PageableInitialOptions {
comparator?: (...options: any[]) => number;
full?: boolean;
state?: PageableState;
queryParam?: PageableQueryParams;
}
interface PageableParseLinksOptions {
xhr?: JQueryXHR;
}
interface PageableSetSortingOptions<TModel extends Model> {
side?: string;
full?: boolean;
sortValue?: (model: TModel, sortKey: string) => any | string;
}
interface PageableSwitchModeOptions {
fetch?: boolean;
resetState?: boolean;
}
type PageableGetPageOptions = CollectionFetchOptions|Silenceable;
class PageableCollection<TModel extends Model> extends Collection<TModel>{
fullCollection: Collection<TModel>;
mode: string;
queryParams: PageableQueryParams;
state: PageableState;
constructor(models?: TModel[], options?: PageableInitialOptions);
fetch(options?: CollectionFetchOptions): JQueryXHR;
getFirstPage(options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
getLastPage(options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
getNextPage(options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
getPage(index: number|string, options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
getPageByOffset(offset: number, options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
getPreviousPage(options?: PageableGetPageOptions):
JQueryXHR|PageableCollection<TModel>;
hasNextPage(): boolean;
hasPreviousPage(): boolean;
parse(resp: any, options?: any): any[];
parseLinks(resp: any, options?: PageableParseLinksOptions): any;
parseRecords(resp: any, options?: any): any[];
parseState(resp: any, queryParams: PageableQueryParams,
state: PageableState, options?: any): PageableState;
setPageSize(pageSize: number,
options?: CollectionFetchOptions):
JQueryXHR|PageableCollection<TModel>;
setSorting(sortKey: string, order?: number,
options?: PageableSetSortingOptions<TModel>):
PageableCollection<TModel>;
switchMode(mode?: string, options?: PageableSwitchModeOptions):
JQueryXHR|PageableCollection<TModel>;
sync(method: string,
model: TModel|Collection<TModel>,
options?: any): JQueryXHR;
static noConflict(): typeof PageableCollection;
}
}