]> git.wh0rd.org - tt-rss.git/blobdiff - js/viewfeed.js
enable tooltips on normal mode
[tt-rss.git] / js / viewfeed.js
index e3db58035da28c911e3027610ee664b7b84a211f..55ebaa7c2280d1dc513964c933bf471d58e833bd 100644 (file)
@@ -13,6 +13,8 @@ var catchup_timeout_id = false;
 var cids_requested = [];
 var loaded_article_ids = [];
 
+var _post_preview_timeout = false;
+
 var has_storage = 'sessionStorage' in window && window['sessionStorage'] !== null;
 
 function headlines_callback2(transport, offset, background, infscroll_req) {
@@ -205,7 +207,7 @@ function headlines_callback2(transport, offset, background, infscroll_req) {
 
                _infscroll_request_sent = 0;
 
-               headlines_scroll_handler($("headlines-frame"));
+               unpackVisibleHeadlines();
 
                notify("");
 
@@ -315,7 +317,7 @@ function article_callback2(transport, id) {
                var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
                request_counters(unread_in_buffer == 0);
 
-               headlines_scroll_handler($("headlines-frame"));
+               //headlines_scroll_handler($("headlines-frame"));
 
 /*             try {
                        if (!_infscroll_disable &&
@@ -397,7 +399,7 @@ function view(id) {
                                        console.warn(e);
                                } */
 
-                               headlines_scroll_handler($("headlines-frame"));
+                               //headlines_scroll_handler($("headlines-frame"));
 
                                return;
                        }
@@ -1166,17 +1168,60 @@ function getActiveArticleId() {
        return _active_article_id;
 }
 
-function postMouseIn(id) {
+function postMouseIn(e, id) {
        post_under_pointer = id;
+
+       if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout);
+
+       if (!isCdmMode() || !getInitParam("cdm_expanded")) {
+               _post_preview_timeout = window.setTimeout(function() {
+                       displaySmallArticlePreview(e, id);
+               }, 1000);
+       }
+}
+
+function displaySmallArticlePreview(e, id) {
+       try {
+               var query = "?op=rpc&method=cdmarticlepreview&id=" + id;
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) {
+                               cexc = $("CEXC-" + id);
+                               preview = $("small_article_preview");
+                               row = $("RROW-" + id);
+
+                               if (id != getActiveArticleId() && (!isCdmMode() || (cexc && Element.visible(cexc))) && row && preview) {
+                                       preview.innerHTML = transport.responseText;
+                                       new Effect.Appear(preview, {duration:0.2});
+
+                                       preview.setStyle({
+                                               left: (e.clientX + 20) + 'px',
+                                               top: (Element.cumulativeOffset(row)[1] + row.offsetHeight + 10) + 'px' });
+
+                               }
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("displaySmallArticlePreview", e);
+       }
 }
 
 function postMouseOut(id) {
        post_under_pointer = false;
+
+       if (_post_preview_timeout) window.clearTimeout(_post_preview_timeout);
+
+       if (Element.visible("small_article_preview"))
+               Element.hide("small_article_preview");
 }
 
-function headlines_scroll_handler(e) {
+function unpackVisibleHeadlines() {
        try {
-               var hsp = $("headlines-spacer");
+
+               if (!isCdmMode()) return;
 
                $$("#headlines-frame > div[id*=RROW]").each(
                        function(child) {
@@ -1195,6 +1240,17 @@ function headlines_scroll_handler(e) {
                );
 
 
+       } catch (e) {
+               exception_error("unpackVisibleHeadlines", e);
+       }
+}
+
+function headlines_scroll_handler(e) {
+       try {
+               var hsp = $("headlines-spacer");
+
+               unpackVisibleHeadlines();
+
                if (!_infscroll_disable) {
                        if ((hsp && e.scrollTop + e.offsetHeight >= hsp.offsetTop - hsp.offsetHeight) ||
                                        (e.scrollHeight != 0 &&
@@ -1374,6 +1430,8 @@ function cdmExpandArticle(id) {
        try {
                console.log("cdmExpandArticle " + id);
 
+               if (!$("RROW-" + id)) return false;
+
                hideAuxDlg();
 
                var elem = $("CICD-" + getActiveArticleId());