Working on favorites.
parent
495606035c
commit
b1e856ddd7
|
@ -682,10 +682,9 @@ article.snipt {
|
|||
}
|
||||
&.copy {
|
||||
background-image: url('/static/images/copy-icon.png');
|
||||
|
||||
span.done {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
&.favorite {
|
||||
background-image: url('/static/images/favorite-icon.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,6 +790,14 @@ article.snipt {
|
|||
}
|
||||
}
|
||||
}
|
||||
div.modal {
|
||||
textarea {
|
||||
font: normal 12px/16px $Consolas;
|
||||
height: 200px;
|
||||
margin: 0;
|
||||
width: 520px;
|
||||
}
|
||||
}
|
||||
&.selected {
|
||||
div.container {
|
||||
-webkit-box-shadow: 0 0 20px #85D2DD;
|
||||
|
@ -802,12 +809,17 @@ article.snipt {
|
|||
}
|
||||
}
|
||||
}
|
||||
div.modal {
|
||||
textarea {
|
||||
font: normal 12px/16px $Consolas;
|
||||
height: 200px;
|
||||
margin: 0;
|
||||
width: 520px;
|
||||
&.favorited {
|
||||
div.container {
|
||||
header {
|
||||
@include vertical-gradient-with-image(url('/static/images/favorited-icon.png') top right no-repeat, #FFF, #FFFAF2);
|
||||
|
||||
h1 {
|
||||
a {
|
||||
padding-right: 25px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -174,6 +174,14 @@
|
|||
});
|
||||
return false;
|
||||
},
|
||||
favorite: function() {
|
||||
|
||||
},
|
||||
initFavorite: function() {
|
||||
this.$favorite.click(function() {
|
||||
return false;
|
||||
});
|
||||
},
|
||||
initLocalVars: function() {
|
||||
this.$aside = $('aside', this.$el);
|
||||
this.$container = $('div.container', this.$el);
|
||||
|
@ -182,6 +190,7 @@
|
|||
this.$copyModalBody = $('div.modal-body', this.$copyModal);
|
||||
this.$embedModal = $('div.embed-modal', this.$el);
|
||||
this.$embedModalBody = $('div.modal-body', this.$embedModal);
|
||||
this.$favorite = $('a.favorite', this.$el);
|
||||
|
||||
this.$h1 = $('header h1 a', this.$el);
|
||||
this.$tags = $('section.tags ul', this.$aside);
|
||||
|
@ -196,6 +205,10 @@
|
|||
window.ui_halted = false;
|
||||
window.from_modal = true;
|
||||
});
|
||||
|
||||
if (this.$favorite.length) {
|
||||
this.initFavorite();
|
||||
}
|
||||
},
|
||||
next: function() {
|
||||
if (!window.ui_halted) {
|
||||
|
@ -283,6 +296,9 @@
|
|||
selectFromClick: function(e) {
|
||||
this.select(true);
|
||||
e.stopPropagation();
|
||||
},
|
||||
unFavorite: function() {
|
||||
|
||||
}
|
||||
});
|
||||
Snipt.SniptListView = Backbone.View.extend({
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<a class="embed" href="#">Embed</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="copy" href="#"><span class="do">Copy</span></a>
|
||||
<a class="copy" href="#">Copy</a>
|
||||
</li>
|
||||
</ul>
|
||||
<section class="tags">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{% load humanize %}
|
||||
{% load humanize snipt_tags %}
|
||||
|
||||
<article id="snipt-{{ snipt.pk }}" class="snipt {% if not snipt.public %}private-snipt{% endif %} {% if snipt.line_count > 8 and not detail %}expandable{% endif %} {% if snipt.user == request.user %}editable{% endif %}">
|
||||
<article id="snipt-{{ snipt.pk }}" class="snipt{% if not snipt.public %} private-snipt{% endif %}{% if snipt.line_count > 8 and not detail %} expandable{% endif %}{% if snipt.user == request.user %} editable{% endif %}{% if request.user.is_authenticated %}{% if snipt|is_favorited_by:request.user %} favorited{% endif %}{% endif %}">
|
||||
<div class="number">#{{ snipt.pk }}</div>
|
||||
<div class="group">
|
||||
<div class="container">
|
||||
|
@ -33,8 +33,17 @@
|
|||
<a class="embed" href="#">Embed</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="copy" href="#"><span class="do">Copy</span></a>
|
||||
<a class="copy" href="#">Copy</a>
|
||||
</li>
|
||||
{% if snipt.user != request.user and request.user.is_authenticated %}
|
||||
<li>
|
||||
{% if snipt|is_favorited_by:request.user %}
|
||||
<a class="favorite favorited" href="#">Favorited</a>
|
||||
{% else %}
|
||||
<a class="favorite unfavorited" href="#">Favorite</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<section class="tags">
|
||||
<h2>{{ snipt.tags.all|length }} tag{{ snipt.tags.all|pluralize }}</h2>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
from django import template
|
||||
|
||||
from snipts.models import Favorite
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter
|
||||
def is_favorited_by(snipt, user):
|
||||
try:
|
||||
Favorite.objects.get(snipt=snipt, user=user)
|
||||
return True
|
||||
except Favorite.DoesNotExist:
|
||||
return False
|
Loading…
Reference in New Issue