@litejs/ui 21.6.0 → 22.8.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/README.md +2 -2
- package/binding/_default.js +7 -4
- package/binding/sticky.js +16 -0
- package/css/base.css +0 -1
- package/css/grid.css +7 -8
- package/{component → el}/Pie.tpl +0 -0
- package/{component → el}/Segment7.tpl +0 -0
- package/{component → el}/Slider.tpl +28 -43
- package/{component → el}/confirm.tpl +37 -9
- package/{component → el}/form1.tpl +12 -10
- package/{component → el}/material.tpl +10 -6
- package/index.js +92 -90
- package/load.js +2 -2
- package/package.json +5 -5
- package/polyfill/index.js +33 -21
- package/schema-apply.js +4 -1
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
[size]: https://packagephobia.now.sh/badge?p=@litejs/ui
|
|
7
7
|
[size-src]: https://packagephobia.now.sh/result?p=@litejs/ui
|
|
8
|
+
[wiki]: https://github.com/litejs/ui/wiki
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
[LiteJS][]
|
|
11
|
-
It is split into three main packages by designated install location:
|
|
11
|
+
[LiteJS][] full-stack framework is split into three main packages by designated install location:
|
|
12
12
|
|
|
13
13
|
- **[litejs][LiteJS]** - Server and core libraries installed as `dependencies`
|
|
14
14
|
- **[@litejs/ui][UI]** - UI engine installed as `devDependencies` and bundled into your app
|
package/binding/_default.js
CHANGED
|
@@ -115,19 +115,22 @@
|
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
bindings.is = function bindingIs(node, model, path, list, state) {
|
|
118
|
+
bindings.is = function bindingIs(node, model, path, list, state, prefix) {
|
|
119
119
|
var match
|
|
120
120
|
, scope = this
|
|
121
121
|
if (typeof model === "string") {
|
|
122
|
+
prefix = state
|
|
122
123
|
state = list
|
|
123
124
|
list = path
|
|
124
125
|
path = model
|
|
125
126
|
model = scope.model
|
|
126
127
|
}
|
|
127
128
|
if (model && path) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
if (!prefix) prefix = "is-"
|
|
130
|
+
match = i18n.pick(state !== match ? state : model.get(path), list)
|
|
131
|
+
path += "-" + list
|
|
132
|
+
El.cls(node, node[prefix + path], 0)
|
|
133
|
+
El.cls(node, node[prefix + path] = match && prefix + match)
|
|
131
134
|
}
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
// .sticky { position: sticky; top: -1px; }
|
|
3
|
+
// .sticky.is-stuck { color: red; }
|
|
4
|
+
|
|
5
|
+
El.bindings.sticky = function sticky(el) {
|
|
6
|
+
;(sticky._ob || (sticky._ob = new IntersectionObserver(function(entries) {
|
|
7
|
+
entries.forEach(function(entry) {
|
|
8
|
+
El.cls(entry.target, "is-stuck", entry.intersectionRatio < 1)
|
|
9
|
+
})
|
|
10
|
+
}, { threshold: 1 }))).observe(el)
|
|
11
|
+
El.cls(el, "sticky")
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
El.bindings.sticky.once = 1
|
|
15
|
+
|
|
16
|
+
|
package/css/base.css
CHANGED
package/css/grid.css
CHANGED
|
@@ -7,8 +7,14 @@ Expects box-sizing: border-box;
|
|
|
7
7
|
.row {
|
|
8
8
|
display: block;
|
|
9
9
|
clear: both;
|
|
10
|
+
contain: content;
|
|
11
|
+
*zoom: 1;
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
.grid:after,
|
|
15
|
+
.row:after {
|
|
16
|
+
content: " ";
|
|
17
|
+
display: block;
|
|
12
18
|
clear: both;
|
|
13
19
|
}
|
|
14
20
|
|
|
@@ -21,13 +27,6 @@ Expects box-sizing: border-box;
|
|
|
21
27
|
clear: none;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
.grid:after,
|
|
25
|
-
.row:after {
|
|
26
|
-
content: " ";
|
|
27
|
-
display: block;
|
|
28
|
-
clear: both;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
30
|
.col,
|
|
32
31
|
.w12, .md .md-w12, .lg .md-w12, .lg .lg-w12 { width: 100%; }
|
|
33
32
|
.w11, .md .md-w11, .lg .md-w11, .lg .lg-w11 { width: 91.6667%; }
|
package/{component → el}/Pie.tpl
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -144,21 +144,6 @@
|
|
|
144
144
|
%js
|
|
145
145
|
var on = El.on
|
|
146
146
|
, off = El.off
|
|
147
|
-
El.bindings.SliderVal = function(el, model, path, range) {
|
|
148
|
-
if (range) {
|
|
149
|
-
El.attr(el, "range", range)
|
|
150
|
-
}
|
|
151
|
-
if (path) {
|
|
152
|
-
if (path.charAt(0)!=="/") path = "/" + path.replace(/\./g, "/")
|
|
153
|
-
model.on("change:" + path, set)
|
|
154
|
-
setTimeout(function(){
|
|
155
|
-
set(model.get(path))
|
|
156
|
-
}, 10)
|
|
157
|
-
}
|
|
158
|
-
function set(val) {
|
|
159
|
-
el.set(parseFloat(val) || 0)
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
147
|
El.bindings.SliderInit = function(el) {
|
|
163
148
|
var knobLen, offset, px, drag, min, max, step, minPx, maxPx, value
|
|
164
149
|
, vert = El.hasClass(el, "is-vertical")
|
|
@@ -167,9 +152,11 @@
|
|
|
167
152
|
, knob = fill.lastChild
|
|
168
153
|
, emit = El.emit.bind(el, el, "change").rate(500, true)
|
|
169
154
|
on(window, "blur", stop)
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
155
|
+
on(el, "pointerdown", start)
|
|
156
|
+
el.val = set
|
|
157
|
+
setTimeout(function() { set(value||0) }, 10)
|
|
158
|
+
function load() {
|
|
159
|
+
var attr = vert ? "offsetHeight" : "offsetWidth"
|
|
173
160
|
, range = (El.attr(el, "range") || "").split(/[^+\-\d.]/) // min:max:step:margin
|
|
174
161
|
min = +(range[0] || 0)
|
|
175
162
|
max = +(range[1] || 100)
|
|
@@ -178,13 +165,15 @@
|
|
|
178
165
|
minPx = 0
|
|
179
166
|
maxPx = track[attr] - knobLen - knobLen
|
|
180
167
|
px = maxPx / (max - min)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
168
|
+
}
|
|
169
|
+
function start(e) {
|
|
170
|
+
drag = true
|
|
171
|
+
load()
|
|
172
|
+
var tmp = el.getBoundingClientRect()
|
|
173
|
+
offset = (vert ? tmp.top + maxPx + El.scrollTop() + knobLen : tmp.left + El.scrollLeft()) + knobLen
|
|
174
|
+
tmp = offset - e.clientX + (value-min||0)*px
|
|
175
|
+
if (tmp < knobLen && tmp > -knobLen) offset -= tmp
|
|
176
|
+
if (track.childNodes.length > 1) {
|
|
188
177
|
fill = track.firstChild
|
|
189
178
|
var next
|
|
190
179
|
, x = maxPx
|
|
@@ -207,24 +196,21 @@
|
|
|
207
196
|
if (range[3]) minPx += px * range[3]
|
|
208
197
|
}
|
|
209
198
|
}
|
|
210
|
-
}
|
|
211
|
-
function start(e) {
|
|
212
|
-
drag = true
|
|
213
|
-
load(e)
|
|
214
199
|
move(e)
|
|
215
200
|
listen(on)
|
|
216
201
|
}
|
|
217
202
|
function move(e) {
|
|
218
203
|
var diff = vert ? offset - e.pageY : e.pageX - offset
|
|
219
204
|
diff = (diff > maxPx ? maxPx : (diff < minPx ? minPx : diff))
|
|
220
|
-
|
|
205
|
+
set((diff / px) + min, e, diff)
|
|
221
206
|
return Event.stop(e)
|
|
222
207
|
}
|
|
223
208
|
function stop(e) {
|
|
224
|
-
if (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
209
|
+
if (drag) {
|
|
210
|
+
drag = false
|
|
211
|
+
listen(off)
|
|
212
|
+
set(value)
|
|
213
|
+
}
|
|
228
214
|
}
|
|
229
215
|
function listen(on) {
|
|
230
216
|
El.cls(fill, "anim", !drag)
|
|
@@ -232,22 +218,21 @@
|
|
|
232
218
|
on(document, "pointerup", stop)
|
|
233
219
|
on(document, "pointermove", move)
|
|
234
220
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
val = (val < min ? min : val > max ? max : val).step(step)
|
|
221
|
+
function set(val, e, pos) {
|
|
222
|
+
load()
|
|
223
|
+
val = (val < min ? min : val > max ? max : val || 0).step(step)
|
|
224
|
+
if (value !== void 0 && (!drag || pos !== void 0)) {
|
|
225
|
+
El.css(fill, vert ? "height" : "width", ((pos || (val-min)*px)+knobLen) + "px", 0)
|
|
226
|
+
}
|
|
238
227
|
if (value !== val) {
|
|
239
228
|
el.value = value = val
|
|
240
229
|
if (drag && e) emit(e)
|
|
241
230
|
var format = El.attr(el, "format")
|
|
242
|
-
El.attr(knob, "data-val", format ? format
|
|
243
|
-
}
|
|
244
|
-
if (!drag || pos !== void 0) {
|
|
245
|
-
fill.style[vert ? "height" : "width"] = ((pos || (value-min)*px)+knobLen) + "px"
|
|
231
|
+
El.attr(knob, "data-val", format ? _(format, {val:val}) : val)
|
|
246
232
|
}
|
|
247
233
|
}
|
|
248
|
-
on(el, "pointerdown", start)
|
|
249
234
|
}
|
|
250
|
-
El.bindings.SliderInit.once =
|
|
235
|
+
El.bindings.SliderInit.once = 1
|
|
251
236
|
|
|
252
237
|
%el Slider
|
|
253
238
|
button.Slider.reset ;SliderInit
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
right: 0;
|
|
14
14
|
margin: 0 auto;
|
|
15
15
|
top: 4%;
|
|
16
|
-
width:
|
|
16
|
+
width: 600px;
|
|
17
17
|
background-color: #fff;
|
|
18
18
|
box-shadow: 0 2px 10px 2px rgba(255,255,255,.5);
|
|
19
19
|
}
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
Object.assign(scope, opts)
|
|
74
74
|
scope.title = title || "Confirm?"
|
|
75
75
|
if (!scope.actions) scope.actions = [
|
|
76
|
-
{ action: "close", title: "Close" }
|
|
76
|
+
{ action: "close", title: "Close", key: "esc" }
|
|
77
77
|
]
|
|
78
78
|
for (var a, i = 0; a = scope.actions[i++]; ) {
|
|
79
79
|
if (typeof a == "string") a = scope.actions[i-1] = {title:a,action:a}
|
|
@@ -106,23 +106,31 @@
|
|
|
106
106
|
var num = _num == void 0 ? e.target[El.T] : _num
|
|
107
107
|
code += num
|
|
108
108
|
if (num == "CLEAR" || num == "del" || num == "backspace") code = ""
|
|
109
|
-
El.
|
|
110
|
-
|
|
109
|
+
El.md(El.find(el, ".js-body"), code.replace(/./g, "•") || opts.body)
|
|
110
|
+
if (typeof scope.code == "number" && code.length == scope.code && id && !sent) next(sent = code, id, resolve, reject)
|
|
111
111
|
}
|
|
112
112
|
function resolve(e, key) {
|
|
113
113
|
if (el) {
|
|
114
|
+
var action = key || El.attr(this, "data-action")
|
|
115
|
+
, result = {
|
|
116
|
+
code: code,
|
|
117
|
+
input: El.val(El.find(el, ".js-input")),
|
|
118
|
+
inputMd: El.val(El.find(el, ".js-inputMd")),
|
|
119
|
+
select: El.val(El.find(el, ".js-select"))
|
|
120
|
+
}
|
|
114
121
|
El.kill(el, "transparent")
|
|
115
122
|
El.cls(blurEl, "Confirm--blur", el = 0)
|
|
116
|
-
var action = key || El.attr(this, "data-action")
|
|
117
123
|
if (action && next) {
|
|
118
|
-
if (typeof next === "function") next(action,
|
|
119
|
-
else if (typeof next[action] === "function") next[action](
|
|
120
|
-
else if (next[action]) View.emit(next[action],
|
|
124
|
+
if (typeof next === "function") next(action, result)
|
|
125
|
+
else if (typeof next[action] === "function") next[action](result)
|
|
126
|
+
else if (next[action]) View.emit(next[action], result)
|
|
121
127
|
}
|
|
122
128
|
if (vibrate) navigator.vibrate(0)
|
|
123
129
|
if (sound) sound.pause()
|
|
124
130
|
}
|
|
125
131
|
}
|
|
132
|
+
scope.resolve = resolve
|
|
133
|
+
View.emit("confirm:open", scope)
|
|
126
134
|
})
|
|
127
135
|
|
|
128
136
|
%el Confirm
|
|
@@ -130,11 +138,31 @@
|
|
|
130
138
|
.Confirm-bg.max.abs
|
|
131
139
|
.Confirm-content.Confirm--blur.grid.p2.anim
|
|
132
140
|
.col.ts3 ;txt:: _(title, map)
|
|
133
|
-
.col.js-body ;
|
|
141
|
+
.col.js-body ;md:: _(body, map)
|
|
134
142
|
.row.js-numpad
|
|
135
143
|
;if: code
|
|
136
144
|
;each: num in [1,2,3,4,5,6,7,8,9,"CLEAR",0]
|
|
137
145
|
.col.w4>.btn {num}
|
|
146
|
+
.row
|
|
147
|
+
;if: input
|
|
148
|
+
.col>input.field.js-input
|
|
149
|
+
.row
|
|
150
|
+
;if: data.inputMd!=null
|
|
151
|
+
.col
|
|
152
|
+
textarea.field.js-inputMd
|
|
153
|
+
@keyup [this.parentNode.nextSibling.nextSibling], "renderMd"
|
|
154
|
+
;val: inputMd
|
|
155
|
+
.col.ts3 Preview
|
|
156
|
+
.p4
|
|
157
|
+
;md: inputMd
|
|
158
|
+
.row
|
|
159
|
+
;if: select
|
|
160
|
+
.col
|
|
161
|
+
select.field.js-select
|
|
162
|
+
;list: select, [""]
|
|
163
|
+
option
|
|
164
|
+
;val:: item.id
|
|
165
|
+
;txt:: _(item.name)
|
|
138
166
|
.col
|
|
139
167
|
.group ;each: action in actions
|
|
140
168
|
.btn.js-btn
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
border: 0;
|
|
4
4
|
padding: 0;
|
|
5
5
|
}
|
|
6
|
-
.Form1-del {
|
|
6
|
+
.Form1-del.right {
|
|
7
7
|
display: block;
|
|
8
8
|
margin: -10px -10px 0 0;
|
|
9
|
+
opacity: .2;
|
|
10
|
+
}
|
|
11
|
+
.Form1-del {
|
|
9
12
|
font-size: 20px;
|
|
10
13
|
font-weight: 700;
|
|
11
|
-
opacity: .2;
|
|
12
14
|
border: 1px solid transparent;
|
|
13
15
|
line-height: 16px;
|
|
14
16
|
width: 20px;
|
|
@@ -28,7 +30,6 @@
|
|
|
28
30
|
display: block;
|
|
29
31
|
border-radius: 4px;
|
|
30
32
|
border: 1px solid #aaa;
|
|
31
|
-
overflow: auto;
|
|
32
33
|
}
|
|
33
34
|
.field {
|
|
34
35
|
width: 100%;
|
|
@@ -93,9 +94,11 @@
|
|
|
93
94
|
opacity: .6;
|
|
94
95
|
pointer-events: none;
|
|
95
96
|
}
|
|
97
|
+
.group {
|
|
98
|
+
overflow: auto;
|
|
99
|
+
}
|
|
96
100
|
.group > .btn {
|
|
97
101
|
border-radius: 0;
|
|
98
|
-
margin-left: -1px;
|
|
99
102
|
float: left;
|
|
100
103
|
}
|
|
101
104
|
.group > .btn:first-child {
|
|
@@ -140,13 +143,11 @@
|
|
|
140
143
|
}
|
|
141
144
|
.btn:hover,
|
|
142
145
|
.btn:focus {
|
|
143
|
-
|
|
144
|
-
color: #333;
|
|
146
|
+
filter: brightness(1.3) saturate(1.2);
|
|
145
147
|
text-decoration: none;
|
|
146
148
|
}
|
|
147
149
|
.btn:active,
|
|
148
150
|
.btn.is-active {
|
|
149
|
-
background-color: #ccc;
|
|
150
151
|
box-shadow: inset 0 0 8px rgba(0, 0, 0, .5);
|
|
151
152
|
}
|
|
152
153
|
|
|
@@ -227,7 +228,7 @@
|
|
|
227
228
|
|
|
228
229
|
%el form1-array
|
|
229
230
|
.col
|
|
230
|
-
.input.p13
|
|
231
|
+
.input.p13.cf
|
|
231
232
|
.left
|
|
232
233
|
= _(title||name)
|
|
233
234
|
.input__hint
|
|
@@ -239,10 +240,11 @@
|
|
|
239
240
|
@click: data.add
|
|
240
241
|
|
|
241
242
|
%el form1-array-item
|
|
242
|
-
.input.p3.m2b.js-del
|
|
243
|
+
.input.p3.m2b.cf.js-del
|
|
243
244
|
a.right.Form1-del.hand ×
|
|
244
245
|
;if: !data.noAdd
|
|
245
|
-
;
|
|
246
|
+
;data:: "tooltip", _("Delete")
|
|
247
|
+
@click: data.del
|
|
246
248
|
b
|
|
247
249
|
;if: title
|
|
248
250
|
;txt: title
|
|
@@ -202,8 +202,8 @@
|
|
|
202
202
|
El.near = near
|
|
203
203
|
function near(source, target, x, y, margin) {
|
|
204
204
|
var rect = target.getBoundingClientRect()
|
|
205
|
-
, top = rect.top
|
|
206
|
-
, left = rect.left
|
|
205
|
+
, top = rect.top + El.scrollTop()
|
|
206
|
+
, left = rect.left + El.scrollLeft()
|
|
207
207
|
// svg elements dont have offsetWidth, IE8 does not have rect.width
|
|
208
208
|
, width = rect.width || target.offsetWidth || 0
|
|
209
209
|
, height = rect.height || target.offsetHeight || 0
|
|
@@ -229,12 +229,15 @@
|
|
|
229
229
|
} else if (y == "bottom") {
|
|
230
230
|
top += height + margin
|
|
231
231
|
y = " -50%"
|
|
232
|
+
setTimeout(function(){
|
|
233
|
+
//document.scrollingElement.scrollHeight
|
|
234
|
+
var overflow = top + source.offsetHeight - El.scrollTop() - document.documentElement.offsetHeight
|
|
235
|
+
if (overflow > 0) scrollBy({ top: overflow, left: 0, behavior: "smooth" })
|
|
236
|
+
}, 400)
|
|
232
237
|
} else {
|
|
233
238
|
top += (height / 2) - (source.offsetHeight/2)
|
|
234
239
|
y = " 50%"
|
|
235
240
|
}
|
|
236
|
-
left += El.scrollLeft()
|
|
237
|
-
top += El.scrollTop()
|
|
238
241
|
El.css(source, {
|
|
239
242
|
"transform-origin": x + y,
|
|
240
243
|
top: (top < 0 ? 0 : top) + "px",
|
|
@@ -271,7 +274,8 @@
|
|
|
271
274
|
}
|
|
272
275
|
function openVisible(tag, target) {
|
|
273
276
|
var el = typeof tag == "string" ? El(tag) : tag
|
|
274
|
-
El.scope(el, El.scope(target))
|
|
277
|
+
, scope = El.scope(el, El.scope(target))
|
|
278
|
+
scope.openTarget = target
|
|
275
279
|
El.render(el)
|
|
276
280
|
El.append(document.body, el)
|
|
277
281
|
El.cls(el, "is-visible", 1, 5)
|
|
@@ -296,7 +300,7 @@
|
|
|
296
300
|
El.cls(menuTarget, "is-active", menuEl = menuTarget = null)
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
|
-
View.on("
|
|
303
|
+
View.on("ping", closeMenu)
|
|
300
304
|
View.on("closeMenu", closeMenu)
|
|
301
305
|
View.on("showMenu", function(e, target, menu, x, y, margin) {
|
|
302
306
|
Event.stop(e)
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* @version
|
|
2
|
+
* @version 22.8.0
|
|
3
3
|
* @author Lauri Rooden <lauri@rooden.ee>
|
|
4
4
|
* @license MIT License
|
|
5
5
|
*/
|
|
@@ -347,26 +347,6 @@
|
|
|
347
347
|
Fn.wait = wait
|
|
348
348
|
|
|
349
349
|
|
|
350
|
-
// Function extensions
|
|
351
|
-
// -------------------
|
|
352
|
-
|
|
353
|
-
F.extend = function() {
|
|
354
|
-
var arg
|
|
355
|
-
, fn = this
|
|
356
|
-
, i = 0
|
|
357
|
-
|
|
358
|
-
function wrapper() {
|
|
359
|
-
return fn.apply(this, arguments)
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
for (wrapper[P] = Object.create(fn[P]); arg = arguments[i++]; ) {
|
|
363
|
-
Object.assign(wrapper[P], arg)
|
|
364
|
-
}
|
|
365
|
-
wrapper[P].constructor = wrapper
|
|
366
|
-
return wrapper
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
370
350
|
// Non-standard
|
|
371
351
|
Object.each = function(obj, fn, scope, key) {
|
|
372
352
|
if (obj) for (key in obj) {
|
|
@@ -555,7 +535,8 @@
|
|
|
555
535
|
for (k in obj) if (typeof obj[k] == "function" && ignore.indexOf(k) < 0) !function(k) {
|
|
556
536
|
hooked.push(k, hasOwn.call(obj, k) && obj[k])
|
|
557
537
|
obj[k] = function() {
|
|
558
|
-
hooks.
|
|
538
|
+
if (hooks === null) obj[k].apply(this, arguments)
|
|
539
|
+
else hooks.push(k, arguments)
|
|
559
540
|
return obj
|
|
560
541
|
}
|
|
561
542
|
}(k)
|
|
@@ -648,9 +629,9 @@
|
|
|
648
629
|
, emitter = this === exports ? empty : this
|
|
649
630
|
, _e = emitter._e
|
|
650
631
|
, arr = _e ? (_e[type] || empty).concat(_e["*"] || empty) : empty
|
|
651
|
-
if (
|
|
652
|
-
for (args = arr.slice.call(arguments, 1); i
|
|
653
|
-
arr[i
|
|
632
|
+
if ((_e = arr.length)) {
|
|
633
|
+
for (i = _e - 1, args = arr.slice.call(arguments, 1); i > 1; i -= 3) {
|
|
634
|
+
arr[i] && arr[i].apply(arr[i - 2] || emitter, args)
|
|
654
635
|
}
|
|
655
636
|
}
|
|
656
637
|
return _e / 3
|
|
@@ -731,12 +712,13 @@
|
|
|
731
712
|
/*** PUSH ***/
|
|
732
713
|
}
|
|
733
714
|
/**/
|
|
734
|
-
checkUrl()
|
|
715
|
+
return checkUrl()
|
|
735
716
|
}
|
|
736
717
|
|
|
737
718
|
function checkUrl() {
|
|
738
|
-
if (lastRoute != (lastRoute = getUrl())
|
|
739
|
-
cb(lastRoute)
|
|
719
|
+
if (lastRoute != (lastRoute = getUrl())) {
|
|
720
|
+
if (cb) cb(lastRoute)
|
|
721
|
+
return true
|
|
740
722
|
}
|
|
741
723
|
}
|
|
742
724
|
|
|
@@ -805,13 +787,14 @@
|
|
|
805
787
|
|
|
806
788
|
|
|
807
789
|
!function(exports) {
|
|
808
|
-
var fn, lastView,
|
|
790
|
+
var fn, lastView, lastStr, lastUrl, syncResume
|
|
809
791
|
, isArray = Array.isArray
|
|
810
792
|
, capture = 1
|
|
811
793
|
, fnStr = ""
|
|
812
794
|
, reStr = ""
|
|
813
795
|
, views = View.views = {}
|
|
814
796
|
, paramCb = {}
|
|
797
|
+
, lastParams = paramCb
|
|
815
798
|
, hasOwn = views.hasOwnProperty
|
|
816
799
|
, escapeRe = /[.*+?^=!:${}()|\[\]\/\\]/g
|
|
817
800
|
, parseRe = /\{([\w%.]+?)\}|.[^{\\]*?/g
|
|
@@ -829,7 +812,7 @@
|
|
|
829
812
|
var key, name
|
|
830
813
|
, opts = Object.assign({}, defaults, _opts)
|
|
831
814
|
for (key in opts) if (hasOwn.call(opts, key)) {
|
|
832
|
-
if (typeof View[key]
|
|
815
|
+
if (typeof View[key] === "function") {
|
|
833
816
|
for (name in opts[key]) if (hasOwn.call(opts[key], name)) {
|
|
834
817
|
View[key](name, opts[key][name])
|
|
835
818
|
}
|
|
@@ -856,7 +839,7 @@
|
|
|
856
839
|
view.el = el
|
|
857
840
|
view.parent = parent && View(parent)
|
|
858
841
|
|
|
859
|
-
if (route.charAt(0)
|
|
842
|
+
if (route.charAt(0) !== "#") {
|
|
860
843
|
var params = "m[" + (view.seq = capture++) + "]?("
|
|
861
844
|
, _re = route.replace(parseRe, function(_, key) {
|
|
862
845
|
return key ?
|
|
@@ -879,13 +862,14 @@
|
|
|
879
862
|
, close = view.isOpen && view
|
|
880
863
|
|
|
881
864
|
View.route = view.route
|
|
865
|
+
emit(view, "init")
|
|
882
866
|
|
|
883
867
|
for (; tmp; tmp = parent) {
|
|
884
868
|
emit(syncResume = params._v = tmp, "ping", params, View)
|
|
885
869
|
syncResume = null
|
|
886
|
-
if (lastParams
|
|
870
|
+
if (lastParams !== params) return
|
|
887
871
|
if (parent = tmp.parent) {
|
|
888
|
-
if (parent.child && parent.child
|
|
872
|
+
if (parent.child && parent.child !== tmp) {
|
|
889
873
|
close = parent.child
|
|
890
874
|
}
|
|
891
875
|
parent.child = tmp
|
|
@@ -899,7 +883,7 @@
|
|
|
899
883
|
view.wait(tmp.file = null)
|
|
900
884
|
)
|
|
901
885
|
} else {
|
|
902
|
-
if (tmp.route
|
|
886
|
+
if (tmp.route === "404") {
|
|
903
887
|
El.txt(tmp = El("h3"), "# Error 404")
|
|
904
888
|
View("404", tmp, "#body")
|
|
905
889
|
}
|
|
@@ -911,7 +895,7 @@
|
|
|
911
895
|
|
|
912
896
|
if (view !== close) emit(view, "change", close)
|
|
913
897
|
|
|
914
|
-
for (tmp in params) if (tmp.charAt(0)
|
|
898
|
+
for (tmp in params) if (tmp.charAt(0) !== "_") {
|
|
915
899
|
if (syncResume = hasOwn.call(paramCb, tmp) && paramCb[tmp] || paramCb["*"]) {
|
|
916
900
|
syncResume.call(view, params[tmp], tmp, params)
|
|
917
901
|
syncResume = null
|
|
@@ -924,7 +908,7 @@
|
|
|
924
908
|
var params = lastParams
|
|
925
909
|
params._p = 1 + (params._p | 0)
|
|
926
910
|
return function() {
|
|
927
|
-
if (--params._p || lastParams
|
|
911
|
+
if (--params._p || lastParams !== params || syncResume) return
|
|
928
912
|
if (params._d) {
|
|
929
913
|
bubbleDown(params)
|
|
930
914
|
} else if (params._v) {
|
|
@@ -957,7 +941,7 @@
|
|
|
957
941
|
if (params._d = params._v = view.child) {
|
|
958
942
|
bubbleDown(params, close)
|
|
959
943
|
}
|
|
960
|
-
if (lastView
|
|
944
|
+
if (lastView === view) {
|
|
961
945
|
emit(view, "show", params)
|
|
962
946
|
blur()
|
|
963
947
|
}
|
|
@@ -990,7 +974,7 @@
|
|
|
990
974
|
"return function(i,o,d){var m=r.exec(i);return m!==null?(" + fnStr + "d):d}"
|
|
991
975
|
)()
|
|
992
976
|
}
|
|
993
|
-
return View(fn(url
|
|
977
|
+
return View(url ? fn(url, params || {}, "404") : View.home)
|
|
994
978
|
}
|
|
995
979
|
|
|
996
980
|
View.ping = function(name, fn) {
|
|
@@ -1005,7 +989,7 @@
|
|
|
1005
989
|
}
|
|
1006
990
|
var params = _params || {}
|
|
1007
991
|
, view = get(url, params)
|
|
1008
|
-
if (!view.isOpen || lastUrl
|
|
992
|
+
if (!view.isOpen || lastUrl !== url) {
|
|
1009
993
|
params._u = lastUrl = url
|
|
1010
994
|
view.show(El.data.params = params)
|
|
1011
995
|
}
|
|
@@ -1056,20 +1040,20 @@
|
|
|
1056
1040
|
/* litejs.com/MIT-LICENSE.txt */
|
|
1057
1041
|
|
|
1058
1042
|
|
|
1059
|
-
!function(window, document, Object, Event,
|
|
1060
|
-
var styleNode
|
|
1043
|
+
!function(window, document, Object, Event, P) {
|
|
1044
|
+
var UNDEF, styleNode
|
|
1061
1045
|
, BIND_ATTR = "data-bind"
|
|
1062
1046
|
, isArray = Array.isArray
|
|
1063
1047
|
, seq = 0
|
|
1064
1048
|
, elCache = El.cache = {}
|
|
1065
|
-
, wrapProto = ElWrap[
|
|
1049
|
+
, wrapProto = ElWrap[P] = []
|
|
1066
1050
|
, slice = wrapProto.slice
|
|
1067
1051
|
, hasOwn = elCache.hasOwnProperty
|
|
1068
1052
|
, body = document.body
|
|
1069
1053
|
, root = document.documentElement
|
|
1070
1054
|
, txtAttr = El.T = "textContent" in body ? "textContent" : "innerText"
|
|
1071
1055
|
, templateRe = /([ \t]*)(%?)((?:("|')(?:\\?.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f+|\n+|$)/g
|
|
1072
|
-
, renderRe = /[;\s]*(\w+)(
|
|
1056
|
+
, renderRe = /[;\s]*(\w+)(?:(::?| )((?:(["'\/])(?:\\?.)*?\3|[^;])*))?/g
|
|
1073
1057
|
, selectorRe = /([.#:[])([-\w]+)(?:\((.+?)\)|([~^$*|]?)=(("|')(?:\\?.)*?\6|[-\w]+))?]?/g
|
|
1074
1058
|
, splitRe = /[,\s]+/
|
|
1075
1059
|
, camelRe = /\-([a-z])/g
|
|
@@ -1087,6 +1071,11 @@
|
|
|
1087
1071
|
html: function(el, html) {
|
|
1088
1072
|
el.innerHTML = html
|
|
1089
1073
|
},
|
|
1074
|
+
md: El.md = function(el, txt) {
|
|
1075
|
+
txt = txt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """)
|
|
1076
|
+
txt = txt.replace(/\n/g, "<br>")
|
|
1077
|
+
el.innerHTML = txt
|
|
1078
|
+
},
|
|
1090
1079
|
ref: function(el, name) {
|
|
1091
1080
|
this[name] = el
|
|
1092
1081
|
},
|
|
@@ -1150,6 +1139,10 @@
|
|
|
1150
1139
|
* <input id="12" class="nice class" type="checkbox" checked="checked" disabled="disabled" data-lang="en">
|
|
1151
1140
|
*/
|
|
1152
1141
|
|
|
1142
|
+
function isObject(obj) {
|
|
1143
|
+
return obj && obj.constructor === Object
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1153
1146
|
window.El = El
|
|
1154
1147
|
|
|
1155
1148
|
function El(name) {
|
|
@@ -1162,14 +1155,14 @@
|
|
|
1162
1155
|
pres = 1
|
|
1163
1156
|
val = quotation ? val.slice(1, -1) : val || key
|
|
1164
1157
|
pre[op =
|
|
1165
|
-
op
|
|
1158
|
+
op === "." ?
|
|
1166
1159
|
(fn = "~", "class") :
|
|
1167
|
-
op
|
|
1160
|
+
op === "#" ?
|
|
1168
1161
|
"id" :
|
|
1169
1162
|
key
|
|
1170
1163
|
] = fn && pre[op] ?
|
|
1171
|
-
fn
|
|
1172
|
-
pre[op] + (fn
|
|
1164
|
+
fn === "^" ? val + pre[op] :
|
|
1165
|
+
pre[op] + (fn === "~" ? " " : "") + val :
|
|
1173
1166
|
val
|
|
1174
1167
|
return ""
|
|
1175
1168
|
}) || "div"
|
|
@@ -1214,7 +1207,7 @@
|
|
|
1214
1207
|
function setAttr(el, key, val) {
|
|
1215
1208
|
var current
|
|
1216
1209
|
|
|
1217
|
-
if (key
|
|
1210
|
+
if (isObject(key)) {
|
|
1218
1211
|
for (current in key) {
|
|
1219
1212
|
setAttr(el, current, key[current])
|
|
1220
1213
|
}
|
|
@@ -1250,11 +1243,11 @@
|
|
|
1250
1243
|
|
|
1251
1244
|
/*** ie8 ***/
|
|
1252
1245
|
// istanbul ignore next: IE fix
|
|
1253
|
-
if (ie67 && (key
|
|
1246
|
+
if (ie67 && (key === "id" || key === "name" || key === "checked")) {
|
|
1254
1247
|
el.mergeAttributes(document.createElement('<INPUT ' + key + '="' + val + '">'), false)
|
|
1255
1248
|
} else
|
|
1256
1249
|
/**/
|
|
1257
|
-
if (key
|
|
1250
|
+
if (key === "class") {
|
|
1258
1251
|
cls(el, val)
|
|
1259
1252
|
} else if (val || val === 0) {
|
|
1260
1253
|
if (current != val) {
|
|
@@ -1266,6 +1259,7 @@
|
|
|
1266
1259
|
}
|
|
1267
1260
|
|
|
1268
1261
|
function valFn(el, val) {
|
|
1262
|
+
if (!el) return ""
|
|
1269
1263
|
var input, step, key, value
|
|
1270
1264
|
, i = 0
|
|
1271
1265
|
, type = el.type
|
|
@@ -1285,7 +1279,7 @@
|
|
|
1285
1279
|
|
|
1286
1280
|
for (; input = el.elements[i++]; ) if (!input.disabled && (key = input.name || input.id)) {
|
|
1287
1281
|
value = valFn(input)
|
|
1288
|
-
if (value !==
|
|
1282
|
+
if (value !== UNDEF) {
|
|
1289
1283
|
step = opts
|
|
1290
1284
|
key.replace(/\[(.*?)\]/g, function(_, _key, offset) {
|
|
1291
1285
|
if (step == opts) key = key.slice(0, offset)
|
|
@@ -1328,8 +1322,8 @@
|
|
|
1328
1322
|
}
|
|
1329
1323
|
|
|
1330
1324
|
return checkbox && !el.checked ?
|
|
1331
|
-
(type === "radio" ?
|
|
1332
|
-
el.valObject !==
|
|
1325
|
+
(type === "radio" ? UNDEF : null) :
|
|
1326
|
+
el.valObject !== UNDEF ? el.valObject : el.value
|
|
1333
1327
|
}
|
|
1334
1328
|
|
|
1335
1329
|
function append(el, child, before) {
|
|
@@ -1340,7 +1334,7 @@
|
|
|
1340
1334
|
, i = 0
|
|
1341
1335
|
, tmp = typeof child
|
|
1342
1336
|
if (child) {
|
|
1343
|
-
if (tmp
|
|
1337
|
+
if (tmp === "string" || tmp === "number") child = document.createTextNode(child)
|
|
1344
1338
|
else if ( !("nodeType" in child) && "length" in child ) {
|
|
1345
1339
|
// document.createDocumentFragment is unsupported in IE5.5
|
|
1346
1340
|
// fragment = "createDocumentFragment" in document ? document.createDocumentFragment() : El("div")
|
|
@@ -1365,7 +1359,7 @@
|
|
|
1365
1359
|
/**/
|
|
1366
1360
|
tmp.insertBefore(child,
|
|
1367
1361
|
(before === true ? tmp.firstChild :
|
|
1368
|
-
typeof before
|
|
1362
|
+
typeof before === "number" ? tmp.childNodes[
|
|
1369
1363
|
before < 0 ? tmp.childNodes.length - before - 2 : before
|
|
1370
1364
|
] : before) || null
|
|
1371
1365
|
)
|
|
@@ -1393,7 +1387,7 @@
|
|
|
1393
1387
|
})
|
|
1394
1388
|
return
|
|
1395
1389
|
}
|
|
1396
|
-
if (name
|
|
1390
|
+
if (isObject(name)) {
|
|
1397
1391
|
for (i in name) {
|
|
1398
1392
|
if (hasOwn.call(name, i)) f(el, i, name[i], val)
|
|
1399
1393
|
}
|
|
@@ -1482,7 +1476,7 @@
|
|
|
1482
1476
|
var fn = fixFn[ev] && fixFn[ev](el, _fn, ev) || _fn
|
|
1483
1477
|
, fix = prefix ? function() {
|
|
1484
1478
|
var e = new Event(ev)
|
|
1485
|
-
if (e.clientX !==
|
|
1479
|
+
if (e.clientX !== UNDEF) {
|
|
1486
1480
|
e.pageX = e.clientX + scrollLeft()
|
|
1487
1481
|
e.pageY = e.clientY + scrollTop()
|
|
1488
1482
|
}
|
|
@@ -1518,14 +1512,14 @@
|
|
|
1518
1512
|
|
|
1519
1513
|
function bindingOn(el, events, selector, data, handler, delay) {
|
|
1520
1514
|
var argi = arguments.length
|
|
1521
|
-
if (argi == 3 || argi == 4 && typeof data
|
|
1515
|
+
if (argi == 3 || argi == 4 && typeof data === "number") {
|
|
1522
1516
|
delay = data
|
|
1523
1517
|
handler = selector
|
|
1524
1518
|
selector = data = null
|
|
1525
|
-
} else if (argi == 4 || argi == 5 && typeof handler
|
|
1519
|
+
} else if (argi == 4 || argi == 5 && typeof handler === "number") {
|
|
1526
1520
|
delay = handler
|
|
1527
1521
|
handler = data
|
|
1528
|
-
if (typeof selector
|
|
1522
|
+
if (typeof selector === "string") {
|
|
1529
1523
|
data = null
|
|
1530
1524
|
} else {
|
|
1531
1525
|
data = selector
|
|
@@ -1537,7 +1531,7 @@
|
|
|
1537
1531
|
return
|
|
1538
1532
|
}
|
|
1539
1533
|
var fn = (
|
|
1540
|
-
typeof handler
|
|
1534
|
+
typeof handler === "string" ? function(e) {
|
|
1541
1535
|
var target = selector ? El.closest(e.target, selector) : el
|
|
1542
1536
|
if (target) View.emit.apply(View, [handler, e, target].concat(data))
|
|
1543
1537
|
} :
|
|
@@ -1597,11 +1591,11 @@
|
|
|
1597
1591
|
return el.kill && el.kill()
|
|
1598
1592
|
}
|
|
1599
1593
|
empty(el)
|
|
1600
|
-
if (
|
|
1601
|
-
delete elScope[
|
|
1594
|
+
if (el._scope !== UNDEF) {
|
|
1595
|
+
delete elScope[el._scope]
|
|
1602
1596
|
}
|
|
1603
|
-
if (el.valObject) {
|
|
1604
|
-
el.valObject =
|
|
1597
|
+
if (el.valObject !== UNDEF) {
|
|
1598
|
+
el.valObject = UNDEF
|
|
1605
1599
|
}
|
|
1606
1600
|
}
|
|
1607
1601
|
}
|
|
@@ -1622,6 +1616,7 @@
|
|
|
1622
1616
|
}
|
|
1623
1617
|
|
|
1624
1618
|
function render(node, _scope) {
|
|
1619
|
+
if (!node) return
|
|
1625
1620
|
var bind, fn
|
|
1626
1621
|
, scope = elScope(node, 0, _scope)
|
|
1627
1622
|
, i = 0
|
|
@@ -1642,7 +1637,7 @@
|
|
|
1642
1637
|
scope._m[i] = match
|
|
1643
1638
|
match = bindings[name]
|
|
1644
1639
|
return (
|
|
1645
|
-
(op
|
|
1640
|
+
(op === "::" || match && hasOwn.call(match, "once")) ?
|
|
1646
1641
|
"s(this,B,data._t=data._t.replace(data._m[" + (i++)+ "],''))||" :
|
|
1647
1642
|
""
|
|
1648
1643
|
) + (
|
|
@@ -1672,7 +1667,7 @@
|
|
|
1672
1667
|
render(bind, scope)
|
|
1673
1668
|
}
|
|
1674
1669
|
/*** ie8 ***/
|
|
1675
|
-
if (ie678 && node.tagName
|
|
1670
|
+
if (ie678 && node.tagName === "SELECT") {
|
|
1676
1671
|
node.parentNode.insertBefore(node, node)
|
|
1677
1672
|
}
|
|
1678
1673
|
/**/
|
|
@@ -1754,16 +1749,16 @@
|
|
|
1754
1749
|
append(parent, parent = q = El(name))
|
|
1755
1750
|
}
|
|
1756
1751
|
if (text && op != "/") {
|
|
1757
|
-
if (op
|
|
1752
|
+
if (op === ">") {
|
|
1758
1753
|
(indent + " " + text).replace(templateRe, work)
|
|
1759
|
-
} else if (op
|
|
1754
|
+
} else if (op === "|" || op === "\\") {
|
|
1760
1755
|
append(parent, text) // + "\n")
|
|
1761
1756
|
} else {
|
|
1762
|
-
if (op
|
|
1757
|
+
if (op === "@") {
|
|
1763
1758
|
text = text.replace(/(\w+):?/, "on:'$1',")
|
|
1764
1759
|
} else if (op != ";" && op != "^") {
|
|
1765
|
-
text = (parent.tagName
|
|
1766
|
-
op
|
|
1760
|
+
text = (parent.tagName === "INPUT" ? "val" : "txt") + (
|
|
1761
|
+
op === "=" ? ":" + text.replace(/'/g, "\\'") :
|
|
1767
1762
|
":_('" + text.replace(/'/g, "\\'") + "', data)"
|
|
1768
1763
|
)
|
|
1769
1764
|
}
|
|
@@ -1779,7 +1774,7 @@
|
|
|
1779
1774
|
function appendBind(el, val, sep, q) {
|
|
1780
1775
|
var current = getAttr(el, BIND_ATTR)
|
|
1781
1776
|
setAttr(el, BIND_ATTR, (current ? (
|
|
1782
|
-
q
|
|
1777
|
+
q === "^" ?
|
|
1783
1778
|
val + sep + current :
|
|
1784
1779
|
current + sep + val
|
|
1785
1780
|
) : val))
|
|
@@ -1793,7 +1788,7 @@
|
|
|
1793
1788
|
t.el.plugin = t
|
|
1794
1789
|
}
|
|
1795
1790
|
|
|
1796
|
-
plugin[
|
|
1791
|
+
plugin[P] = {
|
|
1797
1792
|
_done: function() {
|
|
1798
1793
|
var t = this
|
|
1799
1794
|
, childNodes = t.el.childNodes
|
|
@@ -1826,15 +1821,15 @@
|
|
|
1826
1821
|
t.a = attr1
|
|
1827
1822
|
}
|
|
1828
1823
|
|
|
1829
|
-
js[
|
|
1824
|
+
js[P].done = Fn("Function(this.txt)()")
|
|
1830
1825
|
|
|
1831
1826
|
El.plugins = {
|
|
1832
|
-
binding:
|
|
1827
|
+
binding: extend(js, {
|
|
1833
1828
|
done: function() {
|
|
1834
1829
|
Object.assign(bindings, Function("return({" + this.txt + "})")())
|
|
1835
1830
|
}
|
|
1836
1831
|
}),
|
|
1837
|
-
child:
|
|
1832
|
+
child: extend(plugin, {
|
|
1838
1833
|
done: function() {
|
|
1839
1834
|
var key = "@child-" + (++seq)
|
|
1840
1835
|
, root = append(this.parent, document.createComment(key))
|
|
@@ -1843,28 +1838,25 @@
|
|
|
1843
1838
|
root._cp = root.childNodes.length - 1
|
|
1844
1839
|
}
|
|
1845
1840
|
}),
|
|
1846
|
-
css:
|
|
1841
|
+
css: extend(js, {
|
|
1847
1842
|
done: Fn("xhr.css(this.txt)")
|
|
1848
1843
|
}),
|
|
1849
|
-
def:
|
|
1844
|
+
def: extend(js, {
|
|
1850
1845
|
done: Fn("View.def(this.params||this.txt)")
|
|
1851
1846
|
}),
|
|
1852
|
-
each:
|
|
1847
|
+
each: extend(js, {
|
|
1853
1848
|
done: function() {
|
|
1854
1849
|
var txt = this.txt
|
|
1855
1850
|
|
|
1856
1851
|
JSON.parse(this.params)
|
|
1857
1852
|
.each(function(val) {
|
|
1858
|
-
|
|
1859
|
-
val = { item: val }
|
|
1860
|
-
}
|
|
1861
|
-
parseTemplate(txt.format(val))
|
|
1853
|
+
parseTemplate(txt.format(isObject(val) ? val : { item: val }))
|
|
1862
1854
|
})
|
|
1863
1855
|
}
|
|
1864
1856
|
}),
|
|
1865
1857
|
el: plugin,
|
|
1866
1858
|
js: js,
|
|
1867
|
-
map:
|
|
1859
|
+
map: extend(js, {
|
|
1868
1860
|
done: function() {
|
|
1869
1861
|
var self = this
|
|
1870
1862
|
, txt = (self.params + self.txt)
|
|
@@ -1876,7 +1868,7 @@
|
|
|
1876
1868
|
}
|
|
1877
1869
|
}),
|
|
1878
1870
|
template: plugin,
|
|
1879
|
-
view:
|
|
1871
|
+
view: extend(plugin,{
|
|
1880
1872
|
done: function() {
|
|
1881
1873
|
var fn
|
|
1882
1874
|
, t = this
|
|
@@ -1886,7 +1878,7 @@
|
|
|
1886
1878
|
if (bind) {
|
|
1887
1879
|
fn = bind.replace(renderRe, function(match, name, op, args) {
|
|
1888
1880
|
return "(this['" + name + "']" + (
|
|
1889
|
-
typeof view[name]
|
|
1881
|
+
typeof view[name] === "function" ?
|
|
1890
1882
|
"(" + (args || "") + ")" :
|
|
1891
1883
|
"=" + args
|
|
1892
1884
|
) + "),"
|
|
@@ -1895,7 +1887,7 @@
|
|
|
1895
1887
|
}
|
|
1896
1888
|
}
|
|
1897
1889
|
}),
|
|
1898
|
-
"view-link":
|
|
1890
|
+
"view-link": extend(plugin, {
|
|
1899
1891
|
done: function() {
|
|
1900
1892
|
var t = this
|
|
1901
1893
|
, arr = t.name.split(splitRe)
|
|
@@ -1931,7 +1923,7 @@
|
|
|
1931
1923
|
/*** kb ***/
|
|
1932
1924
|
var kbMaps = []
|
|
1933
1925
|
, kbMod = El.kbMod = iOS ? "metaKey" : "ctrlKey"
|
|
1934
|
-
,
|
|
1926
|
+
, kbMap = El.kbMap = {
|
|
1935
1927
|
8: "backspace", 9: "tab",
|
|
1936
1928
|
13: "enter", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause",
|
|
1937
1929
|
20: "caps", 27: "esc",
|
|
@@ -1964,7 +1956,7 @@
|
|
|
1964
1956
|
var c = e.keyCode || e.which
|
|
1965
1957
|
, numpad = c > 95 && c < 106
|
|
1966
1958
|
, code = numpad ? c - 48 : c
|
|
1967
|
-
, key =
|
|
1959
|
+
, key = kbMap[code] || String.fromCharCode(code).toLowerCase() || code
|
|
1968
1960
|
|
|
1969
1961
|
// Otherwise IE backspace navigates back
|
|
1970
1962
|
if (code == 8 && kbMaps[0].backspace) {
|
|
@@ -2046,4 +2038,14 @@
|
|
|
2046
2038
|
addEvent(window, "orientationchange", setBreakpointsRated)
|
|
2047
2039
|
addEvent(window, "load", setBreakpointsRated)
|
|
2048
2040
|
/**/
|
|
2041
|
+
|
|
2042
|
+
function extend(fn, opts) {
|
|
2043
|
+
function wrapper() {
|
|
2044
|
+
return fn.apply(this, arguments)
|
|
2045
|
+
}
|
|
2046
|
+
wrapper[P] = Object.create(fn[P])
|
|
2047
|
+
Object.assign(wrapper[P], opts)
|
|
2048
|
+
wrapper[P].constructor = wrapper
|
|
2049
|
+
return wrapper
|
|
2050
|
+
}
|
|
2049
2051
|
}(window, document, Object, Event, "prototype")
|
package/load.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// MSXML 6.0 has improved XSD, deprecated several legacy features
|
|
29
29
|
// What's New in MSXML 6.0: https://msdn.microsoft.com/en-us/library/ms753751.aspx
|
|
30
30
|
|
|
31
|
-
!function(window, Function) {
|
|
31
|
+
!function(window, Function, setTimeout) {
|
|
32
32
|
xhr._s = new Date
|
|
33
33
|
var loaded = {}
|
|
34
34
|
, urlEscRe = /[+#\s]+/g
|
|
@@ -275,5 +275,5 @@
|
|
|
275
275
|
/**/
|
|
276
276
|
|
|
277
277
|
function nop() {}
|
|
278
|
-
}(this, Function)
|
|
278
|
+
}(this, Function, setTimeout)
|
|
279
279
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litejs/ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "22.8.0",
|
|
4
4
|
"description": "UI engine for LiteJS full-stack framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lauri Rooden <lauri@rooden.ee>",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"*.js",
|
|
19
19
|
"binding",
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
20
|
+
"css",
|
|
21
|
+
"el",
|
|
22
|
+
"polyfill"
|
|
23
23
|
],
|
|
24
24
|
"litejs": {
|
|
25
|
-
"build": "--out=test/index.html test/dev.html"
|
|
25
|
+
"build": "lj b --out=test/index.html test/dev.html"
|
|
26
26
|
},
|
|
27
27
|
"jshintConfig": {
|
|
28
28
|
"asi": true,
|
package/polyfill/index.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
!function(window, Function) {
|
|
23
23
|
|
|
24
|
+
// Array#flat() - Chrome69, Edge79, Firefox62, Safari12
|
|
24
25
|
// window.PointerEvent - Chrome55, Edge12, Firefox59, Safari13, IE11
|
|
25
26
|
// navigator.sendBeacon - Chrome39, Edge14, Firefox31, Safari11.1
|
|
26
27
|
// Object.fromEntries - Chrome73, Edge79, Firefox63, Safari12.1, Opera60, Node.js12.0.0
|
|
@@ -30,7 +31,6 @@
|
|
|
30
31
|
, P = "prototype"
|
|
31
32
|
, O = window
|
|
32
33
|
, patched = (window.xhr || window)._p = []
|
|
33
|
-
, aSlice = patched.slice
|
|
34
34
|
, jsonRe = /[\x00-\x1f\x22\x5c]/g
|
|
35
35
|
, JSONmap = {"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t",'"':'\\"',"\\":"\\\\"}
|
|
36
36
|
, hasOwn = JSONmap.hasOwnProperty
|
|
@@ -88,6 +88,9 @@
|
|
|
88
88
|
c: "touchcancel"
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
// Missing PointerEvents with Scribble enable on Safari 14
|
|
92
|
+
// https://mikepk.com/2020/10/iOS-safari-scribble-bug/
|
|
93
|
+
// https://bugs.webkit.org/show_bug.cgi?id=217430
|
|
91
94
|
|
|
92
95
|
if (!window.PointerEvent) {
|
|
93
96
|
// IE10
|
|
@@ -161,7 +164,7 @@
|
|
|
161
164
|
patch("escape", "return X(a)", esc("a", 0) != "a", esc)
|
|
162
165
|
|
|
163
166
|
// Patch parameters support for setTimeout callback
|
|
164
|
-
patch("setTimeout", (a = "
|
|
167
|
+
patch("setTimeout", (a = "return O(X(a)&&A.length>2?a.apply.bind(a,null,S.call(A,2)):a,b)"), ie6789, isFn)
|
|
165
168
|
patch("setInterval", a, ie6789, isFn)
|
|
166
169
|
|
|
167
170
|
function createStorage(name) {
|
|
@@ -197,7 +200,7 @@
|
|
|
197
200
|
/**/
|
|
198
201
|
var data = {
|
|
199
202
|
setItem: function(id, val) {
|
|
200
|
-
return data[id] =
|
|
203
|
+
return data[id] = "" + val
|
|
201
204
|
},
|
|
202
205
|
getItem: function(id) {
|
|
203
206
|
return data[id]
|
|
@@ -236,15 +239,14 @@
|
|
|
236
239
|
},
|
|
237
240
|
stringify: function stringify(o) {
|
|
238
241
|
// IE 8 serializes `undefined` as `"undefined"`
|
|
239
|
-
var c = typeof o
|
|
240
242
|
return (
|
|
241
|
-
|
|
242
|
-
o &&
|
|
243
|
+
isStr(o) ? '"' + o.replace(jsonRe, jsonFn) + '"' :
|
|
244
|
+
o && typeof o == "object" ? (
|
|
243
245
|
isFn(o.toJSON) ? stringify(o.toJSON()) :
|
|
244
246
|
isArr(o) ? "[" + o.map(stringify) + "]" :
|
|
245
247
|
"{" + oKeys(o).map(function(a){return stringify(a) + ":" + stringify(o[a])}) + "}"
|
|
246
248
|
) :
|
|
247
|
-
|
|
249
|
+
typeof o == "number" && !isFinite(o) ? "null" :
|
|
248
250
|
"" + o
|
|
249
251
|
)
|
|
250
252
|
}
|
|
@@ -261,21 +263,24 @@
|
|
|
261
263
|
O = Date
|
|
262
264
|
patch("d:now", a)
|
|
263
265
|
|
|
266
|
+
/*** toISOString ***/
|
|
264
267
|
O = O[P]
|
|
265
268
|
// IE8 toJSON does not return milliseconds
|
|
269
|
+
// ISO 8601 format is always 24 or 27 characters long,
|
|
270
|
+
// YYYY-MM-DDTHH:mm:ss.sssZ or ±YYYYYY-MM-DDTHH:mm:ss.sssZ
|
|
266
271
|
patch("toISOString", patch("toJSON", [
|
|
267
|
-
"
|
|
268
|
-
"Hours(),'
|
|
269
|
-
].join(")+X(t.getUTC"), ie678, function(
|
|
270
|
-
|
|
272
|
+
"a=t.getUTCFullYear();if(a!==a)throw RangeError('Invalid time');return(b=a<0?'-':a>9999?'+':'')+X(a<0?-a:a,'-',b?6:4", "Month()+1,'-'", "Date(),'T'",
|
|
273
|
+
"Hours(),':'", "Minutes(),':'", "Seconds(),'.'", "Milliseconds(),'Z',3)"
|
|
274
|
+
].join(")+X(t.getUTC"), ie678, function(a, b, c){ return ("00000" + a).slice(-c || -2) + b }))
|
|
275
|
+
/**/
|
|
271
276
|
|
|
272
277
|
O = Function[P]
|
|
273
278
|
// Chrome7, FF4, IE9, Opera 11.60, Safari 5.1.4
|
|
274
|
-
patch("bind", "b=S.call(
|
|
279
|
+
patch("bind", "b=S.call(A,1);c=function(){return t.apply(this instanceof c?this:a,b.concat(S.call(arguments)))};if(t[P])c[P]=t[P];return c")
|
|
275
280
|
|
|
276
281
|
|
|
277
282
|
O = Object
|
|
278
|
-
patch("assign", "var k,i=1,
|
|
283
|
+
patch("assign", "var k,i=1,l=A.length;for(;i<l;)if(t=A[i++])for(k in t)if(o.call(t,k))a[k]=t[k];return a")
|
|
279
284
|
patch("create", "X[P]=a||Y;return new X", 0, nop, {
|
|
280
285
|
// oKeys is undefined at this point
|
|
281
286
|
constructor: oKeys, hasOwnProperty: oKeys, isPrototypeOf: oKeys, propertyIsEnumerable: oKeys,
|
|
@@ -284,6 +289,7 @@
|
|
|
284
289
|
a = "c=[];for(b in a)o.call(a,b)&&c.push("
|
|
285
290
|
b = ");return c"
|
|
286
291
|
patch("entries", a + "[b,a[b]]" + b)
|
|
292
|
+
patch("hasOwn", "return!!(a&&o.call(a,b))")
|
|
287
293
|
oKeys = patch("keys", a + "b" + b)
|
|
288
294
|
patch("values", a + "a[b]" + b)
|
|
289
295
|
//patch("fromEntries", "for(a=a.entries(),c={};!(b=a.next()).done;c[b[0]]=b[1]" + b)
|
|
@@ -297,7 +303,8 @@
|
|
|
297
303
|
|
|
298
304
|
// TODO:2021-02-25:lauri:Accept iterable objects
|
|
299
305
|
//patch("from", "a=S.call(a);return b?a.map(b,c):a")
|
|
300
|
-
patch("from", "a=
|
|
306
|
+
patch("from", "a=X(a)?a.split(''):b?a:S.call(a);return b?a.map(b,c):a", 0, isStr)
|
|
307
|
+
patch("of", "return S.call(A)")
|
|
301
308
|
|
|
302
309
|
O = O[P]
|
|
303
310
|
a = "var l=t.length,o=[],i=-1;"
|
|
@@ -305,7 +312,7 @@
|
|
|
305
312
|
patch("indexOf", a + "i+=b|0;while(++i<l)" + c)
|
|
306
313
|
patch("lastIndexOf", a + "i=(b|0)||l;i>--l&&(i=l)||i<0&&(i+=l);++i;while(--i>-1)" + c)
|
|
307
314
|
|
|
308
|
-
b = a + "if(
|
|
315
|
+
b = a + "if(A.length<2)b=t"
|
|
309
316
|
c = "b=a.call(null,b,t[i],i,t);return b"
|
|
310
317
|
patch("reduce", b + "[++i];while(++i<l)" + c)
|
|
311
318
|
patch("reduceRight", b + "[--l];i=l;while(i--)" + c)
|
|
@@ -321,6 +328,8 @@
|
|
|
321
328
|
patch("filter", b + "o.push(t[i])" + c)
|
|
322
329
|
patch("some", b + "return!0;return!1")
|
|
323
330
|
|
|
331
|
+
patch("flat", "return a<1?S.call(t):(b=t.concat.apply([],t))&&a>1&&b.some(X)?b.flat(a-1):b", 0, isArr)
|
|
332
|
+
patch("flatMap", "return X.apply(t,A).flat()", 0, O.map)
|
|
324
333
|
//patch("entries", "a=this;b=-1;return{next:function(){c=a.length<=++b;return{done:c,value:c?void 0:a[b]}}}")
|
|
325
334
|
|
|
326
335
|
|
|
@@ -398,7 +407,7 @@
|
|
|
398
407
|
}
|
|
399
408
|
function walk(el, by, sel, first, nextFn) {
|
|
400
409
|
var out = []
|
|
401
|
-
if (
|
|
410
|
+
if (!isFn(sel)) sel = selectorFn(sel)
|
|
402
411
|
for (; el; el = el[by] || nextFn && nextFn(el)) if (sel(el)) {
|
|
403
412
|
if (first === 1) return el
|
|
404
413
|
out.push(el)
|
|
@@ -415,7 +424,7 @@
|
|
|
415
424
|
|
|
416
425
|
// ie6789
|
|
417
426
|
// The documentMode is an IE only property, supported from IE8.
|
|
418
|
-
if (ie678
|
|
427
|
+
if (ie678) {
|
|
419
428
|
try {
|
|
420
429
|
// Remove background image flickers on hover in IE6
|
|
421
430
|
// You could also use CSS
|
|
@@ -424,16 +433,19 @@
|
|
|
424
433
|
} catch(e){}
|
|
425
434
|
}
|
|
426
435
|
|
|
427
|
-
function isFn(
|
|
428
|
-
return typeof
|
|
436
|
+
function isFn(value) {
|
|
437
|
+
return typeof value === "function"
|
|
438
|
+
}
|
|
439
|
+
function isStr(value) {
|
|
440
|
+
return typeof value === "string"
|
|
429
441
|
}
|
|
430
442
|
function nop() {}
|
|
431
443
|
|
|
432
444
|
function patch(key_, src, force, arg1, arg2) {
|
|
433
445
|
var key = key_.split(":").pop()
|
|
434
446
|
return !force && O[key] || (O[patched.push(key_), key] = (
|
|
435
|
-
|
|
436
|
-
Function("o,O,P,S,F,X,Y", "return function(a,b,c){var t=this;" + src + "}")(hasOwn, O[key], P,
|
|
447
|
+
isStr(src) ?
|
|
448
|
+
Function("o,O,P,S,F,X,Y", "return function(a,b,c){var t=this,A=arguments;" + src + "}")(hasOwn, O[key], P, patched.slice, force, arg1, arg2) :
|
|
437
449
|
src || {}
|
|
438
450
|
))
|
|
439
451
|
}
|
package/schema-apply.js
CHANGED
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
} else if (type == "string") {
|
|
47
47
|
if (type !== actualType) data = "" + data
|
|
48
48
|
} else if (type === "number" || type == "integer") {
|
|
49
|
+
if (schema["ui:el"] == "date-time") {
|
|
50
|
+
data = Date.parse(data)
|
|
51
|
+
}
|
|
49
52
|
data = (data + "").replace(",", ".")
|
|
50
53
|
data = type === "number" ? parseFloat(data) : parseInt(data, 10)
|
|
51
54
|
|
|
@@ -75,7 +78,7 @@
|
|
|
75
78
|
return memo
|
|
76
79
|
}, []) :
|
|
77
80
|
null
|
|
78
|
-
} else {
|
|
81
|
+
} else if (data) {
|
|
79
82
|
var reqArr = Array.isArray(schema.required) && schema.required
|
|
80
83
|
Object.each(schema.properties, function(propSchema, prop) {
|
|
81
84
|
if (data[prop] !== void 0) {
|