]> git.wh0rd.org - tt-rss.git/blobdiff - tt-rss.js
compat theme: properly reflow container height
[tt-rss.git] / tt-rss.js
index 495b8631cc6d756f5aa81febdcedb3c577cdc07d..0e4c153c0cf295b7fb2278136b92eab5526da6b4 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -13,6 +13,7 @@ var active_feed_id = 0;
 var active_feed_is_cat = false;
 var number_of_feeds = 0;
 var sanity_check_done = false;
+var _hfd_scrolltop = 0;
 
 var init_params = new Object();
 
@@ -69,12 +70,12 @@ function refetch_callback2(transport) {
 
                debug("refetch_callback2: done");
 
-               if (!daemon_enabled && !daemon_refresh_only) {
+/*             if (!daemon_enabled && !daemon_refresh_only) {
                        notify_info("All feeds updated.");
                        updateTitle("");
                } else {
                        //notify("");
-               }
+               } */
        } catch (e) {
                exception_error("refetch_callback", e);
                updateTitle("");
@@ -140,9 +141,9 @@ function scheduleFeedUpdate(force) {
 
        debug("in scheduleFeedUpdate");
 
-       if (!daemon_enabled && !daemon_refresh_only) {
+/*     if (!daemon_enabled && !daemon_refresh_only) {
                notify_progress("Updating feeds...", true);
-       }
+       } */
 
        var query_str = "backend.php?op=rpc&subop=";
 
@@ -218,20 +219,24 @@ function updateFeedList(silent, fetch) {
 
 function catchupAllFeeds() {
 
-       var query_str = "backend.php?op=feeds&subop=catchupAll";
+       var str = __("Mark all articles as read?");
 
-       notify_progress("Marking all feeds as read...");
+       if (getInitParam("confirm_feed_catchup") != 1 || confirm(str)) {
 
-       debug("catchupAllFeeds Q=" + query_str);
+               var query_str = "backend.php?op=feeds&subop=catchupAll";
 
-       new Ajax.Request(query_str, {
-               onComplete: function(transport) { 
-                       feedlist_callback2(transport); 
-               } });
+               notify_progress("Marking all feeds as read...");
+
+               debug("catchupAllFeeds Q=" + query_str);
 
-       global_unread = 0;
-       updateTitle("");
+               new Ajax.Request(query_str, {
+                       onComplete: function(transport) { 
+                               feedlist_callback2(transport); 
+                       } });
 
+               global_unread = 0;
+               updateTitle("");
+       }
 }
 
 function viewCurrentFeed(subop) {
@@ -354,30 +359,45 @@ function resize_headlines() {
        var h_frame = document.getElementById("headlines-frame");
        var c_frame = document.getElementById("content-frame");
        var f_frame = document.getElementById("footer");
+       var feeds_frame = document.getElementById("feeds-holder");
 
        if (!c_frame || !h_frame) return;
 
-       debug("resize_headlines");
+       if (feeds_frame && getInitParam("theme") == "compat") {
+                       feeds_frame.style.bottom = f_frame.offsetHeight + "px";         
+       }
 
-       if (!is_msie()) {
-               h_frame.style.height = 30 + "%";
-               c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px";
-               h_frame.style.height = h_frame.offsetHeight + "px";
-       } else {
-               h_frame.style.height = document.documentElement.clientHeight * 0.3 + "px";
-               c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px";
+       if (getInitParam("theme") == "3pane") {
+               debug("resize_headlines: HOR-mode");
 
-               var c_bottom = document.documentElement.clientHeight;
+               c_frame.style.width = '35%';
+               h_frame.style.right = c_frame.offsetWidth - 1 + "px";
 
-               if (f_frame) {
-                       c_bottom = f_frame.offsetTop;
-               }
+       } else {
+               debug("resize_headlines: VER-mode");
 
-               c_frame.style.height = c_bottom - (h_frame.offsetTop + 
-                       h_frame.offsetHeight + 1) + "px";
-               h_frame.style.height = h_frame.offsetHeight + "px";
+               if (!is_msie()) {
+                       h_frame.style.height = 30 + "%";
+                       c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px";
+                       h_frame.style.height = h_frame.offsetHeight + "px";
+               } else {
+                       h_frame.style.height = document.documentElement.clientHeight * 0.3 + "px";
+                       c_frame.style.top = h_frame.offsetTop + h_frame.offsetHeight + 1 + "px";
+       
+                       var c_bottom = document.documentElement.clientHeight;
+       
+                       if (f_frame) {
+                               c_bottom = f_frame.offsetTop;
+                       }
+       
+                       c_frame.style.height = c_bottom - (h_frame.offsetTop + 
+                               h_frame.offsetHeight + 1) + "px";
+                       h_frame.style.height = h_frame.offsetHeight + "px";
+       
+               }
 
        }
+
 }
 
 function init_second_stage() {
@@ -476,7 +496,7 @@ function quickMenuGo(opid) {
 
                        var fn = getFeedName(actid);
 
-                       var pr = __("Erase all non-starred articles for %s?").replace("%s", fn);
+                       var pr = __("Erase all non-starred articles in %s?").replace("%s", fn);
 
                        if (confirm(pr)) {
                                clearFeedArticles(actid);
@@ -505,6 +525,10 @@ function quickMenuGo(opid) {
                        displayDlg("quickAddFilter", getActiveFeedId());
                }
 
+               if (opid == "qmcRescoreFeed") {
+                       rescoreCurrentFeed();
+               }
+
        } catch (e) {
                exception_error("quickMenuGo", e);
        }
@@ -525,20 +549,6 @@ function unsubscribeFeed(feed_id) {
        return false;
 }
 
-function clearFeedArticles(feed_id) {
-
-       notify_progress("Clearing feed...");
-
-       var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
-
-       new Ajax.Request(query, {
-               onComplete: function(transport) {
-                               dlg_frefresh_callback(transport, feed_id);
-                       } });
-
-       return false;
-}
-
 
 function updateFeedTitle(t) {
        active_title_text = t;
@@ -623,7 +633,7 @@ function catchupCurrentFeed() {
 
        var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
        
-       var str = "Mark all articles in " + fn + " as read?";
+       var str = __("Mark all articles in %s as read?").replace("%s", fn);
 
 /*     if (active_feed_is_cat) {
                str = "Mark all articles in this category as read?";
@@ -637,8 +647,6 @@ function catchupCurrentFeed() {
 function editFeedDlg(feed) {
        try {
 
-               disableHotkeys();
-       
                if (!feed) {
                        alert(__("Please select some feed first."));
                        return;
@@ -656,7 +664,9 @@ function editFeedDlg(feed) {
                } else {
                        query = "backend.php?op=pref-labels&subop=edit&id=" +   param_escape(-feed-11);
                }
-       
+
+               disableHotkeys();
+
                new Ajax.Request(query, {
                        onComplete: function(transport) { 
                                infobox_callback2(transport); 
@@ -729,3 +739,161 @@ function labelEditSave() {
 
 }
 
+function clearFeedArticles(feed_id) {
+
+       notify_progress("Clearing feed...");
+
+       var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
+
+       new Ajax.Request(query, {
+               onComplete: function(transport) {
+                               dlg_frefresh_callback(transport, feed_id);
+                       } });
+
+       return false;
+}
+
+/*
+function toggle_feedlist() {
+       try {
+               debug("toggle_feedlist");
+
+               var fl = document.getElementById("feeds-holder");
+
+               if (!Element.visible(fl)) {
+                       Element.show(fl);
+                       fl.style.zIndex = 30;
+                       fl.scrollTop = _hfd_scrolltop;
+               } else {
+                       _hfd_scrolltop = fl.scrollTop;
+                       Element.hide(fl);                       
+//                     Effect.Fade(fl, {duration : 0.2, 
+//                             queue: { position: 'end', scope: 'FLFADEQ', limit: 1 }});
+               }
+       } catch (e) {
+               exception_error(e, "toggle_feedlist");
+       }
+} */
+
+function collapse_feedlist() {
+       try {
+               debug("toggle_feedlist");
+               
+               var theme = getInitParam("theme");
+               if (theme != "" && theme != "compact" && theme != "graycube" &&
+                               theme != "compat") return;
+
+               var fl = document.getElementById("feeds-holder");
+               var fh = document.getElementById("headlines-frame");
+               var fc = document.getElementById("content-frame");
+               var ft = document.getElementById("toolbar");
+               var ff = document.getElementById("footer");
+               var fhdr = document.getElementById("header");
+               var fbtn = document.getElementById("collapse_feeds_btn");
+
+               if (!Element.visible(fl)) {
+                       Element.show(fl);
+                       fbtn.value = "<<";
+
+                       if (theme != "graycube") {
+
+                               fh.style.left = fl.offsetWidth + "px";
+                               ft.style.left = fl.offsetWidth + "px";
+                               if (fc) fc.style.left = fl.offsetWidth + "px";
+                               if (ff && theme != "compat") ff.style.left = (fl.offsetWidth-1) + "px";
+
+                               if (theme == "compact") fhdr.style.left = (fl.offsetWidth + 10) + "px";
+                       } else {
+                               fh.style.left = fl.offsetWidth + 40 + "px";
+                               ft.style.left = fl.offsetWidth + 40 +"px";
+                               if (fc) fc.style.left = fl.offsetWidth + 40 + "px";
+                       }
+
+                       setCookie("ttrss_vf_fclps", "0");
+
+               } else {
+                       Element.hide(fl);
+                       fbtn.value = ">>";
+
+                       if (theme != "graycube") {
+
+                               fh.style.left = "0px";
+                               ft.style.left = "0px";
+                               if (fc) fc.style.left = "0px";
+                               if (ff) ff.style.left = "0px";
+
+                               if (theme == "compact") fhdr.style.left = "10px";
+
+                       } else {
+                               fh.style.left = "20px";
+                               ft.style.left = "20px";
+                               if (fc) fc.style.left = "20px";
+
+                       }
+
+                       setCookie("ttrss_vf_fclps", "1");
+               }
+       } catch (e) {
+               exception_error(e, "toggle_feedlist");
+       }
+}
+
+function viewModeChanged() {
+       cache_empty();
+       return viewCurrentFeed(0, '')
+}
+
+function viewLimitChanged() {
+       cache_empty();
+       return viewCurrentFeed(0, '')
+}
+
+function adjustArticleScore(id, score) {
+       try {
+
+               var pr = prompt(__("Assign score to article:"), score);
+
+               if (pr != undefined) {
+                       var query = "backend.php?op=rpc&subop=setScore&id=" + id + "&score=" + pr;
+
+                       new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       viewCurrentFeed();
+                               } });
+
+               }
+       } catch (e) {
+               exception_error(e, "adjustArticleScore");
+       }
+}      
+
+function rescoreCurrentFeed() {
+
+       var actid = getActiveFeedId();
+
+       if (activeFeedIsCat() || actid < 0 || tagsAreDisplayed()) {
+               alert(__("You can't rescore this kind of feed."));
+               return;
+       }       
+
+       if (!actid) {
+               alert(__("Please select some feed first."));
+               return;
+       }
+
+       var fn = getFeedName(actid);
+       var pr = __("Rescore articles in %s?").replace("%s", fn);
+
+       if (confirm(pr)) {
+               notify_progress("Rescoring articles...");
+
+               var query = "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids=" + actid;
+
+               new Ajax.Request(query, {
+               onComplete: function(transport) {
+                       viewCurrentFeed();
+               } });
+       }
+}
+
+