add bookmark model
This commit is contained in:
parent
03db2db899
commit
d0e4d9512c
14 changed files with 223 additions and 16 deletions
|
@ -25,9 +25,12 @@
|
|||
</span>
|
||||
{% endif %}
|
||||
<span class="actionbar-block">
|
||||
<span class="actionbar-button">
|
||||
<span id="bookmark-button-{{bookmark.id}}"
|
||||
class="bookmark-button actionbar-button {% if bookmark.get_bookmark(request.profile) == True %} bookmarked {% endif %}"
|
||||
onclick="javascript:bookmark({{ bookmark.id }})"
|
||||
>
|
||||
<i class="fa fa-bookmark-o" style="font-size: large;"></i>
|
||||
<span class="actionbar-text">{{_("Bookmark")}}</span>
|
||||
<span class="actionbar-text">{{_("Bookmark")}} {{ bookmark.id }} </span>
|
||||
</span>
|
||||
</span>
|
||||
<span class="actionbar-block">
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
.actionbar-text {
|
||||
padding-left: 0.4em;
|
||||
}
|
||||
.bookmarked {
|
||||
color: rgb(180, 180, 7);
|
||||
}
|
||||
|
||||
@media (max-width: 799px) {
|
||||
.actionbar-text {
|
||||
display: none;
|
||||
|
|
|
@ -20,6 +20,39 @@
|
|||
});
|
||||
}
|
||||
|
||||
function ajax_bookmark(url, id, on_success) {
|
||||
return $.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (typeof on_success !== 'undefined')
|
||||
on_success();
|
||||
},
|
||||
error: function (data, textStatus, jqXHR) {
|
||||
alert('Could not bookmark: ' + data.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.bookmark = function(id) {
|
||||
var $bookmark = $('#bookmark-button-' + id);
|
||||
if ($bookmark.hasClass('bookmarked')) {
|
||||
ajax_bookmark('{{ url('undobookmark') }}', id, function () {
|
||||
$bookmark.removeClass('bookmarked');
|
||||
});
|
||||
} else {
|
||||
ajax_bookmark('{{ url('dobookmark') }}', id, function () {
|
||||
if ($bookmark.hasClass('bookmarked'))
|
||||
$bookmark.removeClass('bookmarked');
|
||||
$bookmark.addClass('bookmarked');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var get_$votes = function (id) {
|
||||
var $post = $('#page-vote-' + id);
|
||||
return {
|
||||
|
@ -30,7 +63,6 @@
|
|||
|
||||
window.pagevote_upvote = function (id) {
|
||||
var $votes = get_$votes(id);
|
||||
console.log($votes.upvote, $votes.downvote);
|
||||
if ($votes.upvote.hasClass('voted')) {
|
||||
ajax_vote('{{ url('pagevote_downvote') }}', id, -1, function () {
|
||||
$votes.upvote.removeClass('voted');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue