@cocreate/events 1.22.1 → 1.24.0
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 +32 -0
- package/docs/index.html +341 -360
- package/package.json +1 -1
- package/prettier.config.js +16 -0
- package/src/index.js +166 -141
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
# [1.24.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.23.0...v1.24.0) (2024-11-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* check for value attibutes has empty string indicating that the a value attribute exists and that the value will not be retrieved using getValue() ([c79a0b3](https://github.com/CoCreate-app/CoCreate-events/commit/c79a0b338378b46613e9ba3b5b98c71e040ecbc7))
|
|
7
|
+
* if events ([afaf496](https://github.com/CoCreate-app/CoCreate-events/commit/afaf496cf01eb6a013e050952a08a530d5e63e67))
|
|
8
|
+
* observer taget has been renamed to selector ([fae2134](https://github.com/CoCreate-app/CoCreate-events/commit/fae2134873fea89480a7c28920d4277691d7109a))
|
|
9
|
+
* pretier.config.js and file formating ([f31afac](https://github.com/CoCreate-app/CoCreate-events/commit/f31afac19f6e4875866f6e090e2aa861a453639c))
|
|
10
|
+
* selected group handling ([975008a](https://github.com/CoCreate-app/CoCreate-events/commit/975008a568f8983772a76ae843298fb5cfcc807c))
|
|
11
|
+
* temporarily commented checking for parent events ([09d0394](https://github.com/CoCreate-app/CoCreate-events/commit/09d0394b946306862153ca5164b08e1440cbbb63))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add prettier.config.js and format files ([558b874](https://github.com/CoCreate-app/CoCreate-events/commit/558b8748cb2ba34d479680acb1c25f359283d817))
|
|
17
|
+
* add prettier.config.js and format files ([9920bd7](https://github.com/CoCreate-app/CoCreate-events/commit/9920bd7ebe78ddeb41524377307b08b6271f45b8))
|
|
18
|
+
* handle action and replace ([25fc93c](https://github.com/CoCreate-app/CoCreate-events/commit/25fc93cc8846a4571903e556ec16acd9acf74be1))
|
|
19
|
+
* improved gropu support ([a4b10f8](https://github.com/CoCreate-app/CoCreate-events/commit/a4b10f82a4fbefb42d08346a72bd4731d3c8b71c))
|
|
20
|
+
|
|
21
|
+
# [1.23.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.1...v1.23.0) (2024-09-21)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* observer-target attribute ([92593d3](https://github.com/CoCreate-app/CoCreate-events/commit/92593d32c4b53fe97dab511e44dd1c9f345d708e))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* *-insert-adjacent attribute to apply value using insertAdjacentHTML() ([3d2151d](https://github.com/CoCreate-app/CoCreate-events/commit/3d2151d91d56ad53df006343e4f18b3aa1a99b1d))
|
|
32
|
+
|
|
1
33
|
## [1.22.1](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.0...v1.22.1) (2024-08-24)
|
|
2
34
|
|
|
3
35
|
|
package/docs/index.html
CHANGED
|
@@ -1,173 +1,181 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>CoCreate-events Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://cocreate.app/images/favicon.ico"
|
|
13
|
+
/>
|
|
14
|
+
<meta
|
|
15
|
+
name="description"
|
|
16
|
+
content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable."
|
|
17
|
+
/>
|
|
18
|
+
<meta
|
|
19
|
+
name="keywords"
|
|
20
|
+
content="helper classes, utility classes, css framework, css library, inline style classes"
|
|
21
|
+
/>
|
|
22
|
+
<meta name="robots" content="index,follow" />
|
|
23
|
+
<meta
|
|
24
|
+
property="og:image"
|
|
25
|
+
content="https://cdn.cocreate.app/docs/events.png"
|
|
26
|
+
/>
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
<link
|
|
29
|
+
rel="stylesheet"
|
|
30
|
+
href="../index.css"
|
|
31
|
+
array="files"
|
|
32
|
+
object="60888216117c640e7596303f"
|
|
33
|
+
key="src"
|
|
34
|
+
type="text/css"
|
|
35
|
+
save="true"
|
|
36
|
+
/>
|
|
37
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
38
|
+
</head>
|
|
34
39
|
|
|
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
|
-
share-network="share"
|
|
102
|
-
title="Share on share"
|
|
103
|
-
><i src="/assets/svg/share-alt.svg"></i
|
|
104
|
-
></a>
|
|
105
|
-
</div>
|
|
106
|
-
<a
|
|
107
|
-
href="https://github.com/CoCreate-app/CoCreate-events"
|
|
108
|
-
target="_blank"
|
|
109
|
-
class="margin-right:15px"
|
|
110
|
-
><i src="/assets/svg/github.svg"></i
|
|
111
|
-
></a>
|
|
112
|
-
</div>
|
|
40
|
+
<body>
|
|
41
|
+
<!-- Navbar -->
|
|
42
|
+
<nav
|
|
43
|
+
class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
|
|
44
|
+
content_id="content"
|
|
45
|
+
scroll="sticky-nav,"
|
|
46
|
+
scroll-up="5"
|
|
47
|
+
scroll-down="5"
|
|
48
|
+
path="../"
|
|
49
|
+
src="../components/navbar.html"
|
|
50
|
+
></nav>
|
|
51
|
+
<sidenav
|
|
52
|
+
id="menuL"
|
|
53
|
+
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
54
|
+
resizable
|
|
55
|
+
resize-selector="[content_id='content']"
|
|
56
|
+
resize-property="margin-left"
|
|
57
|
+
resize-value="width"
|
|
58
|
+
>
|
|
59
|
+
<menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
|
|
60
|
+
<div resize="right"></div>
|
|
61
|
+
</sidenav>
|
|
62
|
+
<main
|
|
63
|
+
class="padding-top:15px padding:15px@lg@xl"
|
|
64
|
+
content_id="content"
|
|
65
|
+
id="cocreate-events"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px"
|
|
69
|
+
>
|
|
70
|
+
<div class="display:flex align-items:center">
|
|
71
|
+
<h2>CoCreate-events</h2>
|
|
72
|
+
</div>
|
|
73
|
+
<div
|
|
74
|
+
class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
class="display:flex align-items:center transition:0.3s padding-left:10px"
|
|
78
|
+
share-network="true"
|
|
79
|
+
share-text="Enter decription here"
|
|
80
|
+
share-title="testing im a title"
|
|
81
|
+
share-height="600"
|
|
82
|
+
share-width="700"
|
|
83
|
+
share-media="https://cdn.cocreate.app/docs/events.png"
|
|
84
|
+
hover="display:block!important"
|
|
85
|
+
hover-selector=".social-networks"
|
|
86
|
+
>
|
|
87
|
+
<div class="display:none social-networks">
|
|
88
|
+
<a
|
|
89
|
+
class="margin-right:15px"
|
|
90
|
+
share-network="twitter"
|
|
91
|
+
title="Share on twitter"
|
|
92
|
+
><i src="/assets/svg/twitter.svg"></i
|
|
93
|
+
></a>
|
|
94
|
+
<a
|
|
95
|
+
class="margin-right:15px"
|
|
96
|
+
share-network="facebook"
|
|
97
|
+
title="Share on Facebook"
|
|
98
|
+
><i src="/assets/svg/facebook.svg"></i
|
|
99
|
+
></a>
|
|
100
|
+
<a
|
|
101
|
+
class="margin-right:15px"
|
|
102
|
+
share-network="instagram"
|
|
103
|
+
title="Share on instagram"
|
|
104
|
+
><i src="/assets/svg/instagram.svg"></i
|
|
105
|
+
></a>
|
|
113
106
|
</div>
|
|
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
|
-
|
|
107
|
+
<a
|
|
108
|
+
class="margin-right:15px"
|
|
109
|
+
share-network="share"
|
|
110
|
+
title="Share on share"
|
|
111
|
+
><i src="/assets/svg/share-alt.svg"></i
|
|
112
|
+
></a>
|
|
113
|
+
</div>
|
|
114
|
+
<a
|
|
115
|
+
href="https://github.com/CoCreate-app/CoCreate-events"
|
|
116
|
+
target="_blank"
|
|
117
|
+
class="margin-right:15px"
|
|
118
|
+
><i src="/assets/svg/github.svg"></i
|
|
119
|
+
></a>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
<h1
|
|
123
|
+
class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100"
|
|
124
|
+
>
|
|
125
|
+
It is used to change values in classes or specific attributes, its name
|
|
126
|
+
describes its functionality events.
|
|
127
|
+
</h1>
|
|
128
|
+
<div id="events-section" class="display:flex flex-wrap:wrap">
|
|
129
|
+
<div
|
|
130
|
+
class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px"
|
|
131
|
+
>
|
|
132
|
+
<div
|
|
133
|
+
id="events-install"
|
|
134
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
135
|
+
scroll
|
|
136
|
+
scroll-intersect="color:dodgerblue"
|
|
137
|
+
scroll-selector="#events-install-section"
|
|
138
|
+
>
|
|
139
|
+
<span
|
|
140
|
+
class="display:flex align-items:center width:fit-content"
|
|
141
|
+
hover="display:block!important"
|
|
142
|
+
hover-selector="[href='#events-install']"
|
|
143
|
+
>
|
|
144
|
+
<h2 class="padding:5px_0px">Install</h2>
|
|
145
|
+
<a class="margin-left:10px display:none" href="#events-install"
|
|
146
|
+
><i src="/assets/svg/link.svg"></i
|
|
147
|
+
></a>
|
|
148
|
+
</span>
|
|
149
|
+
</div>
|
|
150
|
+
<pre><code class="language-bash">npm i @cocreate/events</code></pre>
|
|
151
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
152
|
+
Or you can use cdn link:
|
|
153
|
+
</p>
|
|
154
|
+
<pre><code class="language-html"><script>https://cdn.cocreate.app/events/latest/CoCreate-events.min.js</script></code></pre>
|
|
145
155
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
This is events usage
|
|
167
|
-
</p>
|
|
156
|
+
<div
|
|
157
|
+
id="events-usage"
|
|
158
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
159
|
+
scroll
|
|
160
|
+
scroll-intersect="color:dodgerblue"
|
|
161
|
+
scroll-selector="#events-usage-section"
|
|
162
|
+
>
|
|
163
|
+
<span
|
|
164
|
+
class="display:flex align-items:center width:fit-content"
|
|
165
|
+
hover="display:block!important"
|
|
166
|
+
hover-selector="[href='#events-usage']"
|
|
167
|
+
>
|
|
168
|
+
<h2 class="padding:5px_0px">Usage</h2>
|
|
169
|
+
<a class="margin-left:10px display:none" href="#events-usage"
|
|
170
|
+
><i src="/assets/svg/link.svg"></i
|
|
171
|
+
></a>
|
|
172
|
+
</span>
|
|
173
|
+
</div>
|
|
174
|
+
<div class="">
|
|
175
|
+
<p class="padding:10px_0px line-height:1.5">This is events usage</p>
|
|
168
176
|
|
|
169
|
-
|
|
170
|
-
|
|
177
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
178
|
+
<pre>
|
|
171
179
|
<code class="language-js">
|
|
172
180
|
<article>
|
|
173
181
|
<div id="div-01" class="vdom-item">Here is div-01 i should get class hidden
|
|
@@ -191,206 +199,179 @@
|
|
|
191
199
|
<div class="vdom-item" id="hey" data-test="" events-attribute='data-test' events="active, other, hi, jean" >some content</div>
|
|
192
200
|
</code>
|
|
193
201
|
</pre>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
<span class="cocreate-badge success"
|
|
257
|
-
>string</span
|
|
258
|
-
>
|
|
259
|
-
<span class="cocreate-badge warning"
|
|
260
|
-
>optional</span
|
|
261
|
-
>
|
|
262
|
-
</h4>
|
|
263
|
-
<p>
|
|
264
|
-
Apply events functionality to a specific element
|
|
265
|
-
</p>
|
|
266
|
-
</li>
|
|
267
|
-
<li
|
|
268
|
-
class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
269
|
-
<h4>
|
|
270
|
-
<span>events-closest</span>
|
|
271
|
-
<span class="cocreate-badge success"
|
|
272
|
-
>string</span
|
|
273
|
-
>
|
|
274
|
-
<span class="cocreate-badge warning"
|
|
275
|
-
>optional</span
|
|
276
|
-
>
|
|
277
|
-
</h4>
|
|
278
|
-
<p>
|
|
279
|
-
Apply events functionality to a closset element
|
|
280
|
-
</p>
|
|
281
|
-
</li>
|
|
282
|
-
</ul>
|
|
283
|
-
</div>
|
|
202
|
+
</div>
|
|
203
|
+
<p class="padding:10px_0px line-height:1.5">This is events usage</p>
|
|
204
|
+
</div>
|
|
205
|
+
<div
|
|
206
|
+
id="events-attributes"
|
|
207
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
208
|
+
scroll
|
|
209
|
+
scroll-intersect="color:dodgerblue"
|
|
210
|
+
scroll-selector="#events-attributes-section"
|
|
211
|
+
>
|
|
212
|
+
<span
|
|
213
|
+
class="display:flex align-items:center width:fit-content"
|
|
214
|
+
hover="display:block!important"
|
|
215
|
+
hover-selector="[href='#events-attributes']"
|
|
216
|
+
>
|
|
217
|
+
<h2 class="padding:5px_0px">Attributes</h2>
|
|
218
|
+
<a class="margin-left:10px display:none" href="#events-attributes"
|
|
219
|
+
><i src="/assets/svg/link.svg"></i
|
|
220
|
+
></a>
|
|
221
|
+
</span>
|
|
222
|
+
</div>
|
|
223
|
+
<ul class="list-style-type:none">
|
|
224
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
225
|
+
<h4>
|
|
226
|
+
<span>events</span>
|
|
227
|
+
<span class="cocreate-badge success">string</span>
|
|
228
|
+
<span class="cocreate-badge danger">required</span>
|
|
229
|
+
</h4>
|
|
230
|
+
<p>
|
|
231
|
+
It is used to initialize the element, and this attribute is
|
|
232
|
+
added to the specific attribute if it is defined, by default the
|
|
233
|
+
class attribute is used
|
|
234
|
+
</p>
|
|
235
|
+
</li>
|
|
236
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
237
|
+
<h4>
|
|
238
|
+
<span>events-attribute</span>
|
|
239
|
+
<span class="cocreate-badge success">string</span>
|
|
240
|
+
<span class="cocreate-badge warning">optional</span>
|
|
241
|
+
</h4>
|
|
242
|
+
<p>
|
|
243
|
+
Add or remove values, by default the class attribute is used
|
|
244
|
+
</p>
|
|
245
|
+
</li>
|
|
246
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
247
|
+
<h4>
|
|
248
|
+
<span>events-selector</span>
|
|
249
|
+
<span class="cocreate-badge success">string</span>
|
|
250
|
+
<span class="cocreate-badge warning">optional</span>
|
|
251
|
+
</h4>
|
|
252
|
+
<p>Apply events functionality to a specific element</p>
|
|
253
|
+
</li>
|
|
254
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
255
|
+
<h4>
|
|
256
|
+
<span>events-closest</span>
|
|
257
|
+
<span class="cocreate-badge success">string</span>
|
|
258
|
+
<span class="cocreate-badge warning">optional</span>
|
|
259
|
+
</h4>
|
|
260
|
+
<p>Apply events functionality to a closset element</p>
|
|
261
|
+
</li>
|
|
262
|
+
</ul>
|
|
263
|
+
</div>
|
|
284
264
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
265
|
+
<div
|
|
266
|
+
class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey"
|
|
267
|
+
>
|
|
268
|
+
<!-- SandBox -->
|
|
269
|
+
<div
|
|
270
|
+
id="events-demo"
|
|
271
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
272
|
+
scroll
|
|
273
|
+
scroll-intersect="color:dodgerblue"
|
|
274
|
+
scroll-selector="#events-demo-section"
|
|
275
|
+
>
|
|
276
|
+
<span
|
|
277
|
+
class="display:flex align-items:center width:fit-content"
|
|
278
|
+
hover="display:block!important"
|
|
279
|
+
hover-selector="[href='#events-demo']"
|
|
280
|
+
>
|
|
281
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
282
|
+
<a class="margin-left:10px display:none" href="#events-demo"
|
|
283
|
+
><i src="/assets/svg/link.svg"></i
|
|
284
|
+
></a>
|
|
285
|
+
</span>
|
|
286
|
+
</div>
|
|
287
|
+
<div class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
288
|
+
<!-- SandBox -->
|
|
289
|
+
<div
|
|
290
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
291
|
+
id="playground"
|
|
292
|
+
>
|
|
293
|
+
<div
|
|
294
|
+
id="demo-code"
|
|
295
|
+
resizable
|
|
296
|
+
class="position:relative height:50%"
|
|
297
|
+
>
|
|
298
|
+
<textarea
|
|
299
|
+
type="code"
|
|
300
|
+
lang="html"
|
|
301
|
+
array="demos"
|
|
302
|
+
object=""
|
|
303
|
+
key="demo"
|
|
304
|
+
save="false"
|
|
305
|
+
id="demo"
|
|
306
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"
|
|
307
|
+
></textarea>
|
|
308
|
+
<div resize="bottom" class="background:lightgrey"></div>
|
|
309
|
+
</div>
|
|
329
310
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
311
|
+
<div
|
|
312
|
+
id="demo-preview"
|
|
313
|
+
class="position:relative overflow:auto background-color:white"
|
|
314
|
+
>
|
|
315
|
+
<div class="demopreview padding:20px"></div>
|
|
316
|
+
</div>
|
|
335
317
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
fullscreen-selector="#playground"></a>
|
|
380
|
-
</div>
|
|
381
|
-
</div>
|
|
382
|
-
<!-- End SandBox -->
|
|
383
|
-
</div>
|
|
384
|
-
</div>
|
|
318
|
+
<div
|
|
319
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6"
|
|
320
|
+
>
|
|
321
|
+
<a
|
|
322
|
+
class="margin-right:10px"
|
|
323
|
+
id="eye"
|
|
324
|
+
show="#eye-slash"
|
|
325
|
+
hide="#eye, #demo-preview"
|
|
326
|
+
events="code-height"
|
|
327
|
+
events-selector="#demo-code"
|
|
328
|
+
><i class="height:18px" src="/assets/svg/eye.svg"></i
|
|
329
|
+
></a>
|
|
330
|
+
<a
|
|
331
|
+
class="margin-right:10px"
|
|
332
|
+
hidden
|
|
333
|
+
id="eye-slash"
|
|
334
|
+
show="#eye, #demo-preview"
|
|
335
|
+
hide="#eye-slash"
|
|
336
|
+
events="code-height"
|
|
337
|
+
events-selector="#demo-code"
|
|
338
|
+
><i src="/assets/svg/eye-slash.svg"></i
|
|
339
|
+
></a>
|
|
340
|
+
<a
|
|
341
|
+
class="margin-right:10px"
|
|
342
|
+
id="code"
|
|
343
|
+
show="#code-slash"
|
|
344
|
+
hide="#code, #demo-code"
|
|
345
|
+
><i src="/assets/svg/code.svg"></i
|
|
346
|
+
></a>
|
|
347
|
+
<a
|
|
348
|
+
class="margin-right:10px"
|
|
349
|
+
hidden
|
|
350
|
+
id="code-slash"
|
|
351
|
+
show="#code, #demo-code"
|
|
352
|
+
hide="#code-slash"
|
|
353
|
+
><i class="height:18px" src="/assets/svg/code.svg"></i
|
|
354
|
+
></a>
|
|
355
|
+
<a
|
|
356
|
+
class="margin-right:5px"
|
|
357
|
+
fullscreen
|
|
358
|
+
fullscreen-selector="#playground"
|
|
359
|
+
></a>
|
|
360
|
+
</div>
|
|
385
361
|
</div>
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
362
|
+
<!-- End SandBox -->
|
|
363
|
+
</div>
|
|
364
|
+
</div>
|
|
365
|
+
</div>
|
|
366
|
+
<button
|
|
367
|
+
href="https://github.com/CoCreate-app/CoCreate-events/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
|
|
368
|
+
target="_blank"
|
|
369
|
+
class="display:flex justify-content:center align-items:center position:fixed bottom:15px right:15px height:50px width:50px border-radius:50% box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)"
|
|
370
|
+
>
|
|
371
|
+
<i src="../assets/svg/pencil-alt.svg"></i>
|
|
372
|
+
</button>
|
|
373
|
+
</main>
|
|
393
374
|
|
|
394
|
-
|
|
395
|
-
|
|
375
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
376
|
+
</body>
|
|
396
377
|
</html>
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -63,7 +63,7 @@ const CoCreateEvents = {
|
|
|
63
63
|
observer.init({
|
|
64
64
|
name: 'CoCreateEventName',
|
|
65
65
|
observe: ['addedNodes'],
|
|
66
|
-
|
|
66
|
+
selector: `[event-name]`,
|
|
67
67
|
callback: function (mutation) {
|
|
68
68
|
let name = mutation.target.getAttribute('event-name')
|
|
69
69
|
self.initPrefix(name);
|
|
@@ -89,13 +89,13 @@ const CoCreateEvents = {
|
|
|
89
89
|
name: 'CoCreateEventattributes',
|
|
90
90
|
observe: ['attributes', 'addedNodes'],
|
|
91
91
|
attributeName: [`${prefix}-events`],
|
|
92
|
-
|
|
92
|
+
selector: selector,
|
|
93
93
|
callback: function (mutation) {
|
|
94
94
|
self.initElements([mutation.target], prefix, events)
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
if (events.includes('observer')) {
|
|
98
|
+
if (events && events.includes('observer')) {
|
|
99
99
|
observer.init({
|
|
100
100
|
name: 'observerAttributes',
|
|
101
101
|
observe: ['attributes'],
|
|
@@ -146,7 +146,10 @@ const CoCreateEvents = {
|
|
|
146
146
|
if (events.includes('observer')) {
|
|
147
147
|
let target;
|
|
148
148
|
for (let attribute of el.attributes) {
|
|
149
|
-
if (
|
|
149
|
+
if (attribute.name === 'observe-target') {
|
|
150
|
+
target = attribute.value
|
|
151
|
+
break;
|
|
152
|
+
} else if ([`${prefix}-selector`, `${prefix}-closest`, `${prefix}-parent`, `${prefix}-next`, `${prefix}-previous`].includes(attribute.name)) {
|
|
150
153
|
target = attribute.value
|
|
151
154
|
break;
|
|
152
155
|
}
|
|
@@ -154,7 +157,7 @@ const CoCreateEvents = {
|
|
|
154
157
|
if (target)
|
|
155
158
|
observer.init({
|
|
156
159
|
observe: ['addedNodes'],
|
|
157
|
-
target,
|
|
160
|
+
selector: target,
|
|
158
161
|
callback: function (mutation) {
|
|
159
162
|
self.__updateElements(el, prefix, mutation.target);
|
|
160
163
|
}
|
|
@@ -198,20 +201,20 @@ const CoCreateEvents = {
|
|
|
198
201
|
// return;
|
|
199
202
|
self.__updateElements(target, prefix, null, prefixes[prefix].events);
|
|
200
203
|
|
|
201
|
-
let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-selector], [${prefix}-closest], [${prefix}-parent], [${prefix}-next], [${prefix}-previous]`
|
|
204
|
+
// let selector = `[${prefix}], [${prefix}-key], [${prefix}-value], [${prefix}-selector], [${prefix}-closest], [${prefix}-parent], [${prefix}-next], [${prefix}-previous]`
|
|
202
205
|
|
|
203
|
-
let parentElement = target.parentElement;
|
|
204
|
-
if (parentElement) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
206
|
+
// let parentElement = target.parentElement;
|
|
207
|
+
// if (parentElement) {
|
|
208
|
+
// do {
|
|
209
|
+
// parentElement = parentElement.closest(selector)
|
|
210
|
+
// if (parentElement) {
|
|
211
|
+
// self.__updateElements(parentElement, prefix, null, prefixes[prefix].events);
|
|
212
|
+
// parentElement = parentElement.parentElement
|
|
213
|
+
// }
|
|
214
|
+
// }
|
|
215
|
+
// while (parentElement)
|
|
213
216
|
|
|
214
|
-
}
|
|
217
|
+
// }
|
|
215
218
|
|
|
216
219
|
}
|
|
217
220
|
// }, 500);
|
|
@@ -221,139 +224,157 @@ const CoCreateEvents = {
|
|
|
221
224
|
}
|
|
222
225
|
},
|
|
223
226
|
|
|
224
|
-
__updateElements: async function (
|
|
227
|
+
__updateElements: async function (el, prefix, target, events) {
|
|
225
228
|
const self = this;
|
|
226
|
-
|
|
227
|
-
let
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
if (onEvent) {
|
|
234
|
-
await new Promise((resolve, reject) => {
|
|
235
|
-
const handleEvent = () => {
|
|
236
|
-
document.removeEventListener(onEvent, handleEvent);
|
|
237
|
-
resolve();
|
|
238
|
-
};
|
|
239
|
-
document.addEventListener(onEvent, handleEvent);
|
|
240
|
-
});
|
|
229
|
+
let elements = [el]
|
|
230
|
+
let targetGroup = el.getAttribute(`${prefix}-group`);
|
|
231
|
+
if (targetGroup) {
|
|
232
|
+
document.querySelectorAll(`[${prefix}-group="${targetGroup}"]`).forEach((element) => {
|
|
233
|
+
if (element !== el)
|
|
234
|
+
elements.push(element)
|
|
235
|
+
})
|
|
241
236
|
}
|
|
242
237
|
|
|
243
|
-
let
|
|
244
|
-
|
|
245
|
-
let
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
238
|
+
for (let element of elements) {
|
|
239
|
+
// TODO: support empty value when prefix-attribute defined, add and remove the attribute
|
|
240
|
+
let targetAttribute = element.getAttribute(`${prefix}-attribute`);
|
|
241
|
+
let targetPosition = element.getAttribute(`${prefix}-insert-adjacent`);
|
|
242
|
+
// targetAttribute = checkMediaQueries(targetAttribute)
|
|
243
|
+
// if (targetAttribute === false)
|
|
244
|
+
// return
|
|
245
|
+
|
|
246
|
+
let onEvent = element.getAttribute(`${prefix}-on`)
|
|
247
|
+
if (onEvent) {
|
|
248
|
+
await new Promise((resolve, reject) => {
|
|
249
|
+
const handleEvent = () => {
|
|
250
|
+
document.removeEventListener(onEvent, handleEvent);
|
|
251
|
+
resolve();
|
|
252
|
+
};
|
|
253
|
+
document.addEventListener(onEvent, handleEvent);
|
|
254
|
+
});
|
|
252
255
|
}
|
|
253
256
|
|
|
254
|
-
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
257
|
+
let values
|
|
258
|
+
if (prefix === 'localstorage') {
|
|
259
|
+
let key = element.getAttribute('localstorage-get')
|
|
260
|
+
if (key) {
|
|
261
|
+
values = localStorage.getItem(key)
|
|
262
|
+
} else if (key = element.getAttribute('localstorage-set')) {
|
|
263
|
+
values = await element.getValue()
|
|
264
|
+
if (values)
|
|
265
|
+
localStorage.setItem(key, values)
|
|
266
|
+
}
|
|
260
267
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
else
|
|
265
|
-
values = [values]
|
|
266
|
-
} else {
|
|
267
|
-
values = await element.getValue()
|
|
268
|
-
if (!Array.isArray(values))
|
|
269
|
-
values = [values]
|
|
270
|
-
}
|
|
268
|
+
// if (!key || !values)
|
|
269
|
+
if (!key)
|
|
270
|
+
return
|
|
271
|
+
} else {
|
|
271
272
|
|
|
272
|
-
|
|
273
|
-
return;
|
|
273
|
+
values = element.getAttribute(`${prefix}-value`)
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
if (values === null) {
|
|
276
|
+
let valueElements = queryElements({ element, prefix: `${prefix}-value` });
|
|
277
|
+
if (valueElements) {
|
|
278
|
+
let elementValues = []
|
|
279
|
+
for (let i = 0; i < valueElements.length; i++)
|
|
280
|
+
elementValues.push(valueElements[i].getValue())
|
|
277
281
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
ifValue = [ifValue]
|
|
283
|
-
else
|
|
284
|
-
ifValue = values
|
|
282
|
+
if (elementValues.length)
|
|
283
|
+
values = elementValues
|
|
284
|
+
}
|
|
285
|
+
}
|
|
285
286
|
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
if (values === null)
|
|
288
|
+
values = element.getAttribute(`${prefix}-if-value`)
|
|
289
|
+
if (values === null)
|
|
290
|
+
values = element.getAttribute(prefix);
|
|
288
291
|
|
|
289
|
-
|
|
290
|
-
// let hasCondition = this.elements2.get(element)
|
|
291
|
-
if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
|
|
292
|
+
}
|
|
292
293
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return
|
|
304
|
-
}
|
|
294
|
+
if (values || values === '') {
|
|
295
|
+
if (typeof values === 'string')
|
|
296
|
+
values = values.split(',');
|
|
297
|
+
else if (!Array.isArray(values))
|
|
298
|
+
values = [values]
|
|
299
|
+
} else {
|
|
300
|
+
values = await element.getValue()
|
|
301
|
+
if (!Array.isArray(values))
|
|
302
|
+
values = [values]
|
|
303
|
+
}
|
|
305
304
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
let targetKey = element.getAttribute(`${prefix}-key`);
|
|
305
|
+
if (targetAttribute && !values || values.length === 0)
|
|
306
|
+
return;
|
|
309
307
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
document.querySelectorAll(`[${prefix}-group="${targetGroup}"]`).forEach((el) => {
|
|
313
|
-
let groupValue = el.getAttribute(`${prefix}-value`) || el.getAttribute(prefix);
|
|
314
|
-
let groupValues = groupValue.split(',');
|
|
315
|
-
if (!groupValues || groupValues.length == 0) {
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
308
|
+
let ifCondition = element.getAttribute(`${prefix}-if`);
|
|
309
|
+
let elseCondition = element.getAttribute(`${prefix}-else`);
|
|
318
310
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
|
|
323
|
-
|
|
311
|
+
let ifValue = element.getAttribute(`${prefix}-if-value`)
|
|
312
|
+
if (!ifValue && ifValue !== "")
|
|
313
|
+
ifValue = await element.getValue() || values //values // await element.getValue()
|
|
314
|
+
else if (ifValue || ifValue === "")
|
|
315
|
+
ifValue = [ifValue]
|
|
316
|
+
else
|
|
317
|
+
ifValue = values
|
|
324
318
|
|
|
325
|
-
|
|
319
|
+
if (!Array.isArray(ifValue))
|
|
320
|
+
ifValue = [ifValue]
|
|
326
321
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
for (let i = 0; i < targetElements.length; i++)
|
|
331
|
-
self.setValue(prefix, targetElements[i], groupAttribute, groupValues, groupKey, 'deactivate', events)
|
|
322
|
+
//TODO: improved resize toggling of values
|
|
323
|
+
// let hasCondition = this.elements2.get(element)
|
|
324
|
+
if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
|
|
332
325
|
|
|
333
|
-
|
|
334
|
-
|
|
326
|
+
// if (hasCondition && hasCondition.condition === ifCondition) {
|
|
327
|
+
// return
|
|
328
|
+
// } else
|
|
329
|
+
// this.elements2.set(element, { condition: ifCondition })
|
|
330
|
+
} else if (elseCondition && evaluateCondition(elseCondition, ifValue)) {
|
|
331
|
+
// if (hasCondition && hasCondition.condition === elseCondition) {
|
|
332
|
+
// return
|
|
333
|
+
// } else
|
|
334
|
+
// this.elements2.set(element, { condition: elseCondition })
|
|
335
|
+
} else if (ifCondition || elseCondition) {
|
|
336
|
+
return
|
|
337
|
+
}
|
|
335
338
|
|
|
336
|
-
|
|
339
|
+
let targetText = element.getAttribute(`${prefix}-text`);
|
|
340
|
+
let targetHtml = element.getAttribute(`${prefix}-html`);
|
|
341
|
+
let targetKey = element.getAttribute(`${prefix}-key`);
|
|
337
342
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
x = `${prop}:${x}`; // Update x with prop if it exists
|
|
343
|
+
if (prefix === 'selected') {
|
|
344
|
+
if (el !== element)
|
|
345
|
+
element.removeAttribute('selected')
|
|
346
|
+
else
|
|
347
|
+
element.setAttribute('selected', '')
|
|
344
348
|
}
|
|
345
|
-
return x; // Return the updated x
|
|
346
|
-
});
|
|
347
349
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
let deactivate = false
|
|
351
|
+
if (el !== element)
|
|
352
|
+
deactivate = true
|
|
353
|
+
// values = values.map(x => x.trim());
|
|
354
|
+
|
|
355
|
+
values = values.map(x => {
|
|
356
|
+
if (typeof x === 'string')
|
|
357
|
+
x = x.trim(); // Update x with the trimmed value
|
|
358
|
+
let prop = element.getAttribute(`${prefix}-property`);
|
|
359
|
+
if (prop) {
|
|
360
|
+
x = `${prop}:${x}`; // Update x with prop if it exists
|
|
361
|
+
}
|
|
362
|
+
return x; // Return the updated x
|
|
363
|
+
});
|
|
351
364
|
|
|
352
|
-
|
|
353
|
-
if (
|
|
354
|
-
targetElements[
|
|
355
|
-
}
|
|
356
|
-
|
|
365
|
+
let targetElements = queryElements({ element, prefix });
|
|
366
|
+
if (targetElements === false)
|
|
367
|
+
targetElements = [element]
|
|
368
|
+
let action = element.getAttribute(`${prefix}-action`)
|
|
369
|
+
for (let i = 0; i < targetElements.length; i++) {
|
|
370
|
+
if (action) {
|
|
371
|
+
targetElements[i][action]()
|
|
372
|
+
} else if (!targetAttribute && targetAttribute !== '' && ['click', 'focus', 'blur'].includes(prefix)) {
|
|
373
|
+
targetElements[i][prefix]()
|
|
374
|
+
} else {
|
|
375
|
+
this.setValue(prefix, targetElements[i], targetAttribute, values, targetKey, deactivate, events, targetPosition)
|
|
376
|
+
}
|
|
377
|
+
}
|
|
357
378
|
}
|
|
358
379
|
|
|
359
380
|
document.dispatchEvent(new CustomEvent(`${prefix}End`, {
|
|
@@ -362,11 +383,11 @@ const CoCreateEvents = {
|
|
|
362
383
|
|
|
363
384
|
},
|
|
364
385
|
|
|
365
|
-
setValue: async function (prefix, element, attrName, values, key, deactivate, events) {
|
|
386
|
+
setValue: async function (prefix, element, attrName, values, key, deactivate, events, targetPosition) {
|
|
366
387
|
if (events && events.includes('mouseout')) {
|
|
367
388
|
if (element.matches(':hover')) {
|
|
368
389
|
element.addEventListener('mouseout', () => {
|
|
369
|
-
this.setValue(prefix, element, attrName, values, key, deactivate, events);
|
|
390
|
+
this.setValue(prefix, element, attrName, values, key, deactivate, events, targetPosition);
|
|
370
391
|
}, { once: true });
|
|
371
392
|
return;
|
|
372
393
|
}
|
|
@@ -403,13 +424,7 @@ const CoCreateEvents = {
|
|
|
403
424
|
} else {
|
|
404
425
|
if (attrName === 'value') {
|
|
405
426
|
oldValue = await element.getValue()
|
|
406
|
-
} else if (attrName === 'text') {
|
|
407
|
-
attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
|
|
408
|
-
oldValue = values.filter(x => attrValues.includes(x))[0] || '';
|
|
409
|
-
} else if (attrName === 'html') {
|
|
410
|
-
attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
|
|
411
|
-
oldValue = values.filter(x => attrValues.includes(x))[0] || '';
|
|
412
|
-
} else if (element.getAttribute(attrName)) {
|
|
427
|
+
} else if (attrName === 'text' || attrName === 'html' || element.getAttribute(attrName)) {
|
|
413
428
|
attrValues = element.getAttribute(attrName).split(' ').map(x => x.trim());
|
|
414
429
|
oldValue = values.filter(x => attrValues.includes(x))[0] || '';
|
|
415
430
|
}
|
|
@@ -430,19 +445,27 @@ const CoCreateEvents = {
|
|
|
430
445
|
}
|
|
431
446
|
} else if (attrName === 'value') {
|
|
432
447
|
element.setValue(newValue);
|
|
433
|
-
} else if (['$click', '$focus', '$blur'].includes(attrName)) {
|
|
448
|
+
} else if (['$click', '$focus', '$blur', '$save', '$read'].includes(attrName)) {
|
|
434
449
|
element[attrName.substring(1)]()
|
|
435
450
|
} else if (attrName) {
|
|
436
|
-
|
|
451
|
+
// TODO: removeAttribute vs setting empty value, how best to define. operator $remove ???
|
|
452
|
+
if (newValue === '' && element.hasAttribute(attrName))
|
|
453
|
+
element.removeAttribute(attrName);
|
|
454
|
+
else
|
|
455
|
+
element.setAttribute(attrName, newValue);
|
|
456
|
+
} else if (targetPosition) {
|
|
457
|
+
if (targetPosition === 'replace') {
|
|
458
|
+
element.insertAdjacentHTML('beforebegin', newValue); // Insert before oldElement
|
|
459
|
+
element.remove(); // Remove oldElement
|
|
460
|
+
} else
|
|
461
|
+
element.insertAdjacentHTML(targetPosition, newValue);
|
|
437
462
|
} else {
|
|
438
463
|
if (!attrName && ['click', 'focus', 'blur'].includes(newValue)) {
|
|
439
464
|
element[newValue]()
|
|
440
465
|
} else if (['click', 'focus', 'blur'].includes(attrName)) {
|
|
441
466
|
element[attrName]()
|
|
442
467
|
}
|
|
443
|
-
|
|
444
468
|
}
|
|
445
|
-
|
|
446
469
|
}
|
|
447
470
|
}
|
|
448
471
|
},
|
|
@@ -621,7 +644,9 @@ function checkCondition(condition, value) {
|
|
|
621
644
|
result = value === condition;
|
|
622
645
|
}
|
|
623
646
|
|
|
624
|
-
|
|
647
|
+
result = isNegated ? !result : result;
|
|
648
|
+
return result
|
|
649
|
+
|
|
625
650
|
}
|
|
626
651
|
|
|
627
652
|
function parseCondition(condition) {
|