summaryrefslogtreecommitdiff
path: root/_layouts/post.html
diff options
context:
space:
mode:
Diffstat (limited to '_layouts/post.html')
-rw-r--r--_layouts/post.html26
1 files changed, 25 insertions, 1 deletions
diff --git a/_layouts/post.html b/_layouts/post.html
index dca7641..f46dd9e 100644
--- a/_layouts/post.html
+++ b/_layouts/post.html
@@ -97,10 +97,34 @@ $.get(BlogAPI + "/suggest?id={{ page.url }}&update=" + lastUpdated.valueOf(), fu
searchMap[search[i].url] = search[i];
}
+ var tooltip = $('<div class="content-tooltip"></div>').appendTo('body').hide();
for (var j = 0; j < data.length; j++) {
var item = searchMap[data[j].id];
if (item) {
- suggest.append('<a href="' + item.url + '">' + item.title + '</a> - ' + item.date + '<br />');
+ var link = $('<a href="' + item.url + '">' + item.title + '</a>');
+ var contentPreview = item.content.replace(/<[^>]+>/g, "").substring(0, 100);
+
+ link.hover(
+ function(e) {
+ tooltip.text($(this).data('content'))
+ .css({
+ top: e.pageY + 10,
+ left: e.pageX + 10
+ })
+ .show();
+ },
+ function() {
+ tooltip.hide();
+ }
+ ).mousemove(function(e) {
+ tooltip.css({
+ top: e.pageY + 10,
+ left: e.pageX + 10
+ });
+ }).data('content', contentPreview);
+
+ suggest.append(link);
+ suggest.append(' - ' + item.date + '<br />');
}
}
});