summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2017-02-26 17:39:42 +0300
committerAndrew Dolgov <[email protected]>2017-02-26 17:39:42 +0300
commit7c123353b57cb96d84fb7a6b311b0df1e56fa035 (patch)
treeeb9b9d4f622f4c37235045539d40c88289a57690
parent6f11b1d2856359aaca5f7ecc27eec8f27e6d8ce6 (diff)
do not process all dropdowns when offline status changes
-rw-r--r--index.php2
-rw-r--r--js/index.js48
2 files changed, 27 insertions, 23 deletions
diff --git a/index.php b/index.php
index 53a01b5..e7ecb17 100644
--- a/index.php
+++ b/index.php
@@ -159,7 +159,7 @@
$cover_read = $is_read ? "read" : "";
- print "<div class='col-xs-6 col-sm-3 col-md-2 index_cell'>";
+ print "<div class='col-xs-6 col-sm-3 col-md-2 index_cell' id=\"cell-".$line["id"]."\">";
print "<div class=\"thumb $cover_read\">";
if ($read_link) print "<a href=\"$read_link\">";
diff --git a/js/index.js b/js/index.js
index 87279c2..c5f8926 100644
--- a/js/index.js
+++ b/js/index.js
@@ -1,32 +1,36 @@
-function mark_offline_books() {
- var elems = $(".offline_dropitem");
+function mark_offline(elem) {
- $.each(elems, function (i, elem) {
- var bookId = elem.getAttribute("data-book-id");
- var cacheId = "epube-book." + bookId;
+ var bookId = elem.getAttribute("data-book-id");
+ var cacheId = "epube-book." + bookId;
- localforage.getItem(cacheId).then(function(book) {
- if (book) {
+ localforage.getItem(cacheId).then(function(book) {
+ if (book) {
+ elem.onclick = function() {
+ offline_remove(bookId, function() {
+ mark_offline(elem);
+ });
+ };
- elem.onclick = function() {
- offline_remove(bookId, function() {
- mark_offline_books();
- });
- };
+ elem.innerHTML = "Remove offline data";
- elem.innerHTML = "Remove offline data";
+ } else {
+ elem.onclick = function() {
+ offline_cache(bookId, function() {
+ mark_offline(elem);
+ });
+ };
- } else {
- elem.onclick = function() {
- offline_cache(bookId, function() {
- mark_offline_books();
- });
- };
+ elem.innerHTML = "Make available offline";
+ }
+ });
+}
- elem.innerHTML = "Make available offline";
- }
- });
+function mark_offline_books() {
+ var elems = $(".offline_dropitem");
+
+ $.each(elems, function (i, elem) {
+ mark_offline(elem);
});
}