OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #import('dart:html'); | 5 #import('dart:html'); |
6 #import('dart:math', prefix: 'Math'); | 6 #import('dart:math', prefix: 'Math'); |
7 #source('tape.dart'); | 7 #source('tape.dart'); |
8 #source('settings.dart'); | 8 #source('settings.dart'); |
9 #source('calcui.dart'); | 9 #source('calcui.dart'); |
10 | 10 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 document.on.keyUp.add((e) { | 72 document.on.keyUp.add((e) { |
73 processKeyEvent(e); | 73 processKeyEvent(e); |
74 }); | 74 }); |
75 | 75 |
76 document.on.click.add((MouseEvent e) { | 76 document.on.click.add((MouseEvent e) { |
77 bool wasOpened = mySettings.isOpen; | 77 bool wasOpened = mySettings.isOpen; |
78 | 78 |
79 // If settings dialog is open close it. | 79 // If settings dialog is open close it. |
80 mySettings.close(e); | 80 mySettings.close(e); |
81 | 81 |
82 renderPad(document.body.elements.last()); | 82 renderPad(document.body.elements.last); |
83 if (wasOpened) { | 83 if (wasOpened) { |
84 removePadEvents(); | 84 removePadEvents(); |
85 addPadEvents(); | 85 addPadEvents(); |
86 } | 86 } |
87 }); | 87 }); |
88 } | 88 } |
89 | 89 |
90 void addPadEvents() { | 90 void addPadEvents() { |
91 // Hook-up number key events: | 91 // Hook-up number key events: |
92 padUI.keyZero.on.click.add((MouseEvent e) { doCalc(48); }); | 92 padUI.keyZero.on.click.add((MouseEvent e) { doCalc(48); }); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 padUI = new ButtonPadUI(); | 147 padUI = new ButtonPadUI(); |
148 update = true; | 148 update = true; |
149 } | 149 } |
150 | 150 |
151 if (update) { | 151 if (update) { |
152 // Update calculator pad. | 152 // Update calculator pad. |
153 | 153 |
154 // Remove previous pad UI | 154 // Remove previous pad UI |
155 if (parentElement.elements.length > 1) { | 155 if (parentElement.elements.length > 1) { |
156 parentElement.elements.last().remove(); | 156 parentElement.elements.last.remove(); |
157 } | 157 } |
158 | 158 |
159 // Add new pad UI. | 159 // Add new pad UI. |
160 parentElement.elements.add(padUI.root); | 160 parentElement.elements.add(padUI.root); |
161 } | 161 } |
162 } | 162 } |
163 | 163 |
164 /** | 164 /** |
165 * Controls the logic of how to respond to keypresses and then update the | 165 * Controls the logic of how to respond to keypresses and then update the |
166 * UI accordingly. | 166 * UI accordingly. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 renderPad(element); | 375 renderPad(element); |
376 | 376 |
377 // Render the UI. | 377 // Render the UI. |
378 document.body.elements.add(element); | 378 document.body.elements.add(element); |
379 | 379 |
380 currentRegister = ""; | 380 currentRegister = ""; |
381 total = 0.0; | 381 total = 0.0; |
382 | 382 |
383 setupEvents(); | 383 setupEvents(); |
384 } | 384 } |
OLD | NEW |