Skip to content

Commit

Permalink
Task #27 Comic bookmarking.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesgs authored and ardathksheyna committed Jul 23, 2017
1 parent 2e4d3f6 commit 38b71aa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
22 changes: 17 additions & 5 deletions assets/js/bookmark.js
Expand Up @@ -23,33 +23,45 @@
storage : null,
BOOKMARK_HISTORY : 'mangapress-bookmark-history',
BOOKMARK : 'mangapress-bookmark',
$bookmark : null,
init: function() {
this.storage = localStorage;
this.checkItem();
},

checkItem : function() {
var bookmark = JSON.parse(this.storage.getItem(this.BOOKMARK)),
pageHref = window.location.href,
$bookmark = $('#bookmark-comic');
pageHref = window.location.href;

this.$bookmark = $('#bookmark-comic');

if (bookmark == null) {
return;
}

if (bookmark.url == pageHref) {
$bookmark.text($bookmark.data('bookmarkedLabel'));
this.$bookmark.text( this.$bookmark.data('bookmarkedLabel') );
}
},

bookmark : function() {
var href = window.location.href,
pageTitle = window.document.title,
data = {},
d = new Date();
data = {};

var existingBookmarkData = this.storage.getItem(this.BOOKMARK);

if (existingBookmarkData) {
var bookmarkHistory = JSON.parse(this.storage.getItem(this.BOOKMARK_HISTORY));
if (!bookmarkHistory) {
bookmarkHistory = [];
}

bookmarkHistory.push(existingBookmarkData);
this.storage.setItem(this.BOOKMARK_HISTORY, JSON.stringify(bookmarkHistory));

// change label state
this.$bookmark.text( this.$bookmark.data('bookmarkedLabel') );
}

data = {
Expand Down
1 change: 1 addition & 0 deletions includes/template-functions.php
Expand Up @@ -14,6 +14,7 @@
/**
* Bookmark button template tag
* @todo Add l10/i18n functionality
* @todo Define $attrs parameters
* @param array $attrs Attributes
*/
function mangapress_bookmark_button($attrs)
Expand Down
3 changes: 2 additions & 1 deletion mangapress-posts.php
Expand Up @@ -474,6 +474,8 @@ public function save_post($post_id, $post)
if (!wp_verify_nonce(filter_input(INPUT_POST, '_insert_comic'), self::NONCE_INSERT_COMIC))
return $post_id;

$flash_messages = MangaPress_Bootstrap::get_instance()->get_helper('flashmessage');

$image_ID = (int)filter_input(INPUT_POST, '_mangapress_comic_image', FILTER_SANITIZE_NUMBER_INT);
if ($image_ID) {
set_post_thumbnail($post_id, $image_ID);
Expand All @@ -489,7 +491,6 @@ public function save_post($post_id, $post)
}

return $post_id;

}

}
2 changes: 1 addition & 1 deletion templates/single-comic.php
Expand Up @@ -9,7 +9,7 @@
*/
?>
<?php mangapress_comic_navigation(); ?>

<?php var_dump(mangapress_get_comic_term_ID()); ?>
<div class="bookmark">
<?php mangapress_bookmark_button(array()); ?>
</div>
Expand Down

0 comments on commit 38b71aa

Please sign in to comment.