@litejs/ui 26.2.0 → 26.3.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/css/base.css +4 -0
- package/el/dialog.ui +85 -96
- package/el/material.ui +154 -0
- package/el/menu.ui +213 -0
- package/el/ripple.ui +56 -0
- package/el/{Slider.ui → slider.ui} +81 -69
- package/load.js +2 -2
- package/package.json +2 -2
- package/ui.js +97 -91
- package/el/material.tpl +0 -428
- /package/el/{Pie.tpl → Pie.ui} +0 -0
- /package/el/{Segment7.tpl → Segment7.ui} +0 -0
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
:focus > * > .Slider-knob {
|
|
48
48
|
box-shadow: 0 0 0 8px rgb(0, 0, 0, .2), 0 1px 4px rgba(0, 0, 0, .3);
|
|
49
49
|
}
|
|
50
|
-
.
|
|
50
|
+
.is-active > .Slider-knob {
|
|
51
51
|
box-shadow: 0 0 0 12px rgb(0, 0, 0, .2), 0 1px 5px 5px rgba(0, 0, 0, .3);
|
|
52
52
|
}
|
|
53
53
|
/* value bubble */
|
|
@@ -68,13 +68,14 @@
|
|
|
68
68
|
}
|
|
69
69
|
.Slider-knob:after {
|
|
70
70
|
content: attr(data-val);
|
|
71
|
+
text-align: center;
|
|
71
72
|
left: 10px;
|
|
72
73
|
padding: 0 4px;
|
|
73
74
|
transform: translate(-50%, 0);
|
|
74
75
|
}
|
|
75
76
|
:focus > * > .Slider-knob:before,
|
|
76
77
|
:hover > * > .Slider-knob:before,
|
|
77
|
-
.Slider-knob
|
|
78
|
+
.is-active > .Slider-knob:before {
|
|
78
79
|
border-radius: 50% 50% 0 50%;
|
|
79
80
|
box-shadow: 3px 3px 3px 1px rgba(0, 0, 0, .3);
|
|
80
81
|
opacity: 1;
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
}
|
|
83
84
|
:focus > * > .Slider-knob:after,
|
|
84
85
|
:hover > * > .Slider-knob:after,
|
|
85
|
-
.Slider-knob
|
|
86
|
+
.is-active > .Slider-knob:after {
|
|
86
87
|
box-shadow: -4px -3px 3px -2px rgba(0, 0, 0, .15), 4px -3px 3px -2px rgba(0, 0, 0, .15);
|
|
87
88
|
opacity: 1;
|
|
88
89
|
top: -43px;
|
|
@@ -109,113 +110,124 @@
|
|
|
109
110
|
, elOff = El.off
|
|
110
111
|
, elCls = El.cls
|
|
111
112
|
, elGet = El.get
|
|
112
|
-
|
|
113
|
+
, sliderTypes = {
|
|
114
|
+
time: ["0:1440:60", function(s) {
|
|
115
|
+
s = s.split(":")
|
|
116
|
+
return s[0] * 60 + +s[1]
|
|
117
|
+
}, function(m) {
|
|
118
|
+
return (m / 60 | 0) + ":" + ("0" + m % 60).slice(-2)
|
|
119
|
+
}]
|
|
120
|
+
}
|
|
121
|
+
El.$b.sliderInit = function(el, range) {
|
|
113
122
|
range = (range || elGet(el, "range") || "").split(/[^+\-\d.]/) // min:max:step:margin
|
|
114
|
-
var knobLen, offset, px, drag, min, max, minPx, maxPx
|
|
115
|
-
|
|
116
|
-
,
|
|
117
|
-
,
|
|
118
|
-
,
|
|
119
|
-
,
|
|
123
|
+
var knobLen, offset, px, drag, min, max, minPx, maxPx
|
|
124
|
+
, step = +(range[2] || 1)
|
|
125
|
+
, margin = +(range[3] || 0)
|
|
126
|
+
, fmt = elGet(el, "format")
|
|
127
|
+
, idx
|
|
128
|
+
, fill
|
|
129
|
+
, values = []
|
|
130
|
+
, inputs = $$("input", el)
|
|
131
|
+
, type = sliderTypes[elGet(el, "type")]
|
|
132
|
+
, parse = type ? type[1] : Number
|
|
133
|
+
, format = type ? type[2] : String
|
|
134
|
+
, fills = []
|
|
120
135
|
, emit = El.rate(El.emit.bind(el, el, "change"), 500)
|
|
136
|
+
if (type && !range[1]) range = type[0].split(/[^+\-\d.]/)
|
|
137
|
+
for (idx = 0; idx < inputs.length; ) {
|
|
138
|
+
fills[idx] = El("Slider-fill")
|
|
139
|
+
values[idx] = parse(inputs[idx].value)
|
|
140
|
+
idx++
|
|
141
|
+
}
|
|
142
|
+
if (fills.length) {
|
|
143
|
+
El.append(el, fills.slice(0).reverse())
|
|
144
|
+
load()
|
|
145
|
+
for (idx = 0; idx < fills.length; idx++) setVal(idx, values[idx])
|
|
146
|
+
idx = 0
|
|
147
|
+
fill = fills[0]
|
|
148
|
+
} else {
|
|
149
|
+
fill = el.firstChild
|
|
150
|
+
}
|
|
121
151
|
elOn(window, "blur", stop)
|
|
122
|
-
setTimeout(el.val = set, 10, value||0)
|
|
123
152
|
function load() {
|
|
124
153
|
min = +(range[0] || 0)
|
|
125
154
|
max = +(range[1] || 100)
|
|
126
|
-
knobLen =
|
|
155
|
+
knobLen = (fills[0] || fill).firstChild.offsetWidth>>1
|
|
127
156
|
minPx = 0
|
|
128
|
-
maxPx = el
|
|
157
|
+
maxPx = el.offsetWidth - knobLen - knobLen
|
|
129
158
|
px = maxPx / (max - min)
|
|
130
159
|
}
|
|
131
160
|
elOn(el, "pointerdown", function(e) {
|
|
132
161
|
drag = true
|
|
133
162
|
load()
|
|
134
163
|
var tmp = el.getBoundingClientRect()
|
|
135
|
-
offset =
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
fill = tmp
|
|
146
|
-
knob = tmp.firstChild
|
|
147
|
-
x = next < 0 ? -next : next
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (fill.previousSibling) {
|
|
151
|
-
maxPx = fill.previousSibling[attr] - knobLen
|
|
152
|
-
if (range[3]) maxPx -= px * range[3]
|
|
153
|
-
}
|
|
154
|
-
if (fill.nextSibling) {
|
|
155
|
-
minPx = fill.nextSibling[attr] - knobLen
|
|
156
|
-
if (range[3]) minPx += px * range[3]
|
|
164
|
+
offset = tmp.left + El.scrollLeft() + knobLen
|
|
165
|
+
var next, i
|
|
166
|
+
, x = maxPx
|
|
167
|
+
, diff = e.pageX - offset
|
|
168
|
+
for (i = 0; i < fills.length; i++) {
|
|
169
|
+
next = diff - fills[i].offsetWidth + knobLen
|
|
170
|
+
if (next < 0 ? -next <= x : next < x) {
|
|
171
|
+
idx = i
|
|
172
|
+
fill = fills[i]
|
|
173
|
+
x = next < 0 ? -next : next
|
|
157
174
|
}
|
|
158
175
|
}
|
|
159
|
-
|
|
176
|
+
tmp = offset - e.pageX + (values[idx]-min||0)*px
|
|
177
|
+
if (tmp < knobLen && tmp > -knobLen) offset -= tmp
|
|
160
178
|
listen(elOn)
|
|
179
|
+
move(e)
|
|
161
180
|
})
|
|
162
181
|
function move(e) {
|
|
163
|
-
var diff =
|
|
182
|
+
var diff = e.pageX - offset
|
|
164
183
|
diff = (diff > maxPx ? maxPx : (diff < minPx ? minPx : diff))
|
|
165
|
-
|
|
184
|
+
setVal(idx, (diff / px) + min, diff)
|
|
185
|
+
emit(e)
|
|
166
186
|
return El.stop(e)
|
|
167
187
|
}
|
|
168
188
|
function stop(e) {
|
|
169
189
|
if (drag) {
|
|
170
190
|
drag = false
|
|
171
191
|
listen(elOff)
|
|
172
|
-
|
|
192
|
+
setVal(idx, values[idx])
|
|
173
193
|
}
|
|
174
194
|
}
|
|
175
195
|
function listen(onOff) {
|
|
176
196
|
elCls(el, "anim", !drag)
|
|
177
|
-
elCls(
|
|
197
|
+
elCls(fill, "is-active", drag)
|
|
178
198
|
onOff(document, "pointerup", stop)
|
|
179
199
|
onOff(document, "pointermove", move)
|
|
180
200
|
}
|
|
181
|
-
function
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
El.css(fill, vert ? "height" : "width", ((pos || (val-min)*px)+knobLen) + "px", 0)
|
|
201
|
+
function setVal(i, val, pos) {
|
|
202
|
+
val = El.step(val < min ? min : val > max ? max : val || 0, step)
|
|
203
|
+
if (values[i] !== void 0 && (!drag || pos !== void 0 || i !== idx)) {
|
|
204
|
+
El.css(fills[i], "width", ((pos || (val-min)*px)+knobLen) + "px", 0)
|
|
186
205
|
}
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
206
|
+
if (values[i] !== val) {
|
|
207
|
+
values[i] = val
|
|
208
|
+
inputs[i].value = format(val)
|
|
209
|
+
El.set(fills[i].firstChild, "data-val", fmt ? $d._(fmt, {val:val}) : format(val))
|
|
210
|
+
if (drag && margin) {
|
|
211
|
+
if (i > 0 && val - values[i - 1] < margin) setVal(i - 1, +val - margin)
|
|
212
|
+
if (i < fills.length - 1 && values[i + 1] - val < margin) setVal(i + 1, +val + margin)
|
|
213
|
+
}
|
|
192
214
|
}
|
|
193
215
|
}
|
|
194
216
|
}
|
|
217
|
+
El.$b.sliderInit.types = sliderTypes
|
|
195
218
|
|
|
196
|
-
%el
|
|
197
|
-
|
|
198
|
-
.Slider-fill
|
|
199
|
-
.Slider-knob[tabindex=0]
|
|
219
|
+
%el Knob
|
|
220
|
+
input[type=hidden]
|
|
200
221
|
|
|
201
|
-
%el
|
|
202
|
-
|
|
203
|
-
.Slider-
|
|
204
|
-
.Slider-knob[tabindex=0]
|
|
205
|
-
.Slider-fill
|
|
206
|
-
.Slider-knob[tabindex=0]
|
|
222
|
+
%el Slider-fill
|
|
223
|
+
.Slider-fill
|
|
224
|
+
.Slider-knob[tabindex=0]
|
|
207
225
|
|
|
208
|
-
%el
|
|
209
|
-
|
|
210
|
-
.Slider-fill
|
|
211
|
-
.Slider-knob[tabindex=0]
|
|
212
|
-
.Slider-fill
|
|
213
|
-
.Slider-knob[tabindex=0]
|
|
214
|
-
.Slider-fill
|
|
215
|
-
.Slider-knob[tabindex=0]
|
|
226
|
+
%el Slider
|
|
227
|
+
.Slider.hand.anim[data-out="sliderInit!"]
|
|
216
228
|
|
|
217
229
|
%el Toggle
|
|
218
|
-
button.Toggle.reset ;
|
|
230
|
+
button.Toggle.reset ;sliderInit! "0:1"
|
|
219
231
|
;css: "width","36px"
|
|
220
232
|
.Slider-fill.anim
|
|
221
233
|
.Slider-knob.anim[tabindex=0]
|
package/load.js
CHANGED
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
if (lastError !== (lastError =
|
|
64
64
|
[ file
|
|
65
65
|
, line
|
|
66
|
-
, col || (window.event || unsentLog).errorCharacter || "
|
|
66
|
+
, col || (window.event || unsentLog).errorCharacter || ""
|
|
67
67
|
, message
|
|
68
68
|
].join(":")
|
|
69
|
-
)) log("e", lastError, [error && (error.stack || error.stacktrace) || "
|
|
69
|
+
)) log("e", lastError, [error && (error.stack || error.stacktrace) || "", "" + location])
|
|
70
70
|
}
|
|
71
71
|
, log = xhr.log = function(type, msg, extra) {
|
|
72
72
|
if (unsentLog.push([new Date() - initTime, type].concat(msg, extra || [])) < 2) sendLog()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litejs/ui",
|
|
3
|
-
"version": "26.
|
|
3
|
+
"version": "26.3.0",
|
|
4
4
|
"description": "UI engine for LiteJS full-stack framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Lauri Rooden <lauri@rooden.ee>",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"test": "lj t test/index.js"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@litejs/cli": "26.2.
|
|
30
|
+
"@litejs/cli": "26.2.3"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/ui.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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
|
|
8
8
|
// /*** name ***/ code1 /*/ code2 /**/ - `code1` active in source, `code2` commented out; build can swap
|
|
9
9
|
|
|
10
10
|
/*** debug ***/
|
|
11
|
-
console.log("LiteJS is in debug mode
|
|
11
|
+
console.log("LiteJS is in debug mode and that's fine for production")
|
|
12
12
|
/**/
|
|
13
13
|
|
|
14
14
|
!function(window, document, history, localStorage, location, navigator, Function, Object) {
|
|
@@ -318,10 +318,11 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
318
318
|
var fn2 = fixFn[ev] && fixFn[ev](el, fn, ev) || fn
|
|
319
319
|
, ev2 = fixEv[ev] || ev
|
|
320
320
|
|
|
321
|
-
if (ev2 !== ""
|
|
321
|
+
if (ev2 !== "") {
|
|
322
322
|
// polyfilled addEventListener returns patched function
|
|
323
323
|
// useCapture defaults to false
|
|
324
324
|
// Chrome56 touchstart/move sets {passive:true} by default; use {passive:false} to enable preventDefault()
|
|
325
|
+
// FF/Chrome el.onfocusin property is not supported, only addEventListener("focusin", fn)
|
|
325
326
|
fn2 = html.addEventListener.call(el, ev2, fn2, opts) || fn2
|
|
326
327
|
}
|
|
327
328
|
|
|
@@ -336,7 +337,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
336
337
|
if (fn !== evs[id + 1] && evs[id + 1]._rm) {
|
|
337
338
|
evs[id + 1]._rm()
|
|
338
339
|
}
|
|
339
|
-
if (ev2 !== ""
|
|
340
|
+
if (ev2 !== "") {
|
|
340
341
|
html.removeEventListener.call(el, ev2, evs[id + 1], opts)
|
|
341
342
|
}
|
|
342
343
|
evs.splice(id - 1, 3)
|
|
@@ -507,6 +508,8 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
507
508
|
viewEmit(view, "pong", params, View)
|
|
508
509
|
}
|
|
509
510
|
viewEmit(lastView, "show", params)
|
|
511
|
+
close = history.state || 0
|
|
512
|
+
scrollTo(close.x|0, close.y|0)
|
|
510
513
|
blur()
|
|
511
514
|
}
|
|
512
515
|
function viewClose(view, open) {
|
|
@@ -681,9 +684,10 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
681
684
|
return child
|
|
682
685
|
}
|
|
683
686
|
|
|
684
|
-
addPlugin("
|
|
687
|
+
addPlugin("ui", {
|
|
685
688
|
d: Function("p", "p.u.i=1")
|
|
686
689
|
})
|
|
690
|
+
plugins.start = plugins.ui
|
|
687
691
|
addPlugin("slot", {
|
|
688
692
|
d: function(plugin) {
|
|
689
693
|
var slotName = plugin.n || ++elSeq
|
|
@@ -708,6 +712,9 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
708
712
|
addPlugin("el", {
|
|
709
713
|
d: function(plugin, el) {
|
|
710
714
|
el = usePluginContent(plugin)
|
|
715
|
+
/*** debug ***/
|
|
716
|
+
if (elCache[plugin.n]) console.error("El '%s' exist! Loading .ui file twice will execute %js also twice", plugin.n)
|
|
717
|
+
/**/
|
|
711
718
|
elCache[plugin.n] = el
|
|
712
719
|
}
|
|
713
720
|
}, 1)
|
|
@@ -734,7 +741,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
734
741
|
// document.documentElement.clientWidth is 0 in IE5
|
|
735
742
|
bindingsIs(html, (width = html.offsetWidth), breakpoints, "")
|
|
736
743
|
bindingsIs(html, +(width > html.offsetHeight), "port,1=land", "")
|
|
737
|
-
emit(
|
|
744
|
+
emit(LiteJS, "resize")
|
|
738
745
|
}, 99)
|
|
739
746
|
|
|
740
747
|
if (breakpoints) {
|
|
@@ -1005,7 +1012,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1005
1012
|
function setUrl(url, rep) {
|
|
1006
1013
|
/*** pushState ***/
|
|
1007
1014
|
if (pushBase) {
|
|
1008
|
-
history[rep ? "replaceState" : "pushState"](NUL, NUL, pushBase + url)
|
|
1015
|
+
history[rep ? "replaceState" : (history.replaceState({x: pageXOffset, y: pageYOffset}, NUL, location.href), "pushState")](NUL, NUL, pushBase + url)
|
|
1009
1016
|
} else
|
|
1010
1017
|
/**/
|
|
1011
1018
|
location[rep ? "replace" : "assign"]("#" + url)
|
|
@@ -1119,36 +1126,29 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1119
1126
|
assign(El, {
|
|
1120
1127
|
$b: assign(bindings, {
|
|
1121
1128
|
each: function(el, name, list) {
|
|
1122
|
-
|
|
1123
|
-
if (el._li) throw "Binding each must be type of once: each!" + name
|
|
1124
|
-
/**/
|
|
1125
|
-
|
|
1126
|
-
var comm = Comm("each " + name, up)
|
|
1129
|
+
var comm = el._c || (el._c = Comm("each " + name, up))
|
|
1127
1130
|
, pos = 0
|
|
1128
1131
|
, nodes = []
|
|
1129
|
-
|
|
1130
1132
|
comm.$s = this
|
|
1131
1133
|
elReplace(el, comm)
|
|
1132
|
-
|
|
1133
|
-
return {
|
|
1134
|
-
|
|
1135
|
-
function add(item) {
|
|
1136
|
-
var clone = nodes[pos] = el.cloneNode(true)
|
|
1137
|
-
, subScope = elScope(clone, comm)
|
|
1138
|
-
append(comm.parentNode, clone, (pos ? nodes[pos - 1] : comm).nextSibling)
|
|
1139
|
-
subScope.$i = pos++
|
|
1140
|
-
subScope.$len = list.length
|
|
1141
|
-
subScope[name] = item
|
|
1142
|
-
clone._b = el._b
|
|
1143
|
-
/*** debug ***/
|
|
1144
|
-
clone._li = up
|
|
1145
|
-
/**/
|
|
1146
|
-
render(clone)
|
|
1147
|
-
}
|
|
1134
|
+
up()
|
|
1135
|
+
return { u: up }
|
|
1136
|
+
|
|
1148
1137
|
function up() {
|
|
1149
|
-
|
|
1150
|
-
for (
|
|
1151
|
-
for (
|
|
1138
|
+
if (!list) return
|
|
1139
|
+
for (var sub, keys = Object.keys(list), i = keys.length; pos > i; ) elKill(nodes[--pos])
|
|
1140
|
+
for (nodes.length = i; pos < i; ) {
|
|
1141
|
+
sub = nodes[pos] = el.cloneNode(true)
|
|
1142
|
+
sub._b = el._b
|
|
1143
|
+
append(comm.parentNode, sub, (pos++ ? nodes[pos - 2] : comm).nextSibling)
|
|
1144
|
+
elScope(sub, comm)
|
|
1145
|
+
}
|
|
1146
|
+
for (; i--; ) {
|
|
1147
|
+
sub = nodes[i].$s
|
|
1148
|
+
sub[name] = list[sub.$k = keys[sub.$i = i]]
|
|
1149
|
+
sub.$len = pos
|
|
1150
|
+
render(nodes[i])
|
|
1151
|
+
}
|
|
1152
1152
|
}
|
|
1153
1153
|
},
|
|
1154
1154
|
el: function(el, tag, fallback) {
|
|
@@ -1175,7 +1175,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1175
1175
|
},
|
|
1176
1176
|
is: bindingsIs,
|
|
1177
1177
|
name: function(el, name) {
|
|
1178
|
-
setAttr(el, "name", expand(name, 1))
|
|
1178
|
+
if (name) setAttr(el, "name", expand(name, 1))
|
|
1179
1179
|
},
|
|
1180
1180
|
ref: function(el, name) {
|
|
1181
1181
|
this[name] = el
|
|
@@ -1342,7 +1342,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1342
1342
|
if (isObj(tr)) bindingsCss(el, tr)
|
|
1343
1343
|
tr = "transitionend"
|
|
1344
1344
|
// transitionend fires for each property transitioned
|
|
1345
|
-
if ("on" + tr in el) return addEvent(el, tr, bind(elKill, el, el))
|
|
1345
|
+
if ("on" + tr in el) return addEvent(el, tr, bind(elKill, el, el, el = UNDEF))
|
|
1346
1346
|
}
|
|
1347
1347
|
if (el._e) {
|
|
1348
1348
|
emit(el, "kill")
|
|
@@ -1361,9 +1361,9 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1361
1361
|
}
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
|
-
function elScope(el, parent) {
|
|
1364
|
+
function elScope(el, parent, opts) {
|
|
1365
1365
|
return el.$s || (
|
|
1366
|
-
parent ? (
|
|
1366
|
+
parent ? (el.$s = assign(create(parent = elScope(parent)), opts, { $up: parent })) :
|
|
1367
1367
|
closestScope(el)
|
|
1368
1368
|
)
|
|
1369
1369
|
}
|
|
@@ -1432,7 +1432,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1432
1432
|
/*** kb ***/
|
|
1433
1433
|
var kbMaps = []
|
|
1434
1434
|
, kbMod = LiteJS.kbMod = /\bMac|\biP/.test(navigator.userAgent) ? "metaKey" : "ctrlKey"
|
|
1435
|
-
, 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(
|
|
1435
|
+
, 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(",")
|
|
1436
1436
|
|
|
1437
1437
|
El.addKb = addKb
|
|
1438
1438
|
El.rmKb = rmKb
|
|
@@ -1482,22 +1482,23 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1482
1482
|
fn = !input || map.input ? map[code] || map[chr] || map.num && code > 47 && code < 58 && (chr|=0, map.num) || map.all : fn
|
|
1483
1483
|
) && map.bubble; );
|
|
1484
1484
|
if (isStr(fn)) setUrl(fn)
|
|
1485
|
-
if (isFn(fn)) fn(e, chr, el)
|
|
1485
|
+
else if (isFn(fn)) fn(e, chr, el)
|
|
1486
1486
|
}
|
|
1487
1487
|
})
|
|
1488
1488
|
/**/
|
|
1489
1489
|
|
|
1490
1490
|
/*** touch ***/
|
|
1491
|
-
var
|
|
1491
|
+
var e0, touchDist, touchAngle, touchMode, touchTick
|
|
1492
1492
|
, START = "start"
|
|
1493
1493
|
, END = "end"
|
|
1494
1494
|
, touches = []
|
|
1495
|
-
,
|
|
1495
|
+
, tapCount = 0
|
|
1496
|
+
, tapTime = 0
|
|
1496
1497
|
|
|
1497
1498
|
// swipe + left/right/up/down
|
|
1498
|
-
each("hold pan pinch rotate tap", function(name) {
|
|
1499
|
+
each("hold pan pinch rotate tap tap2", function(name) {
|
|
1499
1500
|
fixEv[name] = fixEv[name + START] = fixEv[name + END] = ""
|
|
1500
|
-
fixFn[name] = touchInit
|
|
1501
|
+
fixFn[name] = fixFn[name + START] = fixFn[name + END] = touchInit
|
|
1501
1502
|
})
|
|
1502
1503
|
function touchInit(el) {
|
|
1503
1504
|
if (!el._ti) {
|
|
@@ -1511,21 +1512,21 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1511
1512
|
clearTimeout(touchTick)
|
|
1512
1513
|
var len = e ? touches.push(e) : touches.length
|
|
1513
1514
|
, MOVE = "pointermove"
|
|
1514
|
-
if (touchMode
|
|
1515
|
-
emit(
|
|
1515
|
+
if (touchMode) {
|
|
1516
|
+
emit(el, touchMode + END, e2, el)
|
|
1516
1517
|
touchMode = UNDEF
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
|
|
1518
|
+
} else if (len < 1) {
|
|
1519
|
+
var now = Date.now()
|
|
1520
|
+
tapCount = e2.count = now - tapTime < (LiteJS.tapDelay || 400) ? tapCount + 1 : 1
|
|
1521
|
+
tapTime = now
|
|
1522
|
+
if (!emit(el, "tap" + tapCount, e2, el)) emit(el, "tap", e2, el)
|
|
1520
1523
|
}
|
|
1521
1524
|
if (len === 1) {
|
|
1522
1525
|
if (e) {
|
|
1523
|
-
|
|
1524
|
-
touchEv.X = e.clientX
|
|
1525
|
-
touchEv.Y = e.clientY
|
|
1526
|
+
e0 = e
|
|
1526
1527
|
touchPos("left", "offsetWidth")
|
|
1527
1528
|
touchPos("top", "offsetHeight")
|
|
1528
|
-
if (e.button === 2 || matches(
|
|
1529
|
+
if (e.button === 2 || matches(el, "INPUT,TEXTAREA,SELECT,.no-drag")) return
|
|
1529
1530
|
touchTick = setTimeout(moveOne, LiteJS.holdDelay || 800, e, 1)
|
|
1530
1531
|
}
|
|
1531
1532
|
moveOne(e || touches[0])
|
|
@@ -1537,15 +1538,9 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1537
1538
|
;(len === 1 ? addEvent : rmEvent)(document, MOVE, moveOne)
|
|
1538
1539
|
;(len === 2 ? addEvent : rmEvent)(document, MOVE, moveTwo)
|
|
1539
1540
|
function touchPos(name, offset) {
|
|
1540
|
-
var val = (
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
touchEl.style[name]
|
|
1544
|
-
)
|
|
1545
|
-
touchEv[name] = parseInt(val, 10) || 0
|
|
1546
|
-
if (val && val.indexOf("%") > -1) {
|
|
1547
|
-
touchEv[name] *= touchEl.parentNode[offset] / 100
|
|
1548
|
-
}
|
|
1541
|
+
var val = getAttr(el, name == "top" ? "y" : "x") || getComputedStyle(el)[name]
|
|
1542
|
+
, num = parseInt(val, 10) || 0
|
|
1543
|
+
e0[name] = val && val.indexOf("%") > -1 ? num * el.parentNode[offset] / 100 : num
|
|
1549
1544
|
}
|
|
1550
1545
|
}
|
|
1551
1546
|
function touchUp(e) {
|
|
@@ -1563,7 +1558,7 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1563
1558
|
// alt+wheel may be OS level zoom, use shiftKey as alternative
|
|
1564
1559
|
if (!touches[0]) {
|
|
1565
1560
|
var ev = e.ctrlKey ? "pinch" : e.altKey || e.shiftKey ? "rotate" : UNDEF
|
|
1566
|
-
if (ev &&
|
|
1561
|
+
if (ev && (e.diff = e.deltaY / 20, e.angle = 0, emit(el, ev, e, el))) {
|
|
1567
1562
|
return eventStop(e)
|
|
1568
1563
|
}
|
|
1569
1564
|
}
|
|
@@ -1573,21 +1568,23 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1573
1568
|
if (touches[0].buttons && touches[0].buttons !== (e.buttons || [0, 1, 4, 2][e.which || 0])) {
|
|
1574
1569
|
return touchUp(e)
|
|
1575
1570
|
}
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1571
|
+
e.x0 = e0.clientX
|
|
1572
|
+
e.y0 = e0.clientY
|
|
1573
|
+
e.dx = e.clientX - e.x0
|
|
1574
|
+
e.dy = e.clientY - e.y0
|
|
1575
|
+
e.ex = e.dx + e0.left
|
|
1576
|
+
e.ey = e.dy + e0.top
|
|
1580
1577
|
if (!touchMode) {
|
|
1581
|
-
var evs =
|
|
1578
|
+
var evs = el._e
|
|
1582
1579
|
touchMode = (
|
|
1583
|
-
haveEv("pan",
|
|
1580
|
+
haveEv("pan", e.dx > 10 || e.dx < -10 || e.dy > 10 || e.dy < -10) ||
|
|
1584
1581
|
haveEv("hold", fromTimer)
|
|
1585
1582
|
)
|
|
1586
1583
|
if (!touchMode) return
|
|
1587
1584
|
clearTimeout(touchTick)
|
|
1588
|
-
emit(
|
|
1585
|
+
emit(el, touchMode + START, e, el)
|
|
1589
1586
|
}
|
|
1590
|
-
emit(
|
|
1587
|
+
emit(el, touchMode, e, el)
|
|
1591
1588
|
function haveEv(name, set) {
|
|
1592
1589
|
return set && (evs[name] || evs[name + START] || evs[name + END]) && name
|
|
1593
1590
|
}
|
|
@@ -1595,19 +1592,26 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1595
1592
|
function moveTwo(e) {
|
|
1596
1593
|
touches[ touches[0].pointerId == e.pointerId ? 0 : 1] = e
|
|
1597
1594
|
var diff
|
|
1598
|
-
, x =
|
|
1599
|
-
, y =
|
|
1595
|
+
, x = e0.clientX - touches[1].clientX
|
|
1596
|
+
, y = e0.clientY - touches[1].clientY
|
|
1600
1597
|
, dist = Math.sqrt(x*x + y*y) | 0
|
|
1601
1598
|
, angle = Math.atan2(y, x)
|
|
1602
1599
|
|
|
1603
1600
|
if (touchDist !== UNDEF) {
|
|
1604
1601
|
diff = dist - touchDist
|
|
1605
|
-
if (diff)
|
|
1602
|
+
if (diff) {
|
|
1603
|
+
e.diff = diff
|
|
1604
|
+
e.angle = angle
|
|
1605
|
+
emit(el, "pinch", e, el)
|
|
1606
|
+
}
|
|
1606
1607
|
// GestureEvent onGestureChange: function(e) {
|
|
1607
1608
|
// e.target.style.transform =
|
|
1608
1609
|
// 'scale(' + e.scale + startScale + ') rotate(' + e.rotation + startRotation + 'deg)'
|
|
1609
1610
|
diff = angle - touchAngle
|
|
1610
|
-
if (diff)
|
|
1611
|
+
if (diff) {
|
|
1612
|
+
e.diff = diff * (180/Math.PI)
|
|
1613
|
+
emit(el, "rotate", e, el)
|
|
1614
|
+
}
|
|
1611
1615
|
}
|
|
1612
1616
|
touchDist = dist
|
|
1613
1617
|
touchAngle = angle
|
|
@@ -1667,28 +1671,27 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1667
1671
|
}
|
|
1668
1672
|
return
|
|
1669
1673
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1674
|
+
var result, node
|
|
1675
|
+
, arr = ("" + name).split(splitRe)
|
|
1676
|
+
, i = 0, len = arr.length
|
|
1677
|
+
, value = prepareVal && (selector || isStr(val)) ? function(e, mem, target) {
|
|
1678
|
+
target = selector ? closest(e.target, selector) : el
|
|
1679
|
+
if (target) {
|
|
1680
|
+
if (isStr(val)) emit.apply(NUL, [elScope(target).$ui, val, e, target].concat(data))
|
|
1681
|
+
else if (isFn(val)) val.apply(target, [e, target].concat(data))
|
|
1682
|
+
}
|
|
1683
|
+
} : val
|
|
1684
|
+
, els = !prepareVal && selector ? findAll(el, selector) : isArr(el) ? el : [ el ]
|
|
1685
|
+
for (; (node = els[i++]); ) {
|
|
1686
|
+
for (delay = 0; delay < len; delay++) {
|
|
1687
|
+
if (arr[delay]) {
|
|
1688
|
+
result = fn(node, arr[delay], isArr(value) ? value[delay] : value, data)
|
|
1689
|
+
if (!prepareVal && data > 0) f(node, name, result, "", data)
|
|
1677
1690
|
}
|
|
1678
1691
|
}
|
|
1679
1692
|
}
|
|
1680
1693
|
}
|
|
1681
1694
|
}
|
|
1682
|
-
function delegate(el, val, selector, data) {
|
|
1683
|
-
return isStr(val) ? function(e) {
|
|
1684
|
-
var target = selector ? closest(e.target, selector) : el
|
|
1685
|
-
if (target) emit.apply(target, [elScope(el).$ui, val, e, target].concat(data))
|
|
1686
|
-
} :
|
|
1687
|
-
selector ? function(e, touchEv, touchEl) {
|
|
1688
|
-
if (matches(touchEl = e.target, selector)) val(e, touchEv, touchEl, data)
|
|
1689
|
-
} :
|
|
1690
|
-
val
|
|
1691
|
-
}
|
|
1692
1695
|
}
|
|
1693
1696
|
function assignDeep(target, map) {
|
|
1694
1697
|
if (map) for (var k in map) if (hasOwn(map, k)) {
|
|
@@ -1784,7 +1787,10 @@ console.log("LiteJS is in debug mode, but it's fine for production")
|
|
|
1784
1787
|
}), function(res) {
|
|
1785
1788
|
res = res.concat(sources, next && next.src && next.innerHTML)
|
|
1786
1789
|
if (res[sources.length = 0]) {
|
|
1787
|
-
if (!parser)
|
|
1790
|
+
if (!parser) {
|
|
1791
|
+
var m = res.join("\n").match(/\n%ui\s+(\{[\s\S]*)/)
|
|
1792
|
+
LiteJS.ui = LiteJS(m && Function("return " + m[1])())
|
|
1793
|
+
}
|
|
1788
1794
|
each(res, parser)
|
|
1789
1795
|
}
|
|
1790
1796
|
if (isFn(next)) next()
|