| OLD | NEW |
| (Empty) | |
| 1 // Some things we need. |
| 2 import 'package:polymer/polymer.dart'; |
| 3 import 'dart:html'; |
| 4 import 'dart:async'; |
| 5 import 'count_down.dart'; |
| 6 |
| 7 @CustomTag('x-count-down') |
| 8 class CountDownComponent extends PolymerElement { |
| 9 |
| 10 // Observe errorMsg. |
| 11 // It displays a message for the user. |
| 12 @observable String get errorMsg => __$errorMsg; String __$errorMsg = ''; set e
rrorMsg(String value) { __$errorMsg = notifyPropertyChange(#errorMsg, __$errorMs
g, value); } |
| 13 |
| 14 // These are bound to input elements. |
| 15 @observable String get newMilestoneName => __$newMilestoneName; String __$newM
ilestoneName = "New Year's Day"; set newMilestoneName(String value) { __$newMile
stoneName = notifyPropertyChange(#newMilestoneName, __$newMilestoneName, value);
} |
| 16 @observable String get newMilestoneDate => __$newMilestoneDate; String __$newM
ilestoneDate = '2014-01-01'; set newMilestoneDate(String value) { __$newMileston
eDate = notifyPropertyChange(#newMilestoneDate, __$newMilestoneDate, value); } |
| 17 @observable String get newMilestoneTime => __$newMilestoneTime; String __$newM
ilestoneTime = '00:00:00'; set newMilestoneTime(String value) { __$newMilestoneT
ime = notifyPropertyChange(#newMilestoneTime, __$newMilestoneTime, value); } |
| 18 |
| 19 @observable MilestoneApp get appObj => __$appObj; MilestoneApp __$appObj = app
Object; set appObj(MilestoneApp value) { __$appObj = notifyPropertyChange(#appOb
j, __$appObj, value); } |
| 20 |
| 21 /* |
| 22 * Click handlers. |
| 23 * NOTE: Minus - button handler is in xmilestone web component. |
| 24 */ |
| 25 // Plus + button click handler. |
| 26 void addMilestone(Event e, var detail, Node target) { |
| 27 String str = newMilestoneDate + ' ' + newMilestoneTime; |
| 28 DateTime occursOn = DateTime.parse(str); |
| 29 |
| 30 appObject.addMilestone(newMilestoneName, occursOn); |
| 31 } |
| 32 |
| 33 // Clear button click handler. |
| 34 void clear(Event e, var detail, Node target) { |
| 35 errorMsg = ''; |
| 36 appObject.clear(); |
| 37 } |
| 38 |
| 39 /* |
| 40 * Life-cycle bizness |
| 41 */ |
| 42 void inserted() { |
| 43 appObject.start() |
| 44 .catchError((e) { |
| 45 ($['addbutton'] as ButtonElement).disabled = true; |
| 46 ($['clearbutton'] as ButtonElement).disabled = true; |
| 47 |
| 48 errorMsg = e.toString(); |
| 49 }); |
| 50 } |
| 51 |
| 52 void removed() { |
| 53 appObject.stop(); |
| 54 } |
| 55 } // end class |
| OLD | NEW |