-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmithril.html
76 lines (73 loc) · 3.11 KB
/
mithril.html
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<html>
<head>
<script type='text/javascript' src='http://code.jquery.com/jquery-3.1.1.min.js'></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/mithril/0.2.5/mithril.min.js"></script>
<link href="http://www.opentip.org/js/build/build.css?v=2" media="all" rel="stylesheet" type="text/css">
<link href="https://raw.github.com/enyo/opentip/master/css/opentip.css" media="all" rel="stylesheet" type="text/css">
<script type="text/javascript" src="opentip.js"></script>
<style>
.ot-hidden{
display: none;
}
</style>
<script type="text/javascript" src="adapter-jquery.js"></script>
</head>
<body>
<div id="example"></div>
<script>
var Demo = {
//controller
controller: function() {
return [
{
title: 'Google',
url: 'google.com',
},
{
title: 'Microsoft',
url: '',
},
{
title: 'Apple',
url: 'apple.com',
},
];
},
//view
view: function(pages) {
return m("ul", [
pages.map(function(page, i) {
return m('li', {style: {overflow: 'hidden'}},
(function(link){
if (! page.url) {
return m('span', { style: { float: 'left', background: 'green', border: '1px solid red' } }, m('span', link.attrs, link.children));
}
return link;
}(m("a",
{
config: function(element, alreadyInit){
if( ! alreadyInit && page.url ){
$(element).opentip(page.url, {hideDelay: 1, fixed: true})
}
},
style: {display: 'inline-block', margin: '5px', background: 'yellow'} ,
href: page.url
},
page.title)))
);
}),
m('li',
m("button", {
onclick: function() {
pages.push(pages.shift());
}
}, "Rotate links")
)
]);
}
};
//initialize
m.mount(document.getElementById("example"), Demo);
</script>
</body>
</html>