@litejs/ui 23.3.1 → 23.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/base.css +12 -1
- package/index.js +93 -57
- package/package.json +2 -2
- package/el/Segment7.tpl.js +0 -1
- package/el/confirm.tpl.js +0 -1
- package/el/form1.tpl.js +0 -1
package/css/base.css
CHANGED
|
@@ -231,13 +231,24 @@ button,
|
|
|
231
231
|
float: right !important;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
.sm .sm-t-left,
|
|
235
|
+
.md .md-t-left,
|
|
236
|
+
.lg .md-t-left,
|
|
237
|
+
.lg .lg-t-left,
|
|
234
238
|
.t-left {
|
|
235
239
|
text-align: left;
|
|
236
240
|
}
|
|
237
|
-
|
|
241
|
+
.sm .sm-t-center,
|
|
242
|
+
.md .md-t-center,
|
|
243
|
+
.lg .md-t-center,
|
|
244
|
+
.lg .lg-t-center,
|
|
238
245
|
.t-center {
|
|
239
246
|
text-align: center;
|
|
240
247
|
}
|
|
248
|
+
.sm .sm-t-right,
|
|
249
|
+
.md .md-t-right,
|
|
250
|
+
.lg .md-t-right,
|
|
251
|
+
.lg .lg-t-right,
|
|
241
252
|
.t-right {
|
|
242
253
|
text-align: right;
|
|
243
254
|
}
|
package/index.js
CHANGED
|
@@ -234,6 +234,7 @@
|
|
|
234
234
|
/* global El, xhr */
|
|
235
235
|
!function(exports) {
|
|
236
236
|
var fn, lastView, lastStr, lastUrl, syncResume
|
|
237
|
+
, body = document.body
|
|
237
238
|
, isArray = Array.isArray
|
|
238
239
|
, capture = 1
|
|
239
240
|
, fnStr = ""
|
|
@@ -247,16 +248,17 @@
|
|
|
247
248
|
, defaults = {
|
|
248
249
|
base: "view/",
|
|
249
250
|
home: "home",
|
|
250
|
-
root:
|
|
251
|
+
root: body
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
exports.View = View
|
|
254
255
|
exports.LiteJS = LiteJS
|
|
255
256
|
|
|
256
257
|
|
|
257
|
-
function LiteJS(
|
|
258
|
+
function LiteJS(opts) {
|
|
259
|
+
opts = Object.assign({}, defaults, opts)
|
|
258
260
|
var key, name
|
|
259
|
-
,
|
|
261
|
+
, root = opts.root
|
|
260
262
|
for (key in opts) if (hasOwn.call(opts, key)) {
|
|
261
263
|
if (typeof View[key] === "function") {
|
|
262
264
|
for (name in opts[key]) if (hasOwn.call(opts[key], name)) {
|
|
@@ -266,7 +268,13 @@
|
|
|
266
268
|
View[key] = opts[key]
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
|
-
View("#
|
|
271
|
+
View("#", root)
|
|
272
|
+
View.$ = function(sel, start) {
|
|
273
|
+
return body.querySelector.call(start || root, sel)
|
|
274
|
+
}
|
|
275
|
+
View.$$ = function(sel, start) {
|
|
276
|
+
return Array.from(body.querySelectorAll.call(start || root, sel))
|
|
277
|
+
}
|
|
270
278
|
return View
|
|
271
279
|
}
|
|
272
280
|
|
|
@@ -331,7 +339,7 @@
|
|
|
331
339
|
} else {
|
|
332
340
|
if (tmp.route === "404") {
|
|
333
341
|
El.txt(tmp = El("h3"), "# Error 404")
|
|
334
|
-
View("404", tmp, "#
|
|
342
|
+
View("404", tmp, "#")
|
|
335
343
|
}
|
|
336
344
|
View("404").show({origin:params})
|
|
337
345
|
}
|
|
@@ -506,6 +514,8 @@
|
|
|
506
514
|
, templateRe = /([ \t]*)(%?)((?:("|')(?:\\\4|.)*?\4|[-\w:.#[\]]=?)*)[ \t]*([>^;@|\\\/]|!?=|)(([\])}]?).*?([[({]?))(?=\x1f|\n|$)+/g
|
|
507
515
|
, renderRe = /[;\s]*(\w+)(?:(::?| )((?:(["'\/])(?:\\\3|.)*?\3|[^;])*))?/g
|
|
508
516
|
, selectorRe = /([.#:[])([-\w]+)(?:\(((?:[^()]|\([^)]+\))+?)\)|([~^$*|]?)=(("|')(?:\\.|[^\\])*?\6|[-\w]+))?]?/g
|
|
517
|
+
, fnRe = /('|")(?:\\\1|.)*?\1|\/(?:\\?.)+?\/[gim]*|\b(?:n|data|b|s|B|r|false|in|new|null|this|true|typeof|void|function|var|if|else|return)\b|\.\w+|\w+:/g
|
|
518
|
+
, wordRe = /\b[a-z_$][\w$]*/ig
|
|
509
519
|
, splitRe = /[,\s]+/
|
|
510
520
|
, camelRe = /\-([a-z])/g
|
|
511
521
|
, bindings = El.bindings = {
|
|
@@ -522,11 +532,6 @@
|
|
|
522
532
|
html: function(el, html) {
|
|
523
533
|
el.innerHTML = html
|
|
524
534
|
},
|
|
525
|
-
md: El.md = function(el, txt) {
|
|
526
|
-
txt = txt.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """)
|
|
527
|
-
txt = txt.replace(/\n/g, "<br>")
|
|
528
|
-
el.innerHTML = txt
|
|
529
|
-
},
|
|
530
535
|
ref: function(el, name) {
|
|
531
536
|
this[name] = el
|
|
532
537
|
},
|
|
@@ -616,7 +621,8 @@
|
|
|
616
621
|
|
|
617
622
|
// NOTE: IE-s cloneNode consolidates the two text nodes together as one
|
|
618
623
|
// http://brooknovak.wordpress.com/2009/08/23/ies-clonenode-doesnt-actually-clone/
|
|
619
|
-
el = (elCache[name] || (elCache[name] = document.createElement(name))).cloneNode(true)
|
|
624
|
+
el = (name = elCache[name] || (elCache[name] = document.createElement(name))).cloneNode(true)
|
|
625
|
+
el._s = name._s
|
|
620
626
|
|
|
621
627
|
if (pres) {
|
|
622
628
|
setAttr(el, pre)
|
|
@@ -723,7 +729,7 @@
|
|
|
723
729
|
// Read-only checkboxes can be changed by the user
|
|
724
730
|
|
|
725
731
|
for (opts = {}; (input = el.elements[i++]); ) if (!input.disabled && (key = input.name || input.id)) {
|
|
726
|
-
value = valFn(input)
|
|
732
|
+
value = valFn(input, val != UNDEF ? val[key] : UNDEF)
|
|
727
733
|
if (value !== UNDEF) {
|
|
728
734
|
step = opts
|
|
729
735
|
key.replace(/\[(.*?)\]/g, replacer)
|
|
@@ -734,7 +740,7 @@
|
|
|
734
740
|
return opts
|
|
735
741
|
}
|
|
736
742
|
|
|
737
|
-
if (
|
|
743
|
+
if (val !== UNDEF) {
|
|
738
744
|
if (opts) {
|
|
739
745
|
value = (isArray(val) ? val : [ val ]).map(String)
|
|
740
746
|
for (; (input = opts[i++]); ) {
|
|
@@ -795,8 +801,12 @@
|
|
|
795
801
|
|
|
796
802
|
if (child.nodeType) {
|
|
797
803
|
tmp = el.insertBefore ? el : el[el.length - 1]
|
|
798
|
-
if ((i = getAttr(
|
|
799
|
-
|
|
804
|
+
if ((i = getAttr(child, "slot"))) {
|
|
805
|
+
child.removeAttribute("slot")
|
|
806
|
+
before = findCom(tmp, "%slot-" + i) || tmp
|
|
807
|
+
tmp = before.parentNode
|
|
808
|
+
} else if ((i = getAttr(tmp, "data-slot"))) {
|
|
809
|
+
before = findCom(tmp, "%slot-" + i) || tmp
|
|
800
810
|
tmp = before.parentNode
|
|
801
811
|
// TODO:2016-07-05:lauri:handle numeric befores
|
|
802
812
|
}
|
|
@@ -1068,14 +1078,30 @@
|
|
|
1068
1078
|
if (!node) return
|
|
1069
1079
|
var bind, fn
|
|
1070
1080
|
, scope = elScope(node, 0, _scope)
|
|
1071
|
-
, i = 0
|
|
1072
1081
|
|
|
1073
1082
|
if (node.nodeType != 1) {
|
|
1074
1083
|
if (node.render) node.render(scope)
|
|
1075
1084
|
return
|
|
1076
1085
|
}
|
|
1077
1086
|
|
|
1078
|
-
|
|
1087
|
+
/*** ie8 ***/
|
|
1088
|
+
if (ie678 && node.tagName === "SELECT") {
|
|
1089
|
+
node.parentNode.insertBefore(node, node)
|
|
1090
|
+
}
|
|
1091
|
+
/**/
|
|
1092
|
+
|
|
1093
|
+
if (hydrate(node, BIND_ATTR, scope)) return
|
|
1094
|
+
for (bind = node.firstChild; bind; bind = fn) {
|
|
1095
|
+
fn = bind.nextSibling
|
|
1096
|
+
render(bind, scope)
|
|
1097
|
+
}
|
|
1098
|
+
hydrate(node, "data-out", scope)
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
function hydrate(node, attr, scope) {
|
|
1102
|
+
var bind, fn
|
|
1103
|
+
, i = 0
|
|
1104
|
+
if ((bind = getAttr(node, attr))) {
|
|
1079
1105
|
scope._m = bindMatch
|
|
1080
1106
|
scope._t = bind
|
|
1081
1107
|
// i18n(bind, lang).format(scope)
|
|
@@ -1097,8 +1123,14 @@
|
|
|
1097
1123
|
}) + "r)"
|
|
1098
1124
|
|
|
1099
1125
|
try {
|
|
1100
|
-
|
|
1101
|
-
|
|
1126
|
+
var vars = fn.replace(fnRe, "").match(wordRe) || []
|
|
1127
|
+
for (i = vars.length; i--; ) if (vars.indexOf(vars[i]) !== i) vars.splice(i, 1)
|
|
1128
|
+
if (Function(
|
|
1129
|
+
"n,data,b,s,B,r",
|
|
1130
|
+
(vars[0] ? "var " + vars.join("='',") + "='';" : "") +
|
|
1131
|
+
"with(data||{})return " + fn
|
|
1132
|
+
).call(node, node, scope, bindings, setAttr, attr)) {
|
|
1133
|
+
return true
|
|
1102
1134
|
}
|
|
1103
1135
|
} catch (e) {
|
|
1104
1136
|
/*** debug ***/
|
|
@@ -1110,21 +1142,17 @@
|
|
|
1110
1142
|
}
|
|
1111
1143
|
}
|
|
1112
1144
|
}
|
|
1113
|
-
|
|
1114
|
-
for (bind = node.firstChild; bind; bind = fn) {
|
|
1115
|
-
fn = bind.nextSibling
|
|
1116
|
-
render(bind, scope)
|
|
1117
|
-
}
|
|
1118
|
-
/*** ie8 ***/
|
|
1119
|
-
if (ie678 && node.tagName === "SELECT") {
|
|
1120
|
-
node.parentNode.insertBefore(node, node)
|
|
1121
|
-
}
|
|
1122
|
-
/**/
|
|
1123
1145
|
}
|
|
1124
1146
|
|
|
1147
|
+
|
|
1125
1148
|
El.empty = empty
|
|
1126
1149
|
El.kill = kill
|
|
1127
1150
|
El.render = render
|
|
1151
|
+
El.replace = replace
|
|
1152
|
+
function replace(oldEl, newEl) {
|
|
1153
|
+
var parent = oldEl && oldEl.parentNode
|
|
1154
|
+
if (parent && newEl) return parent.replaceChild(oldEl, newEl)
|
|
1155
|
+
}
|
|
1128
1156
|
|
|
1129
1157
|
for (var key in El) wrap(key)
|
|
1130
1158
|
|
|
@@ -1145,10 +1173,8 @@
|
|
|
1145
1173
|
|
|
1146
1174
|
wrapProto.append = function(el) {
|
|
1147
1175
|
var elWrap = this
|
|
1148
|
-
if (elWrap.
|
|
1149
|
-
append(elWrap[elWrap.
|
|
1150
|
-
// } else if (elWrap._cb > -1) {
|
|
1151
|
-
// elWrap.splice(elWrap._cb, 0, el)
|
|
1176
|
+
if (elWrap._s) {
|
|
1177
|
+
append(elWrap[elWrap._s[getAttr(el, "slot") || elWrap._s._] || 0], el)
|
|
1152
1178
|
} else {
|
|
1153
1179
|
elWrap.push(el)
|
|
1154
1180
|
}
|
|
@@ -1157,8 +1183,7 @@
|
|
|
1157
1183
|
|
|
1158
1184
|
wrapProto.cloneNode = function(deep) {
|
|
1159
1185
|
deep = new ElWrap(this, deep)
|
|
1160
|
-
deep.
|
|
1161
|
-
//deep._cb = this._cb
|
|
1186
|
+
deep._s = this._s
|
|
1162
1187
|
return deep
|
|
1163
1188
|
}
|
|
1164
1189
|
|
|
@@ -1185,10 +1210,10 @@
|
|
|
1185
1210
|
if (parent._r) {
|
|
1186
1211
|
parent.txt += all + "\n"
|
|
1187
1212
|
} else if (plugin || mapStart && (name = "map")) {
|
|
1188
|
-
if (
|
|
1213
|
+
if (plugins[name]) {
|
|
1189
1214
|
parentStack.push(parent)
|
|
1190
1215
|
stack.unshift(q)
|
|
1191
|
-
parent = (new
|
|
1216
|
+
parent = (new plugins[name](parent, op + text, mapEnd ? "" : ";")).el
|
|
1192
1217
|
} else {
|
|
1193
1218
|
append(parent, all)
|
|
1194
1219
|
}
|
|
@@ -1210,8 +1235,8 @@
|
|
|
1210
1235
|
text = text.replace(/(\w+):?/, "on:'$1',")
|
|
1211
1236
|
} else if (op != ";" && op != "^") {
|
|
1212
1237
|
text = (parent.tagName === "INPUT" ? "val" : "txt") + (
|
|
1213
|
-
op === "=" ? ":" + text.replace(
|
|
1214
|
-
":_('" + text.replace(
|
|
1238
|
+
op === "=" ? ":" + text.replace(/'/g, "\\'") :
|
|
1239
|
+
":_('" + text.replace(/'/g, "\\'") + "',data)"
|
|
1215
1240
|
)
|
|
1216
1241
|
}
|
|
1217
1242
|
appendBind(parent, text, ";", op)
|
|
@@ -1234,7 +1259,9 @@
|
|
|
1234
1259
|
|
|
1235
1260
|
function plugin(parent, name) {
|
|
1236
1261
|
var t = this
|
|
1237
|
-
|
|
1262
|
+
, arr = name.split(splitRe)
|
|
1263
|
+
t.name = arr[0]
|
|
1264
|
+
t.attr = arr.slice(1)
|
|
1238
1265
|
t.parent = parent
|
|
1239
1266
|
t.el = El("div")
|
|
1240
1267
|
t.el.plugin = t
|
|
@@ -1248,18 +1275,14 @@
|
|
|
1248
1275
|
, el = childNodes[1] ? new ElWrap(childNodes) : childNodes[0]
|
|
1249
1276
|
|
|
1250
1277
|
if (i > -1) {
|
|
1251
|
-
if (childNodes[i].nodeType == 1
|
|
1252
|
-
|
|
1278
|
+
if (childNodes[i].nodeType == 1 && t.el._sk) {
|
|
1279
|
+
setAttr(childNodes[i], "data-slot", t.el._sk)
|
|
1280
|
+
}
|
|
1281
|
+
el._s = t.el._s
|
|
1253
1282
|
}
|
|
1254
1283
|
|
|
1255
1284
|
t.el.plugin = t.el = t.parent = null
|
|
1256
1285
|
return el
|
|
1257
|
-
},
|
|
1258
|
-
done: function() {
|
|
1259
|
-
var t = this
|
|
1260
|
-
, parent = t.parent
|
|
1261
|
-
elCache[t.name] = t._done()
|
|
1262
|
-
return parent
|
|
1263
1286
|
}
|
|
1264
1287
|
}
|
|
1265
1288
|
|
|
@@ -1275,18 +1298,20 @@
|
|
|
1275
1298
|
|
|
1276
1299
|
js[P].done = Function("Function(this.txt)()")
|
|
1277
1300
|
|
|
1278
|
-
El.plugins = {
|
|
1301
|
+
var plugins = El.plugins = {
|
|
1279
1302
|
binding: extend(js, {
|
|
1280
1303
|
done: function() {
|
|
1281
1304
|
Object.assign(bindings, Function("return({" + this.txt + "})")())
|
|
1282
1305
|
}
|
|
1283
1306
|
}),
|
|
1284
|
-
|
|
1307
|
+
slot: extend(plugin, {
|
|
1285
1308
|
done: function() {
|
|
1286
|
-
var
|
|
1309
|
+
var name = this.name || ++seq
|
|
1310
|
+
var key = "%slot-" + name
|
|
1287
1311
|
, root = append(this.parent, document.createComment(key))
|
|
1288
1312
|
for (; root.parentNode; root = root.parentNode);
|
|
1289
|
-
root.
|
|
1313
|
+
;(root._s || (root._s = {}))[name] = root.childNodes.length - 1
|
|
1314
|
+
if (!this.name) root._s._ = root._sk = name
|
|
1290
1315
|
root._cp = root.childNodes.length - 1
|
|
1291
1316
|
}
|
|
1292
1317
|
}),
|
|
@@ -1308,6 +1333,16 @@
|
|
|
1308
1333
|
}),
|
|
1309
1334
|
el: extend(plugin, {
|
|
1310
1335
|
content: 1,
|
|
1336
|
+
done: function() {
|
|
1337
|
+
var t = this
|
|
1338
|
+
, parent = t.parent
|
|
1339
|
+
, arr = t.attr
|
|
1340
|
+
t = elCache[t.name] = t._done()
|
|
1341
|
+
if (arr[0]) {
|
|
1342
|
+
// TODO:2023-03-22:lauri:Add new scope
|
|
1343
|
+
}
|
|
1344
|
+
return parent
|
|
1345
|
+
}
|
|
1311
1346
|
}),
|
|
1312
1347
|
js: js,
|
|
1313
1348
|
map: extend(js, {
|
|
@@ -1326,9 +1361,9 @@
|
|
|
1326
1361
|
done: function() {
|
|
1327
1362
|
var fn
|
|
1328
1363
|
, t = this
|
|
1329
|
-
, arr = t.
|
|
1364
|
+
, arr = t.attr
|
|
1330
1365
|
, bind = getAttr(t.el, BIND_ATTR)
|
|
1331
|
-
, view = View(
|
|
1366
|
+
, view = View(t.name, t._done(), arr[0], arr[1])
|
|
1332
1367
|
if (bind) {
|
|
1333
1368
|
fn = bind.replace(renderRe, function(match, name, op, args) {
|
|
1334
1369
|
return "(this['" + name + "']" + (
|
|
@@ -1344,14 +1379,15 @@
|
|
|
1344
1379
|
"view-link": extend(plugin, {
|
|
1345
1380
|
done: function() {
|
|
1346
1381
|
var t = this
|
|
1347
|
-
, arr = t.
|
|
1348
|
-
View(
|
|
1382
|
+
, arr = t.attr
|
|
1383
|
+
View(t.name, null, arr[1])
|
|
1349
1384
|
.on("ping", function(opts) {
|
|
1350
|
-
View.show(arr[
|
|
1385
|
+
View.show(arr[0].format(opts))
|
|
1351
1386
|
})
|
|
1352
1387
|
}
|
|
1353
1388
|
})
|
|
1354
1389
|
}
|
|
1390
|
+
plugins.child = plugins.slot
|
|
1355
1391
|
|
|
1356
1392
|
xhr.view = xhr.tpl = El.tpl = parseTemplate
|
|
1357
1393
|
xhr.css = function(str) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litejs/ui",
|
|
3
|
-
"version": "23.3.
|
|
3
|
+
"version": "23.3.3",
|
|
4
4
|
"description": "UI engine for LiteJS full-stack framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lauri Rooden <lauri@rooden.ee>",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"test": "TZ='Europe/Tallinn' lj test test/index.js --brief --coverage && jshint --verbose *.js src/*.js binding/*.js polyfill/*.js"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@litejs/cli": "23.3.
|
|
28
|
+
"@litejs/cli": "23.3.2",
|
|
29
29
|
"jshint": "2.13.6"
|
|
30
30
|
},
|
|
31
31
|
"litejs": {
|
package/el/Segment7.tpl.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
El.tpl('%css .Segment7 { position: relative; height: 1em; width: .5em; margin-right: 8px; } .Seg-V, .Seg-H { position: absolute; top: 0; left: .105em; height: .098em; width: .28em; background-color: currentColor; } .Seg-V + .Seg-V { top: .392em; } .Seg-V + .Seg-V + .Seg-V { top: .784em; } .Seg:before, .Seg:after { position: absolute; content: ""; border: .049em solid transparent; } .Seg-V:before { left: -.098em; border-right-color: currentColor; } .Seg-V:after { right: -.098em; border-left-color: currentColor; } .Seg-H:before { top: -.098em; border-bottom-color: currentColor; } .Seg-H:after { bottom: -.098em; border-top-color: currentColor; } .Seg-H { top: .105em; left: 0; height: .28em; width: .098em; } .Seg-H + .Seg-H { left: .392em; } .Seg-H + .Seg-H + .Seg-H { top: .497em; } .Seg-H + .Seg-H + .Seg-H + .Seg-H { left: 0; } [data-value="0"]>[off~="0"], [data-value="1"]>[off~="1"], [data-value="2"]>[off~="2"], [data-value="3"]>[off~="3"], [data-value="4"]>[off~="4"], [data-value="5"]>[off~="5"], [data-value="6"]>[off~="6"], [data-value="7"]>[off~="7"], [data-value="8"]>[off~="8"], [data-value="9"]>[off~="9"], [data-value="a"]>[off~="a"], [data-value="b"]>[off~="b"], [data-value="c"]>[off~="c"], [data-value="d"]>[off~="d"], [data-value="e"]>[off~="e"], [data-value="f"]>[off~="f"] { color: rgba(0,0,0,0.07); }%el Segment7 .Segment7.left .Seg.Seg-V.Seg-A[off="1 4 b d"] .Seg.Seg-V.Seg-G[off="0 1 7 c"] .Seg.Seg-V.Seg-D[off="1 4 7 a f"] .Seg.Seg-H.Seg-F[off="1 2 3 7 d"] .Seg.Seg-H.Seg-B[off="5 6 b c e f"] .Seg.Seg-H.Seg-C[off="2 c e f"] .Seg.Seg-H.Seg-E[off="1 3 4 5 7 9"]')
|
package/el/confirm.tpl.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
El.tpl('%css .Confirm { z-index: 9; } .Confirm-bg { backdrop-filter: blur(5px); background-color: rgba(0, 0, 0, .6); } .Confirm-content { position: absolute; left: 0; right: 0; margin: 0 auto; top: 4%; width: 600px; background-color: #fff; box-shadow: 0 2px 10px 2px rgba(255,255,255,.5); } .sm .Confirm-content { width: 94%; } .Confirm--blur { transform: scale(.85); transform-origin: 50% 100vh; }// reverse animation: x1, y1, x2, y2 -> (1 - x2), (1 - y2), (1 - x1), (1 - y1)// https://developer.mozilla.org/en-US/docs/Web/API/Notification// https://developers.google.com/web/fundamentals/push-notifications/display-a-notification// var n = new Notification(title, options);// {// "//": "Visual Options",// "body": "Did you make a $1,000,000 purchase at Dr. Evil...",// "icon": "images/ccard.png", // 192px or more is a safe bet// "image": "<URL String>", // width 1350px or more, ratio of 4:3 for desktop and Android will crop the image// "badge": "<URL String>", // 72px or more should be good// "vibrate": "<Array of Integers>",// "sound": "<URL String>",// "dir": "<String of \'auto\' | \'ltr\' | \'rtl\'>",// "//": "Behavioural Options",// "tag": "<String>", // group messages so that any old notifications that are currently displayed will be closed if they have the same tag as a new notification.// "data": "<Anything>",// "requireInteraction": "<boolean>", // for Chrome on desktop// "renotify": "<Boolean>",// "silent": "<Boolean>",// "//": "Both Visual & Behavioural Options",// "actions": "<Array of Strings>",// "//": "Information Option. No visual affect.",// "timestamp": "<Long>" // ms// }// Star Wars shamelessly taken from the awesome Peter Beverloo// https://tests.peter.sh/notification-generator/// "vibrate": [500,110,500,110,450,110,200,110,170,40,450,110,200,110,170,40,500]// "actions": [// { "action": "yes", "title": "Yes", "icon": "images/yes.png" },// { "action": "no", "title": "No", "icon": "images/no.png" }// ]%js View.on("confirm", function(title, opts, next) { View.blur() if (!next && typeof opts === "function") { next = opts opts = null } var sound, vibrate , code = "" , el = El("Confirm") , scope = El.scope(el, El.data) , kbMap = {} , body = document.body , blurEl = body.lastChild Object.assign(scope, opts) scope.title = title || "Confirm?" if (!scope.actions) scope.actions = [ { action: "close", title: "Close", key: "esc" } ] for (var a, i = 0; a = scope.actions[i++]; ) { if (typeof a == "string") a = scope.actions[i-1] = {title:a,action:a} if (a.key) kbMap[a.key] = resolve.bind(el, el, a.action) } El.cls(blurEl, "Confirm--blur") El.cls(el.lastChild, "Confirm--blur", 0, 1) El.append(body, el) El.render(el, scope) if (scope.code) { El.findAll(el, ".js-numpad").on("click", numpad) kbMap.backspace = kbMap.del = kbMap.num = numpad } El.addKb(kbMap, el) El.findAll(el, ".js-btn").on("click", resolve) View.one("navigation", resolve) if (scope.bgClose) El.on(el, "click", resolve) El.on(el, "wheel", Event.stop) El.on(el.lastChild, "click", Event.stop) if (scope.vibrate && navigator.vibrate) { vibrate = navigator.vibrate(scope.vibrate) } if (scope.sound && window.Audio) { sound = new Audio(scope.sound) sound.play() } function numpad(e, _num) { // Enter pressed on focused element if (_num == void 0 && e.clientX == 0) return var num = _num == void 0 ? e.target[El.T] : _num code += num if (num == "CLEAR" || num == "del" || num == "backspace") code = "" El.md(El.find(el, ".js-body"), code.replace(/./g, "•") || opts.body) if (typeof scope.code == "number" && code.length == scope.code && id && !sent) next(sent = code, id, resolve, reject) } function resolve(e, key) { if (el) { var action = key || El.attr(this, "data-action") , result = { code: code, input: El.val(El.find(el, ".js-input")), inputMd: El.val(El.find(el, ".js-inputMd")), select: El.val(El.find(el, ".js-select")) } El.kill(el, "transparent") El.cls(blurEl, "Confirm--blur", el = 0) if (action && next) { if (typeof next === "function") next(action, result) else if (typeof next[action] === "function") next[action](result) else if (next[action]) View.emit(next[action], result) } if (vibrate) navigator.vibrate(0) if (sound) sound.pause() } } scope.resolve = resolve View.emit("confirm:open", scope) })%el Confirm .Confirm.max.fix.anim .Confirm-bg.max.abs .Confirm-content.Confirm--blur.grid.p2.anim .col.ts3 ;txt:: _(title, map) .col.js-body ;md:: _(body, map) .row.js-numpad ;if: code ;each: num in [1,2,3,4,5,6,7,8,9,"CLEAR",0] .col.w4>.btn {num} .row ;if: input .col>input.field.js-input .row ;if: data.inputMd!=null .col textarea.field.js-inputMd @keyup [this.parentNode.nextSibling.nextSibling], "renderMd" ;val: inputMd .col.ts3 Preview .p4 ;md: inputMd .row ;if: select .col select.field.js-select ;list: select, [""] option ;val:: item.id ;txt:: _(item.name) .col .group ;each: action in actions .btn.js-btn ;txt:: _(action.title) ;class:: "w" + (12/actions.length) ;nop: this.focus() ;data: "action", action.action ;class:: "is-" + action.action, action.action')
|
package/el/form1.tpl.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
El.tpl('%css ::-moz-focus-inner { border: 0; padding: 0; } .Form1-del.right { display: block; margin: -10px -10px 0 0; opacity: .2; } .Form1-del { font-size: 20px; font-weight: 700; border: 1px solid transparent; line-height: 16px; width: 20px; height: 20px; text-align: center; border-radius: 4px; } .Form1-del:hover { opacity: 1; border: 1px solid #aaa; background-image: linear-gradient(to bottom, #ddd, #888); } /** * 1. avoid ios styling the submit button */ .input { display: block; border-radius: 4px; border: 1px solid #aaa; } .field { width: 100%; } .btn, input, select, textarea { display: block; border-radius: 4px; border: 1px solid #aaa; font-size: 14px; font-weight: 400; line-height: 30px; height: 32px; padding: 0 8px; margin: 0; } input[type=checkbox] { height: auto; } input[type=time] { padding: 0 0 0 8px; } textarea { height: 64px; padding: 8px; margin: 0; line-height: 1.1; } select { padding-right: 0; } select[multiple] { height: auto; padding: 0; } input[type=radio], input[type=checkbox] { width: auto; display: inline; margin-top: -2px; } .btn, input[type=submit] { /* 1 */ -webkit-appearance: none; /* 1 */ position: relative; padding: 0px 14px; text-align: center; text-decoration: none; /* default look */ background-color: #ddd; color: #444; cursor: pointer; } option[disabled], .btn.disabled, .btn[disabled] { box-shadow: none; cursor: not-allowed; font-style: italic; opacity: .6; pointer-events: none; } .group { overflow: auto; } .group > .btn { border-radius: 0; float: left; } .group > .btn:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .group > .btn:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; } .btn--narrow { line-height: 1.6; margin: .7em 0; } .btn__spacer { height: 33px; } .md .input__label, .lg .input__label { padding-right: 8px; text-align: right; line-height: 28px; } .input__hint { text-align: right; color: #444; } input[type=checkbox]+.input__hint { display: inline-block; margin-left: 8px; } .btn:active, .btn:focus, input:active, input:focus, select:active, select:focus, textarea:active, textarea:focus { border-color: #257; outline: 0 none; box-shadow: 0 2px 5px rgba(0, 0, 0, .5) inset, 0 0 2px 2px #6ae; z-index: 1; } .btn:hover, .btn:focus { filter: brightness(1.3) saturate(1.2); text-decoration: none; } .btn:active, .btn.is-active { box-shadow: inset 0 0 8px rgba(0, 0, 0, .5); }%el form1-row label.row .col.md-w4.input__label = _(title||name) .col.md-w8 %child .input__hint = _(description) ;if: description%el form1-subheader .col = _(title)%el form1-fieldset fieldset.grid.b2 legend = _(schema.title || _link.title || "")%el form1 form1-row input.field%el form1-ro form1-row>span ;txt: value%el form1-hidden div>input.field[type=hidden]%el form1-boolean form1-row input.field[type=checkbox] ;value: value%el form1-boolean-ro form1-row>span = _(!!value)%el form1-password form1-row input.field[type=password]%el form1-new-password form1-row input.field[type=password][autocomplete=new-password]%el form1-text form1-row textarea.field%el form1-text-ro form1-ro%el form1-enum form1-row select.field ;each:val in data["enum"] option ;val:: val = _("" + val)%el form1-enum-ro form1-ro%el form1-list form1-row select.field ;list: api(resourceCollection.format(data.params, data)), required ? 0 : [""], value option ;val:: item.id ;txt:: _(item.name)%el form1-list-ro form1-row>span = _(item.name)%el form1-array .col .input.p13.cf .left = _(title||name) .input__hint = _(description) .js-items.cf a.btn.right ;if: !data.noAdd ;txt: _(data.name + ".Add") @click: data.add%el form1-array-item .input.p3.m2b.cf.js-del a.right.Form1-del.hand × ;if: !data.noAdd ;data:: "tooltip", _("Delete") @click: data.del b ;if: title ;txt: title .grid.b2.js-item')
|