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

Side by Side Diff: client/samples/spirodraw/Spirodraw.dart

Issue 8637013: Remove support for attribute event listeners. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « client/samples/spirodraw/ColorPicker.dart ('k') | client/samples/sunflower/Sunflower.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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('spirodraw'); 5 #library('spirodraw');
6 6
7 #import('dart:dom'); 7 #import('dart:dom');
8 #source("ColorPicker.dart"); 8 #source("ColorPicker.dart");
9 #resource("spirodraw.css"); 9 #resource("spirodraw.css");
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 penRadiusSlider = doc.getElementById("pen_radius"); 49 penRadiusSlider = doc.getElementById("pen_radius");
50 penWidthSlider = doc.getElementById("pen_width"); 50 penWidthSlider = doc.getElementById("pen_width");
51 speedSlider = doc.getElementById("speed"); 51 speedSlider = doc.getElementById("speed");
52 numTurns = doc.getElementById("num_turns"); 52 numTurns = doc.getElementById("num_turns");
53 mainDiv = doc.getElementById("main"); 53 mainDiv = doc.getElementById("main");
54 frontCanvas = doc.getElementById("canvas"); 54 frontCanvas = doc.getElementById("canvas");
55 front = frontCanvas.getContext("2d"); 55 front = frontCanvas.getContext("2d");
56 backCanvas = doc.createElement("canvas"); 56 backCanvas = doc.createElement("canvas");
57 back = backCanvas.getContext("2d"); 57 back = backCanvas.getContext("2d");
58 paletteElement = doc.getElementById("palette"); 58 paletteElement = doc.getElementById("palette");
59 window.onresize = (EventListener) { onResize(); }; 59 window.addEventListener('resize', (Event) => onResize(), true);
60 initControlPanel(); 60 initControlPanel();
61 } 61 }
62 62
63 void go() { 63 void go() {
64 onResize(); 64 onResize();
65 } 65 }
66 66
67 void onResize() { 67 void onResize() {
68 height = window.innerHeight; 68 height = window.innerHeight;
69 width = window.innerWidth - 270; 69 width = window.innerWidth - 270;
70 yc = height~/2; 70 yc = height~/2;
71 xc = width~/2; 71 xc = width~/2;
72 frontCanvas.height = height; 72 frontCanvas.height = height;
73 frontCanvas.width = width; 73 frontCanvas.width = width;
74 backCanvas.height = height; 74 backCanvas.height = height;
75 backCanvas.width = width; 75 backCanvas.width = width;
76 clear(); 76 clear();
77 } 77 }
78 78
79 void initControlPanel() { 79 void initControlPanel() {
80 inOrOut.onchange = (EventListener) { refresh(); }; 80 inOrOut.addEventListener('change', (Event) => refresh(), true);
81 fixedRadiusSlider.onchange = (EventListener) { refresh(); }; 81 fixedRadiusSlider.addEventListener('change', (Event) => refresh(), true);
82 wheelRadiusSlider.onchange = (EventListener) { refresh(); }; 82 wheelRadiusSlider.addEventListener('change', (Event) => refresh(), true);
83 speedSlider.onchange = (EventListener) { onSpeedChange(); }; 83 speedSlider.addEventListener('change', (Event) => onSpeedChange(), true);
84 penRadiusSlider.onchange = (EventListener) { refresh(); }; 84 penRadiusSlider.addEventListener('change', (Event) => refresh(), true);
85 penWidthSlider.onchange = (EventListener) { onPenWidthChange(); }; 85 penWidthSlider.addEventListener('change', (Event) => onPenWidthChange(), tru e);
86 colorPicker = new ColorPicker(paletteElement); 86 colorPicker = new ColorPicker(paletteElement);
87 colorPicker.addListener((String color) { onColorChange(color); }); 87 colorPicker.addListener((String color) => onColorChange(color));
88 doc.getElementById("start").onclick = (EventListener) { start(); }; 88 doc.getElementById("start").addEventListener('click', (EventListener) => sta rt(), true);
89 doc.getElementById("stop").onclick = (EventListener) { stop(); }; 89 doc.getElementById("stop").addEventListener('click', (EventListener) => stop (), true);
90 doc.getElementById("clear").onclick = (EventListener) { clear(); }; 90 doc.getElementById("clear").addEventListener('click', (EventListener) => cle ar(), true);
91 doc.getElementById("lucky").onclick = (EventListener) { lucky(); }; 91 doc.getElementById("lucky").addEventListener('click', (EventListener) => luc ky(), true);
92 } 92 }
93 93
94 void onColorChange(String color) { 94 void onColorChange(String color) {
95 penColor = color; 95 penColor = color;
96 drawFrame(rad); 96 drawFrame(rad);
97 } 97 }
98 98
99 void onSpeedChange() { 99 void onSpeedChange() {
100 speed = speedSlider.valueAsNumber; 100 speed = speedSlider.valueAsNumber;
101 stepSize = calcStepSize(); 101 stepSize = calcStepSize();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 300
301 int gcf(int n, int d) { 301 int gcf(int n, int d) {
302 if (n==d) 302 if (n==d)
303 return n; 303 return n;
304 int max = Math.max(n, d); 304 int max = Math.max(n, d);
305 for (int i = max ~/ 2; i > 1; i--) 305 for (int i = max ~/ 2; i > 1; i--)
306 if ((n % i == 0) && (d % i == 0)) 306 if ((n % i == 0) && (d % i == 0))
307 return i; 307 return i;
308 return 1; 308 return 1;
309 } 309 }
OLDNEW
« no previous file with comments | « client/samples/spirodraw/ColorPicker.dart ('k') | client/samples/sunflower/Sunflower.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698