diff options
author | Andrew Dolgov <[email protected]> | 2017-02-28 19:13:00 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-02-28 19:13:00 +0300 |
commit | 4eb861026b8aed148f411a307cf7c0a48d0d15f0 (patch) | |
tree | 30f417d394de785ed5d40bb7cfdee679cfc68d89 /js | |
parent | c348dcdc5faca033272fb39d3cc36086a85a0704 (diff) |
add book description tooltips using qtip2
Diffstat (limited to 'js')
-rw-r--r-- | js/index.js | 43 | ||||
-rw-r--r-- | js/offline.js | 22 |
2 files changed, 62 insertions, 3 deletions
diff --git a/js/index.js b/js/index.js index 60e4d12..349794a 100644 --- a/js/index.js +++ b/js/index.js @@ -110,3 +110,46 @@ function offline_cache(bookId, callback) { }); } + +function init_tooltips() { + + $('.index_cell img').qtip({ + position: { + target: 'mouse', + adjust: { + mouse: false + } + }, + style: { + classes: 'qtip-light qtip-custom' + }, + show: { + delay: 1000 + }, + hide: 'unfocus mouseleave', + content: { + text: function(event, api) { + $.ajax({ + url: 'backend.php?op=getinfo&id=' + $(this).attr('data-book-id') + }) + .then(function(content) { + + api.set('content.title', content.title); + + if (content.comment) { + api.set('content.text', + content.comment); + } else { + api.set('content.text', 'No description available'); + } + }, function(xhr, status, error) { + api.set('content.text', status + ': ' + error); + }); + + return 'Loading...'; + } + } + }); + + +} diff --git a/js/offline.js b/js/offline.js index 540fc60..b6c8a24 100644 --- a/js/offline.js +++ b/js/offline.js @@ -44,8 +44,6 @@ function populate_list() { if (query) query = query.toLowerCase(); - console.log(query); - var books = $("#books_container"); books.html(""); @@ -125,7 +123,25 @@ function populate_list() { var cell = $(cell); if (cover) { - cell.find("img").attr("src", cover); + cell.find("img").attr("src", cover).qtip({ + position: { + target: 'mouse', + adjust: { + mouse: false + } + }, + style: { + classes: 'qtip-light qtip-custom' + }, + show: { + delay: 1000 + }, + hide: 'unfocus mouseleave', + content: { + text: info.comment ? info.comment : "No description available", + title: info.title + } + }); cell.find(".series_link") .attr("title", info.series_name + " [" + info.series_index + "]") |