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

Side by Side Diff: samples/survey/web/elements/selection/selection_element.dart

Issue 27618002: package:observe fix various api issues (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
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 survey.web.selection; 5 library survey.web.selection;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 8
9 import 'package:polymer/polymer.dart'; 9 import 'package:polymer/polymer.dart';
10 10
11 /** 11 /**
12 * The SelectionElement view. A selection element can be used as a substitute 12 * The SelectionElement view. A selection element can be used as a substitute
13 * for radios and checkboxes. When passed with a [multi] set to true, this 13 * for radios and checkboxes. When passed with a [multi] set to true, this
14 * element permits the user to select 0 or more options, otherwise it permits 14 * element permits the user to select 0 or more options, otherwise it permits
15 * the user to select 0 or 1 option. 15 * the user to select 0 or 1 option.
16 */ 16 */
17 @CustomTag('selection-element') 17 @CustomTag('selection-element')
18 class SelectionElement extends PolymerElement with ObservableMixin { 18 class SelectionElement extends PolymerElement with Observable {
19 bool get applyAuthorStyles => true; 19 bool get applyAuthorStyles => true;
20 20
21 @observable List<String> values = toObservable([]); 21 @observable List<String> values = toObservable([]);
22 @observable List<int> selectedIndices = toObservable([]); 22 @observable List<int> selectedIndices = toObservable([]);
23 @observable bool multi = false; 23 @observable bool multi = false;
24 24
25 inserted() { 25 inserted() {
26 super.inserted(); 26 super.inserted();
27 var root = getShadowRoot('selection-element'); 27 var root = getShadowRoot('selection-element');
28 var items = root.queryAll('li'); 28 var items = root.queryAll('li');
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
62 62
63 dispatchSelectionResults() { 63 dispatchSelectionResults() {
64 List<String> results = []; 64 List<String> results = [];
65 for (var index in selectedIndices) { 65 for (var index in selectedIndices) {
66 results.add(values[index]); 66 results.add(values[index]);
67 } 67 }
68 dispatchEvent(new CustomEvent('selectionmade', detail: results)); 68 dispatchEvent(new CustomEvent('selectionmade', detail: results));
69 } 69 }
70 } 70 }
OLDNEW
« no previous file with comments | « samples/survey/web/elements/question/question_element.dart ('k') | samples/survey/web/elements/survey/survey_element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698