]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
load scriptaculous in prefs.php
[tt-rss.git] / functions.js
index 6ba37811e4d3b2ad0b37aaf612011767299e52a5..220c56bbecd2d738ee8436c624ab938deacbb3d2 100644 (file)
@@ -70,9 +70,17 @@ function open_article_callback() {
 
                        if (xmlhttp_rpc.responseXML) {
                                var link = xmlhttp_rpc.responseXML.getElementsByTagName("link")[0];
+                               var id = xmlhttp_rpc.responseXML.getElementsByTagName("id")[0];
 
                                if (link) {
                                        window.open(link.firstChild.nodeValue, "_blank");
+
+                                       if (id) {
+                                               id = id.firstChild.nodeValue;
+                                               if (!document.getElementById("headlinesList")) {
+                                                       window.setTimeout("toggleUnread(" + id + ", 0)", 100);
+                                               }
+                                       }
                                }
                        }
 
@@ -327,6 +335,29 @@ function hotkey_handler(e) {
                        }
                }
 
+               if (keycode == 84) { // t
+
+                       var id = getActiveArticleId();
+
+                       if (id) {                               
+
+                               var cb = document.getElementById("RCHK-" + id);
+
+                               if (cb) {
+                                       cb.checked = !cb.checked;
+                                       toggleSelectRowById(cb, "RROW-" + id);
+                               }
+                       }
+               }
+
+               if (keycode == 67) { // c
+                       var id = getActiveArticleId();
+
+                       if (id) {                               
+                               toggleUnread(id, 0);
+                       }
+               }
+
                if (typeof localHotkeyHandler != 'undefined') {
                        try {
                                return localHotkeyHandler(e);
@@ -655,7 +686,9 @@ function parse_counters(reply, scheduled_call) {
                                if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) {
                                        viewCurrentFeed();
                                }
-               
+
+                               var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML));
+
                                feedu.innerHTML = ctr;
 
                                if (error) {
@@ -676,8 +709,12 @@ function parse_counters(reply, scheduled_call) {
                
                                                if (is_selected) {
                                                        feedr.className = feedr.className + "Selected";
-                                               }
-               
+                                               }       
+                                               
+                                       }
+
+                                       if (row_needs_hl) { 
+                                               new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5"});
                                        }
                                } else {
                                        feedctr.className = "invisible";
@@ -973,21 +1010,26 @@ function hideOrShowFeedsCategory(doc, node, hide, cat_node) {
                        if (node.childNodes[i].style != undefined) {
 
                                var has_unread = (node.childNodes[i].className != "feed" &&
+                                       node.childNodes[i].className != "label" && 
                                        node.childNodes[i].className != "tag");
        
        //                      debug(node.childNodes[i].id + " --> " + has_unread);
        
                                if (hide && !has_unread) {
-                                       node.childNodes[i].style.display = "none";
+                                       //node.childNodes[i].style.display = "none";
+                                       Effect.Fade(node.childNodes[i], {duration : 0.3});
                                }
        
                                if (!hide) {
                                        node.childNodes[i].style.display = "list-item";
+                                       //Effect.Appear(node.childNodes[i], {duration : 0.3});
                                }
        
                                if (has_unread) {
                                        node.childNodes[i].style.display = "list-item";
                                        cat_unread++;
+                                       //Effect.Appear(node.childNodes[i], {duration : 0.3});
+                                       //Effect.Highlight(node.childNodes[i]);
                                }
                        }
                }
@@ -1000,7 +1042,8 @@ function hideOrShowFeedsCategory(doc, node, hide, cat_node) {
                        return;
                }
                if (hide) {
-                       cat_node.style.display = "none";
+                       //cat_node.style.display = "none";
+                       Effect.Fade(cat_node, {duration : 0.3});
                } else {
                        cat_node.style.display = "list-item";
                }
@@ -1165,7 +1208,48 @@ function openExternalUrl(url) {
 }
 
 function getRelativeFeedId(list, id, direction, unread_only) { 
+       var rows = list.getElementsByTagName("LI");
+       var feeds = new Array();
+
+       for (var i = 0; i < rows.length; i++) {
+               if (rows[i].id.match("FEEDR-")) {
+
+                       if (rows[i].id == "FEEDR-" + id || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
+
+                               if (!unread_only || 
+                                               (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) {
+                                       feeds.push(rows[i].id.replace("FEEDR-", ""));
+                               }
+                       }
+               }
+       }
+
        if (!id) {
+               if (direction == "next") {
+                       return feeds.shift();
+               } else {
+                       return feeds.pop();
+               }
+       } else {
+               if (direction == "next") {
+                       var idx = feeds.indexOf(id);
+                       if (idx != -1 && idx < feeds.length) {
+                               return feeds[idx+1];                                    
+                       } else {
+                               return getRelativeFeedId(list, false, direction, unread_only);
+                       }
+               } else {
+                       var idx = feeds.indexOf(id);
+                       if (idx > 0) {
+                               return feeds[idx-1];
+                       } else {
+                               return getRelativeFeedId(list, false, direction, unread_only);
+                       }
+               }
+
+       }
+
+/*     if (!id) {
                if (direction == "next") {
                        for (i = 0; i < list.childNodes.length; i++) {
                                var child = list.childNodes[i];
@@ -1185,7 +1269,7 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                if (direction == "prev") {
                        for (i = list.childNodes.length-1; i >= 0; i--) {
                                var child = list.childNodes[i];                         
-                               if (child.id == "feedCatHolder" && child.className != "invisible") {
+                               if (child.id == "feedCatHolder" && Element.visible(child)) {
                                        if (child.firstChild) {
                                                var cr = getRelativeFeedId(child.firstChild, id, direction);
                                                if (cr) return cr;                                      
@@ -1243,8 +1327,8 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                                if (e) {
                                        if (!unread_only || (unread_only && e.className != "feed" &&
                                                        e.className.match("feed")))     {
-                                               if (e.parentNode.parentNode && e.parentNode.parentNode.className 
-                                                       != "invisible") {
+                                               if (e.parentNode.parentNode && 
+                                                       Element.visible(e.parentNode.parentNode)) {
                                                        return e.id.replace("FEEDR-", "");
                                                }
                                        }
@@ -1283,15 +1367,15 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                                if (e) {
                                        if (!unread_only || (unread_only && e.className != "feed" && 
                                                        e.className.match("feed")))     {
-                                               if (e.parentNode.parentNode && e.parentNode.parentNode.className 
-                                                       != "invisible") {
+                                               if (e.parentNode.parentNode && 
+                                                       Element.visible(e.parentNode.parentNode)) {
                                                        return e.id.replace("FEEDR-", "");
                                                }
                                        }
                                }
                        }
                }
-       }
+       } */
 }
 
 function showBlockElement(id, h_id) {
@@ -1432,6 +1516,9 @@ function infobox_callback() {
                        var box = document.getElementById('infoBox');
                        var shadow = document.getElementById('infoBoxShadow');
                        if (box) {                      
+
+                               new Draggable(shadow);
+
                                box.innerHTML=xmlhttp.responseText;                     
                                if (shadow) {
                                        shadow.style.display = "block";
@@ -1439,6 +1526,15 @@ function infobox_callback() {
                                        box.style.display = "block";                            
                                }
                        }
+
+                       /* FIXME this needs to be moved out somewhere */
+
+                       if (document.getElementById("tags_choices")) {
+                               new Ajax.Autocompleter('tags_str', 'tags_choices',
+                                       "backend.php?op=rpc&subop=completeTags",
+                                       { tokens: ',', paramName: "search" });
+                       }
+
                        notify("");
                } catch (e) {
                        exception_error("infobox_callback", e);
@@ -1473,7 +1569,7 @@ function addFilter() {
        var reg_exp = form.reg_exp.value;
 
        if (reg_exp == "") {
-               alert("Can't add filter: nothing to match on.");
+               alert(__("Can't add filter: nothing to match on."));
                return false;
        }
 
@@ -1509,7 +1605,7 @@ function qaddFeed() {
        var feed_url = form.feed_url.value;
 
        if (feed_url == "") {
-               alert("Can't subscribe: no feed URL given.");
+               alert(__("Can't subscribe: no feed URL given."));
                return false;
        }
 
@@ -1762,3 +1858,4 @@ function openArticleInNewWindow(id) {
                exception_error("openArticleInNewWindow", e);
        }
 }
+