This repository has been archived by the owner on Jul 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.d.ts
144 lines (113 loc) · 5.28 KB
/
index.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
import { ViewBase } from "ui/core/view-base";
/**
* Get the child element with the id. ** NativeScript DOM plugin only **
* @param {string} id - The id of the element to get.
* @returns {ViewBase} - The view element with the specified id.
*/
export function getElementById(id: string): ViewBase;
/**
* Gets all child elements of the parent view with the specified className. ** NativeScript DOM plugin only **
* @param {string} className - The class name to get children elements with.
* @returns {Array} - An array of view elements with the specified class name.
*/
export function getElementsByClassName(className: string): Array<ViewBase>;
/**
* Gets all child elements with specified tag name in the parent view. ** NativeScript DOM plugin only **
* @param {string} tagName - The tag name to get children elements with.
* @returns {Array} - An array of view elements with the specified tag name.
*/
export function getElementsByTagName(tagName: string): Array<ViewBase>;
/**
* Execute a function on any view with the id. ** NativeScript DOM plugin only **
* @param {string} id - The view id.
* @param {Function} callback - The function to run
*/
export function runAgainstId(id: string, callback: (element: ViewBase) => void);
/**
* Executes a function on all view components with a matching className. ** NativeScript DOM plugin only **
* @param {string} className - The tag name to get children elements with.
* @param {Function} callback - The function to run
*/
export function runAgainstClasses(className: string, callback: (element: ViewBase) => void);
/**
* Executes a function on all view components with a matching tagName. ** NativeScript DOM plugin only **
* @param {string} tagName - The tag name to get children elements with.
* @param {Function} callback - The function to run
*/
export function runAgainstTagNames(tagName: string, callback: (element: ViewBase) => void);
declare module "ui/core/view-base" {
interface ViewBase {
/**
* Get the child element with the id. ** NativeScript DOM plugin only **
* @param {string} id - The id of the element to get.
* @returns {ViewBase} - The view element with the specified id.
*/
getElementById(id: string): ViewBase;
/**
* Gets all child elements of the parent view with the specified className. ** NativeScript DOM plugin only **
* @param {string} className - The class name to get children elements with.
* @returns {Array} - An array of view elements with the specified class name.
*/
getElementsByClassName(className: string): Array<ViewBase>;
/**
* Gets all child elements with specified tag name in the parent view. ** NativeScript DOM plugin only **
* @param {string} tagName - The tag name to get children elements with.
* @returns {Array} - An array of view elements with the specified tag name.
*/
getElementsByTagName(tagName: string): Array<ViewBase>;
/**
* Execute a function on any child view with the id. ** NativeScript DOM plugin only **
* @param {string} id - The view id.
*/
runAgainstId(id: string, callback: (element: ViewBase) => void);
/**
* Executes a function on the child view components with the className. ** NativeScript DOM plugin only **
* @param {string} className - The tag name to get children elements with.
*/
runAgainstClasses(className: string, callback: (element: ViewBase) => void);
/**
* Executes a function on the child view components with the tagName. ** NativeScript DOM plugin only **
* @param {string} tagName - The tag name to get children elements with.
*/
runAgainstTagNames(tagName: string, callback: (element: ViewBase) => void);
/**
* Property that contains the CSS classes for a view component.
*/
classList: classList;
}
}
interface classList {
/**
* Add a class to the view's class list at the end.
* @param {string} className - The class to add.
*/
add(...className: string[]);
/**
* Add a class to the view's class list at the front.
* @param {string} className - The class to add.
*/
insert(...className: string[]);
/**
* Removes a class from the view's class list
* @param {string} className - The class to remove.
*/
remove(...className: string[]);
/**
* Toggles a class name if force = true, will force adding the class name only. (And won't remove it, but you won't have a second) if force = false, will force removing the class name only. (And won't add it)
* @param {string} className - The class to toggle.
* @param {boolean} force - Force this class on (true) or off (false) the class list
*/
toggle(className: string, force?: boolean);
/**
* Get the class at the specified location in the classList.
* @param {number} index - The class item in the classList.
* @returns - The class at the index of the classList.
*/
item(index: number);
/**
* Check if a view has a class name.
* @param {string} className - The className to check in the classList.
* @returns - True if the class name exists in the class list.
*/
contains(className: string);
}