Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(690)

Side by Side Diff: lib/components/accordion.dart

Issue 14295009: Fix widget.dart to work with the latest web_ui library. Specifically, query selectors need to use "… (Closed) Base URL: https://github.com/kevmoo/widget.dart.git@master
Patch Set: ptal Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « changelog.md ('k') | lib/components/accordion.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import 'dart:html'; 1 import 'dart:html';
2 import 'package:web_ui/web_ui.dart'; 2 import 'package:web_ui/web_ui.dart';
3 import 'package:widget/effects.dart'; 3 import 'package:widget/effects.dart';
4 import 'package:widget/widget.dart'; 4 import 'package:widget/widget.dart';
5 import 'package:bot/bot.dart'; 5 import 'package:bot/bot.dart';
6 6
7 /** 7 /**
8 * [Accordion] wraps a set of [Collapse] elements and ensures only one is visibl e 8 * [Accordion] wraps a set of [Collapse] elements and ensures only one is visibl e
9 * at a time. 9 * at a time.
10 * 10 *
11 * See [Collapse] for details on how content is interpreted. 11 * See [Collapse] for details on how content is interpreted.
12 */ 12 */
13 class Accordion extends WebComponent { 13 class Accordion extends WebComponent {
14 @protected 14 @protected
15 void created() { 15 void created() {
16 ShowHideComponent.toggleEvent.forTarget(this).listen(_onOpen); 16 ShowHideComponent.toggleEvent.forTarget(this).listen(_onOpen);
17 } 17 }
18 18
19 @protected 19 @protected
20 void inserted() { 20 void inserted() {
21 // collapse all 'collapse' children 21 // collapse all 'collapse' children
22 _getAllCollapseElements() 22 _getAllCollapseElements()
23 .map((Element e) => e.xtag) 23 .map((Element e) => e.xtag)
24 .forEach((ShowHideComponent e) { 24 .forEach((ShowHideComponent e) {
25 e.hide(); 25 e.hide();
26 }); 26 });
27 } 27 }
28 28
29 List<Element> _getAllCollapseElements() => this.queryAll('x-accordion > x-coll apse'); 29 List<Element> _getAllCollapseElements() =>
30 this.queryAll('[is=x-accordion] > [is=x-collapse]');
30 31
31 void _onOpen(Event openEvent) { 32 void _onOpen(Event openEvent) {
32 if(openEvent.target is UnknownElement) { 33 Element target = openEvent.target;
33 final UnknownElement target = openEvent.target; 34 if (target.xtag is ShowHideComponent) {
34 final ShowHideComponent shc = target.xtag as ShowHideComponent; 35 _onShowHideToggle(target.xtag);
35 if(shc != null) {
36 _onShowHideToggle(shc);
37 }
38 } 36 }
39 } 37 }
40 38
41 void _onShowHideToggle(ShowHideComponent shc) { 39 void _onShowHideToggle(ShowHideComponent shc) {
42 if(shc.isShown) { 40 if (shc.isShown) {
43 _getAllCollapseElements() 41 _getAllCollapseElements()
44 .map((Element e) => e.xtag) 42 .map((Element e) => e.xtag)
45 .where((e) => e != shc) 43 .where((e) => e != shc)
46 .forEach((ShowHideComponent e) { 44 .forEach((ShowHideComponent e) {
47 e.hide(); 45 e.hide();
48 }); 46 });
49 } 47 }
50 } 48 }
51 } 49 }
OLDNEW
« no previous file with comments | « changelog.md ('k') | lib/components/accordion.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698