@litejs/ui 26.2.1 → 26.4.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 -1
- package/css/anim.css +14 -2
- package/css/base.css +4 -0
- package/css/global.css +6 -0
- package/el/dialog.ui +97 -98
- package/el/gallery.ui +187 -0
- package/el/material.ui +0 -274
- package/el/menu.ui +213 -0
- package/el/ripple.ui +56 -0
- package/el/{Slider.ui → slider.ui} +84 -72
- package/el/sortable.ui +85 -0
- package/load.js +3 -3
- package/package.json +2 -2
- package/ui.js +280 -140
package/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
/* litejs.com/MIT-LICENSE.txt */
|
|
3
3
|
|
|
4
|
-
/* global escape, navigator, xhr */
|
|
4
|
+
/* global escape, getComputedStyle, navigator, pageXOffset, pageYOffset, scrollTo, xhr */
|
|
5
5
|
|
|
6
6
|
// Conditional compilation via toggle comments (processed by build tool):
|
|
7
7
|
// /*** name ***/ code /**/ - `code` active in source; build can strip it
|
|
@@ -21,6 +21,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
21
21
|
, THIS = this
|
|
22
22
|
, html = document.documentElement
|
|
23
23
|
, body = document.body
|
|
24
|
+
, canTransit = "on" + (canTransit = "transitionend") in body && canTransit
|
|
24
25
|
, splitRe = /[,\s]+/
|
|
25
26
|
, emptyArr = []
|
|
26
27
|
, plugins = {}
|
|
@@ -32,12 +33,11 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
32
33
|
, hasOwn = bind(plugins.hasOwnProperty)
|
|
33
34
|
, isArr = Array.isArray
|
|
34
35
|
, slice = emptyArr.slice
|
|
35
|
-
|
|
36
|
-
,
|
|
37
|
-
,
|
|
38
|
-
,
|
|
39
|
-
,
|
|
40
|
-
, toCamel = replace.bind(NUL, /\-([a-z])/g, Function("a,b", "return b.toUpperCase()"))
|
|
36
|
+
, elReplace = function(el, to, p) { if (el && to && (p = el.parentNode)) p.replaceChild(to, el) }
|
|
37
|
+
, elRm = function(el, p) { if (el && (p = el.parentNode)) p.removeChild(el) }
|
|
38
|
+
, getAttr = function(el, key) { return el && el.getAttribute && el.getAttribute(key) }
|
|
39
|
+
, replace = function(re, to, str) { return str.replace(re, to) }
|
|
40
|
+
, toCamel = function(str) { return str.replace(/\-([a-z])/g, function(_, ch) { return ch.toUpperCase() }) }
|
|
41
41
|
|
|
42
42
|
/*** ie9 ***/
|
|
43
43
|
// JScript engine in IE8 and below does not recognize vertical tabulation character `\v`.
|
|
@@ -65,6 +65,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
65
65
|
// Matches tokens to exclude from scope variable extraction: strings, keywords, member access, labels
|
|
66
66
|
, fnRe = /('|")(?:\\.|[^\\])*?\1|\/(?:\\.|[^\\])+?\/[gim]*|\$el\b|\$[aorsS]\b|\b(?:false|in|if|new|null|this|true|typeof|void|function|var|else|return)\b|\.\w+|\w+:/g
|
|
67
67
|
, wordRe = /[a-z_$][\w$]*/ig
|
|
68
|
+
, bindingsCls = acceptMany(cls)
|
|
68
69
|
, bindingsCss = acceptMany(function(el, key, val, current) {
|
|
69
70
|
current = el.style[key = toCamel(key)]
|
|
70
71
|
el.style[key] = val
|
|
@@ -72,15 +73,10 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
72
73
|
})
|
|
73
74
|
, bindingsOn = acceptMany(addEvent, 1)
|
|
74
75
|
, bindings = {
|
|
75
|
-
cls:
|
|
76
|
+
cls: bindingsCls,
|
|
76
77
|
css: bindingsCss,
|
|
77
78
|
on: bindingsOn,
|
|
78
|
-
one: acceptMany(
|
|
79
|
-
addEvent(el, ev, function remove() {
|
|
80
|
-
rmEvent(el, ev, remove)
|
|
81
|
-
fn.apply(el, arguments)
|
|
82
|
-
})
|
|
83
|
-
}, 1),
|
|
79
|
+
one: acceptMany(onceEvent, 1),
|
|
84
80
|
set: acceptMany(setAttr),
|
|
85
81
|
txt: elTxt,
|
|
86
82
|
/*** form ***/
|
|
@@ -187,10 +183,12 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
187
183
|
, fixFn = Event.fixFn || (Event.fixFn = {})
|
|
188
184
|
|
|
189
185
|
/*** markup ***/
|
|
190
|
-
, blockRe = /^(?:(=+|>|
|
|
186
|
+
, blockRe = /^(?:(=+|>| -| \d+\.) ([\s\S]+))/
|
|
191
187
|
, tags = {
|
|
192
188
|
" -": "ul",
|
|
193
|
-
"
|
|
189
|
+
"\"": "q",
|
|
190
|
+
"%": "small",
|
|
191
|
+
"&": "kbd",
|
|
194
192
|
"*": "b",
|
|
195
193
|
"+": "ins",
|
|
196
194
|
",": "sub",
|
|
@@ -199,33 +197,57 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
199
197
|
":": "mark",
|
|
200
198
|
";": "span",
|
|
201
199
|
">": "blockquote",
|
|
200
|
+
"?": "abbr",
|
|
202
201
|
"@": "time",
|
|
203
202
|
"^": "sup",
|
|
204
203
|
"_": "u",
|
|
205
204
|
"`": "code",
|
|
206
205
|
"~": "s"
|
|
207
206
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
)
|
|
218
|
-
"
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
207
|
+
, abbrs = {}
|
|
208
|
+
, embeds = {}
|
|
209
|
+
function a(name, val) {
|
|
210
|
+
return val ? " " + name + "=\"" + replace(/"/g, """, val) + "\"" : ""
|
|
211
|
+
}
|
|
212
|
+
function renderOp(op, text, extra) {
|
|
213
|
+
var num = parseInt(op, 10)
|
|
214
|
+
, tag = num >= 0 ? (extra += a("start", num != 1 && "" + num), "ol") : tags[op] || "h" + op.length
|
|
215
|
+
return "<" + (extra ? tag + extra : tag) + ">" + (
|
|
216
|
+
op === ">" ? doc(replace(/^> ?/gm, "", text)) :
|
|
217
|
+
tag == "ul" || num >= 0 ? "<li>" + text.split(/\n (?:\d+\.|-) (?=\S)/).map(inline).join("</li>\n<li>") + "</li>" :
|
|
218
|
+
inline(text)
|
|
219
|
+
) + "</" + tag + ">"
|
|
220
|
+
}
|
|
221
|
+
function inline(tag, text, url, op, content, attr) {
|
|
222
|
+
var extra = attr ? a("class", attr.slice(1)) : ""
|
|
223
|
+
if (url && !isArr(url)) {
|
|
224
|
+
return "<a" + a("href", url) + extra + ">" + inline(text || url) + "</a>"
|
|
225
|
+
}
|
|
226
|
+
if (op) {
|
|
227
|
+
if (op == "!") {
|
|
228
|
+
var fn = embeds[content.split(":")[0]]
|
|
229
|
+
return fn ? fn(content, text, extra, a) :
|
|
230
|
+
"<img" + a("src", content) + a("alt", text || replace(/.*\//, "", content)) + extra + ">"
|
|
231
|
+
}
|
|
232
|
+
if (op == "?") {
|
|
233
|
+
if (text) abbrs[content] = text
|
|
234
|
+
else text = abbrs[content]
|
|
235
|
+
}
|
|
236
|
+
extra += op == "@" ? a("datetime", content) : a(op == "\"" ? "cite" : "title", text)
|
|
237
|
+
if (op == "@") {
|
|
238
|
+
content = text || content
|
|
239
|
+
}
|
|
240
|
+
return renderOp(op, content, extra)
|
|
241
|
+
}
|
|
242
|
+
return replace(/\[(?:(.+?) )?(?:<([^>]+)>|([-!"%&*+,/:;?@^_`~])(.+?)\3)(\.[\w.]+)?]/g, inline, tag)
|
|
243
|
+
}
|
|
244
|
+
function block(tag, op, text) {
|
|
245
|
+
return op && !isArr(text) ? renderOp(op, text, "") :
|
|
224
246
|
blockRe.test(tag) ? replace(blockRe, block, tag) :
|
|
225
247
|
tag === "---" ? "<hr>" : "<p>" + inline(tag) + "</p>"
|
|
226
248
|
}
|
|
227
249
|
function doc(txt) {
|
|
228
|
-
return replace(/^ \b/gm, "<br>", txt.trim()).split(/\n\n+/).map(block).join("\n")
|
|
250
|
+
return replace(/^ (?!\d+\. )\b/gm, "<br>", txt.trim()).split(/\n\n+/).map(block).join("\n")
|
|
229
251
|
}
|
|
230
252
|
bindings.t = function(el, text) {
|
|
231
253
|
el.innerHTML = inline(replace(/</g, "<", text))
|
|
@@ -233,6 +255,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
233
255
|
bindings.d = function(el, text) {
|
|
234
256
|
el.innerHTML = doc(replace(/</g, "<", text))
|
|
235
257
|
}
|
|
258
|
+
bindings.d.embed = embeds
|
|
236
259
|
/**/
|
|
237
260
|
|
|
238
261
|
/*** svg ***/
|
|
@@ -305,29 +328,41 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
305
328
|
if (emitter === window) emitter = emptyArr
|
|
306
329
|
var args, i
|
|
307
330
|
, _e = emitter._e
|
|
308
|
-
, arr = _e
|
|
309
|
-
|
|
310
|
-
|
|
331
|
+
, arr = _e && _e[type] || emptyArr
|
|
332
|
+
, wild = _e && _e["*"] || emptyArr
|
|
333
|
+
, len = arr.length + wild.length
|
|
334
|
+
if (len) {
|
|
335
|
+
args = slice.call(arguments, 2)
|
|
336
|
+
for (i = arr.length - 1; i > 1; i -= 3) {
|
|
311
337
|
if (arr[i]) arr[i].apply(arr[i - 2] || emitter, args)
|
|
312
338
|
}
|
|
339
|
+
for (i = wild.length - 1; i > 1; i -= 3) {
|
|
340
|
+
if (wild[i]) wild[i].apply(wild[i - 2] || emitter, args)
|
|
341
|
+
}
|
|
313
342
|
}
|
|
314
|
-
return
|
|
343
|
+
return len / 3
|
|
315
344
|
}
|
|
316
345
|
|
|
317
|
-
function addEvent(el, ev, fn, opts) {
|
|
318
|
-
var fn2 = fixFn[ev] && fixFn[ev](el, fn, ev) || fn
|
|
346
|
+
function addEvent(el, ev, fn, opts, fix) {
|
|
347
|
+
var fn2 = fix || fixFn[ev] && fixFn[ev](el, fn, ev) || fn
|
|
319
348
|
, ev2 = fixEv[ev] || ev
|
|
320
349
|
|
|
321
|
-
if (ev2 !== ""
|
|
350
|
+
if (ev2 !== "") {
|
|
322
351
|
// polyfilled addEventListener returns patched function
|
|
323
352
|
// useCapture defaults to false
|
|
324
353
|
// Chrome56 touchstart/move sets {passive:true} by default; use {passive:false} to enable preventDefault()
|
|
354
|
+
// FF/Chrome el.onfocusin property is not supported, only addEventListener("focusin", fn)
|
|
325
355
|
fn2 = html.addEventListener.call(el, ev2, fn2, opts) || fn2
|
|
326
356
|
}
|
|
327
357
|
|
|
328
358
|
on(el, ev, fn2, el, fn)
|
|
329
359
|
}
|
|
330
|
-
|
|
360
|
+
function onceEvent(el, ev, fn, opts) {
|
|
361
|
+
addEvent(el, ev, fn, opts, function remove() {
|
|
362
|
+
rmEvent(el, ev, fn, opts)
|
|
363
|
+
fn.apply(el, arguments)
|
|
364
|
+
})
|
|
365
|
+
}
|
|
331
366
|
function rmEvent(el, ev, fn, opts) {
|
|
332
367
|
var evs = el._e && el._e[ev]
|
|
333
368
|
, id = evs && evs.indexOf(fn)
|
|
@@ -336,7 +371,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
336
371
|
if (fn !== evs[id + 1] && evs[id + 1]._rm) {
|
|
337
372
|
evs[id + 1]._rm()
|
|
338
373
|
}
|
|
339
|
-
if (ev2 !== ""
|
|
374
|
+
if (ev2 !== "") {
|
|
340
375
|
html.removeEventListener.call(el, ev2, evs[id + 1], opts)
|
|
341
376
|
}
|
|
342
377
|
evs.splice(id - 1, 3)
|
|
@@ -507,6 +542,8 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
507
542
|
viewEmit(view, "pong", params, View)
|
|
508
543
|
}
|
|
509
544
|
viewEmit(lastView, "show", params)
|
|
545
|
+
close = history.state || 0
|
|
546
|
+
scrollTo(close.x|0, close.y|0)
|
|
510
547
|
blur()
|
|
511
548
|
}
|
|
512
549
|
function viewClose(view, open) {
|
|
@@ -709,6 +746,9 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
709
746
|
addPlugin("el", {
|
|
710
747
|
d: function(plugin, el) {
|
|
711
748
|
el = usePluginContent(plugin)
|
|
749
|
+
/*** debug ***/
|
|
750
|
+
if (elCache[plugin.n]) console.error("El '%s' exist! Loading .ui file twice will execute %js also twice", plugin.n)
|
|
751
|
+
/**/
|
|
712
752
|
elCache[plugin.n] = el
|
|
713
753
|
}
|
|
714
754
|
}, 1)
|
|
@@ -735,7 +775,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
735
775
|
// document.documentElement.clientWidth is 0 in IE5
|
|
736
776
|
bindingsIs(html, (width = html.offsetWidth), breakpoints, "")
|
|
737
777
|
bindingsIs(html, +(width > html.offsetHeight), "port,1=land", "")
|
|
738
|
-
emit(
|
|
778
|
+
emit(LiteJS, "resize")
|
|
739
779
|
}, 99)
|
|
740
780
|
|
|
741
781
|
if (breakpoints) {
|
|
@@ -1006,7 +1046,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1006
1046
|
function setUrl(url, rep) {
|
|
1007
1047
|
/*** pushState ***/
|
|
1008
1048
|
if (pushBase) {
|
|
1009
|
-
history[rep ? "replaceState" : "pushState"](NUL, NUL, pushBase + url)
|
|
1049
|
+
history[rep ? "replaceState" : (history.replaceState({x: pageXOffset, y: pageYOffset}, NUL, location.href), "pushState")](NUL, NUL, pushBase + url)
|
|
1010
1050
|
} else
|
|
1011
1051
|
/**/
|
|
1012
1052
|
location[rep ? "replace" : "assign"]("#" + url)
|
|
@@ -1096,9 +1136,12 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1096
1136
|
assign(El, bindings, {
|
|
1097
1137
|
emit: emit,
|
|
1098
1138
|
empty: elEmpty,
|
|
1139
|
+
flip: elFlip,
|
|
1099
1140
|
kill: elKill,
|
|
1141
|
+
morph: elMorph,
|
|
1100
1142
|
off: acceptMany(rmEvent),
|
|
1101
1143
|
render: render,
|
|
1144
|
+
rect: rect,
|
|
1102
1145
|
rm: elRm
|
|
1103
1146
|
})
|
|
1104
1147
|
|
|
@@ -1169,7 +1212,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1169
1212
|
},
|
|
1170
1213
|
is: bindingsIs,
|
|
1171
1214
|
name: function(el, name) {
|
|
1172
|
-
setAttr(el, "name", expand(name, 1))
|
|
1215
|
+
if (name) setAttr(el, "name", expand(name, 1))
|
|
1173
1216
|
},
|
|
1174
1217
|
ref: function(el, name) {
|
|
1175
1218
|
this[name] = el
|
|
@@ -1287,12 +1330,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1287
1330
|
|
|
1288
1331
|
function hasClass(el, name) {
|
|
1289
1332
|
var current = el.className || ""
|
|
1290
|
-
|
|
1291
|
-
if (!isStr(current)) {
|
|
1292
|
-
current = getAttr(el, "class") || ""
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
return !!current && current.split(splitRe).indexOf(name) > -1
|
|
1333
|
+
return (" " + (isStr(current) ? current : getAttr(el, "class") || "-") + " ").indexOf(" " + name + " ") > -1
|
|
1296
1334
|
}
|
|
1297
1335
|
|
|
1298
1336
|
function cls(el, name, set) {
|
|
@@ -1328,15 +1366,108 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1328
1366
|
function elEmpty(el) {
|
|
1329
1367
|
for (; el.lastChild; elKill(el.lastChild));
|
|
1330
1368
|
}
|
|
1369
|
+
function elFlip(el, sel, fn, opts) {
|
|
1370
|
+
opts = assign({ anim: "flip", enter: "op0", leave: "op0" }, opts)
|
|
1371
|
+
var newPos, c, idx, r1
|
|
1372
|
+
, i = 0
|
|
1373
|
+
, anim = 0
|
|
1374
|
+
, anims = []
|
|
1375
|
+
, parent = rect(el)
|
|
1376
|
+
, oldPos = opts.old || rects()
|
|
1377
|
+
, leave = opts.leave
|
|
1378
|
+
, stagger = opts.stagger|0
|
|
1379
|
+
, transformTransition = "transform,transition"
|
|
1380
|
+
if (!fn) return oldPos
|
|
1381
|
+
fn()
|
|
1382
|
+
newPos = rects(1)
|
|
1383
|
+
for (; (c = oldPos[i]); i += 2) if (c !== opts.skip) {
|
|
1384
|
+
idx = newPos.indexOf(c)
|
|
1385
|
+
r1 = oldPos[i + 1]
|
|
1386
|
+
if (idx > -1) {
|
|
1387
|
+
if (addTransform(c, r1, newPos[idx + 1], opts)) anims[anim++] = c
|
|
1388
|
+
} else if (leave) {
|
|
1389
|
+
bindingsCss(c, {
|
|
1390
|
+
position: "absolute",
|
|
1391
|
+
left: (r1.left - parent.left) + "px",
|
|
1392
|
+
top: (r1.top - parent.top) + "px",
|
|
1393
|
+
width: r1.width + "px",
|
|
1394
|
+
height: r1.height + "px",
|
|
1395
|
+
})
|
|
1396
|
+
c._flip = 1
|
|
1397
|
+
append(el, (anims[anim++] = c))
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
if ((r1 = opts.enter)) for (i = 0; (c = newPos[i]); i += 2) if (oldPos.indexOf(c) < 0) {
|
|
1401
|
+
bindingsCls(c, r1, 1, 0, anim*stagger || 1)
|
|
1402
|
+
anims[anim++] = c
|
|
1403
|
+
}
|
|
1404
|
+
for (el.offsetHeight; anim; ) {
|
|
1405
|
+
c = anims[--anim]
|
|
1406
|
+
bindingsCls(c, opts.anim, 1, 0, -1)
|
|
1407
|
+
if (c._flip) {
|
|
1408
|
+
elKill(c, leave, anim*stagger)
|
|
1409
|
+
} else {
|
|
1410
|
+
bindingsCss(c, transformTransition, "", anim*stagger)
|
|
1411
|
+
}
|
|
1412
|
+
}
|
|
1413
|
+
return newPos
|
|
1414
|
+
function rects(reset) {
|
|
1415
|
+
var child
|
|
1416
|
+
, j = 0
|
|
1417
|
+
, arr = sel ? findAll(el, sel) : el.children
|
|
1418
|
+
, res = []
|
|
1419
|
+
if (reset) {
|
|
1420
|
+
for (el.offsetHeight; (child = arr[j++]); ) if (!child._flip) {
|
|
1421
|
+
cls(child, opts.anim, 0)
|
|
1422
|
+
bindingsCss(child, transformTransition, "none")
|
|
1423
|
+
}
|
|
1424
|
+
j = 0
|
|
1425
|
+
}
|
|
1426
|
+
for (el.offsetHeight; (child = arr[j++]); ) if (!child._flip) {
|
|
1427
|
+
res.push(child, rect(child))
|
|
1428
|
+
bindingsCss(child, transformTransition, "")
|
|
1429
|
+
}
|
|
1430
|
+
return res
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
function addTransform(el, from, to, opts) {
|
|
1434
|
+
var a = rect(from)
|
|
1435
|
+
, b = rect(to)
|
|
1436
|
+
, dx = a.left - b.left
|
|
1437
|
+
, dy = a.top - b.top
|
|
1438
|
+
, aw = a.width
|
|
1439
|
+
, ah = a.height
|
|
1440
|
+
, bw = b.width
|
|
1441
|
+
, bh = b.height
|
|
1442
|
+
if (canTransit && (dx || dy || (aw - bw) || (ah - bh))) {
|
|
1443
|
+
bindingsCss(el, "transform", "translate(" + dx + "px," + dy + "px)" + (opts.scale ? " scale(" + (aw / bw) + "," + (ah / bh) + ")" : ""))
|
|
1444
|
+
swap("height", ah, bh)
|
|
1445
|
+
swap("width", aw, bw)
|
|
1446
|
+
return el
|
|
1447
|
+
}
|
|
1448
|
+
function swap(key, from, to) {
|
|
1449
|
+
if (opts[key] && (from - to)) {
|
|
1450
|
+
bindingsCss(el, key, to + "px", 1, -2)
|
|
1451
|
+
bindingsCss(el, key, from + "px")
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
function elMorph(from, to, opts) {
|
|
1456
|
+
opts = assign({ anim: "flip" }, opts)
|
|
1457
|
+
if (from && to && addTransform(to, from, to, opts)) {
|
|
1458
|
+
void to.offsetWidth
|
|
1459
|
+
bindingsCls(to, opts.anim, 1, 0, -1)
|
|
1460
|
+
bindingsCss(to, "transform", "")
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1331
1463
|
function elKill(el, tr, delay) {
|
|
1332
1464
|
if (el) {
|
|
1333
1465
|
if (delay > 0) return setTimeout(elKill, delay, el, tr)
|
|
1334
|
-
if (tr) {
|
|
1466
|
+
if (tr && canTransit) {
|
|
1335
1467
|
if (isStr(tr)) cls(el, tr)
|
|
1336
1468
|
if (isObj(tr)) bindingsCss(el, tr)
|
|
1337
|
-
tr = "transitionend"
|
|
1338
1469
|
// transitionend fires for each property transitioned
|
|
1339
|
-
|
|
1470
|
+
return onceEvent(el, canTransit, bind(elKill, el, el, UNDEF))
|
|
1340
1471
|
}
|
|
1341
1472
|
if (el._e) {
|
|
1342
1473
|
emit(el, "kill")
|
|
@@ -1344,27 +1475,19 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1344
1475
|
}
|
|
1345
1476
|
elRm(el)
|
|
1346
1477
|
if (el.nodeType < 2) {
|
|
1347
|
-
el.$s = UNDEF
|
|
1348
1478
|
elKill(el._r) // Replacement element like comment from if binding
|
|
1349
1479
|
elEmpty(el)
|
|
1350
|
-
|
|
1351
|
-
el.valObject = UNDEF
|
|
1352
|
-
}
|
|
1480
|
+
el.$s = el.valObject = UNDEF
|
|
1353
1481
|
} else {
|
|
1354
1482
|
if (el.kill) el.kill()
|
|
1355
1483
|
}
|
|
1356
1484
|
}
|
|
1357
1485
|
}
|
|
1358
|
-
function elScope(el, parent) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
function closestScope(node) {
|
|
1366
|
-
for (; (node = node.parentNode); ) {
|
|
1367
|
-
if (node.$s) return node.$s
|
|
1486
|
+
function elScope(el, parent, opts) {
|
|
1487
|
+
if (el.$s) return el.$s
|
|
1488
|
+
if (parent) return (el.$s = assign(create(parent = elScope(parent)), opts, { $up: parent }))
|
|
1489
|
+
for (; (el = el.parentNode); ) {
|
|
1490
|
+
if (el.$s) return el.$s
|
|
1368
1491
|
}
|
|
1369
1492
|
return globalScope
|
|
1370
1493
|
}
|
|
@@ -1376,7 +1499,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1376
1499
|
}
|
|
1377
1500
|
|
|
1378
1501
|
var el, next
|
|
1379
|
-
, scope = node.$s || $s ||
|
|
1502
|
+
, scope = node.$s || $s || elScope(node)
|
|
1380
1503
|
|
|
1381
1504
|
/*** ie9 ***/
|
|
1382
1505
|
if (ie678 && node.tagName === "SELECT") {
|
|
@@ -1385,6 +1508,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1385
1508
|
/**/
|
|
1386
1509
|
|
|
1387
1510
|
if (hydrate(node, "_b", scope)) return
|
|
1511
|
+
scope = node.$s || scope
|
|
1388
1512
|
for (el = node.firstChild; el; el = next) {
|
|
1389
1513
|
next = el.nextSibling
|
|
1390
1514
|
render(el, scope)
|
|
@@ -1426,7 +1550,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1426
1550
|
/*** kb ***/
|
|
1427
1551
|
var kbMaps = []
|
|
1428
1552
|
, kbMod = LiteJS.kbMod = /\bMac|\biP/.test(navigator.userAgent) ? "metaKey" : "ctrlKey"
|
|
1429
|
-
, kbCodes = LiteJS.kbCodes = ",,,,,,,,backspace,tab,,,,enter,,,shift,ctrl,alt,pause,caps,,,,,,,esc,,,,,,pgup,pgdown,end,home,left,up,right,down,,,,,ins,del,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,cmd,,,,,,,,,,,,,,,,,,,,,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12".split(
|
|
1553
|
+
, kbCodes = LiteJS.kbCodes = ",,,,,,,,backspace,tab,,,,enter,,,shift,ctrl,alt,pause,caps,,,,,,,esc,,,,,,pgup,pgdown,end,home,left,up,right,down,,,,,ins,del,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,cmd,,,,,,,,,,,,,,,,,,,,,f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12".split(",")
|
|
1430
1554
|
|
|
1431
1555
|
El.addKb = addKb
|
|
1432
1556
|
El.rmKb = rmKb
|
|
@@ -1476,23 +1600,27 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1476
1600
|
fn = !input || map.input ? map[code] || map[chr] || map.num && code > 47 && code < 58 && (chr|=0, map.num) || map.all : fn
|
|
1477
1601
|
) && map.bubble; );
|
|
1478
1602
|
if (isStr(fn)) setUrl(fn)
|
|
1479
|
-
if (isFn(fn)) fn(e, chr, el)
|
|
1603
|
+
else if (isFn(fn)) fn(e, chr, el)
|
|
1480
1604
|
}
|
|
1481
1605
|
})
|
|
1482
1606
|
/**/
|
|
1483
1607
|
|
|
1484
1608
|
/*** touch ***/
|
|
1485
|
-
var
|
|
1609
|
+
var e0, touchAngle, touchDist, touchEl, touchMode, touchTick
|
|
1486
1610
|
, START = "start"
|
|
1487
1611
|
, END = "end"
|
|
1488
1612
|
, touches = []
|
|
1489
|
-
,
|
|
1613
|
+
, tapCount = 0
|
|
1614
|
+
, tapTime = 0
|
|
1490
1615
|
|
|
1491
1616
|
// swipe + left/right/up/down
|
|
1492
|
-
each("hold pan pinch rotate tap", function(name) {
|
|
1617
|
+
each("hold pan pinch rotate tap tap2", function(name) {
|
|
1493
1618
|
fixEv[name] = fixEv[name + START] = fixEv[name + END] = ""
|
|
1494
|
-
fixFn[name] = touchInit
|
|
1619
|
+
fixFn[name] = fixFn[name + START] = fixFn[name + END] = touchInit
|
|
1495
1620
|
})
|
|
1621
|
+
function haveEv(evs, name, set) {
|
|
1622
|
+
return set && (evs[name] || evs[name + START] || evs[name + END]) && name
|
|
1623
|
+
}
|
|
1496
1624
|
function touchInit(el) {
|
|
1497
1625
|
if (!el._ti) {
|
|
1498
1626
|
addEvent(el, "pointerdown", touchDown)
|
|
@@ -1505,21 +1633,24 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1505
1633
|
clearTimeout(touchTick)
|
|
1506
1634
|
var len = e ? touches.push(e) : touches.length
|
|
1507
1635
|
, MOVE = "pointermove"
|
|
1508
|
-
if (touchMode
|
|
1509
|
-
emit(
|
|
1636
|
+
if (touchMode) {
|
|
1637
|
+
emit(el, touchMode + END, e2, el)
|
|
1510
1638
|
touchMode = UNDEF
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
|
|
1639
|
+
} else if (len < 1) {
|
|
1640
|
+
var now = Date.now()
|
|
1641
|
+
tapCount = e2.count = now - tapTime < (LiteJS.tapDelay || 400) ? tapCount + 1 : 1
|
|
1642
|
+
tapTime = now
|
|
1643
|
+
if (!emit(el, "tap" + tapCount, e2, el)) emit(el, "tap", e2, el)
|
|
1514
1644
|
}
|
|
1515
1645
|
if (len === 1) {
|
|
1516
1646
|
if (e) {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
touchPos("
|
|
1522
|
-
|
|
1647
|
+
e0 = e
|
|
1648
|
+
e.x0 = e.clientX
|
|
1649
|
+
e.y0 = e.clientY
|
|
1650
|
+
touchEl = el
|
|
1651
|
+
touchPos("x", "left", "offsetWidth")
|
|
1652
|
+
touchPos("y", "top", "offsetHeight")
|
|
1653
|
+
if (e.button === 2 || matches(el, "INPUT,TEXTAREA,SELECT,.no-drag")) return
|
|
1523
1654
|
touchTick = setTimeout(moveOne, LiteJS.holdDelay || 800, e, 1)
|
|
1524
1655
|
}
|
|
1525
1656
|
moveOne(e || touches[0])
|
|
@@ -1529,17 +1660,13 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1529
1660
|
moveTwo(e)
|
|
1530
1661
|
}
|
|
1531
1662
|
;(len === 1 ? addEvent : rmEvent)(document, MOVE, moveOne)
|
|
1663
|
+
// TODO:2026-03-24:lauri:touches are shared, touchDown is per-element closures, move out
|
|
1664
|
+
;(len === 1 ? addEvent : rmEvent)(document, "pointerup", touchUp)
|
|
1532
1665
|
;(len === 2 ? addEvent : rmEvent)(document, MOVE, moveTwo)
|
|
1533
|
-
function touchPos(name, offset) {
|
|
1534
|
-
var val = (
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
touchEl.style[name]
|
|
1538
|
-
)
|
|
1539
|
-
touchEv[name] = parseInt(val, 10) || 0
|
|
1540
|
-
if (val && val.indexOf("%") > -1) {
|
|
1541
|
-
touchEv[name] *= touchEl.parentNode[offset] / 100
|
|
1542
|
-
}
|
|
1666
|
+
function touchPos(coord, name, offset) {
|
|
1667
|
+
var val = getAttr(el, coord) || getComputedStyle(el)[name]
|
|
1668
|
+
, num = parseInt(val, 10) || 0
|
|
1669
|
+
e0[name] = val && val.indexOf("%") > -1 ? num * el.parentNode[offset] / 100 : num
|
|
1543
1670
|
}
|
|
1544
1671
|
}
|
|
1545
1672
|
function touchUp(e) {
|
|
@@ -1557,7 +1684,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1557
1684
|
// alt+wheel may be OS level zoom, use shiftKey as alternative
|
|
1558
1685
|
if (!touches[0]) {
|
|
1559
1686
|
var ev = e.ctrlKey ? "pinch" : e.altKey || e.shiftKey ? "rotate" : UNDEF
|
|
1560
|
-
if (ev &&
|
|
1687
|
+
if (ev && (e.diff = e.deltaY / 20, e.angle = 0, emit(el, ev, e, el))) {
|
|
1561
1688
|
return eventStop(e)
|
|
1562
1689
|
}
|
|
1563
1690
|
}
|
|
@@ -1567,41 +1694,46 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1567
1694
|
if (touches[0].buttons && touches[0].buttons !== (e.buttons || [0, 1, 4, 2][e.which || 0])) {
|
|
1568
1695
|
return touchUp(e)
|
|
1569
1696
|
}
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
touchMode
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
)
|
|
1580
|
-
if (!touchMode) return
|
|
1697
|
+
e.el = touchEl
|
|
1698
|
+
e.x0 = e0.x0
|
|
1699
|
+
e.y0 = e0.y0
|
|
1700
|
+
var dx = e.dx = e.clientX - e.x0
|
|
1701
|
+
, dy = e.dy = e.clientY - e.y0
|
|
1702
|
+
if (!touchMode && (touchMode = touchEl._e) && (touchMode = (
|
|
1703
|
+
haveEv(touchMode, "pan", dx > 10 || dx < -10 || dy > 10 || dy < -10) ||
|
|
1704
|
+
haveEv(touchMode, "hold", fromTimer)
|
|
1705
|
+
))) {
|
|
1581
1706
|
clearTimeout(touchTick)
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
emit(touchEl, touchMode, e, touchEv, touchEl)
|
|
1585
|
-
function haveEv(name, set) {
|
|
1586
|
-
return set && (evs[name] || evs[name + START] || evs[name + END]) && name
|
|
1707
|
+
e0.mode = touchMode
|
|
1708
|
+
emit(el, touchMode + START, e0, el)
|
|
1587
1709
|
}
|
|
1710
|
+
e.ex = dx + e0.left
|
|
1711
|
+
e.ey = dy + e0.top
|
|
1712
|
+
if (touchMode) emit(el, touchMode, e, el)
|
|
1588
1713
|
}
|
|
1589
1714
|
function moveTwo(e) {
|
|
1590
1715
|
touches[ touches[0].pointerId == e.pointerId ? 0 : 1] = e
|
|
1591
1716
|
var diff
|
|
1592
|
-
, x =
|
|
1593
|
-
, y =
|
|
1717
|
+
, x = e0.clientX - touches[1].clientX
|
|
1718
|
+
, y = e0.clientY - touches[1].clientY
|
|
1594
1719
|
, dist = Math.sqrt(x*x + y*y) | 0
|
|
1595
1720
|
, angle = Math.atan2(y, x)
|
|
1596
1721
|
|
|
1597
1722
|
if (touchDist !== UNDEF) {
|
|
1598
1723
|
diff = dist - touchDist
|
|
1599
|
-
if (diff)
|
|
1724
|
+
if (diff) {
|
|
1725
|
+
e.diff = diff
|
|
1726
|
+
e.angle = angle
|
|
1727
|
+
emit(el, "pinch", e, el)
|
|
1728
|
+
}
|
|
1600
1729
|
// GestureEvent onGestureChange: function(e) {
|
|
1601
1730
|
// e.target.style.transform =
|
|
1602
1731
|
// 'scale(' + e.scale + startScale + ') rotate(' + e.rotation + startRotation + 'deg)'
|
|
1603
1732
|
diff = angle - touchAngle
|
|
1604
|
-
if (diff)
|
|
1733
|
+
if (diff) {
|
|
1734
|
+
e.diff = diff * (180/Math.PI)
|
|
1735
|
+
emit(el, "rotate", e, el)
|
|
1736
|
+
}
|
|
1605
1737
|
}
|
|
1606
1738
|
touchDist = dist
|
|
1607
1739
|
touchAngle = angle
|
|
@@ -1643,13 +1775,14 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1643
1775
|
function acceptMany(fn, prepareVal) {
|
|
1644
1776
|
return function f(el, name, val, selector, delay, data) {
|
|
1645
1777
|
if (el && name) {
|
|
1646
|
-
if (
|
|
1778
|
+
if (!isStr(selector)) {
|
|
1647
1779
|
data = delay
|
|
1648
1780
|
delay = selector
|
|
1649
|
-
selector =
|
|
1650
|
-
}
|
|
1651
|
-
|
|
1652
|
-
|
|
1781
|
+
selector = ""
|
|
1782
|
+
}
|
|
1783
|
+
if (!isNum(delay)) {
|
|
1784
|
+
data = delay
|
|
1785
|
+
delay = 0
|
|
1653
1786
|
}
|
|
1654
1787
|
if (delay > 0) {
|
|
1655
1788
|
setTimeout(f, delay, el, name, val, selector, 0, data)
|
|
@@ -1661,28 +1794,32 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1661
1794
|
}
|
|
1662
1795
|
return
|
|
1663
1796
|
}
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1797
|
+
var result, node
|
|
1798
|
+
, arr = ("" + name).split(splitRe)
|
|
1799
|
+
, i = 0, len = arr.length
|
|
1800
|
+
, value = prepareVal && (selector || isStr(val)) ? function(e, mem, target) {
|
|
1801
|
+
target = selector ? closest(e.target, selector) : el
|
|
1802
|
+
if (target) {
|
|
1803
|
+
if (isStr(val)) emit.apply(NUL, [elScope(target).$ui, val, e, target].concat(data))
|
|
1804
|
+
else if (isFn(val)) val.apply(target, [e, target].concat(data))
|
|
1805
|
+
}
|
|
1806
|
+
} : val
|
|
1807
|
+
, els = !prepareVal && selector ? findAll(el, selector) : isArr(el) ? el : [ el ]
|
|
1808
|
+
for (; (node = els[i++]); ) for (delay = 0; delay < len; delay++) {
|
|
1809
|
+
if ((result = arr[delay])) {
|
|
1810
|
+
result = fn(node, result, isArr(value) ? value[delay] : value && typeof value === "object" && !value.nodeType ? value[result] : value, data)
|
|
1811
|
+
if (!prepareVal) {
|
|
1812
|
+
if (fn === cls || data < -1) result = !val || ""
|
|
1813
|
+
if (data < 0) {
|
|
1814
|
+
if (canTransit) onceEvent(node, canTransit, bind(f, node, node, name, result))
|
|
1815
|
+
else data = 1
|
|
1816
|
+
}
|
|
1817
|
+
if (data > 0) f(node, name, result, "", data)
|
|
1671
1818
|
}
|
|
1672
1819
|
}
|
|
1673
1820
|
}
|
|
1674
1821
|
}
|
|
1675
1822
|
}
|
|
1676
|
-
function delegate(el, val, selector, data) {
|
|
1677
|
-
return isStr(val) ? function(e) {
|
|
1678
|
-
var target = selector ? closest(e.target, selector) : el
|
|
1679
|
-
if (target) emit.apply(target, [elScope(el).$ui, val, e, target].concat(data))
|
|
1680
|
-
} :
|
|
1681
|
-
selector ? function(e, touchEv, touchEl) {
|
|
1682
|
-
if (matches(touchEl = e.target, selector)) val(e, touchEv, touchEl, data)
|
|
1683
|
-
} :
|
|
1684
|
-
val
|
|
1685
|
-
}
|
|
1686
1823
|
}
|
|
1687
1824
|
function assignDeep(target, map) {
|
|
1688
1825
|
if (map) for (var k in map) if (hasOwn(map, k)) {
|
|
@@ -1759,6 +1896,9 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1759
1896
|
}
|
|
1760
1897
|
}
|
|
1761
1898
|
}
|
|
1899
|
+
function rect(el) {
|
|
1900
|
+
return el && el.nodeType ? el.getBoundingClientRect() : el
|
|
1901
|
+
}
|
|
1762
1902
|
function scrollPos(page, key) {
|
|
1763
1903
|
return window[page] || html[key] || body[key] || 0
|
|
1764
1904
|
}
|
|
@@ -1779,7 +1919,7 @@ console.log("LiteJS is in debug mode and that's fine for production")
|
|
|
1779
1919
|
res = res.concat(sources, next && next.src && next.innerHTML)
|
|
1780
1920
|
if (res[sources.length = 0]) {
|
|
1781
1921
|
if (!parser) {
|
|
1782
|
-
var m = res.join("\n").match(/\n%ui\s+(\{[\s\S]
|
|
1922
|
+
var m = res.join("\n").match(/\n%ui\s+(\{[\s\S]*)/)
|
|
1783
1923
|
LiteJS.ui = LiteJS(m && Function("return " + m[1])())
|
|
1784
1924
|
}
|
|
1785
1925
|
each(res, parser)
|