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 // TODO(jacobr): there is a lot of dead code in this class. Checking is as is | 7 // TODO(jacobr): there is a lot of dead code in this class. Checking is as is |
8 // and then doing a large pass to remove functionality that doesn't make sense | 8 // and then doing a large pass to remove functionality that doesn't make sense |
9 // given the UI layout. | 9 // given the UI layout. |
10 | 10 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 $thumbnail | 727 $thumbnail |
728 <div class="title">$title</div> | 728 <div class="title">$title</div> |
729 <div class="byline">$byline</div> | 729 <div class="byline">$byline</div> |
730 <div class="dateline">$date</div> | 730 <div class="dateline">$date</div> |
731 <div class="snippet">$snippet</div> | 731 <div class="snippet">$snippet</div> |
732 </div>'''); | 732 </div>'''); |
733 | 733 |
734 // Remove the snippet entirely if it's empty. This keeps it from taking up | 734 // Remove the snippet entirely if it's empty. This keeps it from taking up |
735 // space and pushing the padding down. | 735 // space and pushing the padding down. |
736 if ((item.textBody == null) || (item.textBody.trim() == '')) { | 736 if ((item.textBody == null) || (item.textBody.trim() == '')) { |
737 node.query('.snippet').remove(); | 737 node.querySelector('.snippet').remove(); |
738 } | 738 } |
739 | 739 |
740 return node; | 740 return node; |
741 } | 741 } |
742 | 742 |
743 void afterRender(Element node) { | 743 void afterRender(Element node) { |
744 | 744 |
745 // Select this view's item. | 745 // Select this view's item. |
746 addOnClick((e) { | 746 addOnClick((e) { |
747 // Mark the item as read, so it shows as read in other views | 747 // Mark the item as read, so it shows as read in other views |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 | 843 |
844 View _pagedStory; | 844 View _pagedStory; |
845 | 845 |
846 StoryContentView(this.swarm, this.item) : super(); | 846 StoryContentView(this.swarm, this.item) : super(); |
847 | 847 |
848 get childViews => [_pagedStory]; | 848 get childViews => [_pagedStory]; |
849 | 849 |
850 Element render() { | 850 Element render() { |
851 final storyContent = new Element.html( | 851 final storyContent = new Element.html( |
852 '<div class="story-content">${item.htmlBody}</div>'); | 852 '<div class="story-content">${item.htmlBody}</div>'); |
853 for (Element element in storyContent.queryAll( | 853 for (Element element in storyContent.querySelectorAll( |
854 "iframe, script, style, object, embed, frameset, frame")) { | 854 "iframe, script, style, object, embed, frameset, frame")) { |
855 element.remove(); | 855 element.remove(); |
856 } | 856 } |
857 _pagedStory = new PagedContentView(new View.fromNode(storyContent)); | 857 _pagedStory = new PagedContentView(new View.fromNode(storyContent)); |
858 | 858 |
859 // Modify all links to open in new windows.... | 859 // Modify all links to open in new windows.... |
860 // TODO(jacobr): would it be better to add an event listener on click that | 860 // TODO(jacobr): would it be better to add an event listener on click that |
861 // intercepts these instead? | 861 // intercepts these instead? |
862 for (AnchorElement anchor in storyContent.queryAll('a')) { | 862 for (AnchorElement anchor in storyContent.querySelectorAll('a')) { |
863 anchor.target = '_blank'; | 863 anchor.target = '_blank'; |
864 } | 864 } |
865 | 865 |
866 final date = DateUtils.toRecentTimeString(item.date); | 866 final date = DateUtils.toRecentTimeString(item.date); |
867 final container = new Element.html(''' | 867 final container = new Element.html(''' |
868 <div class="story-view"> | 868 <div class="story-view"> |
869 <div class="story-text-view"> | 869 <div class="story-text-view"> |
870 <div class="story-header"> | 870 <div class="story-header"> |
871 <a class="story-title" href="${item.srcUrl}" target="_blank"> | 871 <a class="story-title" href="${item.srcUrl}" target="_blank"> |
872 ${item.title}</a> | 872 ${item.title}</a> |
873 <div class="story-byline"> | 873 <div class="story-byline"> |
874 ${item.author} - ${item.dataSource.title} | 874 ${item.author} - ${item.dataSource.title} |
875 </div> | 875 </div> |
876 <div class="story-dateline">$date</div> | 876 <div class="story-dateline">$date</div> |
877 </div> | 877 </div> |
878 <div class="paged-story"></div> | 878 <div class="paged-story"></div> |
879 <div class="spacer"></div> | 879 <div class="spacer"></div> |
880 </div> | 880 </div> |
881 </div>'''); | 881 </div>'''); |
882 | 882 |
883 container.query('.paged-story').replaceWith(_pagedStory.node); | 883 container.querySelector('.paged-story').replaceWith(_pagedStory.node); |
884 | 884 |
885 return container; | 885 return container; |
886 } | 886 } |
887 } | 887 } |
888 | 888 |
889 class SectionView extends CompositeView { | 889 class SectionView extends CompositeView { |
890 final Section section; | 890 final Section section; |
891 final Swarm swarm; | 891 final Swarm swarm; |
892 final DataSourceViewFactory _viewFactory; | 892 final DataSourceViewFactory _viewFactory; |
893 final View loadingText; | 893 final View loadingText; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 * [Feed]. | 963 * [Feed]. |
964 */ | 964 */ |
965 DataSourceView findView(Feed dataSource) { | 965 DataSourceView findView(Feed dataSource) { |
966 return dataSourceView.getSubview(dataSourceView.findIndex(dataSource)); | 966 return dataSourceView.getSubview(dataSourceView.findIndex(dataSource)); |
967 } | 967 } |
968 | 968 |
969 bool inCurrentView(Article article) { | 969 bool inCurrentView(Article article) { |
970 return dataSourceView.findIndex(article.dataSource) != null; | 970 return dataSourceView.findIndex(article.dataSource) != null; |
971 } | 971 } |
972 } | 972 } |
OLD | NEW |