diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/FeedTree.js | 14 | ||||
-rw-r--r-- | js/PluginHost.js | 1 | ||||
-rw-r--r-- | js/PrefFilterTree.js | 16 | ||||
-rw-r--r-- | js/PrefLabelTree.js | 4 | ||||
-rw-r--r-- | js/feedlist.js | 33 | ||||
-rw-r--r-- | js/functions.js | 128 | ||||
-rw-r--r-- | js/prefs.js | 19 | ||||
-rw-r--r-- | js/tt-rss.js | 113 | ||||
-rw-r--r-- | js/viewfeed.js | 351 |
9 files changed, 475 insertions, 204 deletions
diff --git a/js/FeedTree.js b/js/FeedTree.js index e35417daf..6c06f00d5 100644 --- a/js/FeedTree.js +++ b/js/FeedTree.js @@ -58,12 +58,12 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, { if (is_cat) { treeItem = this.store._itemsByIdentity['CAT:' + feed]; - items = this.store._arrayOfTopLevelItems; } else { treeItem = this.store._itemsByIdentity['FEED:' + feed]; - items = this.store._arrayOfAllItems; } + items = this.store._arrayOfAllItems; + for (var i = 0; i < items.length; i++) { if (items[i] == treeItem) { @@ -71,14 +71,18 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, { var unread = this.store.getValue(items[j], 'unread'); var id = this.store.getValue(items[j], 'id'); - if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j]; + if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { + if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j]; + } } for (var j = 0; j < i; j++) { var unread = this.store.getValue(items[j], 'unread'); var id = this.store.getValue(items[j], 'id'); - if (unread > 0 && (is_cat || id.match("FEED:"))) return items[j]; + if (unread > 0 && ((is_cat && id.match("CAT:")) || (!is_cat && id.match("FEED:")))) { + if( !is_cat || ! (this.store.hasAttribute(items[j], 'parent_id') && this.store.getValue(items[j], 'parent_id') == feed) ) return items[j]; + } } } } @@ -539,7 +543,7 @@ dojo.declare("fox.FeedTree", dijit.Tree, { } items = this.model.store._arrayOfAllItems; - var item = items[0]; + var item = items[0] == treeItem ? items[items.length-1] : items[0]; for (var i = 0; i < items.length; i++) { if (items[i] == treeItem) { diff --git a/js/PluginHost.js b/js/PluginHost.js index 668d215f9..ae89ba481 100644 --- a/js/PluginHost.js +++ b/js/PluginHost.js @@ -10,6 +10,7 @@ var PluginHost = { HOOK_ARTICLE_COLLAPSED: 7, HOOK_PARAMS_LOADED: 8, HOOK_RUNTIME_INFO_LOADED: 9, + HOOK_FLOATING_TITLE: 10, hooks: [], register: function (name, callback) { if (typeof(this.hooks[name]) == 'undefined') diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 4e49075bd..7a561c55b 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -24,6 +24,7 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { var enabled = this.model.store.getValue(args.item, 'enabled'); var param = this.model.store.getValue(args.item, 'param'); + var rules = this.model.store.getValue(args.item, 'rules'); if (param) { param = dojo.doc.createElement('span'); @@ -32,6 +33,21 @@ dojo.declare("fox.PrefFilterTree", lib.CheckBoxTree, { dojo.place(param, tnode.rowNode, 'first'); } + if (rules) { + param = dojo.doc.createElement('span'); + param.className = 'filterRules'; + param.innerHTML = rules; + dojo.place(param, tnode.rowNode, 'next'); + } + + if (this.model.store.getValue(args.item, 'id') != 'root') { + var img = dojo.doc.createElement('img'); + img.src ='images/filter.png'; + img.className = 'markedPic'; + tnode._filterIconNode = img; + dojo.place(tnode._filterIconNode, tnode.labelNode, 'before'); + } + return tnode; }, diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index 05a0c15b6..2f7dc0f53 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -22,7 +22,7 @@ dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, { if (type == 'label') { var span = dojo.doc.createElement('span'); span.innerHTML = 'α'; - span.className = 'labelColorIndicator2'; + span.className = 'labelColorIndicator'; span.id = 'LICID-' + bare_id; span.setStyle({ @@ -38,6 +38,6 @@ dojo.declare("fox.PrefLabelTree", lib.CheckBoxTree, { }, getIconClass: function (item, opened) { return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "invisible"; - }, + }, }); diff --git a/js/feedlist.js b/js/feedlist.js index 84b561227..7c2e08052 100644 --- a/js/feedlist.js +++ b/js/feedlist.js @@ -2,6 +2,7 @@ var _infscroll_disable = 0; var _infscroll_request_sent = 0; var _search_query = false; var _viewfeed_last = 0; +var _viewfeed_timeout = false; var counters_last_request = 0; @@ -34,10 +35,7 @@ function loadMoreHeadlines() { } else if (_search_query) { offset = num_all; } else if (view_mode == "adaptive") { - if (num_unread > 0) - offset = unread_in_buffer; - else - offset = num_all; + offset = num_unread > 0 ? unread_in_buffer : num_all; } else { offset = num_all; } @@ -52,7 +50,7 @@ function loadMoreHeadlines() { } -function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { +function viewfeed(feed, method, is_cat, offset, background, infscroll_req, can_wait) { try { if (is_cat == undefined) is_cat = false; @@ -94,7 +92,7 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { var toolbar_query = Form.serialize("main_toolbar_form"); - var query = "?op=feeds&method=view&feed=" + feed + "&" + + var query = "?op=feeds&method=view&feed=" + param_escape(feed) + "&" + toolbar_query; if (method) { @@ -132,15 +130,24 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) { console.log(query); + if (can_wait && _viewfeed_timeout) { + setFeedExpandoIcon(getActiveFeedId(), activeFeedIsCat(), 'images/blank_icon.gif'); + clearTimeout(_viewfeed_timeout); + } + setActiveFeedId(feed, is_cat); - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); - headlines_callback2(transport, offset, background, infscroll_req); - PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); - } }); + timeout_ms = can_wait ? 250 : 0; + _viewfeed_timeout = setTimeout(function() { + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif'); + headlines_callback2(transport, offset, background, infscroll_req); + PluginHost.run(PluginHost.HOOK_FEED_LOADED, [feed, is_cat]); + } }); + }, timeout_ms); // Wait 250ms } catch (e) { exception_error("viewfeed", e); diff --git a/js/functions.js b/js/functions.js index 8691c1ee5..720a5654a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -44,11 +44,8 @@ function exception_error(location, e, ext_info) { try { - if (ext_info) { - if (ext_info.responseText) { - ext_info = ext_info.responseText; - } - } + if (ext_info) + ext_info = JSON.stringify(ext_info); try { new Ajax.Request("backend.php", { @@ -104,13 +101,15 @@ function exception_error(location, e, ext_info) { title: "Unhandled exception", style: "width: 600px", report: function() { - if (confirm(__("Are you sure to report this exception to tt-rss.org? The report will include your browser information. Your IP would be saved in the database."))) { + if (confirm(__("Are you sure to report this exception to tt-rss.org? The report will include information about your web browser and tt-rss configuration. Your IP will be saved in the database."))) { document.forms['exceptionForm'].params.value = $H({ browserName: navigator.appName, browserVersion: navigator.appVersion, browserPlatform: navigator.platform, browserCookies: navigator.cookieEnabled, + ttrssVersion: __ttrss_version, + initParams: JSON.stringify(init_params), }).toQueryString(); document.forms['exceptionForm'].submit(); @@ -183,11 +182,6 @@ function param_unescape(arg) { return unescape(arg); } - -function hide_notify() { - Element.hide('notify'); -} - function notify_real(msg, no_hide, n_type) { var n = $("notify"); @@ -199,12 +193,11 @@ function notify_real(msg, no_hide, n_type) { } if (msg == "") { - if (Element.visible(n)) { - notify_hide_timerid = window.setTimeout("hide_notify()", 0); + if (n.hasClassName("visible")) { + notify_hide_timerid = window.setTimeout(function() { + n.removeClassName("visible") }, 0); } return; - } else { - Element.show(n); } /* types: @@ -218,21 +211,21 @@ function notify_real(msg, no_hide, n_type) { msg = "<span class=\"msg\"> " + __(msg) + "</span>"; - if (n_type == 1) { - n.className = "notify"; - } else if (n_type == 2) { - n.className = "notify progress"; + if (n_type == 2) { + n.className = "notify notify_progress visible"; msg = "<span><img src='images/indicator_white.gif'></span>" + msg; no_hide = true; } else if (n_type == 3) { - n.className = "notify error"; - msg = "<span><img src='images/sign_excl.svg'></span>" + msg; + n.className = "notify notify_error visible"; + msg = "<span><img src='images/alert.png'></span>" + msg; } else if (n_type == 4) { - n.className = "notify info"; - msg = "<span><img src='images/sign_info.svg'></span>" + msg; + n.className = "notify notify_info visible"; + msg = "<span><img src='images/information.png'></span>" + msg; + } else { + n.className = "notify visible"; } - msg += " <span><img src=\"images/close_notify.svg\" class=\"close\" title=\"" + + msg += " <span><img src=\"images/cross.png\" class=\"close\" title=\"" + __("Click to close") + "\" onclick=\"notify('')\"></span>"; // msg = "<img src='images/live_com_loading.gif'> " + msg; @@ -240,7 +233,8 @@ function notify_real(msg, no_hide, n_type) { n.innerHTML = msg; if (!no_hide) { - notify_hide_timerid = window.setTimeout("hide_notify()", 5*1000); + notify_hide_timerid = window.setTimeout(function() { + n.removeClassName("visible") }, 5*1000); } } @@ -829,7 +823,14 @@ function quickAddFeed() { onComplete: function(transport) { try { - var reply = JSON.parse(transport.responseText); + try { + var reply = JSON.parse(transport.responseText); + } catch (e) { + Element.hide("feed_add_spinner"); + alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); + console.log('quickAddFeed, backend returned:' + transport.responseText); + return; + } var rc = reply['result']; @@ -854,6 +855,8 @@ function quickAddFeed() { case 4: feeds = rc['feeds']; + Element.show("fadd_multiple_notify"); + var select = dijit.byId("feedDlg_feedContainerSelect"); while (select.getOptions().length > 0) @@ -1148,33 +1151,48 @@ function quickAddFilter() { href: query}); if (!inPreferences()) { + var selectedText = getSelectionText(); + var lh = dojo.connect(dialog, "onLoad", function(){ dojo.disconnect(lh); - var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId(); + if (selectedText != "") { - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - var reply = JSON.parse(transport.responseText); + var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : + getActiveFeedId(); - var title = false; + var rule = { reg_exp: selectedText, feed_id: feed_id, filter_type: 1 }; - if (reply && reply) title = reply.title; + addFilterRule(null, dojo.toJson(rule)); - if (title || getActiveFeedId() || activeFeedIsCat()) { + } else { - console.log(title + " " + getActiveFeedId()); + var query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId(); - var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : - getActiveFeedId(); + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); - var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 }; + var title = false; - addFilterRule(null, dojo.toJson(rule)); - } + if (reply && reply) title = reply.title; - } }); + if (title || getActiveFeedId() || activeFeedIsCat()) { + + console.log(title + " " + getActiveFeedId()); + + var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) : + getActiveFeedId(); + + var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 }; + + addFilterRule(null, dojo.toJson(rule)); + } + + } }); + + } }); } @@ -1270,10 +1288,8 @@ function backend_sanity_check_callback(transport) { console.log('reading init-params...'); for (k in params) { - var v = params[k]; - console.log("IP: " + k + " => " + v); - - if (k == "label_base_index") _label_base_index = parseInt(v); + console.log("IP: " + k + " => " + JSON.stringify(params[k])); + if (k == "label_base_index") _label_base_index = parseInt(params[k]); } init_params = params; @@ -1934,3 +1950,25 @@ function feed_to_label_id(feed) { return _label_base_index - 1 + Math.abs(feed); } +// http://stackoverflow.com/questions/6251937/how-to-get-selecteduser-highlighted-text-in-contenteditable-element-and-replac + +function getSelectionText() { + var text = ""; + + if (typeof window.getSelection != "undefined") { + var sel = window.getSelection(); + if (sel.rangeCount) { + var container = document.createElement("div"); + for (var i = 0, len = sel.rangeCount; i < len; ++i) { + container.appendChild(sel.getRangeAt(i).cloneContents()); + } + text = container.innerHTML; + } + } else if (typeof document.selection != "undefined") { + if (document.selection.type == "Text") { + text = document.selection.createRange().textText; + } + } + + return text.stripTags(); +} diff --git a/js/prefs.js b/js/prefs.js index 287804c6f..67a4a378c 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -1529,25 +1529,6 @@ function clearFeedAccessKeys() { return false; } -function clearArticleAccessKeys() { - - var ok = confirm(__("This will invalidate all previously shared article URLs. Continue?")); - - if (ok) { - notify_progress("Clearing URLs..."); - - var query = "?op=rpc&method=clearArticleKeys"; - - new Ajax.Request("backend.php", { - parameters: query, - onComplete: function(transport) { - notify_info("Shared URLs cleared."); - } }); - } - - return false; -} - function resetFilterOrder() { try { notify_progress("Loading, please wait..."); diff --git a/js/tt-rss.js b/js/tt-rss.js index ee3156c28..84f2e67b1 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -231,6 +231,7 @@ function init() { dojo.require("dijit.form.Select"); dojo.require("dijit.form.SimpleTextarea"); dojo.require("dijit.form.TextBox"); + dojo.require("dijit.form.ComboBox"); dojo.require("dijit.form.ValidationTextBox"); dojo.require("dijit.InlineEditBox"); dojo.require("dijit.layout.AccordionContainer"); @@ -272,13 +273,13 @@ function init() { var rv = dijit.byId("feedTree").getNextFeed( getActiveFeedId(), activeFeedIsCat()); - if (rv) viewfeed(rv[0], '', rv[1]); + if (rv) viewfeed(rv[0], '', rv[1], null, null, null, true); }; hotkey_actions["prev_feed"] = function() { var rv = dijit.byId("feedTree").getPreviousFeed( getActiveFeedId(), activeFeedIsCat()); - if (rv) viewfeed(rv[0], '', rv[1]); + if (rv) viewfeed(rv[0], '', rv[1], null, null, null, true); }; hotkey_actions["next_article"] = function() { moveToPost('next'); @@ -301,21 +302,27 @@ function init() { hotkey_actions["collapse_article"] = function() { var id = getActiveArticleId(); var elem = $("CICD-"+id); - if(elem.visible()) { - cdmCollapseArticle(null, id); - } - else { - cdmExpandArticle(id); + + if (elem) { + if (elem.visible()) { + cdmCollapseArticle(null, id); + } + else { + cdmExpandArticle(id); + } } }; hotkey_actions["toggle_expand"] = function() { var id = getActiveArticleId(); var elem = $("CICD-"+id); - if(elem.visible()) { - cdmCollapseArticle(null, id, false); - } - else { - cdmExpandArticle(id); + + if (elem) { + if (elem.visible()) { + cdmCollapseArticle(null, id, false); + } + else { + cdmExpandArticle(id); + } } }; hotkey_actions["search_dialog"] = function() { @@ -339,6 +346,9 @@ function init() { hotkey_actions["dismiss_selected"] = function() { dismissSelectedArticles(); }; + hotkey_actions["dismiss_read"] = function() { + dismissReadArticles(); + }; hotkey_actions["open_in_new_window"] = function() { if (getActiveArticleId()) { openArticleInNewWindow(getActiveArticleId()); @@ -497,6 +507,10 @@ function init() { if (!isCdmMode()) { _widescreen_mode = !_widescreen_mode; + // reset stored sizes because geometry changed + setCookie("ttrss_ci_width", 0); + setCookie("ttrss_ci_height", 0); + switchPanelMode(_widescreen_mode); } }; @@ -547,36 +561,26 @@ function init_second_stage() { updateFeedList(); closeArticlePanel(); - _widescreen_mode = getInitParam("widescreen"); - switchPanelMode(_widescreen_mode); - if (parseInt(getCookie("ttrss_fh_width")) > 0) { dijit.byId("feeds-holder").domNode.setStyle( {width: getCookie("ttrss_fh_width") + "px" }); } - if (parseInt(getCookie("ttrss_ci_width")) > 0) { - if (_widescreen_mode) { - dijit.byId("content-insert").domNode.setStyle( - {width: getCookie("ttrss_ci_width") + "px" }); - - } else { - dijit.byId("content-insert").domNode.setStyle( - {height: getCookie("ttrss_ci_height") + "px" }); - } - } - dijit.byId("main").resize(); var tmph = dojo.connect(dijit.byId('feeds-holder'), 'resize', function (args) { - setCookie("ttrss_fh_width", args.w, getInitParam("cookie_lifetime")); + if (args && args.w >= 0) { + setCookie("ttrss_fh_width", args.w, getInitParam("cookie_lifetime")); + } }); var tmph = dojo.connect(dijit.byId('content-insert'), 'resize', function (args) { - setCookie("ttrss_ci_width", args.w, getInitParam("cookie_lifetime")); - setCookie("ttrss_ci_height", args.h, getInitParam("cookie_lifetime")); + if (args && args.w >= 0 && args.h >= 0) { + setCookie("ttrss_ci_width", args.w, getInitParam("cookie_lifetime")); + setCookie("ttrss_ci_height", args.h, getInitParam("cookie_lifetime")); + } }); }); @@ -617,6 +621,9 @@ function init_second_stage() { hotkeys[1] = tmp; setInitParam("hotkeys", hotkeys); + _widescreen_mode = getInitParam("widescreen"); + switchPanelMode(_widescreen_mode); + console.log("second stage ok"); if (getInitParam("simple_update")) { @@ -699,6 +706,10 @@ function quickMenuGo(opid) { if (!isCdmMode()) { _widescreen_mode = !_widescreen_mode; + // reset stored sizes because geometry changed + setCookie("ttrss_ci_width", 0); + setCookie("ttrss_ci_height", 0); + switchPanelMode(_widescreen_mode); } break; @@ -844,11 +855,16 @@ function hotkey_handler(e) { var keycode = false; var shift_key = false; + var ctrl_key = false; + var alt_key = false; + var meta_key = false; var cmdline = $('cmdline'); shift_key = e.shiftKey; ctrl_key = e.ctrlKey; + alt_key = e.altKey; + meta_key = e.metaKey; if (window.event) { keycode = window.event.keyCode; @@ -890,6 +906,8 @@ function hotkey_handler(e) { // ensure ^*char notation if (shift_key) hotkey = "*" + hotkey; if (ctrl_key) hotkey = "^" + hotkey; + if (alt_key) hotkey = "+" + hotkey; + if (meta_key) hotkey = "%" + hotkey; hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey; hotkey_prefix = false; @@ -975,6 +993,12 @@ function handle_rpc_json(transport, scheduled_call) { try { var reply = JSON.parse(transport.responseText); + var netalert_dijit = dijit.byId("net-alert"); + var netalert = false; + + if (netalert_dijit) + netalert = netalert_dijit.domNode; + if (reply) { var error = reply['error']; @@ -1021,16 +1045,21 @@ function handle_rpc_json(transport, scheduled_call) { if (runtime_info) parse_runtime_info(runtime_info); - Element.hide(dijit.byId("net-alert").domNode); + if (netalert) Element.hide(netalert); } else { - //notify_error("Error communicating with server."); - Element.show(dijit.byId("net-alert").domNode); + if (netalert) + Element.show(netalert); + else + notify_error("Communication problem with server."); } } catch (e) { - Element.show(dijit.byId("net-alert").domNode); - //notify_error("Error communicating with server."); + if (netalert) + Element.show(netalert); + else + notify_error("Communication problem with server."); + console.log(e); //exception_error("handle_rpc_json", e, transport); } @@ -1050,11 +1079,13 @@ function switchPanelMode(wide) { dijit.byId("content-insert").domNode.setStyle({width: '50%', height: 'auto', - borderLeftWidth: '1px', - borderLeftColor: '#c0c0c0', borderTopWidth: '0px' }); - $("headlines-toolbar").setStyle({ borderBottomWidth: '0px' }); + if (parseInt(getCookie("ttrss_ci_width")) > 0) { + dijit.byId("content-insert").domNode.setStyle( + {width: getCookie("ttrss_ci_width") + "px" }); + } + $("headlines-frame").setStyle({ borderBottomWidth: '0px' }); $("headlines-frame").addClassName("wide"); @@ -1064,10 +1095,12 @@ function switchPanelMode(wide) { dijit.byId("content-insert").domNode.setStyle({width: 'auto', height: '50%', - borderLeftWidth: '0px', - borderTopWidth: '1px'}); + borderTopWidth: '0px'}); - $("headlines-toolbar").setStyle({ borderBottomWidth: '1px' }); + if (parseInt(getCookie("ttrss_ci_height")) > 0) { + dijit.byId("content-insert").domNode.setStyle( + {height: getCookie("ttrss_ci_height") + "px" }); + } $("headlines-frame").setStyle({ borderBottomWidth: '1px' }); $("headlines-frame").removeClassName("wide"); diff --git a/js/viewfeed.js b/js/viewfeed.js index b7e321d73..c319a8ed0 100644 --- a/js/viewfeed.js +++ b/js/viewfeed.js @@ -87,8 +87,12 @@ function headlines_callback2(transport, offset, background, infscroll_req) { dijit.byId("headlines-frame").attr('content', reply['headlines']['content']); - dijit.byId("headlines-toolbar").attr('content', - reply['headlines']['toolbar']); + //dijit.byId("headlines-toolbar").attr('content', + // reply['headlines']['toolbar']); + + dojo.html.set($("headlines-toolbar"), + reply['headlines']['toolbar'], + {parseContent: true}); $$("#headlines-frame > div[id*=RROW]").each(function(row) { if (loaded_article_ids.indexOf(row.id) != -1) { @@ -104,6 +108,10 @@ function headlines_callback2(transport, offset, background, infscroll_req) { initHeadlinesMenu(); + if (_infscroll_disable) + hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" + + __("Click to open next unread feed.") + "</a>"; + if (_search_query) { $("feed_title").innerHTML += "<span id='cancel_search'>" + " (<a href='#' onclick='cancelSearch()'>" + __("Cancel search") + "</a>)" + @@ -143,9 +151,9 @@ function headlines_callback2(transport, offset, background, infscroll_req) { if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"}); - if (getInitParam("cdm_auto_catchup") == 1) { +// if (getInitParam("cdm_auto_catchup") == 1) { c.domNode.appendChild(hsp); - } +// } console.log("added " + new_elems.size() + " headlines"); @@ -172,7 +180,8 @@ function headlines_callback2(transport, offset, background, infscroll_req) { var hsp = $("headlines-spacer"); - if (hsp) hsp.innerHTML = ""; + if (hsp) hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" + + __("Click to open next unread feed.") + "</a>"; } } @@ -190,14 +199,11 @@ function headlines_callback2(transport, offset, background, infscroll_req) { else request_counters(true); - } else if (transport.responseText) { + } else { console.error("Invalid object received: " + transport.responseText); dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" + __('Could not update headlines (invalid object received - see error console for details)') + "</div>"); - } else { - //notify_error("Error communicating with server."); - Element.show(dijit.byId("net-alert").domNode); } _infscroll_request_sent = 0; @@ -314,13 +320,11 @@ function article_callback2(transport, id) { // return; // } - } else if (transport.responseText) { + } else { console.error("Invalid object received: " + transport.responseText); render_article("<div class='whiteBox'>" + __('Could not display article (invalid object received - see error console for details)') + "</div>"); - } else { - Element.show(dijit.byId("net-alert").domNode); } var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length @@ -835,6 +839,8 @@ function selectionToggleUnread(set_state, callback, no_error, ids) { } } + updateFloatingTitle(true); + if (rows.length > 0) { var cmode = ""; @@ -959,10 +965,12 @@ function getLoadedArticleIds() { } // mode = all,none,unread,invert,marked,published -function selectArticles(mode) { +function selectArticles(mode, query) { try { - var children = $$("#headlines-frame > div[id*=RROW]"); + if (!query) query = "#headlines-frame > div[id*=RROW]"; + + var children = $$(query); children.each(function(child) { var id = child.id.replace("RROW-", ""); @@ -1241,7 +1249,7 @@ function postMouseOut(id) { function unpackVisibleHeadlines() { try { - if (!isCdmMode()) return; + if (!isCdmMode() || !getInitParam("cdm_expanded")) return; $$("#headlines-frame > div[id*=RROW]").each( function(child) { @@ -1273,15 +1281,17 @@ function headlines_scroll_handler(e) { unpackVisibleHeadlines(); // set topmost child in the buffer as active - if (getInitParam("cdm_auto_catchup") == 1 && - (!isCdmMode() || getInitParam("cdm_expanded"))) { + if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 && + getSelectedArticleIds2().length <= 1 && + getInitParam("cdm_expanded")) { var rows = $$("#headlines-frame > div[id*=RROW]"); for (var i = 0; i < rows.length; i++) { var child = rows[i]; - if ($("headlines-frame").scrollTop < child.offsetTop && - child.offsetTop - $("headlines-frame").scrollTop < 100) { + if ($("headlines-frame").scrollTop <= child.offsetTop && + child.offsetTop - $("headlines-frame").scrollTop < 100 && + child.id.replace("RROW-", "") != _active_article_id) { if (_active_article_id) { var row = $("RROW-" + _active_article_id); @@ -1302,18 +1312,23 @@ function headlines_scroll_handler(e) { ((e.scrollTop + e.offsetHeight) / e.scrollHeight >= 0.7))) { if (hsp) - hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " + - __("Loading, please wait..."); + hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " + + __("Loading, please wait...") + "</span>"; loadMoreHeadlines(); return; } } else { - if (hsp) hsp.innerHTML = ""; + if (hsp) + if (_infscroll_disable) + hsp.innerHTML = "<a href='#' onclick='openNextUnreadFeed()'>" + + __("Click to open next unread feed.") + "</a>"; + else + hsp.innerHTML = ""; } - if (getInitParam("cdm_expanded") && isCdmMode()) { + if (isCdmMode()) { updateFloatingTitle(); } @@ -1346,6 +1361,20 @@ function headlines_scroll_handler(e) { 500); } } + + if (_infscroll_disable) { + var child = $$("#headlines-frame div[id*=RROW]").last(); + + if (child && $("headlines-frame").scrollTop > + (child.offsetTop + child.offsetHeight - 50)) { + + console.log("we seem to be at an end"); + + if (getInitParam("on_catchup_show_next_feed") == "1") { + openNextUnreadFeed(); + } + } + } } } catch (e) { @@ -1353,6 +1382,16 @@ function headlines_scroll_handler(e) { } } +function openNextUnreadFeed() { + try { + var is_cat = activeFeedIsCat(); + var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat); + if (nuf) viewfeed(nuf, '', is_cat); + } catch (e) { + exception_error("openNextUnreadFeed", e); + } +} + function catchupBatchedArticles() { try { if (catchup_id_batch.length > 0 && !_infscroll_request_sent) { @@ -1379,6 +1418,8 @@ function catchupBatchedArticles() { catchup_id_batch.remove(id); }); + updateFloatingTitle(true); + } }); } @@ -1487,6 +1528,12 @@ function cdmCollapseArticle(event, id, unmark) { if (event) Event.stop(event); PluginHost.run(PluginHost.HOOK_ARTICLE_COLLAPSED, id); + + if (row.offsetTop < $("headlines-frame").scrollTop) + scrollToRowId(row.id); + + Element.hide("floatingTitle"); + $("floatingTitle").setAttribute("rowid", false); } } catch (e) { @@ -1591,9 +1638,9 @@ function show_labels_in_headlines(transport) { if (data) { data['info-for-headlines'].each(function(elem) { - var ctr = $("HLLCTR-" + elem.id); - - if (ctr) ctr.innerHTML = elem.labels; + $$(".HLLCTR-" + elem.id).each(function(ctr) { + ctr.innerHTML = elem.labels; + }); }); } } catch (e) { @@ -1611,6 +1658,12 @@ function dismissArticle(id) { new Effect.Fade(elem, {duration : 0.5}); + // Remove the content, too + var elem_content = $("CICD-" + id); + if (elem_content) { + Element.remove(elem_content); + } + if (id == getActiveArticleId()) { setActiveArticleId(0); } @@ -1634,6 +1687,12 @@ function dismissSelectedArticles() { ids[i] != getActiveArticleId()) { new Effect.Fade(elem, {duration : 0.5}); sel.push(ids[i]); + + // Remove the content, too + var elem_content = $("CICD-" + ids[i]); + if (elem_content) { + Element.remove(elem_content); + } } else { tmp.push(ids[i]); } @@ -1661,13 +1720,19 @@ function dismissReadArticles() { !elem.hasClassName("Selected")) { new Effect.Fade(elem, {duration : 0.5}); + + // Remove the content, too + var elem_content = $("CICD-" + ids[i]); + if (elem_content) { + Element.remove(elem_content); + } } else { tmp.push(ids[i]); } } } catch (e) { - exception_error("dismissSelectedArticles", e); + exception_error("dismissReadArticles", e); } } @@ -1716,6 +1781,7 @@ function cdmClicked(event, id) { if (article_is_unread) { decrementFeedCounter(getActiveFeedId(), activeFeedIsCat()); + updateFloatingTitle(true); } var query = "?op=rpc&method=catchupSelected" + @@ -1730,7 +1796,8 @@ function cdmClicked(event, id) { return !event.shiftKey; } - } else { + } else if (event.target.parents(".cdmHeader").length > 0) { + toggleSelected(id, true); var elem = $("RROW-" + id); @@ -1890,58 +1957,39 @@ function closeArticlePanel() { dijit.byId("content-insert")); } -function initHeadlinesMenu() { +function initFloatingMenu() { try { - if (dijit.byId("headlinesMenu")) - dijit.byId("headlinesMenu").destroyRecursive(); - - var ids = []; - - if (!isCdmMode()) { - nodes = $$("#headlines-frame > div[id*=RROW]"); - } else { - nodes = $$("#headlines-frame span[id*=RTITLE]"); - } + if (dijit.byId("floatingMenu")) + dijit.byId("floatingMenu").destroyRecursive(); - nodes.each(function(node) { - ids.push(node.id); - }); - - var menu = new dijit.Menu({ - id: "headlinesMenu", - targetNodeIds: ids, - }); + var menu = new dijit.Menu({ + id: "floatingMenu", + targetNodeIds: ["floatingTitle"] + }); - var tmph = dojo.connect(menu, '_openMyself', function (event) { - var callerNode = event.target, match = null, tries = 0; + var id = $("floatingTitle").getAttribute("rowid").replace("RROW-", ""); - while (match == null && callerNode && tries <= 3) { - match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$"); - callerNode = callerNode.parentNode; - ++tries; - } + headlinesMenuCommon(menu, id); - if (match) this.callerRowId = parseInt(match[1]); - - }); + menu.startup(); + } catch (e) { + exception_error("initFloatingMenu", e); + } +} -/* if (!isCdmMode()) - menu.addChild(new dijit.MenuItem({ - label: __("View article"), - onClick: function(event) { - view(this.getParent().callerRowId); - }})); */ +function headlinesMenuCommon(menu, base_id) { + try { menu.addChild(new dijit.MenuItem({ label: __("Open original article"), onClick: function(event) { - openArticleInNewWindow(this.getParent().callerRowId); + openArticleInNewWindow(base_id ? base_id : this.getParent().callerRowId); }})); menu.addChild(new dijit.MenuItem({ label: __("Display article URL"), onClick: function(event) { - displayArticleUrl(this.getParent().callerRowId); + displayArticleUrl(base_id ? base_id : this.getParent().callerRowId); }})); menu.addChild(new dijit.MenuSeparator()); @@ -1951,7 +1999,7 @@ function initHeadlinesMenu() { onClick: function(event) { var ids = getSelectedArticleIds2(); // cast to string - var id = this.getParent().callerRowId + ""; + var id = (base_id ? base_id : this.getParent().callerRowId) + ""; ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionToggleUnread(undefined, false, true, ids); @@ -1962,7 +2010,7 @@ function initHeadlinesMenu() { onClick: function(event) { var ids = getSelectedArticleIds2(); // cast to string - var id = this.getParent().callerRowId + ""; + var id = (base_id ? base_id : this.getParent().callerRowId) + ""; ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionToggleMarked(undefined, false, true, ids); @@ -1973,7 +2021,7 @@ function initHeadlinesMenu() { onClick: function(event) { var ids = getSelectedArticleIds2(); // cast to string - var id = this.getParent().callerRowId + ""; + var id = (base_id ? base_id : this.getParent().callerRowId) + ""; ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; selectionTogglePublished(undefined, false, true, ids); @@ -1984,13 +2032,13 @@ function initHeadlinesMenu() { menu.addChild(new dijit.MenuItem({ label: __("Mark above as read"), onClick: function(event) { - catchupRelativeToArticle(0, this.getParent().callerRowId); + catchupRelativeToArticle(0, base_id ? base_id : this.getParent().callerRowId); }})); menu.addChild(new dijit.MenuItem({ label: __("Mark below as read"), onClick: function(event) { - catchupRelativeToArticle(1, this.getParent().callerRowId); + catchupRelativeToArticle(1, base_id ? base_id : this.getParent().callerRowId); }})); @@ -2016,7 +2064,7 @@ function initHeadlinesMenu() { onClick: function(event) { var ids = getSelectedArticleIds2(); // cast to string - var id = this.getParent().ownerMenu.callerRowId + ""; + var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + ""; ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; @@ -2029,7 +2077,7 @@ function initHeadlinesMenu() { onClick: function(event) { var ids = getSelectedArticleIds2(); // cast to string - var id = this.getParent().ownerMenu.callerRowId + ""; + var id = (base_id ? base_id : this.getParent().ownerMenu.callerRowId) + ""; ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id]; @@ -2050,8 +2098,117 @@ function initHeadlinesMenu() { } + + } catch (e) { + exception_error("headlinesMenuCommon", e); + } +} + +function initHeadlinesMenu() { + try { + if (dijit.byId("headlinesMenu")) + dijit.byId("headlinesMenu").destroyRecursive(); + + var ids = []; + + if (!isCdmMode()) { + nodes = $$("#headlines-frame > div[id*=RROW]"); + } else { + nodes = $$("#headlines-frame span[id*=RTITLE]"); + } + + nodes.each(function(node) { + ids.push(node.id); + }); + + var menu = new dijit.Menu({ + id: "headlinesMenu", + targetNodeIds: ids, + }); + + var tmph = dojo.connect(menu, '_openMyself', function (event) { + var callerNode = event.target, match = null, tries = 0; + + while (match == null && callerNode && tries <= 3) { + match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$"); + callerNode = callerNode.parentNode; + ++tries; + } + + if (match) this.callerRowId = parseInt(match[1]); + + }); + + headlinesMenuCommon(menu, false); + menu.startup(); + /* vgroup feed title menu */ + + var nodes = $$("#headlines-frame > div[class='cdmFeedTitle']"); + var ids = []; + + nodes.each(function(node) { + ids.push(node.id); + }); + + if (ids.length > 0) { + if (dijit.byId("headlinesFeedTitleMenu")) + dijit.byId("headlinesFeedTitleMenu").destroyRecursive(); + + var menu = new dijit.Menu({ + id: "headlinesFeedTitleMenu", + targetNodeIds: ids, + }); + + var tmph = dojo.connect(menu, '_openMyself', function (event) { + var callerNode = event.target, match = null, tries = 0; + + while (match == null && callerNode && tries <= 3) { + console.log(callerNode.id); + + match = callerNode.id.match("^[A-Z]+[-]([0-9]+)$"); + callerNode = callerNode.parentNode; + ++tries; + + console.log(match[1]); + } + + if (match) this.callerRowId = parseInt(match[1]); + + }); + + menu.addChild(new dijit.MenuItem({ + label: __("Select articles in group"), + onClick: function(event) { + selectArticles("all", + "#headlines-frame > div[id*=RROW]"+ + "[orig-feed-id='"+menu.callerRowId+"']"); + + }})); + + menu.addChild(new dijit.MenuItem({ + label: __("Mark group as read"), + onClick: function(event) { + selectArticles("none"); + selectArticles("all", + "#headlines-frame > div[id*=RROW]"+ + "[orig-feed-id='"+menu.callerRowId+"']"); + + catchupSelection(); + }})); + + + menu.addChild(new dijit.MenuItem({ + label: __("Mark feed as read"), + onClick: function(event) { + catchupFeedInGroup(menu.callerRowId); + }})); + + menu.startup(); + + } + } catch (e) { exception_error("initHeadlinesMenu", e); } @@ -2195,33 +2352,67 @@ function openSelectedAttachment(elem) { } } -function updateFloatingTitle() { +function scrollToRowId(id) { try { + var row = $(id); + + if (row) + $("headlines-frame").scrollTop = row.offsetTop; + + } catch (e) { + exception_error("scrollToRowId", e); + } +} + +function updateFloatingTitle(unread_only) { + try { + if (!isCdmMode()) return; + var hf = $("headlines-frame"); var elems = $$("#headlines-frame > div[id*=RROW]"); for (var i = 0; i < elems.length; i++) { + var child = elems[i]; - if (child.offsetTop + child.offsetHeight > hf.scrollTop) { + if (child && child.offsetTop + child.offsetHeight > hf.scrollTop) { var header = child.getElementsByClassName("cdmHeader")[0]; - if (child.id != $("floatingTitle").getAttribute("rowid")) { - $("floatingTitle").setAttribute("rowid", child.id); - $("floatingTitle").innerHTML = header.innerHTML; + if (unread_only || child.id != $("floatingTitle").getAttribute("rowid")) { + if (child.id != $("floatingTitle").getAttribute("rowid")) { + $("floatingTitle").setAttribute("rowid", child.id); + $("floatingTitle").innerHTML = header.innerHTML; + $("floatingTitle").firstChild.innerHTML = "<img class='anchor markedPic' src='images/page_white_go.png' onclick=\"scrollToRowId('"+child.id+"')\">" + $("floatingTitle").firstChild.innerHTML; + + initFloatingMenu(); + + var cb = $$("#floatingTitle .dijitCheckBox")[0]; + + if (cb) + cb.parentNode.removeChild(cb); + } + + if (child.hasClassName("Unread")) + $("floatingTitle").addClassName("Unread"); + else + $("floatingTitle").removeClassName("Unread"); + + PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child); } - if (child.offsetTop < hf.scrollTop - header.offsetHeight - 100 && - child.offsetTop + child.offsetHeight - hf.scrollTop > 100) + if (child.offsetTop < hf.scrollTop - header.offsetHeight && + child.offsetTop + child.offsetHeight - hf.scrollTop > header.offsetHeight) Element.show("floatingTitle"); else Element.hide("floatingTitle"); - break; + return; + } } + } catch (e) { exception_error("updateFloatingTitle", e); } |