/
tap.fun
59 lines (51 loc) · 1.72 KB
/
tap.fun
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
tap = {
button:function(selectHandler) {
hashAttributes = { class:'tap-button' }
<script hashAttributes=hashAttributes selectHandler=selectHandler>
var module = window.__fun_tap
module.registerTapHandler(hashAttributes, 'button', 'onTouchStart', selectHandler)
if (module.supportClick) {
module.registerTapHandler(hashAttributes, 'button', 'onMouseDown', selectHandler)
}
</script>
return hashAttributes
}
listItem:function(selectHandler) {
hashAttributes = { class:'tap-list-item' }
<script hashAttributes=hashAttributes selectHandler=selectHandler>
var module = window.__fun_tap
module.registerTapHandler(hashAttributes, 'listItem', 'onTouchStart', selectHandler)
if (module.supportClick) {
module.registerTapHandler(hashAttributes, 'button', 'onMouseDown', selectHandler)
}
</script>
return hashAttributes
}
}
<script module=tap>
var tap = require('fun/node_modules/dom/tap'),
client = require('fun/node_modules/std/client')
window.__fun_tap = {
supportClick: !client.isMobile,
registerTapHandler: function(hashAttributes, type, name, selectHandler) {
hashAttributes.set([name], fun.expressions.Handler(function(funEvent) {
var event = funEvent.jsEvent,
element = this,
handler = function(e) { selectHandler.evaluate().invoke(element, fun.expressions.Event(e)) }
tap[type][name](element, handler, event)
}))
}
}
</script>
// TODO inject styles
// .tap-button {
// -webkit-touch-callout: none;
// -webkit-user-select: none; /* Disable selection/Copy of UIWebView */
// -webkit-touch-callout: none;
// -webkit-user-select: none;
// -khtml-user-select: none;
// -moz-user-select: none;
// -ms-user-select: none;
// user-select: none;
// }
//