Skip to content

Commit e0e3bc0

Browse files
committed
Add starred option to archive and news page
1 parent 79490ed commit e0e3bc0

3 files changed

Lines changed: 25 additions & 2 deletions

File tree

app/public/css/styles.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ li.story.open .story-preview {
179179
margin-right: 25px;
180180
}
181181

182+
.story-starred {
183+
display: inline-block;
184+
cursor: pointer;
185+
-webkit-touch-callout: none;
186+
-webkit-user-select: none;
187+
-khtml-user-select: none;
188+
-moz-user-select: none;
189+
-ms-user-select: none;
190+
user-select: none;
191+
margin-right: 25px;
192+
}
193+
182194
.story-body {
183195
margin-left: 20px;
184196
margin-right: 20px;

app/public/js/app.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ var Story = Backbone.Model.extend({
5353
} else {
5454
this.set("is_starred", true);
5555
}
56+
57+
if (this.shouldSave()) this.save();
5658
},
5759

5860
close: function() {
@@ -92,6 +94,7 @@ var StoryView = Backbone.View.extend({
9294
this.listenTo(this.model, 'change:open', this.itemOpened);
9395
this.listenTo(this.model, 'change:is_read', this.itemRead);
9496
this.listenTo(this.model, 'change:keep_unread', this.itemKeepUnread);
97+
this.listenTo(this.model, 'change:is_starred', this.itemStarred);
9598
},
9699

97100
render: function() {
@@ -119,11 +122,16 @@ var StoryView = Backbone.View.extend({
119122
if (!this.$el.visible()) window.scrollTo(0, this.$el.offset().top);
120123
},
121124

122-
itemKeepUnread: function(){
125+
itemKeepUnread: function() {
123126
var icon = this.model.get("keep_unread") ? "icon-check" : "icon-check-empty";
124127
this.$(".story-keep-unread > i").attr("class", icon);
125128
},
126129

130+
itemStarred: function() {
131+
var icon = this.model.get("is_starred") ? "icon-star" : "icon-star-empty";
132+
this.$(".story-starred > i").attr("class", icon);
133+
},
134+
127135
storyClicked: function() {
128136
this.model.toggle();
129137
window.scrollTo(0, this.$el.offset().top);

app/views/js/templates/_story.js.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
<div class="story-keep-unread">
3333
<i class="icon-check{{ if(!keep_unread) { }}-empty{{ } }}"></i> <%= t('stories.keep_unread') %>
3434
</div>
35+
<div class="story-starred">
36+
<i class="icon-star{{ if(!is_starred) { }}-empty{{ } }}"></i>
37+
</div>
3538
<a class="story-permalink" href="{{= permalink }}">
3639
<i class="icon-external-link"></i>
3740
</a>
3841
</div>
3942
</div>
4043
</div>
41-
</script>
44+
</script>

0 commit comments

Comments
 (0)