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

Side by Side Diff: client/fling/dist/runtime/apps/adminz/adminz.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/dom/scripts/dartgenerator.py ('k') | client/samples/spirodraw/ColorPicker.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 typedef void XhrCallback(XMLHttpRequest xhr); 5 typedef void XhrCallback(XMLHttpRequest xhr);
6 6
7 class Xhr { 7 class Xhr {
8 static void post(Window window, String url, String data, String contentType, 8 static void post(Window window, String url, String data, String contentType,
9 XhrCallback onSuccess, XhrCallback onFailure) { 9 XhrCallback onSuccess, XhrCallback onFailure) {
10 _request(window, 'POST', url, data, contentType, onSuccess, onFailure); 10 _request(window, 'POST', url, data, contentType, onSuccess, onFailure);
11 } 11 }
12 12
13 static void _request(Window window, String method, String url, String data, 13 static void _request(Window window, String method, String url, String data,
14 String contentType, XhrCallback onSuccess, XhrCallback onFailure) { 14 String contentType, XhrCallback onSuccess, XhrCallback onFailure) {
15 // TODO(knorton): Catch exceptions. 15 // TODO(knorton): Catch exceptions.
16 final xhr = new XMLHttpRequest(); 16 final xhr = new XMLHttpRequest();
17 xhr.onreadystatechange = () { 17 final onReadyStateChange = () {
18 if (xhr.readyState != 4) 18 if (xhr.readyState != 4)
19 return; 19 return;
20 20
21 xhr.onreadystatechange = null; 21 xhr.removeEventListener('readystatechange', onReadyStateChange);
22 if (xhr.status == 200) { 22 if (xhr.status == 200) {
23 if (onSuccess != null) 23 if (onSuccess != null)
24 onSuccess(xhr); 24 onSuccess(xhr);
25 } else { 25 } else {
26 if (onFailure != null) 26 if (onFailure != null)
27 onFailure(xhr); 27 onFailure(xhr);
28 } 28 }
29 }; 29 };
30 xhr.addEventListener('readystatechange', onReadyStateChange, true);
30 xhr.open(method, url, true); 31 xhr.open(method, url, true);
31 if (contentType == null) { 32 if (contentType == null) {
32 xhr.setRequestHeader('Content-Type', contentType); 33 xhr.setRequestHeader('Content-Type', contentType);
33 } 34 }
34 // TODO(knorton): This is a problem with dart_dom bindings. A fix will arriv e 35 // TODO(knorton): This is a problem with dart_dom bindings. A fix will arriv e
35 // soon. 36 // soon.
36 // xhr.send(data); 37 // xhr.send(data);
37 xhr.send(null); 38 xhr.send(null);
38 } 39 }
39 } 40 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 return src.substring(0, src.length - name.length); 134 return src.substring(0, src.length - name.length);
134 } 135 }
135 window.console.warn('Adminz was unable find itself in the DOM :-('); 136 window.console.warn('Adminz was unable find itself in the DOM :-(');
136 return null; 137 return null;
137 } 138 }
138 139
139 static void main() { 140 static void main() {
140 Adminz.attach(window, window.document); 141 Adminz.attach(window, window.document);
141 } 142 }
142 } 143 }
OLDNEW
« no previous file with comments | « client/dom/scripts/dartgenerator.py ('k') | client/samples/spirodraw/ColorPicker.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698