diff options
author | Andrew Dolgov <[email protected]> | 2017-03-05 23:05:42 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-03-05 23:05:42 +0300 |
commit | 3cfa1d1cae9cc5dc1b4ca3210ae39a16e3c45ccf (patch) | |
tree | 67eedd3ee523d1561524d801c1865cca9c0c4ca9 | |
parent | 237a9e913ddf1c281a62dc3fb144aa543c483fb0 (diff) |
add dropdown menu item to show book summary
-rw-r--r-- | css/index.css | 3 | ||||
-rw-r--r-- | index.php | 21 | ||||
-rw-r--r-- | js/index.js | 15 | ||||
-rw-r--r-- | js/offline.js | 17 | ||||
-rw-r--r-- | offline.html | 19 |
5 files changed, 74 insertions, 1 deletions
diff --git a/css/index.css b/css/index.css index b3231ad..484b21d 100644 --- a/css/index.css +++ b/css/index.css @@ -24,7 +24,8 @@ white-space : nowrap; } -.qtip-custom { +.qtip-custom, .book-summary { max-height : 250px; overflow : auto; } + @@ -103,6 +103,24 @@ <div class="container"> +<div class="modal fade" id="summary-modal" tabindex="-1" role="dialog"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Summary</h4> + </div> + <div class="modal-body"> + <div class="book-summary"> </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + </div> + </div> + </div> +</div> + + <?php require_once "config.php"; @@ -228,6 +246,9 @@ } ?> --> + <li><a href="#" onclick="show_summary(this)" + data-book-id="<?php echo $line["id"] ?>">Summary</a></li> + <?php if ($line["epub_id"]) { ?> <li><a href="#" onclick="" data-book-id="<?php echo $line["id"] ?>" class="offline_dropitem"></a></li> diff --git a/js/index.js b/js/index.js index 349794a..ac418da 100644 --- a/js/index.js +++ b/js/index.js @@ -150,6 +150,21 @@ function init_tooltips() { } } }); +} + +function show_summary(elem) { + var id = elem.getAttribute("data-book-id"); + + $.post("backend.php", {op: 'getinfo', id: id}, function(data) { + + var comment = data.comment ? data.comment : 'No description available'; + + $("#summary-modal .modal-title").html(data.title); + $("#summary-modal .book-summary").html(comment); + + $("#summary-modal").modal(); + + }); } diff --git a/js/offline.js b/js/offline.js index b6c8a24..e0138fb 100644 --- a/js/offline.js +++ b/js/offline.js @@ -112,6 +112,7 @@ function populate_list() { "More..." + "<span class=\"caret\"></span></a>"; cell += "<ul class=\"dropdown-menu\">"; + cell += "<li><a href=\"#\" data-book-id=\""+info.id+"\" onclick=\"show_summary(this)\">Summary</a></li>"; cell += "<li><a href=\"#\" data-book-id=\""+info.id+"\" onclick=\"offline_remove2(this)\">Remove offline data</a></li>"; cell += "</ul>"; @@ -163,3 +164,19 @@ function populate_list() { } +function show_summary(elem) { + var bookId = elem.getAttribute("data-book-id"); + + localforage.getItem("epube-book." + bookId).then(function(data) { + + var comment = data.comment ? data.comment : 'No description available'; + + $("#summary-modal .modal-title").html(data.title); + $("#summary-modal .book-summary").html(comment); + + $("#summary-modal").modal(); + + }); +} + + diff --git a/offline.html b/offline.html index 429b776..cc98443 100644 --- a/offline.html +++ b/offline.html @@ -80,6 +80,25 @@ </script> <div class="container"> + +<div class="modal fade" id="summary-modal" tabindex="-1" role="dialog"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> + <h4 class="modal-title">Summary</h4> + </div> + <div class="modal-body"> + <div class="book-summary"> </div> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> + </div> + </div> + </div> +</div> + + <div class="row" id="books_container"> </div> </div> </body> |