OLD | NEW |
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 part of swarmlib; | 5 part of swarmlib; |
6 | 6 |
7 /** | 7 /** |
8 * A simple news reader in Dart. | 8 * A simple news reader in Dart. |
9 */ | 9 */ |
10 class Swarm extends App { | 10 class Swarm extends App { |
11 /** | 11 /** |
12 * Flag to insure the onLoad isn't called when callback from initializeFromUrl | 12 * Flag to insure the onLoad isn't called when callback from initializeFromUrl |
13 * could occur before the document's onload event. | 13 * could occur before the document's onload event. |
14 */ | 14 */ |
15 bool onLoadFired; | 15 bool onLoadFired; |
16 | 16 |
17 /** Collections of datafeeds to show per page. */ | 17 /** Collections of datafeeds to show per page. */ |
18 Sections sections; | 18 Sections sections; |
19 | 19 |
20 /** The front page of the app. */ | 20 /** The front page of the app. */ |
21 FrontView frontView; | 21 FrontView frontView; |
22 | 22 |
23 /** Observable UI state. */ | 23 /** Observable UI state. */ |
24 SwarmState state; | 24 SwarmState state; |
25 | 25 |
26 Swarm({bool useCannedData : false}) : super(), onLoadFired = false { | 26 Swarm({bool useCannedData: false}) |
| 27 : super(), |
| 28 onLoadFired = false { |
27 Sections.initializeFromUrl(useCannedData, (currSections) { | 29 Sections.initializeFromUrl(useCannedData, (currSections) { |
28 sections = currSections; | 30 sections = currSections; |
29 state = new SwarmState(sections); | 31 state = new SwarmState(sections); |
30 setupApp(); | 32 setupApp(); |
31 }); | 33 }); |
32 // Catch user keypresses and decide whether to use them for the | 34 // Catch user keypresses and decide whether to use them for the |
33 // Streams app or pass them on to the browser. | 35 // Streams app or pass them on to the browser. |
34 document.onKeyUp.listen((e) { | 36 document.onKeyUp.listen((e) { |
35 if (frontView != null) { | 37 if (frontView != null) { |
36 frontView.processKeyEvent(e); | 38 frontView.processKeyEvent(e); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 refresh(); | 82 refresh(); |
81 eraseSplashScreen(); | 83 eraseSplashScreen(); |
82 } | 84 } |
83 } | 85 } |
84 | 86 |
85 void render() { | 87 void render() { |
86 frontView = new FrontView(this); | 88 frontView = new FrontView(this); |
87 frontView.addToDocument(document.body); | 89 frontView.addToDocument(document.body); |
88 } | 90 } |
89 } | 91 } |
OLD | NEW |