-
Notifications
You must be signed in to change notification settings - Fork 2
/
nerdclustr-polymer.html
87 lines (63 loc) · 1.75 KB
/
nerdclustr-polymer.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
77
78
79
80
81
// Hackathon would not be complete without
// Demonstrating The Future of the Web
// What is Polymer.js
// - Built ontop of Polymer.js
// - Chrome Dev Tools
// - - Shadow DOM turned on
// - - log="bind,ready"
// HTML Imports
// - View the Network tab, and see that nerdclustr was imported
// 2 Custom Elements - nerdclustr-geo & nerdclustr-map
// Shadow DOM
// Styling Host
// - Show that you can scope styling -->
// Templates
// MDV
// - MDV listen for changes?
// - set up basic pubsub
<!DOCTYPE html>
<html>
<head>
<title>Nerdclustr Polymer</title>
<!-- 1. Shim missing platform features -->
<script src="polymer/polymer.js" log="bind,ready"></script>
<!-- 2. Load nerdclustr component -->
<link rel="import" href="nc-map-module.html">
<link rel="import" href="nc-geo-module.html">
</head>
<body>
<!-- 3. Instantiate the nerdclustr-geo and nerdclustr-map component with its tag. -->
<nerdclustr-geo date="today" lng="1" lat="1"></nerdclustr-geo>
<nerdclustr-map></nerdclustr-map>
</body>
<script>
window.pubsub = (function() {
var callbacks = [];
function publish() {
var event = arguments[0],
args = [].slice.call(arguments, 1),
re = new RegExp("^" + event + "$");
console.log(event);
callbacks.forEach(function(call) {
if(re.test(call.key)) {
call.handler.apply(call.context, args);
} else {
console.log("fail");
}
});
}
function subscribe(key, handler, context) {
context = context || {};
callbacks.push({
key: key,
handler: handler,
context: context
});
}
return {
publish: publish,
subscribe: subscribe
};
})();
</script>
</html>