| 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 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 @DocsEditable() | 7 @DocsEditable() |
| 8 $if DART2JS | 8 $if DART2JS |
| 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { | 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { |
| 10 $else | 10 $else |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 } | 285 } |
| 286 | 286 |
| 287 $if DART2JS | 287 $if DART2JS |
| 288 int get scrollX => JS('bool', '("scrollX" in #)', this) ? JS('int', | 288 int get scrollX => JS('bool', '("scrollX" in #)', this) ? JS('int', |
| 289 '#.scrollX', this) : document.documentElement.scrollLeft; | 289 '#.scrollX', this) : document.documentElement.scrollLeft; |
| 290 int get scrollY => JS('bool', '("scrollY" in #)', this) ? JS('int', | 290 int get scrollY => JS('bool', '("scrollY" in #)', this) ? JS('int', |
| 291 '#.scrollY', this) : document.documentElement.scrollTop; | 291 '#.scrollY', this) : document.documentElement.scrollTop; |
| 292 $endif | 292 $endif |
| 293 } | 293 } |
| 294 | 294 |
| 295 $if DART2JS |
| 295 class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent { | 296 class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent { |
| 296 String _returnValue; | 297 String _returnValue; |
| 297 | 298 |
| 298 _BeforeUnloadEvent(Event base): super(base); | 299 _BeforeUnloadEvent(Event base): super(base); |
| 299 | 300 |
| 300 String get returnValue => _returnValue; | 301 String get returnValue => _returnValue; |
| 301 | 302 |
| 302 void set returnValue(String value) { | 303 void set returnValue(String value) { |
| 303 _returnValue = value; | 304 _returnValue = value; |
| 304 $if DART2JS | |
| 305 // FF and IE use the value as the return value, Chrome will return this from | 305 // FF and IE use the value as the return value, Chrome will return this from |
| 306 // the event callback function. | 306 // the event callback function. |
| 307 if (JS('bool', '("returnValue" in #)', wrapped)) { | 307 if (JS('bool', '("returnValue" in #)', wrapped)) { |
| 308 JS('void', '#.returnValue = #', wrapped, value); | 308 JS('void', '#.returnValue = #', wrapped, value); |
| 309 } | 309 } |
| 310 $endif | |
| 311 } | 310 } |
| 312 } | 311 } |
| 312 $endif |
| 313 | 313 |
| 314 class _BeforeUnloadEventStreamProvider implements | 314 class _BeforeUnloadEventStreamProvider implements |
| 315 EventStreamProvider<BeforeUnloadEvent> { | 315 EventStreamProvider<BeforeUnloadEvent> { |
| 316 final String _eventType; | 316 final String _eventType; |
| 317 | 317 |
| 318 const _BeforeUnloadEventStreamProvider(this._eventType); | 318 const _BeforeUnloadEventStreamProvider(this._eventType); |
| 319 | 319 |
| 320 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { | 320 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { |
| 321 var stream = new _EventStream(e, _eventType, useCapture); |
| 322 $if DART2JS |
| 321 var controller = new StreamController(sync: true); | 323 var controller = new StreamController(sync: true); |
| 322 var stream = new _EventStream(e, _eventType, useCapture); | 324 |
| 323 stream.listen((event) { | 325 stream.listen((event) { |
| 324 var wrapped = new _BeforeUnloadEvent(event); | 326 var wrapped = new _BeforeUnloadEvent(event); |
| 325 controller.add(wrapped); | 327 controller.add(wrapped); |
| 326 return wrapped.returnValue; | 328 return wrapped.returnValue; |
| 327 }); | 329 }); |
| 328 | 330 |
| 329 return controller.stream; | 331 return controller.stream; |
| 332 $else |
| 333 return stream; |
| 334 $endif |
| 330 } | 335 } |
| 331 | 336 |
| 332 String getEventType(EventTarget target) { | 337 String getEventType(EventTarget target) { |
| 333 return _eventType; | 338 return _eventType; |
| 334 } | 339 } |
| 335 } | 340 } |
| OLD | NEW |