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 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'js/index.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...'; + } + } + }); + + +} -- cgit v1.2.3