diff --git a/js/common.js b/js/common.js index 21ab20ee..4dc1a2b3 100644 --- a/js/common.js +++ b/js/common.js @@ -187,15 +187,8 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], if (localStorage.Results !== "undefined" && localStorage.SearchResults !== "undefined") { $("#resultwrap").html(localStorage.Results); $("#searchresultswrap").html(localStorage.SearchResults); - $("#resultwrap").find(".hiddenlink").click(function(e) { - Util.HandleHiddenLink(e); - }); - $("#resultwrap").find(".removeresult").click(function(e) { - Util.RemoveResult(e); - }); - $("#searchresultswrap").find(".link").click(function(e) { - Util.HandleLink(e); - }); + Bible.AttachEvents($("#resultwrap")); + Words.AttachEvents($("#searchresultswrap")); } } }, @@ -252,7 +245,7 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], $("#result").css("font-family", fontfamily); this.Save(); }, - ChangeDisplayStrongsInDialog: function(fontfamily) { + ChangeDisplayStrongsInDialog: function() { this.Save(); }, SaveResults: function() { @@ -299,35 +292,7 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], // TODO(jwall): hover should show tags for the verse. var t = $("
" + "

" + ref.toString() + "

" + r + "

"); - t.find(".hiddenlink").click(function(e) { - Util.HandleHiddenLink(e); - }); - t.find(".removeresult").click(function(e) { - Util.RemoveResult(e); - }); - // TODO(jwall): support longtouch events on mobile? - t.find(".resultbody h2").tooltip({ - items: ".resultbody h2", - content: function(tt) { - tagging.GetTags( - ref.toString(), { - success: function(data) { - var tags = data ? - (data.data ? - data.data.tagList : null) : null; - var hoverContent = - $("
Tags:
"); - hoverContent.append( - tags ? tags.join(", ") : "N/A"); - tt(hoverContent); - }}); - } - }); - t.find(".hiddenlink").tooltip( - { - items: ".hiddenlink" - } - ); + Bible.AttachEvents(t, ref); $("#result").prepend(t); } catch (err) { @@ -403,6 +368,32 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], Util.HandleError(err); } return null; + }, + AttachEvents: function(t, ref){ + t.find(".hiddenlink").click(function(e) { + Util.HandleHiddenLink(e); + }); + t.find(".removeresult").click(function(e) { + Util.RemoveResult(e); + }); + // TODO(jwall): support longtouch events on mobile? + t.find(".resultbody h2").tooltip({ + items: ".resultbody h2", + content: function(tt) { + tagging.GetTags( + ref.toString(), { + success: function(data) { + var tags = data ? + (data.data ? + data.data.tagList : null) : null; + var hoverContent = + $("
Tags:
"); + hoverContent.append( + tags ? tags.join(", ") : "N/A"); + tt(hoverContent); + }}); + } + }); } }; var Strongs = { @@ -614,9 +605,7 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], var t = $(txt); - t.find(".link").click(function(e) { - Util.HandleLink(e); - }); + Words.AttachEvents(t); $("#searchresults").html(t); $("#searchTotal").html(results.length); @@ -1042,6 +1031,11 @@ define(['jquery', 'reference', 'tagging', 'jquery.ui'], Util.HandleError(err); } return null; + }, + AttachEvents: function(t){ + t.find(".link").click(function(e) { + Util.HandleLink(e); + }); } }; return { diff --git a/js/tagging.js b/js/tagging.js index 4a691970..1fde6f73 100644 --- a/js/tagging.js +++ b/js/tagging.js @@ -3,6 +3,9 @@ var tagStore = 'tags'; define( ['db', 'reference'], function(db, reference) { return { + Capable: function() { + return db.Capable(); + }, // UpdateTags updates a given references tags asynchronously. // ref should be a Reference object. // tags should be a list of strings representing the tags for this