forked from Polymer/old-docs-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs-menu.html
More file actions
102 lines (95 loc) · 5.33 KB
/
docs-menu.html
File metadata and controls
102 lines (95 loc) · 5.33 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<link rel="import" href="../components/polymer/polymer.html">
<link rel="import" href="../components/polymer-ui-menu/polymer-ui-menu.html">
<link rel="import" href="../components/polymer-ui-menu-item/polymer-ui-menu-item.html">
<link rel="import" href="../components/polymer-ui-submenu-item/polymer-ui-submenu-item.html">
<link rel="import" href="../components/polymer-ui-nav-arrow/polymer-ui-nav-arrow.html">
<polymer-element name="docs-menu" attributes="ajaxify">
<template>
<polymer-ui-menu id="menu" selectedItem="{{item}}" on-click="{{onClick}}">
<polymer-ui-submenu-item id="gettingstarted" label="Getting started">
<polymer-ui-menu-item><a href="/getting-the-code.html">Get the code</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/getting-started.html">Getting started</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/runtime-config.html">Runtime configuration</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-submenu-item label="Elements" class="elements icon">
<polymer-ui-menu-item><a href="/docs/elements/#elements">Polymer elements</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/docs/elements/#ui-elements">Polymer UI elements</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/docs/elements/other.html">Other</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-submenu-item label="Core" class="core icon">
<polymer-ui-menu-item><a href="/polymer.html">API reference</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/docs/polymer/styling.html">Styling reference</a></polymer-ui-menu-item>
<polymer-ui-submenu-item label="Data-binding ▾">
<polymer-ui-menu-item><a href="/docs/polymer/databinding.html">Introduction</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/docs/polymer/expressions.html">Expressions</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/docs/polymer/filters.html">Filters</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-menu-item><a href="/articles/">Articles</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-submenu-item label="Platform" class="foundation icon">
<polymer-ui-menu-item><a href="/platform/custom-elements.html">Custom Elements</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/shadow-dom.html">Shadow DOM</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/html-imports.html">HTML Imports</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/pointer-events.html">Pointer Events</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/web-animations.html">Web Animations</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/template.html">Template Binding</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/platform/node_bind.html">Node.bind()</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-submenu-item label="More information">
<polymer-ui-menu-item><a href="/tooling-strategy.html">Tools & testing</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/compatibility.html">Browser compatibility</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/changelog.html">Releases</a></polymer-ui-menu-item>
<polymer-ui-menu-item><a href="/faq.html">FAQ</a></polymer-ui-menu-item>
</polymer-ui-submenu-item>
<polymer-ui-nav-arrow target="{{item}}" borderColor="rgba(0, 0, 0,0.15)"></polymer-ui-nav-arrow>
</polymer-ui-menu>
</template>
<script>
Polymer('docs-menu', {
applyAuthorStyles: true,
ajaxify: false,
ready: function() {
// TODO: Remove when Shadow DOM polyfill is fixed.
// https://github.com/Polymer/ShadowDOM/issues/255
this.offsetHeight;
// Allow user-defined styles to override polymer-ui-submenu-item's.
[].forEach.call(this.$.menu.children, function(el, i) {
if (el.localName == 'polymer-ui-submenu-item' && el.classList.contains('icon')) {
el.shadowRoot.applyAuthorStyles = true;
}
});
this.highlightItemWithURL(location.pathname);
},
highlightItemWithURL: function(href) {
if (href.match(/^\/articles\//)) {
this.$.menu.selected = 0;
// TODO: brittle if articles changes position in nav.
this.$.gettingstarted.selected = this.$.gettingstarted.items.length - 1;
}
var link = this.querySelector('a[href="' + href + '"]');
if (link) {
var item = link.parentElement;
var submenu = item.parentElement;
submenu.selected = submenu.items.indexOf(item);
if (submenu.parentElement.localName == 'polymer-ui-submenu-item') {
do {
submenu.parentElement.selected = submenu.parentElement.items.indexOf(submenu);
submenu = submenu.parentElement;
} while (submenu && submenu.localName == 'polymer-ui-submenu-item');
} else {
this.$.menu.selected = this.$.menu.items.indexOf(submenu);
}
} else {
this.$.menu.selected = 0;
}
},
onClick: function(e, detail, sender) {
if (e.target.localName == 'a' && this.ajaxify) {
this.fire('click', {link: e.target});
e.preventDefault();
e.stopPropagation();
}
}
});
</script>
</polymer-element>