@cntwg/html-helper 0.0.14
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 +123 -0
- package/LICENSE +9 -0
- package/README.md +32 -0
- package/doc/html-ctrls-btn.md +222 -0
- package/doc/html-ctrls-list.md +405 -0
- package/doc/html-helper-lib.md +118 -0
- package/index.js +54 -0
- package/lib/html-ctrls/lists-btns.js +277 -0
- package/lib/html-ctrls/lists-stubs.js +185 -0
- package/lib/html-ctrls-btn.js +341 -0
- package/lib/html-ctrls-list.js +568 -0
- package/lib/html-helper-lib.js +228 -0
- package/package.json +45 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#### *v0.0.14*
|
|
2
|
+
|
|
3
|
+
Pre-release version.
|
|
4
|
+
|
|
5
|
+
> - `html-ctrls-list.md` updated;
|
|
6
|
+
> - some fixes in `html-ctrls/list-stubs.js` module;
|
|
7
|
+
> - alter behavior for the `loadItems` method of a `THtmlStubItemsSet` class in case when its `options` parameter is set to `boolean` (see `html-ctrls-list.md` for details);
|
|
8
|
+
> - added method `rstDefItem` to `THtmlStubItemsSet` class;
|
|
9
|
+
> - added `THtmlButtonsControllerARCSet` class;
|
|
10
|
+
|
|
11
|
+
#### *v0.0.13*
|
|
12
|
+
|
|
13
|
+
Pre-release version.
|
|
14
|
+
|
|
15
|
+
> - `html-helper-lib.md` updated;
|
|
16
|
+
> - `html-ctrls-btn.md` updated;
|
|
17
|
+
> - `html-ctrls-list.md` updated;
|
|
18
|
+
> - some fixes in `html-helper-lib.js` module;
|
|
19
|
+
> - some fixes in `html-ctrls-btn.js` module;
|
|
20
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
21
|
+
> - move definition of `THtmlStubItemsSet` from `html-ctrls-list.js` module to `html-ctrls/lists-stubs.js` submodule;
|
|
22
|
+
> - add function `valueToClassList` into `html-helper-lib.js` module;
|
|
23
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.2.
|
|
24
|
+
|
|
25
|
+
#### *v0.0.12*
|
|
26
|
+
|
|
27
|
+
Pre-release version.
|
|
28
|
+
|
|
29
|
+
> - updated dependency on `@ygracs/bsfoc-lib-js` module to v0.1.1.
|
|
30
|
+
|
|
31
|
+
#### *v0.0.11*
|
|
32
|
+
|
|
33
|
+
Pre-release version.
|
|
34
|
+
|
|
35
|
+
> - `html-ctrls-btn.md` updated;
|
|
36
|
+
> - `html-ctrls-list.md` updated;
|
|
37
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
38
|
+
> - some fixes in `html-ctrls-btn.js` module.
|
|
39
|
+
|
|
40
|
+
#### *v0.0.10*
|
|
41
|
+
|
|
42
|
+
Pre-release version.
|
|
43
|
+
|
|
44
|
+
> - `html-ctrls-btn.md` updated;
|
|
45
|
+
> - added `THtmlListButtonsController` class;
|
|
46
|
+
|
|
47
|
+
#### *v0.0.9*
|
|
48
|
+
|
|
49
|
+
Pre-release version.
|
|
50
|
+
|
|
51
|
+
> - switch dependency from `@cntwg/bsfoc-lib-js` module to `@ygracs/bsfoc-lib-js` module.
|
|
52
|
+
|
|
53
|
+
#### *v0.0.8*
|
|
54
|
+
|
|
55
|
+
Pre-release version.
|
|
56
|
+
|
|
57
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.11.
|
|
58
|
+
|
|
59
|
+
#### *v0.0.7*
|
|
60
|
+
|
|
61
|
+
Pre-release version.
|
|
62
|
+
|
|
63
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.10;
|
|
64
|
+
> - some fixes in `html-helper-lib.js` module;
|
|
65
|
+
> - some fixes in `html-ctrls-list.js` module.
|
|
66
|
+
|
|
67
|
+
#### *v0.0.6*
|
|
68
|
+
|
|
69
|
+
Pre-release version.
|
|
70
|
+
|
|
71
|
+
> - `html-ctrls-btn.md` updated;
|
|
72
|
+
> - `html-ctrls-list.md` updated;
|
|
73
|
+
> - `html-helper-lib.md` updated;
|
|
74
|
+
> - some fixes in `html-ctrls-btn.js` module;
|
|
75
|
+
> - some fixes in `html-ctrls-list.js` module.
|
|
76
|
+
|
|
77
|
+
#### *v0.0.5*
|
|
78
|
+
|
|
79
|
+
Pre-release version.
|
|
80
|
+
|
|
81
|
+
> - `$module/test/README.md` added;
|
|
82
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.8;
|
|
83
|
+
> - `html-ctrls-list.md` updated;
|
|
84
|
+
> - added `minIndex` property to `THtmlItemsListContainer` class;
|
|
85
|
+
> - some fixes in `html-ctrls-list.js` module;
|
|
86
|
+
> - added 'classes' property for module exports;
|
|
87
|
+
> - MIT-license applied.
|
|
88
|
+
|
|
89
|
+
#### *v0.0.4*
|
|
90
|
+
|
|
91
|
+
Pre-release version.
|
|
92
|
+
|
|
93
|
+
> - updated dependency on `@cntwg/bsfoc-lib-js` module to v0.0.5.
|
|
94
|
+
|
|
95
|
+
#### *v0.0.3*
|
|
96
|
+
|
|
97
|
+
Pre-release version.
|
|
98
|
+
|
|
99
|
+
> - added `activateHTMLElements` function;
|
|
100
|
+
> - added `inactivateHTMLElements` function;
|
|
101
|
+
> - added `createNewHtmlElement` function (experimental);
|
|
102
|
+
> - `html-helper-lib.md` updated;
|
|
103
|
+
> - `html-ctrls-btn.md` updated;
|
|
104
|
+
> - `html-ctrls-list.md` updated.
|
|
105
|
+
|
|
106
|
+
#### *v0.0.2*
|
|
107
|
+
|
|
108
|
+
Pre-release version.
|
|
109
|
+
|
|
110
|
+
> - `README.md` added;
|
|
111
|
+
> - `html-helper-lib.md` added to `doc`;
|
|
112
|
+
> - `html-ctrls-btn.md` added to `doc`;
|
|
113
|
+
> - `html-ctrls-list.md` added to `doc`;
|
|
114
|
+
> - added `CSS_CLASS_ACTIVE` constant to `CSS_CLASS_STRING`;
|
|
115
|
+
> - added `isActiveHTMLElement` function;
|
|
116
|
+
> - added `markHtmlElementAsActive` function;
|
|
117
|
+
> - added `unmarkActiveHtmlElement` function;
|
|
118
|
+
> - `html-btn-ctrl.js` was renamed `html-ctrls-btn.js`;
|
|
119
|
+
> - `html-list-ctrl.js` was renamed `html-ctrls-list.js`.
|
|
120
|
+
|
|
121
|
+
#### *v0.0.1*
|
|
122
|
+
|
|
123
|
+
Pre-release version.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019-2022 Yuri Grachev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
>|***rev.*:**|0.1.2|
|
|
2
|
+
>|:---|---:|
|
|
3
|
+
>|date:|2022-09-12|
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
This module provide a base set of helpers for javascript. So your work can run a bit easy by using it when you deal with HTML-forms.
|
|
8
|
+
|
|
9
|
+
## Use cases
|
|
10
|
+
|
|
11
|
+
This module was make for use as a library in a development of a Web-apps based on [Electron](https://en.wikipedia.org/wiki/Electron_(software_framework)) as main target.
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
This module contains the following components:
|
|
16
|
+
|
|
17
|
+
- base helper module which provided a set of constants and functions usefull for some manipulation with HTML-elements.
|
|
18
|
+
|
|
19
|
+
> *For more details see `html-helper.md` in module `doc` directory*.
|
|
20
|
+
|
|
21
|
+
- class `THtmlButtonsSet`,
|
|
22
|
+
- class `THtmlListButtonsController`,
|
|
23
|
+
- class `THtmlButtonsControllerARCSet`.
|
|
24
|
+
|
|
25
|
+
> *For more details see `html-ctrls-btn.md` in module `doc` directory*.
|
|
26
|
+
|
|
27
|
+
- classes for working with HTML-elements maintaining a lists support such as:
|
|
28
|
+
- `THtmlItemsListContainer`,
|
|
29
|
+
- `THtmlItemsListController`,
|
|
30
|
+
- `THtmlStubItemsSet`.
|
|
31
|
+
|
|
32
|
+
> *For more details see `html-ctrls-list.md` in module `doc` directory*.
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
>|***rev.*:**|0.1.8|
|
|
2
|
+
>|:---|---:|
|
|
3
|
+
>|date:|2022-09-12|
|
|
4
|
+
|
|
5
|
+
## Introduction
|
|
6
|
+
|
|
7
|
+
This paper describes a classes provided by `html-ctrls-btn.js` module.
|
|
8
|
+
|
|
9
|
+
## Module constants
|
|
10
|
+
|
|
11
|
+
By module, constants that is provided listed in the following table:
|
|
12
|
+
|
|
13
|
+
|name|value|
|
|
14
|
+
|:---|---:|
|
|
15
|
+
|`BTS_DEF_GROUP_NAME`|'all'|
|
|
16
|
+
|
|
17
|
+
## Module classes
|
|
18
|
+
|
|
19
|
+
### **THtmlButtonsSet**
|
|
20
|
+
|
|
21
|
+
This class provide a manageable collection which used to group buttons placed on an HTML-form and controls those groups and all its members.
|
|
22
|
+
|
|
23
|
+
#### class constructor
|
|
24
|
+
|
|
25
|
+
The class constructor creates a new instance of the class. No arguments is receives by it.
|
|
26
|
+
|
|
27
|
+
#### class properties
|
|
28
|
+
|
|
29
|
+
The table below describes a properties of a `THtmlButtonsSet` class:
|
|
30
|
+
|
|
31
|
+
|property name|property type|read only|description|
|
|
32
|
+
|:---|---|---|:---|
|
|
33
|
+
|`ItemNames`|`array`|yes|contains a list of all buttons names|
|
|
34
|
+
|`GroupNames`|`array`|yes|contains a list of all buttons groups|
|
|
35
|
+
|
|
36
|
+
#### class methods
|
|
37
|
+
|
|
38
|
+
##### **hasItem(name)**
|
|
39
|
+
|
|
40
|
+
This method returns `true` if item named by `name` exist in the collection and `false` if else.
|
|
41
|
+
|
|
42
|
+
##### **addItem(name, item\[, groups])**
|
|
43
|
+
|
|
44
|
+
This method adds a "button" element given by `item` named by `name` to a set members and returns `true` if succeed. If `groups` is given the `item` will be added to a groups members listed by `groups` but only if such a group was already declared.
|
|
45
|
+
|
|
46
|
+
##### **addItemToGroup(name, args)**
|
|
47
|
+
|
|
48
|
+
This method adds an existing item addressed by 'name' to a members of a groups listed by 'args'. If succeed `true` is returned.
|
|
49
|
+
|
|
50
|
+
##### **delItem(name)**
|
|
51
|
+
|
|
52
|
+
This method deletes a "button" element named by `name` and returned `true` if succeed.
|
|
53
|
+
|
|
54
|
+
##### **delItemFromGroup(name, args)**
|
|
55
|
+
|
|
56
|
+
This method deletes an existing item addressed by 'name' from a members of a groups listed by 'args'. If succeed `true` is returned.
|
|
57
|
+
|
|
58
|
+
##### **renameItem(oldName, newName)**
|
|
59
|
+
|
|
60
|
+
This method renames a "button" element addressed by `oldName` to its `newName`.
|
|
61
|
+
|
|
62
|
+
##### **enableItem(name)**
|
|
63
|
+
|
|
64
|
+
This methods activates a "button" element named by `name`.
|
|
65
|
+
|
|
66
|
+
##### **disableItem(name)**
|
|
67
|
+
|
|
68
|
+
This methods inactivates a "button" element named by `name`.
|
|
69
|
+
|
|
70
|
+
##### **hasGroup(name)**
|
|
71
|
+
|
|
72
|
+
This method returns `true` if an items group named by `name` exist in the collection and `false` if else.
|
|
73
|
+
|
|
74
|
+
##### **addGroup(name)**
|
|
75
|
+
|
|
76
|
+
This method adds a group given by `name`. If succeed `true` is returned.
|
|
77
|
+
|
|
78
|
+
##### **delGroup(name)**
|
|
79
|
+
|
|
80
|
+
This method deletes the gpoup given by `name`. If succeed `true` is returned.
|
|
81
|
+
|
|
82
|
+
##### **renameGroup(oldName, newName)**
|
|
83
|
+
|
|
84
|
+
This method renames a group addressed by `oldName` to its `newName`.
|
|
85
|
+
|
|
86
|
+
##### **enableGroup(name)**
|
|
87
|
+
|
|
88
|
+
This method activates all "button" elements present in a group named by `name`.
|
|
89
|
+
|
|
90
|
+
##### **disableGroup(name)**
|
|
91
|
+
|
|
92
|
+
This method inactivates all "button" elements present in a group named by `name`.
|
|
93
|
+
|
|
94
|
+
#### class methods (*static*)
|
|
95
|
+
|
|
96
|
+
##### **isHTMLButton(object)**
|
|
97
|
+
|
|
98
|
+
This method checks if the given object represents a "button" element and if so `true` is returned.
|
|
99
|
+
|
|
100
|
+
### **THtmlListButtonsController**
|
|
101
|
+
|
|
102
|
+
This class provide a buttons controller to use with a list components to performs actions for list elements selection.
|
|
103
|
+
|
|
104
|
+
#### class constructor
|
|
105
|
+
|
|
106
|
+
The class constructor creates a new instance of the class. It receives an `options` parameter which structure has listed below:
|
|
107
|
+
|
|
108
|
+
|option name|option type|default value|description|
|
|
109
|
+
|:---|---|---:|:---|
|
|
110
|
+
|`btnFirst`|`HTMLElement`|---|define HTML-button which will select the first element|
|
|
111
|
+
|`btn_frst`|`HTMLElement`|---|*will deprecate (use `btnFirst` instead)*|
|
|
112
|
+
|`btnPrev`|`HTMLElement`|---|define HTML-button which will select the previous element|
|
|
113
|
+
|`btn_prev`|`HTMLElement`|---|*will deprecate (use `btnPrev` instead)*|
|
|
114
|
+
|`btnNext`|`HTMLElement`|---|define HTML-button which will select the next element|
|
|
115
|
+
|`btn_next`|`HTMLElement`|---|*will deprecate (use `btnNext` instead)*|
|
|
116
|
+
|`btnLast`|`HTMLElement`|---|define HTML-button which will select the last element|
|
|
117
|
+
|`btn_last`|`HTMLElement`|---|*will deprecate (use `btnLast` instead)*|
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
#### class properties
|
|
121
|
+
|
|
122
|
+
This class has none.
|
|
123
|
+
|
|
124
|
+
#### class methods
|
|
125
|
+
|
|
126
|
+
##### **disableAll()**
|
|
127
|
+
|
|
128
|
+
This method disables all buttons that holds by the controller.
|
|
129
|
+
|
|
130
|
+
##### **disableBkwd()**
|
|
131
|
+
|
|
132
|
+
This method disables all buttons in *'move backward'* group (*i.e. `btnFirst` and `btnPrev`*) that holds by the controller.
|
|
133
|
+
|
|
134
|
+
##### **disableFrwd()**
|
|
135
|
+
|
|
136
|
+
This method disables all buttons in *'move forward'* group (*i.e. `btnNext` and `btnLast`*) that holds by the controller.
|
|
137
|
+
|
|
138
|
+
##### **enableAll()**
|
|
139
|
+
|
|
140
|
+
This method enables all buttons that holds by the controller.
|
|
141
|
+
|
|
142
|
+
##### **enableBkwd()**
|
|
143
|
+
|
|
144
|
+
This method enables all buttons in *'move backward'* group (*i.e. `btnFirst` and `btnPrev`*) that holds by the controller.
|
|
145
|
+
|
|
146
|
+
##### **enableFrwd()**
|
|
147
|
+
|
|
148
|
+
This method enables all buttons in *'move forward'* group (*i.e. `btnNext` and `btnLast`*) that holds by the controller.
|
|
149
|
+
|
|
150
|
+
#### class methods (*special*)
|
|
151
|
+
|
|
152
|
+
##### **on(name, event)**
|
|
153
|
+
|
|
154
|
+
This method sets event handler addressed by `name` parameter for the class instance.
|
|
155
|
+
|
|
156
|
+
> Note: for current implementation you can't reset or set new event handler (*especially another one*) if a handler with the same name exists already.
|
|
157
|
+
|
|
158
|
+
#### class events
|
|
159
|
+
|
|
160
|
+
The class generates the events listed in the table bellow:
|
|
161
|
+
|
|
162
|
+
|event name|description|
|
|
163
|
+
|:---|:---|
|
|
164
|
+
|`btn-first-pressed`|fired if the `btnFirst` was pressed|
|
|
165
|
+
|`btn-prev-pressed`|fired if the `btnPrev` was pressed|
|
|
166
|
+
|`btn-next-pressed`|fired if the `btnNext` was pressed|
|
|
167
|
+
|`btn-last-pressed`|fired if the `btnLast` was pressed|
|
|
168
|
+
|
|
169
|
+
### **THtmlButtonsControllerARCSet**
|
|
170
|
+
|
|
171
|
+
This class provide a buttons controller to use with a form components to performs apply/reject actions on a form data when editing.
|
|
172
|
+
|
|
173
|
+
#### class constructor
|
|
174
|
+
|
|
175
|
+
The class constructor creates a new instance of the class. It receives an `options` parameter which structure has listed below:
|
|
176
|
+
|
|
177
|
+
|option name|option type|default value|description|
|
|
178
|
+
|:---|---|---:|:---|
|
|
179
|
+
|`btnApply`|`HTMLElement`|---|define HTML-button which will accept all changes|
|
|
180
|
+
|`btnReset`|`HTMLElement`|---|define HTML-button that will require reset all changes to data if made|
|
|
181
|
+
|`btnCancel`|`HTMLElement`|---|define HTML-button that will require reject all changes and close the form|
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
#### class properties
|
|
185
|
+
|
|
186
|
+
This class has none.
|
|
187
|
+
|
|
188
|
+
#### class methods
|
|
189
|
+
|
|
190
|
+
##### **disableAll()**
|
|
191
|
+
|
|
192
|
+
This method disables all buttons that holds by the controller.
|
|
193
|
+
|
|
194
|
+
##### **disableMain()**
|
|
195
|
+
|
|
196
|
+
This method disables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
|
|
197
|
+
|
|
198
|
+
##### **enableAll()**
|
|
199
|
+
|
|
200
|
+
This method enables all buttons that holds by the controller.
|
|
201
|
+
|
|
202
|
+
##### **enableMain()**
|
|
203
|
+
|
|
204
|
+
This method enables all buttons in *'main'* group (*i.e. `btnApply` and `btnReset`*) that holds by the controller.
|
|
205
|
+
|
|
206
|
+
#### class methods (*special*)
|
|
207
|
+
|
|
208
|
+
##### **on(name, event)**
|
|
209
|
+
|
|
210
|
+
This method sets event handler addressed by `name` parameter for the class instance.
|
|
211
|
+
|
|
212
|
+
> Note: for current implementation you can't reset or set new event handler (*especially another one*) if a handler with the same name exists already.
|
|
213
|
+
|
|
214
|
+
#### class events
|
|
215
|
+
|
|
216
|
+
The class generates the events listed in the table bellow:
|
|
217
|
+
|
|
218
|
+
|event name|description|
|
|
219
|
+
|:---|:---|
|
|
220
|
+
|`btn-apply-pressed`|fired if the `btnApply` was pressed|
|
|
221
|
+
|`btn-reset-pressed`|fired if the `btnReset` was pressed|
|
|
222
|
+
|`btn-cancel-pressed`|fired if the `btnCancel` was pressed|
|