From 4eb861026b8aed148f411a307cf7c0a48d0d15f0 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 28 Feb 2017 19:13:00 +0300 Subject: add book description tooltips using qtip2 --- js/index.js | 43 +++++++++++++++++++++++++++++++++++++++++++ js/offline.js | 22 +++++++++++++++++++--- 2 files changed, 62 insertions(+), 3 deletions(-) (limited to 'js') 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 + "]") -- cgit v1.2.3