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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 } | 228 } |
229 } | 229 } |
230 | 230 |
231 /** | 231 /** |
232 * Called when the user chooses a section on the SliderMenu. Hides | 232 * Called when the user chooses a section on the SliderMenu. Hides |
233 * all views except the one they want to see. | 233 * all views except the one they want to see. |
234 */ | 234 */ |
235 void _onSectionSelected(String sectionTitle) { | 235 void _onSectionSelected(String sectionTitle) { |
236 final section = swarm.sections.findSection(sectionTitle); | 236 final section = swarm.sections.findSection(sectionTitle); |
237 // Find the view for this section. | 237 // Find the view for this section. |
238 for (final view in sections.childViews) { | 238 for (SectionView view in sections.childViews) { |
239 if (view.section == section) { | 239 if (view.section == section) { |
240 // Have the conveyor show it. | 240 // Have the conveyor show it. |
241 sections.selectView(view); | 241 sections.selectView(view); |
242 break; | 242 break; |
243 } | 243 } |
244 } | 244 } |
245 } | 245 } |
246 | 246 |
247 /** | 247 /** |
248 * Create SectionViews for each Section in the app and add them to the | 248 * Create SectionViews for each Section in the app and add them to the |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 if(dataView != null) { | 803 if(dataView != null) { |
804 dataView.itemsView.showView(selArticle); | 804 dataView.itemsView.showView(selArticle); |
805 } | 805 } |
806 } | 806 } |
807 } | 807 } |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 String getDataUriForImage(final img) { | 811 String getDataUriForImage(final img) { |
812 // TODO(hiltonc,jimhug) eval perf of this vs. reusing one canvas element | 812 // TODO(hiltonc,jimhug) eval perf of this vs. reusing one canvas element |
813 final canvas = new Element.html( | 813 final CanvasElement canvas = new CanvasElement( |
814 '<canvas width="${img.width}" height="${img.height}"></canvas>'); | 814 height: img.height, width: img.width); |
815 | 815 |
816 final ctx = canvas.getContext("2d"); | 816 final CanvasRenderingContext2D ctx = canvas.getContext("2d"); |
817 ctx.drawImage(img, 0, 0, img.width, img.height); | 817 ctx.drawImage(img, 0, 0, img.width, img.height); |
818 | 818 |
819 return canvas.toDataURL("image/png"); | 819 return canvas.toDataURL("image/png"); |
820 } | 820 } |
821 | 821 |
822 /** | 822 /** |
823 * Update this view's selected appearance based on the currently selected | 823 * Update this view's selected appearance based on the currently selected |
824 * Article. | 824 * Article. |
825 */ | 825 */ |
826 void _refreshSelected(curItem) { | 826 void _refreshSelected(curItem) { |
(...skipping 28 matching lines...) Expand all Loading... |
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 |
862 // Modify all links to open in new windows.... | 862 // Modify all links to open in new windows.... |
863 // TODO(jacobr): would it be better to add an event listener on click that | 863 // TODO(jacobr): would it be better to add an event listener on click that |
864 // intercepts these instead? | 864 // intercepts these instead? |
865 for (final anchor in storyContent.queryAll('a')) { | 865 for (AnchorElement anchor in storyContent.queryAll('a')) { |
866 anchor.target = '_blank'; | 866 anchor.target = '_blank'; |
867 } | 867 } |
868 | 868 |
869 final date = DateUtils.toRecentTimeString(item.date); | 869 final date = DateUtils.toRecentTimeString(item.date); |
870 final container = new Element.html(''' | 870 final container = new Element.html(''' |
871 <div class="story-view"> | 871 <div class="story-view"> |
872 <div class="story-text-view"> | 872 <div class="story-text-view"> |
873 <div class="story-header"> | 873 <div class="story-header"> |
874 <a class="story-title" href="${item.srcUrl}" target="_blank"> | 874 <a class="story-title" href="${item.srcUrl}" target="_blank"> |
875 ${item.title}</a> | 875 ${item.title}</a> |
(...skipping 90 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 |