forked from Polymer/old-docs-site
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent-docs.html
More file actions
207 lines (194 loc) · 7.85 KB
/
component-docs.html
File metadata and controls
207 lines (194 loc) · 7.85 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../components/polymer/polymer.html">
<link rel="import" href="../components/context-free-parser/context-free-parser.html">
<link rel="import" href="../components/marked-element/marked-element.html">
<!-- <link rel="import" href="../components/highlightjs-element/highlightjs-element.html"> -->
<polymer-element name="component-docs" attributes="elements">
<template>
<context-free-parser url="{{url}}" data="{{data}}" on-data-ready="{{dataReady}}">
</context-free-parser>
<template repeat="{{c in data.classes}}">
<doc-page id="{{c.name}}" name="{{c.name}}" data="{{c}}"
downloadable?="{{ isTopLevelElement(c.name, url) }}"></doc-page>
</template>
</template>
<script>
Polymer('component-docs', {
elementName: null,
url: null,
elements: {},
updateElementFromHash: function(e) {
var elementName = window.location.hash.slice(1);
if (this.elementName !== elementName && this.elements[elementName]) {
this.elementName = elementName;
document.body.classList.add('hide-on-hash'); // Hide on .hide-on-hash elements.
}
},
domReady: function() {
this.updateElementFromHash();
window.addEventListener('hashchange', this.updateElementFromHash.bind(this));
},
detached: function() {
document.body.classList.remove('hide-on-hash');
window.removeEventListener('hashchange', this.updateElementFromHash.bind(this));
},
elementNameChanged: function() {
this.url = '/' + this.elements[this.elementName];
window.location.hash = this.elementName;
},
dataChanged: function() {
if (this.data.classes[0].name === 'Entity') {
this.data.classes[0].name = this.elementName;
}
},
isTopLevelElement: function(name, url) {
return url.indexOf('/components/' + name + '/') == 0;
}
});
</script>
</polymer-element>
<polymer-element name="doc-page" attributes="data downloadable" assetpath="../core-doc-viewer/elements/">
<template>
<link rel="stylesheet" href="../components/highlightjs/styles/default.css">
<link rel="stylesheet" href="../css/elements/doc-page.css">
<div class="main" on-marked-js-highlight="{{prettyPrint}}">
<h1>{{data.name}}</h1>
<template if="{{data.extends}}">
<section class="top">
<h3>Extends: <a href="{{data.extends | collectionPrefix}}-elements.html#{{data.extends}}">{{data.extends}}</a></h3>
</section>
</template>
<template if="{{downloadable}}">
<p>
<component-download-button id="downloadButton"
org="Polymer" component="{{data.name}}"
label="Get {{data.name}}"></component-download-button>
<a class="badge" target="_blank" href="/components/{{data.name}}/demo.html"
on-click="{{recordDemoPageview}}">
<paper-button raised>Demo</paper-button>
</a>
</p>
</template>
<template if="{{data.description}}">
<section class="box top">
<h3>Summary</h3>
<marked-element text="{{data.description}}"></marked-element>
</section>
</template>
<template if="{{data.attributes.length}}">
<section class="box attribute-box">
<h3>Attributes</h3>
<template repeat="{{data.attributes}}">
<div class="details" horizontal layout>
<div class="details-name" flex>
<p><code>{{name}}</code></p>
</div>
<div class="details-info" flex three>
<p layout horizontal center justified>
<code>{{type}}</code><span class="default" hidden?="{{!default}}">default: <code>{{default}}</code></span>
</p>
<marked-element text="{{description}}"></marked-element>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.properties.length}}">
<section class="box property-box">
<h3>Properties</h3>
<template repeat="{{data.properties}}">
<div class="details" horizontal layout>
<div class="details-name" flex>
<p><code>{{name}}</code></p>
</div>
<div class="details-info" flex three>
<p layout horizontal center justified>
<code>{{type}}</code><span class="default" hidden?="{{!default}}">default: <code>{{default}}</code></span>
</p>
<marked-element text="{{description}}"></marked-element>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.events.length}}">
<section class="box event-box">
<h3>Events</h3>
<template repeat="{{data.events}}">
<div class="details" horizontal layout>
<div class="details-name" flex>
<p><code>{{name}}</code></p>
</div>
<div class="details-info" flex three>
<marked-element text="{{description}}"></marked-element>
<template if="{{params.length}}">
<div class="params">
<p>Event details:</p>
<template repeat="{{params}}">
<p><code>{{name}}</code><span> <code>( {{type}} )</code></span></p>
<p><span>{{description}}</span></p>
</template>
</div>
</template>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.methods.length}}">
<section class="box method-box">
<h3>Methods</h3>
<template repeat="{{data.methods}}">
<div class="details" horizontal layout>
<div class="details-name" flex>
<p><code>{{name}}</code></p>
</div>
<div class="details-info" flex three>
<marked-element text="{{description}}"></marked-element>
<template if="{{params.length}}">
<div class="params">
<p>Method parameters:</p>
<template repeat="{{params}}">
<p><code>{{name}}</code><span> <code>( {{type}} )</code></span></p>
<p><span>{{description}}</span></p>
</template>
</div>
</template>
</div>
</div>
</template>
</section>
</template>
</div>
</template>
<script>
(function() {
function encodeHTMLEntities_(htmlStr) {
return htmlStr.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
}
Polymer('doc-page', {
downloadable: false,
recordDemoPageview: function(e, detail, sender) {
window.recordPageview && window.recordPageview(sender.href); // global pollution.
},
prettyPrint: function(e, detail, sender) {
if (window.prettyPrintOne) {
detail.code = window.prettyPrintOne(encodeHTMLEntities_(detail.code));
}
},
collectionPrefix: function(elementName) {
var match = elementName.match(/(\w+)-/);
return match ? match[1] : 'core';
}
});
})();
</script>
</polymer-element>