OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library category; | 5 library category; |
6 | 6 |
7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
8 import 'package:dartdoc_viewer/item.dart'; | 8 import 'package:dartdoc_viewer/item.dart'; |
9 import 'app.dart'; | 9 import 'app.dart'; |
10 import 'member.dart'; | 10 import 'member.dart'; |
11 import 'dart:html'; | 11 import 'dart:html'; |
12 | 12 |
13 /** | 13 /** |
14 * An HTML representation of a Category. | 14 * An HTML representation of a Category. |
15 * | 15 * |
16 * Used as a placeholder for an CategoryItem object. | 16 * Used as a placeholder for an CategoryItem object. |
17 */ | 17 */ |
18 @CustomTag("dartdoc-category") | 18 @CustomTag("dartdoc-category") |
19 class CategoryElement extends DartdocElement { | 19 class CategoryElement extends DartdocElement { |
20 | 20 |
21 CategoryElement.created() : super.created() { | 21 CategoryElement.created() : super.created() { |
22 new PathObserver(viewer, "isDesktop").changes.listen((changes) { | 22 new PathObserver(viewer, "isDesktop").changes.listen((changes) { |
23 var change = changes.first; | 23 var change = changes.first; |
24 notifyPropertyChange( | 24 notifyPropertyChange( |
25 #accordionStyle, accordionStyleFor(change.oldValue), accordionStyle); | 25 #accordionStyle, accordionStyleFor(change.oldValue), accordionStyle); |
26 notifyPropertyChange(#accordionParent, | 26 notifyPropertyChange(#accordionParent, |
27 accordionParentFor(change.oldValue), accordionParent); | 27 accordionParentFor(change.oldValue), accordionParent); |
28 notifyPropertyChange(#divClass, divClassFor(change.oldValue), divClass); | 28 notifyPropertyChange(#divClass, divClassFor(change.oldValue), divClass); |
29 notifyPropertyChange(#divStyle, divStyleFor(change.oldValue), divStyle); | |
30 }); | 29 }); |
31 new PathObserver(viewer, "isInherited").changes.listen((changes) { | 30 new PathObserver(viewer, "isInherited").changes.listen((changes) { |
32 _flushCache(); | 31 _flushCache(); |
33 addChildren(); | 32 addChildren(); |
34 }); | 33 }); |
35 style.setProperty('display', 'block'); | 34 style.setProperty('display', 'block'); |
36 } | 35 } |
37 | 36 |
38 @observable void addChildren() { | 37 @observable void addChildren() { |
39 if (shadowRoot == null) return; | 38 if (shadowRoot == null) return; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 _everythingElseCache = null; | 114 _everythingElseCache = null; |
116 } | 115 } |
117 | 116 |
118 @observable get accordionStyle => accordionStyleFor(viewer.isDesktop); | 117 @observable get accordionStyle => accordionStyleFor(viewer.isDesktop); |
119 accordionStyleFor(isDesktop) => isDesktop ? '' : 'collapsed'; | 118 accordionStyleFor(isDesktop) => isDesktop ? '' : 'collapsed'; |
120 @observable get accordionParent => accordionParentFor(viewer.isDesktop); | 119 @observable get accordionParent => accordionParentFor(viewer.isDesktop); |
121 accordionParentFor(isDesktop) => isDesktop ? '' : '#accordion-grouping'; | 120 accordionParentFor(isDesktop) => isDesktop ? '' : '#accordion-grouping'; |
122 | 121 |
123 @observable get divClass => divClassFor(viewer.isDesktop); | 122 @observable get divClass => divClassFor(viewer.isDesktop); |
124 divClassFor(isDesktop) => isDesktop ? 'collapse in' : 'collapse'; | 123 divClassFor(isDesktop) => isDesktop ? 'collapse in' : 'collapse'; |
125 @observable get divStyle => divStyleFor(viewer.isDesktop); | |
126 divStyleFor(isDesktop) => isDesktop ? 'auto' : '0px'; | |
127 | |
128 | 124 |
129 var validator = new NodeValidatorBuilder() | 125 var validator = new NodeValidatorBuilder() |
130 ..allowHtml5(uriPolicy: new SameProtocolUriPolicy()) | 126 ..allowHtml5(uriPolicy: new SameProtocolUriPolicy()) |
131 ..allowCustomElement("method-panel", attributes: ["item"]) | 127 ..allowCustomElement("method-panel", attributes: ["item"]) |
132 ..allowCustomElement("dartdoc-item", attributes: ["item"]) | 128 ..allowCustomElement("dartdoc-item", attributes: ["item"]) |
133 ..allowCustomElement("dartdoc-variable", attributes: ["item"]) | 129 ..allowCustomElement("dartdoc-variable", attributes: ["item"]) |
134 ..allowCustomElement("dartdoc-category-interior", attributes: ["item"]) | 130 ..allowCustomElement("dartdoc-category-interior", attributes: ["item"]) |
135 ..allowTagExtension("method-panel", "div", attributes: ["item"]); | 131 ..allowTagExtension("method-panel", "div", attributes: ["item"]); |
136 | 132 |
137 hideShow(event, detail, AnchorElement target) { | 133 hideShow(event, detail, AnchorElement target) { |
138 var list = shadowRoot.querySelector(target.attributes["data-target"]); | 134 var list = shadowRoot.querySelector(target.attributes["data-target"]); |
139 if (list.classes.contains("in")) { | 135 if (list.classes.contains("in")) { |
140 list.classes.remove("in"); | 136 list.classes.remove("in"); |
141 list.style.height = '0px'; | 137 list.style.height = '0px'; |
142 } else { | 138 } else { |
143 list.classes.add("in"); | 139 list.classes.add("in"); |
144 list.style.height = 'auto'; | 140 list.style.height = 'auto'; |
145 } | 141 } |
146 } | 142 } |
147 | 143 |
148 @observable get currentLocation => window.location.toString(); | 144 @observable get currentLocation => window.location.toString(); |
149 } | 145 } |
OLD | NEW |