@k37z3r/jbase 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +59 -43
- package/dist/browser.d.ts +5 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/core.d.ts +9 -14
- package/dist/core.d.ts.map +1 -1
- package/dist/index.cjs +577 -452
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +304 -603
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +575 -452
- package/dist/index.mjs.map +7 -0
- package/dist/jbase.browser.js +338 -281
- package/dist/jbase.browser.js.map +7 -0
- package/dist/jbase.min.js +3 -2
- package/dist/jbase.min.js.map +7 -0
- package/dist/modules/css/classes.d.ts +15 -29
- package/dist/modules/css/classes.d.ts.map +1 -1
- package/dist/modules/css/index.d.ts +5 -9
- package/dist/modules/css/index.d.ts.map +1 -1
- package/dist/modules/css/styles.d.ts +7 -13
- package/dist/modules/css/styles.d.ts.map +1 -1
- package/dist/modules/data/arrays.d.ts +96 -64
- package/dist/modules/data/arrays.d.ts.map +1 -1
- package/dist/modules/data/index.d.ts +5 -9
- package/dist/modules/data/index.d.ts.map +1 -1
- package/dist/modules/data/objects.d.ts +86 -54
- package/dist/modules/data/objects.d.ts.map +1 -1
- package/dist/modules/data/types.d.ts +3 -22
- package/dist/modules/data/types.d.ts.map +1 -1
- package/dist/modules/dom/attributes.d.ts +10 -19
- package/dist/modules/dom/attributes.d.ts.map +1 -1
- package/dist/modules/dom/content.d.ts +9 -17
- package/dist/modules/dom/content.d.ts.map +1 -1
- package/dist/modules/dom/index.d.ts +8 -15
- package/dist/modules/dom/index.d.ts.map +1 -1
- package/dist/modules/dom/manipulation.d.ts +41 -81
- package/dist/modules/dom/manipulation.d.ts.map +1 -1
- package/dist/modules/dom/states.d.ts +12 -23
- package/dist/modules/dom/states.d.ts.map +1 -1
- package/dist/modules/dom/traversal.d.ts +64 -127
- package/dist/modules/dom/traversal.d.ts.map +1 -1
- package/dist/modules/effects/fade.d.ts +13 -31
- package/dist/modules/effects/fade.d.ts.map +1 -1
- package/dist/modules/effects/index.d.ts +15 -23
- package/dist/modules/effects/index.d.ts.map +1 -1
- package/dist/modules/effects/slide.d.ts +13 -31
- package/dist/modules/effects/slide.d.ts.map +1 -1
- package/dist/modules/effects/types.d.ts +33 -0
- package/dist/modules/effects/types.d.ts.map +1 -0
- package/dist/modules/effects/vertical.d.ts +13 -31
- package/dist/modules/effects/vertical.d.ts.map +1 -1
- package/dist/modules/events/binding.d.ts +11 -21
- package/dist/modules/events/binding.d.ts.map +1 -1
- package/dist/modules/events/form.d.ts +18 -35
- package/dist/modules/events/form.d.ts.map +1 -1
- package/dist/modules/events/index.d.ts +9 -17
- package/dist/modules/events/index.d.ts.map +1 -1
- package/dist/modules/events/keyboard.d.ts +16 -31
- package/dist/modules/events/keyboard.d.ts.map +1 -1
- package/dist/modules/events/lifecycle.d.ts +6 -11
- package/dist/modules/events/lifecycle.d.ts.map +1 -1
- package/dist/modules/events/mouse.d.ts +30 -59
- package/dist/modules/events/mouse.d.ts.map +1 -1
- package/dist/modules/events/touch.d.ts +15 -29
- package/dist/modules/events/touch.d.ts.map +1 -1
- package/dist/modules/http/get.d.ts +18 -25
- package/dist/modules/http/get.d.ts.map +1 -1
- package/dist/modules/http/index.d.ts +11 -15
- package/dist/modules/http/index.d.ts.map +1 -1
- package/dist/modules/http/post.d.ts +13 -19
- package/dist/modules/http/post.d.ts.map +1 -1
- package/dist/server.d.ts +15 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2246 -0
- package/dist/server.js.map +7 -0
- package/dist/types.d.ts +11 -21
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +20 -23
- package/dist/utils.d.ts.map +1 -1
- package/package.json +14 -4
- package/wiki/CSS-Classes-&-Styles.md +128 -0
- package/wiki/DATA-Utilities-(Arrays).md +332 -0
- package/wiki/DATA-Utilities-(Objects).md +263 -0
- package/wiki/DOM-Attributes.md +56 -0
- package/wiki/DOM-Content.md +48 -0
- package/wiki/DOM-Manipulation.md +272 -0
- package/wiki/DOM-States.md +73 -0
- package/wiki/DOM-Traversal.md +529 -0
- package/wiki/EFFECTS-Fade.md +76 -0
- package/wiki/EFFECTS-Slide-(horizontal).md +70 -0
- package/wiki/EFFECTS-Slide-(vertical).md +75 -0
- package/wiki/EVENTS-Bindings.md +55 -0
- package/wiki/EVENTS-Form.md +122 -0
- package/wiki/EVENTS-Keyboard.md +98 -0
- package/wiki/EVENTS-Lifecycle.md +25 -0
- package/wiki/EVENTS-Mouse.md +218 -0
- package/wiki/EVENTS-Touch.md +98 -0
- package/wiki/HTTP-Requests.md +93 -0
- package/wiki/Home.md +118 -0
- package/wiki/Installation.md +44 -0
- package/wiki/Quick-Start.md +139 -0
- package/dist/browser.js +0 -29
- package/dist/browser.js.map +0 -1
- package/dist/core.js +0 -78
- package/dist/core.js.map +0 -1
- package/dist/index.js +0 -100
- package/dist/index.js.map +0 -1
- package/dist/jbase.js +0 -1898
- package/dist/modules/css/classes.js +0 -88
- package/dist/modules/css/classes.js.map +0 -1
- package/dist/modules/css/index.js +0 -33
- package/dist/modules/css/index.js.map +0 -1
- package/dist/modules/css/styles.js +0 -49
- package/dist/modules/css/styles.js.map +0 -1
- package/dist/modules/data/arrays.js +0 -177
- package/dist/modules/data/arrays.js.map +0 -1
- package/dist/modules/data/index.js +0 -33
- package/dist/modules/data/index.js.map +0 -1
- package/dist/modules/data/objects.js +0 -168
- package/dist/modules/data/objects.js.map +0 -1
- package/dist/modules/data/types.js +0 -43
- package/dist/modules/data/types.js.map +0 -1
- package/dist/modules/dom/attributes.js +0 -69
- package/dist/modules/dom/attributes.js.map +0 -1
- package/dist/modules/dom/content.js +0 -63
- package/dist/modules/dom/content.js.map +0 -1
- package/dist/modules/dom/index.js +0 -48
- package/dist/modules/dom/index.js.map +0 -1
- package/dist/modules/dom/manipulation.js +0 -343
- package/dist/modules/dom/manipulation.js.map +0 -1
- package/dist/modules/dom/states.js +0 -89
- package/dist/modules/dom/states.js.map +0 -1
- package/dist/modules/dom/traversal.js +0 -527
- package/dist/modules/dom/traversal.js.map +0 -1
- package/dist/modules/effects/fade.js +0 -104
- package/dist/modules/effects/fade.js.map +0 -1
- package/dist/modules/effects/index.js +0 -38
- package/dist/modules/effects/index.js.map +0 -1
- package/dist/modules/effects/slide.js +0 -103
- package/dist/modules/effects/slide.js.map +0 -1
- package/dist/modules/effects/vertical.js +0 -118
- package/dist/modules/effects/vertical.js.map +0 -1
- package/dist/modules/events/binding.js +0 -60
- package/dist/modules/events/binding.js.map +0 -1
- package/dist/modules/events/form.js +0 -106
- package/dist/modules/events/form.js.map +0 -1
- package/dist/modules/events/index.js +0 -53
- package/dist/modules/events/index.js.map +0 -1
- package/dist/modules/events/keyboard.js +0 -83
- package/dist/modules/events/keyboard.js.map +0 -1
- package/dist/modules/events/lifecycle.js +0 -40
- package/dist/modules/events/lifecycle.js.map +0 -1
- package/dist/modules/events/mouse.js +0 -172
- package/dist/modules/events/mouse.js.map +0 -1
- package/dist/modules/events/touch.js +0 -74
- package/dist/modules/events/touch.js.map +0 -1
- package/dist/modules/http/get.js +0 -65
- package/dist/modules/http/get.js.map +0 -1
- package/dist/modules/http/index.js +0 -42
- package/dist/modules/http/index.js.map +0 -1
- package/dist/modules/http/post.js +0 -54
- package/dist/modules/http/post.js.map +0 -1
- package/dist/types.js +0 -15
- package/dist/types.js.map +0 -1
- package/dist/utils.js +0 -71
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
* [`mergeObjects`](#usage-mergeObjects) | [`pick`](#usage-pick) | [`omit`](#usage-omit)
|
|
2
|
+
* [`get`](#usage-obj-get) | [`set`](#usage-obj-set)
|
|
3
|
+
* [`find.key`](#usage-find-key) | [`find.value`](#usage-find-value) | [`find.at`](#usage-find-at) | [`find.first`](#usage-find-first) | [`find.last`](#usage-find-last)
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## <a id="usage-mergeObjects"></a>.mergeObjects
|
|
8
|
+
|
|
9
|
+
**Description**
|
|
10
|
+
Recursively merges one or more source objects into a target object (Deep Merge).
|
|
11
|
+
*Note: This modifies the `target` object in place.*
|
|
12
|
+
|
|
13
|
+
**Parameters**
|
|
14
|
+
|
|
15
|
+
* `target` (Object): The target object to receive properties.
|
|
16
|
+
* `...sources` (Object[]): One or more source objects to merge into the target.
|
|
17
|
+
|
|
18
|
+
**Returns**
|
|
19
|
+
|
|
20
|
+
* (Object): The modified target object.
|
|
21
|
+
|
|
22
|
+
**Example**
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
const defaults = { app: { theme: 'light', debug: false } };
|
|
26
|
+
const config = { app: { debug: true } };
|
|
27
|
+
|
|
28
|
+
$.data.mergeObjects(defaults, config);
|
|
29
|
+
// defaults is now: { app: { theme: 'light', debug: true } }
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## <a id="usage-pick"></a>.pick
|
|
36
|
+
|
|
37
|
+
**Description**
|
|
38
|
+
Creates a new object containing *only* the specified keys (Allowlist).
|
|
39
|
+
|
|
40
|
+
**Parameters**
|
|
41
|
+
|
|
42
|
+
* `obj` (Object): The source object.
|
|
43
|
+
* `keys` (String[]): An array of keys to keep.
|
|
44
|
+
|
|
45
|
+
**Returns**
|
|
46
|
+
|
|
47
|
+
* (Object): A new object with the selected keys.
|
|
48
|
+
|
|
49
|
+
**Example**
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
const user = { id: 1, name: 'Alice', role: 'admin' };
|
|
53
|
+
const publicProfile = $.data.pick(user, ['name']);
|
|
54
|
+
// Result: { name: 'Alice' }
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## <a id="usage-omit"></a>.omit
|
|
61
|
+
|
|
62
|
+
**Description**
|
|
63
|
+
Creates a new object containing all keys *except* the specified ones (Blocklist).
|
|
64
|
+
|
|
65
|
+
**Parameters**
|
|
66
|
+
|
|
67
|
+
* `obj` (Object): The source object.
|
|
68
|
+
* `keys` (String[]): An array of keys to remove.
|
|
69
|
+
|
|
70
|
+
**Returns**
|
|
71
|
+
|
|
72
|
+
* (Object): A new object without the specified keys.
|
|
73
|
+
|
|
74
|
+
**Example**
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const user = { id: 1, name: 'Alice', password: '123' };
|
|
78
|
+
const safeUser = $.data.omit(user, ['password']);
|
|
79
|
+
// Result: { id: 1, name: 'Alice' }
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## <a id="usage-get"></a>.get
|
|
86
|
+
|
|
87
|
+
**Description**
|
|
88
|
+
Safely retrieves a value from a nested object using dot-notation. Returns `undefined` if the path does not exist, preventing runtime errors.
|
|
89
|
+
|
|
90
|
+
**Parameters**
|
|
91
|
+
|
|
92
|
+
* `obj` (Object): The object to query.
|
|
93
|
+
* `path` (String): The path as a dot-notation string (e.g., `'user.address.city'`).
|
|
94
|
+
|
|
95
|
+
**Returns**
|
|
96
|
+
|
|
97
|
+
* (Any): The found value or `undefined`.
|
|
98
|
+
|
|
99
|
+
**Example**
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
const val = $.data.get(response, 'data.items.0.id');
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## <a id="usage-set"></a>.set
|
|
109
|
+
|
|
110
|
+
**Description**
|
|
111
|
+
Sets a value deeply within a nested object. It automatically creates missing intermediate objects if the path doesn't exist.
|
|
112
|
+
|
|
113
|
+
**Parameters**
|
|
114
|
+
|
|
115
|
+
* `obj` (Object): The object to modify.
|
|
116
|
+
* `path` (String): The path string (e.g., `'settings.theme.color'`).
|
|
117
|
+
* `value` (Any): The value to set.
|
|
118
|
+
|
|
119
|
+
**Returns**
|
|
120
|
+
|
|
121
|
+
* (Void): This function mutates the object and returns nothing.
|
|
122
|
+
|
|
123
|
+
**Example**
|
|
124
|
+
|
|
125
|
+
```javascript
|
|
126
|
+
const config = {};
|
|
127
|
+
$.data.set(config, 'database.connection.host', 'localhost');
|
|
128
|
+
// config is now: { database: { connection: { host: 'localhost' } } }
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## <a id="usage-find-at"></a>.find.at
|
|
135
|
+
|
|
136
|
+
**Description**
|
|
137
|
+
Returns the n-th entry of an object as a `[key, value]` pair. Supports negative indices to count from the end.
|
|
138
|
+
|
|
139
|
+
**Parameters**
|
|
140
|
+
|
|
141
|
+
* `obj` (Object): The object to search.
|
|
142
|
+
* `index` (Number): The 0-based index. Negative numbers count from the back.
|
|
143
|
+
|
|
144
|
+
**Returns**
|
|
145
|
+
|
|
146
|
+
* ([String, Any] | undefined): A tuple containing the key and value, or undefined.
|
|
147
|
+
|
|
148
|
+
**Example**
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
const data = { a: 1, b: 2, c: 3 };
|
|
152
|
+
const entry = $.data.find.at(data, -1);
|
|
153
|
+
// Result: ['c', 3]
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## <a id="usage-find-first"></a>.find.first
|
|
160
|
+
|
|
161
|
+
**Description**
|
|
162
|
+
Finds the **first** entry where the key or value matches the query.
|
|
163
|
+
|
|
164
|
+
**Parameters**
|
|
165
|
+
|
|
166
|
+
* `obj` (Object): The object to search.
|
|
167
|
+
* `query` (String|Number): The search term.
|
|
168
|
+
* `mode` (String, optional): Comparison mode: `'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`. Default is `'exact'`.
|
|
169
|
+
* `searchBy` (String, optional): Search by `'key'` or `'value'`. Default is `'key'`.
|
|
170
|
+
|
|
171
|
+
**Returns**
|
|
172
|
+
|
|
173
|
+
* ([String, Any] | undefined): The first matching `[key, value]` pair.
|
|
174
|
+
|
|
175
|
+
**Example**
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
const config = { admin_id: 10, user_id: 20 };
|
|
179
|
+
// Find first entry where key starts with 'user'
|
|
180
|
+
const match = $.data.find.first(config, 'user', 'startsWith', 'key');
|
|
181
|
+
// Result: ['user_id', 20]
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## <a id="usage-find-last"></a>.find.last
|
|
188
|
+
|
|
189
|
+
**Description**
|
|
190
|
+
Finds the **last** entry where the key or value matches the query. Useful for prioritized overrides or ordered objects.
|
|
191
|
+
|
|
192
|
+
**Parameters**
|
|
193
|
+
|
|
194
|
+
* `obj` (Object): The object to search.
|
|
195
|
+
* `query` (String|Number): The search term.
|
|
196
|
+
* `mode` (String, optional): `'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`. Default is `'exact'`.
|
|
197
|
+
* `searchBy` (String, optional): `'key'` or `'value'`. Default is `'key'`.
|
|
198
|
+
|
|
199
|
+
**Returns**
|
|
200
|
+
|
|
201
|
+
* ([String, Any] | undefined): The last matching `[key, value]` pair.
|
|
202
|
+
|
|
203
|
+
**Example**
|
|
204
|
+
|
|
205
|
+
```javascript
|
|
206
|
+
const files = { 'script.js': 1, 'style.css': 2, 'main.css': 3 };
|
|
207
|
+
// Find last entry where key ends with '.css'
|
|
208
|
+
const match = $.data.find.last(files, '.css', 'endsWith', 'key');
|
|
209
|
+
// Result: ['main.css', 3]
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## <a id="usage-find-key"></a>.find.key
|
|
216
|
+
|
|
217
|
+
**Description**
|
|
218
|
+
Finds **all keys** in the object that match the query.
|
|
219
|
+
|
|
220
|
+
**Parameters**
|
|
221
|
+
|
|
222
|
+
* `obj` (Object): The object to search.
|
|
223
|
+
* `query` (String): The search term.
|
|
224
|
+
* `mode` (String, optional): `'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`. Default is `'exact'`.
|
|
225
|
+
|
|
226
|
+
**Returns**
|
|
227
|
+
|
|
228
|
+
* (String[]): An array of matching keys.
|
|
229
|
+
|
|
230
|
+
**Example**
|
|
231
|
+
|
|
232
|
+
```javascript
|
|
233
|
+
const settings = { theme_dark: true, theme_light: false, lang: 'en' };
|
|
234
|
+
const themes = $.data.find.key(settings, 'theme_', 'startsWith');
|
|
235
|
+
// Result: ['theme_dark', 'theme_light']
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## <a id="usage-find-value"></a>.find.value
|
|
242
|
+
|
|
243
|
+
**Description**
|
|
244
|
+
Finds **all values** in the object that match the query.
|
|
245
|
+
|
|
246
|
+
**Parameters**
|
|
247
|
+
|
|
248
|
+
* `obj` (Object): The object to search.
|
|
249
|
+
* `query` (String): The search term.
|
|
250
|
+
* `mode` (String, optional): `'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`. Default is `'exact'`.
|
|
251
|
+
|
|
252
|
+
**Returns**
|
|
253
|
+
|
|
254
|
+
* (Any[]): An array of matching values.
|
|
255
|
+
|
|
256
|
+
**Example**
|
|
257
|
+
|
|
258
|
+
```javascript
|
|
259
|
+
const roles = { bob: 'admin', alice: 'editor', john: 'admin' };
|
|
260
|
+
const admins = $.data.find.value(roles, 'admin', 'exact');
|
|
261
|
+
// Result: ['admin', 'admin']
|
|
262
|
+
|
|
263
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
* [`attr`](#usage-attr) | [`val`](#usage-val)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## <a id="usage-attr"></a>.attr
|
|
6
|
+
|
|
7
|
+
**Description**
|
|
8
|
+
Get the value of an attribute for the first element in the set, or set one or more attributes for every matched element.
|
|
9
|
+
|
|
10
|
+
**Parameters**
|
|
11
|
+
|
|
12
|
+
* `name` (String): The name of the attribute.
|
|
13
|
+
* `value` (String|Number, optional): The value to set. If omitted, the method acts as a getter.
|
|
14
|
+
|
|
15
|
+
**Returns**
|
|
16
|
+
|
|
17
|
+
* (String): Value of the attribute (if getter).
|
|
18
|
+
* (jBase): Current instance for chaining (if setter).
|
|
19
|
+
|
|
20
|
+
**Example**
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
// Get href
|
|
24
|
+
const link = $('a.my-link').attr('href');
|
|
25
|
+
|
|
26
|
+
// Set id and title
|
|
27
|
+
$('.item').attr('id', 'item-1').attr('title', 'Item One');
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## <a id="usage-val"></a>.val
|
|
34
|
+
|
|
35
|
+
**Description**
|
|
36
|
+
Get the current value of the first element in the set of matched elements or set the value of every matched element.
|
|
37
|
+
|
|
38
|
+
**Parameters**
|
|
39
|
+
|
|
40
|
+
* `value` (String|Number, optional): The value to set.
|
|
41
|
+
|
|
42
|
+
**Returns**
|
|
43
|
+
|
|
44
|
+
* (String|Number): The value of the input (if getter).
|
|
45
|
+
* (jBase): Current instance (if setter).
|
|
46
|
+
|
|
47
|
+
**Example**
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
// Get input value
|
|
51
|
+
const username = $('#username').val();
|
|
52
|
+
|
|
53
|
+
// Set input value
|
|
54
|
+
$('#username').val('NewUser');
|
|
55
|
+
|
|
56
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
* [`html`](#usage-html) | [`text`](#usage-text)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## <a id="usage-html"></a>.html
|
|
6
|
+
|
|
7
|
+
**Description**
|
|
8
|
+
Get the HTML contents of the first element in the set or set the HTML contents of every matched element.
|
|
9
|
+
|
|
10
|
+
**Parameters**
|
|
11
|
+
|
|
12
|
+
* `content` (String, optional): The HTML string to set.
|
|
13
|
+
|
|
14
|
+
**Returns**
|
|
15
|
+
|
|
16
|
+
* (String): Inner HTML (if getter).
|
|
17
|
+
* (jBase): Current instance (if setter).
|
|
18
|
+
|
|
19
|
+
**Example**
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
// Set HTML
|
|
23
|
+
$('#container').html('<div class="child">Hello</div>');
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## <a id="usage-text"></a>.text
|
|
30
|
+
|
|
31
|
+
**Description**
|
|
32
|
+
Get the combined text contents of each element in the set of matched elements, including their descendants, or set the text contents of the matched elements.
|
|
33
|
+
|
|
34
|
+
**Parameters**
|
|
35
|
+
|
|
36
|
+
* `content` (String, optional): The text to set.
|
|
37
|
+
|
|
38
|
+
**Returns**
|
|
39
|
+
|
|
40
|
+
* (String): Text content (if getter).
|
|
41
|
+
* (jBase): Current instance (if setter).
|
|
42
|
+
|
|
43
|
+
**Example**
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
$('h1').text('Welcome to jBase');
|
|
47
|
+
|
|
48
|
+
```
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
* [`remove`](#usage-remove) | [`empty`](#usage-empty) | [`replaceWithClone`](#usage-replaceWithClone)
|
|
2
|
+
* [`append`](#usage-append) | [`prepend`](#usage-prepend) | [`before`](#usage-before) | [`after`](#usage-after)
|
|
3
|
+
* [`replaceWith`](#usage-replaceWith) | [`appendTo`](#usage-appendTo) | [`prependTo`](#usage-prependTo)
|
|
4
|
+
* [`insertBefore`](#usage-insertBefore) | [`insertAfter`](#usage-insertAfter)
|
|
5
|
+
* [`wrap`](#usage-wrap) | [`unwrap`](#usage-unwrap)
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## <a id="usage-remove"></a>.remove
|
|
10
|
+
|
|
11
|
+
**Description**
|
|
12
|
+
Removes the set of matched elements from the DOM.
|
|
13
|
+
|
|
14
|
+
**Parameters**
|
|
15
|
+
|
|
16
|
+
* None.
|
|
17
|
+
|
|
18
|
+
**Returns**
|
|
19
|
+
|
|
20
|
+
* (jBase): The removed elements (detached).
|
|
21
|
+
|
|
22
|
+
**Example**
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
$('.ads').remove();
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## <a id="usage-empty"></a>.empty
|
|
32
|
+
|
|
33
|
+
**Description**
|
|
34
|
+
Remove all child nodes of the set of matched elements from the DOM.
|
|
35
|
+
|
|
36
|
+
**Parameters**
|
|
37
|
+
|
|
38
|
+
* None.
|
|
39
|
+
|
|
40
|
+
**Returns**
|
|
41
|
+
|
|
42
|
+
* (jBase): Current instance.
|
|
43
|
+
|
|
44
|
+
**Example**
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
// Clears the content of .container but keeps the container itself
|
|
48
|
+
$('.container').empty();
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## <a id="usage-replaceWithClone"></a>.replaceWithClone
|
|
55
|
+
|
|
56
|
+
**Description**
|
|
57
|
+
Replaces the selected elements with a deep clone of themselves. Useful for stripping event listeners.
|
|
58
|
+
|
|
59
|
+
**Parameters**
|
|
60
|
+
|
|
61
|
+
* None.
|
|
62
|
+
|
|
63
|
+
**Returns**
|
|
64
|
+
|
|
65
|
+
* (jBase): The new cloned elements.
|
|
66
|
+
|
|
67
|
+
**Example**
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// Removes all events attached to the button by cloning it
|
|
71
|
+
$('button#reset').replaceWithClone();
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## <a id="usage-append"></a>.append
|
|
78
|
+
|
|
79
|
+
**Description**
|
|
80
|
+
Insert content, specified by the parameter, to the end of each element in the set of matched elements.
|
|
81
|
+
|
|
82
|
+
**Parameters**
|
|
83
|
+
|
|
84
|
+
* `content` (String|HTMLElement|jBase): The content to insert.
|
|
85
|
+
|
|
86
|
+
**Returns**
|
|
87
|
+
|
|
88
|
+
* (jBase): Current instance.
|
|
89
|
+
|
|
90
|
+
**Example**
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
$('.list').append('<li>New Item</li>');
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## <a id="usage-prepend"></a>.prepend
|
|
100
|
+
|
|
101
|
+
**Description**
|
|
102
|
+
Insert content, specified by the parameter, to the beginning of each element in the set of matched elements.
|
|
103
|
+
|
|
104
|
+
**Parameters**
|
|
105
|
+
|
|
106
|
+
* `content` (String|HTMLElement|jBase): The content to insert.
|
|
107
|
+
|
|
108
|
+
**Returns**
|
|
109
|
+
|
|
110
|
+
* (jBase): Current instance.
|
|
111
|
+
|
|
112
|
+
**Example**
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
$('.list').prepend('<li>First Item</li>');
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## <a id="usage-before"></a>.before
|
|
122
|
+
|
|
123
|
+
**Description**
|
|
124
|
+
Insert content before each element in the set of matched elements.
|
|
125
|
+
|
|
126
|
+
**Parameters**
|
|
127
|
+
|
|
128
|
+
* `content` (String|HTMLElement|jBase): The content to insert.
|
|
129
|
+
|
|
130
|
+
**Returns**
|
|
131
|
+
|
|
132
|
+
* (jBase): Current instance.
|
|
133
|
+
|
|
134
|
+
**Example**
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
$('#main').before('<div class="header"></div>');
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## <a id="usage-after"></a>.after
|
|
144
|
+
|
|
145
|
+
**Description**
|
|
146
|
+
Insert content after each element in the set of matched elements.
|
|
147
|
+
|
|
148
|
+
**Parameters**
|
|
149
|
+
|
|
150
|
+
* `content` (String|HTMLElement|jBase): The content to insert.
|
|
151
|
+
|
|
152
|
+
**Returns**
|
|
153
|
+
|
|
154
|
+
* (jBase): Current instance.
|
|
155
|
+
|
|
156
|
+
**Example**
|
|
157
|
+
|
|
158
|
+
```javascript
|
|
159
|
+
$('#main').after('<div class="footer"></div>');
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## <a id="usage-replaceWith"></a>.replaceWith
|
|
166
|
+
|
|
167
|
+
**Description**
|
|
168
|
+
Replace each element in the set of matched elements with the provided new content.
|
|
169
|
+
|
|
170
|
+
**Parameters**
|
|
171
|
+
|
|
172
|
+
* `content` (String|HTMLElement|jBase): The content to insert.
|
|
173
|
+
|
|
174
|
+
**Returns**
|
|
175
|
+
|
|
176
|
+
* (jBase): The new content.
|
|
177
|
+
|
|
178
|
+
**Example**
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
$('.old-element').replaceWith('<div class="new-element">Updated</div>');
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## <a id="usage-appendTo"></a>.appendTo
|
|
188
|
+
|
|
189
|
+
**Description**
|
|
190
|
+
Insert every element in the set of matched elements to the end of the target.
|
|
191
|
+
|
|
192
|
+
**Parameters**
|
|
193
|
+
|
|
194
|
+
* `target` (String|HTMLElement|jBase): The element to append to.
|
|
195
|
+
|
|
196
|
+
**Returns**
|
|
197
|
+
|
|
198
|
+
* (jBase): Current instance.
|
|
199
|
+
|
|
200
|
+
**Example**
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
$('<p>Test</p>').appendTo('.container');
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## <a id="usage-prependTo"></a>.prependTo
|
|
210
|
+
|
|
211
|
+
**Description**
|
|
212
|
+
Insert every element in the set of matched elements to the beginning of the target.
|
|
213
|
+
|
|
214
|
+
**Parameters**
|
|
215
|
+
|
|
216
|
+
* `target` (String|HTMLElement|jBase): The target element.
|
|
217
|
+
|
|
218
|
+
**Returns**
|
|
219
|
+
|
|
220
|
+
* (jBase): Current instance.
|
|
221
|
+
|
|
222
|
+
**Example**
|
|
223
|
+
|
|
224
|
+
```javascript
|
|
225
|
+
$('<p>Intro</p>').prependTo('body');
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## <a id="usage-wrap"></a>.wrap
|
|
232
|
+
|
|
233
|
+
**Description**
|
|
234
|
+
Wrap an HTML structure around each element in the set of matched elements.
|
|
235
|
+
|
|
236
|
+
**Parameters**
|
|
237
|
+
|
|
238
|
+
* `structure` (String): HTML string specifying the structure (e.g., `<div class="wrapper"></div>`).
|
|
239
|
+
|
|
240
|
+
**Returns**
|
|
241
|
+
|
|
242
|
+
* (jBase): Current instance.
|
|
243
|
+
|
|
244
|
+
**Example**
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
$('.item').wrap('<div class="item-wrapper"></div>');
|
|
248
|
+
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## <a id="usage-unwrap"></a>.unwrap
|
|
254
|
+
|
|
255
|
+
**Description**
|
|
256
|
+
Remove the parents of the set of matched elements from the DOM, leaving the matched elements in their place.
|
|
257
|
+
|
|
258
|
+
**Parameters**
|
|
259
|
+
|
|
260
|
+
* None.
|
|
261
|
+
|
|
262
|
+
**Returns**
|
|
263
|
+
|
|
264
|
+
* (jBase): Current instance.
|
|
265
|
+
|
|
266
|
+
**Example**
|
|
267
|
+
|
|
268
|
+
```javascript
|
|
269
|
+
// Removes the parent <div> but keeps the <span>
|
|
270
|
+
$('span').unwrap();
|
|
271
|
+
|
|
272
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
* [`checked`](#usage-checked) | [`selected`](#usage-selected) | [`disabled`](#usage-disabled)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## <a id="usage-checked"></a>.checked
|
|
6
|
+
|
|
7
|
+
**Description**
|
|
8
|
+
Get the checked state of the first element or set the state for all matched elements.
|
|
9
|
+
|
|
10
|
+
**Parameters**
|
|
11
|
+
|
|
12
|
+
* `state` (Boolean, optional): True to check, false to uncheck.
|
|
13
|
+
|
|
14
|
+
**Returns**
|
|
15
|
+
|
|
16
|
+
* (Boolean): Current state (if getter).
|
|
17
|
+
* (jBase): Current instance (if setter).
|
|
18
|
+
|
|
19
|
+
**Example**
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
if ($('#agree').checked()) {
|
|
23
|
+
// do something
|
|
24
|
+
}
|
|
25
|
+
$('#agree').checked(true);
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## <a id="usage-selected"></a>.selected
|
|
32
|
+
|
|
33
|
+
**Description**
|
|
34
|
+
Get the selected state of an option or set it.
|
|
35
|
+
|
|
36
|
+
**Parameters**
|
|
37
|
+
|
|
38
|
+
* `state` (Boolean, optional): True to select, false to deselect.
|
|
39
|
+
|
|
40
|
+
**Returns**
|
|
41
|
+
|
|
42
|
+
* (Boolean): Current state (if getter).
|
|
43
|
+
* (jBase): Current instance (if setter).
|
|
44
|
+
|
|
45
|
+
**Example**
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
$('option[value="de"]').selected(true);
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## <a id="usage-disabled"></a>.disabled
|
|
55
|
+
|
|
56
|
+
**Description**
|
|
57
|
+
Get the disabled state of an element or set it.
|
|
58
|
+
|
|
59
|
+
**Parameters**
|
|
60
|
+
|
|
61
|
+
* `state` (Boolean, optional): True to disable, false to enable.
|
|
62
|
+
|
|
63
|
+
**Returns**
|
|
64
|
+
|
|
65
|
+
* (Boolean): Current state (if getter).
|
|
66
|
+
* (jBase): Current instance (if setter).
|
|
67
|
+
|
|
68
|
+
**Example**
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
$('button').disabled(true);
|
|
72
|
+
|
|
73
|
+
```
|