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 // TODO(jacobr): there is a lot of dead code in this class. Checking is as is | 5 // TODO(jacobr): there is a lot of dead code in this class. Checking is as is |
6 // and then doing a large pass to remove functionality that doesn't make sense | 6 // and then doing a large pass to remove functionality that doesn't make sense |
7 // given the UI layout. | 7 // given the UI layout. |
8 | 8 |
9 /** | 9 /** |
10 * Front page of Swarm. | 10 * Front page of Swarm. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 topView.addChild(sliderMenu); | 78 topView.addChild(sliderMenu); |
79 addChild(topView); | 79 addChild(topView); |
80 | 80 |
81 bottomView = new CompositeView('bottom-view', false, false, false); | 81 bottomView = new CompositeView('bottom-view', false, false, false); |
82 addChild(bottomView); | 82 addChild(bottomView); |
83 | 83 |
84 sections = new ConveyorView(); | 84 sections = new ConveyorView(); |
85 sections.viewSelected = _onSectionTransitionEnded; | 85 sections.viewSelected = _onSectionTransitionEnded; |
86 } | 86 } |
87 | 87 |
88 SectionView get currentSection() { | 88 SectionView get currentSection { |
89 var view = sections.selectedView; | 89 var view = sections.selectedView; |
90 // TODO(jmesserly): this code works around a bug in the DartC --optimize | 90 // TODO(jmesserly): this code works around a bug in the DartC --optimize |
91 if (view == null) { | 91 if (view == null) { |
92 view = sections.childViews[0]; | 92 view = sections.childViews[0]; |
93 sections.selectView(view); | 93 sections.selectView(view); |
94 } | 94 } |
95 return view; | 95 return view; |
96 } | 96 } |
97 | 97 |
98 void afterRender(Element node) { | 98 void afterRender(Element node) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 /** | 506 /** |
507 * A factory that creates a view for data sources. | 507 * A factory that creates a view for data sources. |
508 */ | 508 */ |
509 class DataSourceViewFactory implements ViewFactory<Feed> { | 509 class DataSourceViewFactory implements ViewFactory<Feed> { |
510 Swarm swarm; | 510 Swarm swarm; |
511 | 511 |
512 DataSourceViewFactory(this.swarm) {} | 512 DataSourceViewFactory(this.swarm) {} |
513 | 513 |
514 View newView(Feed data) => new DataSourceView(data, swarm); | 514 View newView(Feed data) => new DataSourceView(data, swarm); |
515 | 515 |
516 int get width() => ArticleViewLayout.getSingleton().width; | 516 int get width => ArticleViewLayout.getSingleton().width; |
517 int get height() => null; // Width for this view isn't known. | 517 int get height => null; // Width for this view isn't known. |
518 } | 518 } |
519 | 519 |
520 | 520 |
521 /** | 521 /** |
522 * A view for the items from a single data source. | 522 * A view for the items from a single data source. |
523 * Shows a title and a list of items. | 523 * Shows a title and a list of items. |
524 */ | 524 */ |
525 class DataSourceView extends CompositeView { | 525 class DataSourceView extends CompositeView { |
526 // TODO(jacobr): make this value be coupled with the CSS file. | 526 // TODO(jacobr): make this value be coupled with the CSS file. |
527 static const TAB_ONLY_HEIGHT = 34; | 527 static const TAB_ONLY_HEIGHT = 34; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 : super(), | 568 : super(), |
569 onChanged = new EventListeners(); | 569 onChanged = new EventListeners(); |
570 | 570 |
571 Element render() => new Element.tag('button'); | 571 Element render() => new Element.tag('button'); |
572 | 572 |
573 void afterRender(Element node) { | 573 void afterRender(Element node) { |
574 state = states[0]; | 574 state = states[0]; |
575 node.on.click.add((event) { toggle(); }, false); | 575 node.on.click.add((event) { toggle(); }, false); |
576 } | 576 } |
577 | 577 |
578 String get state() { | 578 String get state { |
579 final currentState = node.innerHTML; | 579 final currentState = node.innerHTML; |
580 assert(states.indexOf(currentState, 0) >= 0); | 580 assert(states.indexOf(currentState, 0) >= 0); |
581 return currentState; | 581 return currentState; |
582 } | 582 } |
583 | 583 |
584 void set state(String state) { | 584 void set state(String state) { |
585 assert(states.indexOf(state, 0) >= 0); | 585 assert(states.indexOf(state, 0) >= 0); |
586 node.innerHTML = state; | 586 node.innerHTML = state; |
587 onChanged.fire(null); | 587 onChanged.fire(null); |
588 } | 588 } |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 * in-place as opposed to as an embedded web-page. | 841 * in-place as opposed to as an embedded web-page. |
842 */ | 842 */ |
843 class StoryContentView extends View { | 843 class StoryContentView extends View { |
844 final Swarm swarm; | 844 final Swarm swarm; |
845 final Article item; | 845 final Article item; |
846 | 846 |
847 View _pagedStory; | 847 View _pagedStory; |
848 | 848 |
849 StoryContentView(this.swarm, this.item) : super(); | 849 StoryContentView(this.swarm, this.item) : super(); |
850 | 850 |
851 get childViews() => [_pagedStory]; | 851 get childViews => [_pagedStory]; |
852 | 852 |
853 Element render() { | 853 Element render() { |
854 final storyContent = new Element.html( | 854 final storyContent = new Element.html( |
855 '<div class="story-content">${item.htmlBody}</div>'); | 855 '<div class="story-content">${item.htmlBody}</div>'); |
856 for (Element element in storyContent.queryAll( | 856 for (Element element in storyContent.queryAll( |
857 "iframe, script, style, object, embed, frameset, frame")) { | 857 "iframe, script, style, object, embed, frameset, frame")) { |
858 element.remove(); | 858 element.remove(); |
859 } | 859 } |
860 _pagedStory = new PagedContentView(new View.fromNode(storyContent)); | 860 _pagedStory = new PagedContentView(new View.fromNode(storyContent)); |
861 | 861 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 * [Feed]. | 966 * [Feed]. |
967 */ | 967 */ |
968 DataSourceView findView(Feed dataSource) { | 968 DataSourceView findView(Feed dataSource) { |
969 return dataSourceView.getSubview(dataSourceView.findIndex(dataSource)); | 969 return dataSourceView.getSubview(dataSourceView.findIndex(dataSource)); |
970 } | 970 } |
971 | 971 |
972 bool inCurrentView(Article article) { | 972 bool inCurrentView(Article article) { |
973 return dataSourceView.findIndex(article.dataSource) != null; | 973 return dataSourceView.findIndex(article.dataSource) != null; |
974 } | 974 } |
975 } | 975 } |
OLD | NEW |