diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/FeedTree.js | 19 | ||||
-rw-r--r-- | js/feedlist.js | 10 | ||||
-rw-r--r-- | js/functions.js | 66 | ||||
-rw-r--r-- | js/prefs.js | 7 | ||||
-rw-r--r-- | js/tt-rss.js | 20 | ||||
-rw-r--r-- | js/viewfeed.js | 116 |
6 files changed, 206 insertions, 32 deletions
diff --git a/js/FeedTree.js b/js/FeedTree.js index 0b75629f0..2e686c156 100644 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -162,6 +162,14 @@ dojo.declare("fox.FeedTree", dijit.Tree, { tnode._menu = menu; } + if (id.match("CAT:")) { + loading = dojo.doc.createElement('img'); + loading.className = 'loadingNode'; + loading.src = 'images/blank_icon.gif'; + dojo.place(loading, tnode.labelNode, 'after'); + tnode.loadingNode = loading; + } + if (id.match("CAT:") && bare_id == -1) { var menu = new dijit.Menu(); menu.row_id = bare_id; @@ -243,8 +251,15 @@ dojo.declare("fox.FeedTree", dijit.Tree, { if (treeNode) { treeNode = treeNode[0]; - treeNode.expandoNode.src = src; - return true; + if (is_cat) { + if (treeNode.loadingNode) { + treeNode.loadingNode.src = src; + return true; + } + } else { + treeNode.expandoNode.src = src; + return true; + } } return false; diff --git a/js/feedlist.js b/js/feedlist.js index 4dc8b503e..ae4c3a2fb 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -125,13 +125,11 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { Form.enable("main_toolbar_form"); - if (!offset) - if (!is_cat) { - if (!setFeedExpandoIcon(feed, is_cat, 'images/indicator_white.gif')) - notify_progress("Loading, please wait...", true); - } else { + if (!offset) { + if (!setFeedExpandoIcon(feed, is_cat, + (is_cat) ? 'images/indicator_tiny.gif' : 'images/indicator_white.gif')) notify_progress("Loading, please wait...", true); - } + } } query += "&cat=" + is_cat; diff --git a/js/functions.js b/js/functions.js index be78294df..4840bcbe1 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1746,7 +1746,7 @@ function feedBrowser() { } }); }, removeFromArchive: function() { - var selected = this.getSelectedFeeds(); + var selected = this.getSelectedFeedIds(); if (selected.length > 0) { @@ -1755,7 +1755,7 @@ function feedBrowser() { if (confirm(pr)) { Element.show('feed_browser_spinner'); - var query = "?op=rpc&method=remarchived&ids=" + + var query = "?op=rpc&method=remarchive&ids=" + param_escape(selected.toString());; new Ajax.Request("backend.php", { @@ -1913,3 +1913,65 @@ function helpDialog(topic) { } } +function htmlspecialchars_decode (string, quote_style) { + // http://kevin.vanzonneveld.net + // + original by: Mirek Slugen + // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Mateusz "loonquawl" Zalega + // + input by: ReverseSyntax + // + input by: Slawomir Kaniecki + // + input by: Scott Cariss + // + input by: Francois + // + bugfixed by: Onno Marsman + // + revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Brett Zamir (http://brett-zamir.me) + // + input by: Ratheous + // + input by: Mailfaker (http://www.weedem.fr/) + // + reimplemented by: Brett Zamir (http://brett-zamir.me) + // + bugfixed by: Brett Zamir (http://brett-zamir.me) + // * example 1: htmlspecialchars_decode("<p>this -> "</p>", 'ENT_NOQUOTES'); + // * returns 1: '<p>this -> "</p>' + // * example 2: htmlspecialchars_decode("&quot;"); + // * returns 2: '"' + var optTemp = 0, + i = 0, + noquotes = false; + if (typeof quote_style === 'undefined') { + quote_style = 2; + } + string = string.toString().replace(/</g, '<').replace(/>/g, '>'); + var OPTS = { + 'ENT_NOQUOTES': 0, + 'ENT_HTML_QUOTE_SINGLE': 1, + 'ENT_HTML_QUOTE_DOUBLE': 2, + 'ENT_COMPAT': 2, + 'ENT_QUOTES': 3, + 'ENT_IGNORE': 4 + }; + if (quote_style === 0) { + noquotes = true; + } + if (typeof quote_style !== 'number') { // Allow for a single string or an array of string flags + quote_style = [].concat(quote_style); + for (i = 0; i < quote_style.length; i++) { + // Resolve string input to bitwise e.g. 'PATHINFO_EXTENSION' becomes 4 + if (OPTS[quote_style[i]] === 0) { + noquotes = true; + } else if (OPTS[quote_style[i]]) { + optTemp = optTemp | OPTS[quote_style[i]]; + } + } + quote_style = optTemp; + } + if (quote_style & OPTS.ENT_HTML_QUOTE_SINGLE) { + string = string.replace(/�*39;/g, "'"); // PHP doesn't currently escape if more than one 0, but it should + // string = string.replace(/'|�*27;/g, "'"); // This would also be useful here, but not a part of PHP + } + if (!noquotes) { + string = string.replace(/"/g, '"'); + } + // Put this in last place to avoid escape being double-decoded + string = string.replace(/&/g, '&'); + + return string; +} diff --git a/js/prefs.js b/js/prefs.js index e6257e1fb..082f62679 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -722,6 +722,13 @@ function editSelectedFeeds() { } } catch (e) { } + try { + if (!query.match("&hide_images=") && + this.getChildByName('hide_images').attr('disabled') == false) { + query = query + "&hide_images=false"; + } + } catch (e) { } + if (!query.match("&include_in_digest=") && this.getChildByName('include_in_digest').attr('disabled') == false) { query = query + "&include_in_digest=false"; diff --git a/js/tt-rss.js b/js/tt-rss.js index 357e07780..bced92674 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -659,17 +659,31 @@ function hotkey_handler(e) { catchupRelativeToArticle(0); return false; case "article_scroll_down": - scrollArticle(50); + var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame"); + + scrollArticle(ctr.offsetHeight/3); return false; case "article_scroll_up": - scrollArticle(-50); + var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame"); + + scrollArticle(-ctr.offsetHeight/3); return false; case "close_article": - closeArticlePanel(); + if (isCdmMode()) { + if (!getInitParam("cdm_expanded")) { + cdmCollapseArticle(false, getActiveArticleId()); + } else { + dismissArticle(getActiveArticleId()); + } + } else { + closeArticlePanel(); + } return false; case "email_article": if (typeof emailArticle != "undefined") { emailArticle(); + } else if (typeof mailtoArticle != "undefined") { + mailtoArticle(); } else { alert(__("Please enable mail plugin first.")); } diff --git a/js/viewfeed.js b/js/viewfeed.js index 622a8109f..5567c717a 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -205,6 +205,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) { _infscroll_request_sent = 0; + headlines_scroll_handler($("headlines-frame")); + notify(""); } catch (e) { @@ -541,7 +543,7 @@ function moveToPost(mode, noscroll) { } else if (next_id) { cdmExpandArticle(next_id); - cdmScrollToArticleId(next_id, noscroll); + cdmScrollToArticleId(next_id, true); } } else if (next_id) { @@ -559,16 +561,28 @@ function moveToPost(mode, noscroll) { var prev_article = $("RROW-" + prev_id); var ctr = $("headlines-frame"); - if (!noscroll && article && article.offsetTop < ctr.scrollTop) { - scrollArticle(-ctr.offsetHeight/2); - } else if (!noscroll && prev_article && - prev_article.offsetTop < ctr.scrollTop) { - cdmExpandArticle(prev_id); - scrollArticle(-ctr.offsetHeight/2); - } else if (prev_id) { - cdmExpandArticle(prev_id); - cdmScrollToArticleId(prev_id, noscroll); + if (!getInitParam("cdm_expanded")) { + + if (!noscroll && article.offsetTop < ctr.scrollTop) { + scrollArticle(-ctr.offsetHeight/3); + } else { + cdmExpandArticle(prev_id); + cdmScrollToArticleId(prev_id, true); + } + } else { + + if (!noscroll && article && article.offsetTop < ctr.scrollTop) { + scrollArticle(-ctr.offsetHeight/3); + } else if (!noscroll && prev_article && + prev_article.offsetTop < ctr.scrollTop) { + cdmExpandArticle(prev_id); + scrollArticle(-ctr.offsetHeight/3); + } else if (prev_id) { + cdmExpandArticle(prev_id); + cdmScrollToArticleId(prev_id, noscroll); + } } + } else if (prev_id) { correctHeadlinesOffset(prev_id); view(prev_id, getActiveFeedId()); @@ -1164,6 +1178,23 @@ function headlines_scroll_handler(e) { try { var hsp = $("headlines-spacer"); + $$("#headlines-frame > div[id*=RROW]").each( + function(child) { + if (child.offsetTop <= $("headlines-frame").scrollTop + + $("headlines-frame").offsetHeight) { + + var cencw = $("CENCW-" + child.id.replace("RROW-", "")); + + if (cencw) { + cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML); + cencw.setAttribute('id', ''); + Element.show(cencw); + } + } + } + ); + + if (!_infscroll_disable) { if ((hsp && e.scrollTop + e.offsetHeight >= hsp.offsetTop - hsp.offsetHeight) || (e.scrollHeight != 0 && @@ -1185,7 +1216,7 @@ function headlines_scroll_handler(e) { $$("#headlines-frame > div[id*=RROW][class*=Unread]").each( function(child) { - if ($("headlines-frame").scrollTop > + if (child.hasClassName("Unread") && $("headlines-frame").scrollTop > (child.offsetTop + child.offsetHeight/2)) { var id = child.id.replace("RROW-", ""); @@ -1312,8 +1343,36 @@ function catchupRelativeToArticle(below, id) { } } +function cdmCollapseArticle(event, id) { + try { + var row = $("RROW-" + id); + var elem = $("CICD-" + id); + + if (elem && row) { + var collapse = $$("div#RROW-" + id + + " span[class='collapseBtn']")[0]; + + Element.hide(elem); + Element.show("CEXC-" + id); + Element.hide(collapse); + + markHeadline(id, false); + + if (id == getActiveArticleId()) { + setActiveArticleId(0); + } + + if (event) Event.stop(event); + } + + } catch (e) { + exception_error("cdmCollapseArticle", e); + } +} + function cdmExpandArticle(id) { try { + console.log("cdmExpandArticle " + id); hideAuxDlg(); @@ -1327,25 +1386,39 @@ function cdmExpandArticle(id) { var old_offset = $("RROW-" + id).offsetTop; if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) { + var collapse = $$("div#RROW-" + getActiveArticleId() + + " span[class='collapseBtn']")[0]; + Element.hide(elem); Element.show("CEXC-" + getActiveArticleId()); + Element.hide(collapse); } setActiveArticleId(id); elem = $("CICD-" + id); + var collapse = $$("div#RROW-" + id + + " span[class='collapseBtn']")[0]; + + var cencw = $("CENCW-" + id); + if (!Element.visible(elem)) { + if (cencw) { + cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML); + cencw.setAttribute('id', ''); + Element.show(cencw); + } + Element.show(elem); Element.hide("CEXC-" + id); + Element.show(collapse); } - /* var new_offset = $("RROW-" + id).offsetTop; + var new_offset = $("RROW-" + id).offsetTop; - $("headlines-frame").scrollTop += (new_offset-old_offset); - - if ($("RROW-" + id).offsetTop != old_offset) - $("headlines-frame").scrollTop = new_offset; */ + if (old_offset > new_offset) + $("headlines-frame").scrollTop -= (old_offset-new_offset); toggleUnread(id, 0, true); toggleSelected(id); @@ -1609,16 +1682,21 @@ function isCdmMode() { return getInitParam("combined_display_mode"); } -function markHeadline(id) { +function markHeadline(id, marked) { + if (marked == undefined) marked = true; + var row = $("RROW-" + id); if (row) { var check = dijit.byId("RCHK-" + id); if (check) { - check.attr("checked", true); + check.attr("checked", marked); } - row.addClassName("Selected"); + if (marked) + row.addClassName("Selected"); + else + row.removeClassName("Selected"); } } |