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

Side by Side Diff: samples/third_party/todomvc/web/router_options.dart

Issue 26051002: Updating Polymer to derive from custom elements. (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 todomvc.web.router_options; 5 library todomvc.web.router_options;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:polymer/polymer.dart'; 8 import 'package:polymer/polymer.dart';
9 9
10 /** 10 /**
11 * Given a set of child links to this page, this will add the "selected" CSS 11 * Given a set of child links to this page, this will add the "selected" CSS
12 * class to the link that matches window.location.hash. 12 * class to the link that matches window.location.hash.
13 * 13 *
14 * For example, if the current window.location.hash is "#/completed" and we 14 * For example, if the current window.location.hash is "#/completed" and we
15 * have a tag like `<a href="#/completed">` it will get the class 15 * have a tag like `<a href="#/completed">` it will get the class
16 * `class="selected"`, and other links will have that CSS class removed. 16 * `class="selected"`, and other links will have that CSS class removed.
17 */ 17 */
18 @CustomTag('router-options') 18 @CustomTag('router-options')
19 class RouterOptions extends PolymerElement { 19 class RouterOptions extends PolymerElement {
20 20
21 factory RouterOptions() => new Element.tag('router-options');
22
23 RouterOptions.created() : super.created();
24
21 bool get applyAuthorStyles => true; 25 bool get applyAuthorStyles => true;
22 var _sub; 26 var _sub;
23 27
24 void inserted() { 28 void enteredView() {
25 super.inserted(); 29 super.enteredView();
26 30
27 var anchors = this.queryAll('a'); 31 var anchors = this.queryAll('a');
28 32
29 _updateHash(records) { 33 _updateHash(records) {
30 var hash = window.location.hash; 34 var hash = window.location.hash;
31 if (hash == '') hash = '#/'; 35 if (hash == '') hash = '#/';
32 for (var a in anchors) { 36 for (var a in anchors) {
33 if (a.hash == hash) { 37 if (a.hash == hash) {
34 a.classes.add('selected'); 38 a.classes.add('selected');
35 } else { 39 } else {
36 a.classes.remove('selected'); 40 a.classes.remove('selected');
37 } 41 }
38 } 42 }
39 } 43 }
40 44
41 _updateHash(null); 45 _updateHash(null);
42 _sub = windowLocation.changes.listen(_updateHash); 46 _sub = windowLocation.changes.listen(_updateHash);
43 } 47 }
44 48
45 void removed() { 49 void leftView() {
46 _sub.cancel(); 50 _sub.cancel();
47 super.removed(); 51 super.leftView();
48 } 52 }
49 } 53 }
OLDNEW
« no previous file with comments | « samples/third_party/todomvc/web/editable_label.dart ('k') | samples/third_party/todomvc/web/todo_row.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698