forked from googlearchive/flatiron-director
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflatiron-director.html
38 lines (37 loc) · 1.12 KB
/
flatiron-director.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
<!--
Copyright 2013 The Polymer Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<link rel="import" href="../polymer/polymer.html">
<script src="director/director.min.js"></script>
<polymer-element name="flatiron-director" attributes="route autoHash" hidden>
<script>
(function() {
var private_router;
Polymer('flatiron-director', {
autoHash: false,
ready: function() {
this.router.on(/(.*)/, function(route) {
this.route = route;
}.bind(this));
this.route = this.router.getRoute() ?
this.router.getRoute().join(this.router.delimiter): '';
},
routeChanged: function() {
if (this.autoHash) {
window.location.hash = this.route;
}
this.fire('director-route', this.route);
},
get router() {
if (!private_router) {
private_router = new Router();
private_router.init();
}
return private_router;
}
});
})();
</script>
</polymer-element>