if (!handle_rpc_reply(transport)) return;
- loading_set_progress(100);
+ loading_set_progress(25);
console.log("headlines_callback2 [page=" + feed_cur_page + "]");
if (feed_cur_page == 0) {
if (headlines) {
- $("headlinesInnerContainer").innerHTML = headlines_content.firstChild.nodeValue;
- $("headlines-toolbar").innerHTML = headlines_toolbar.firstChild.nodeValue;
+ dijit.byId("headlines-frame").attr('content',
+ headlines_content.firstChild.nodeValue);
- dojo.parser.parse("headlines-toolbar");
- //dijit.byId("main").resize();
+ dijit.byId("headlines-toolbar").attr('content',
+ headlines_toolbar.firstChild.nodeValue);
+
+ initHeadlinesMenu();
var cache_prefix = "";
} else {
console.warn("headlines_callback: returned no data");
- $('headlinesInnerContainer').innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+ dijit.byId("headlines-frame").attr('content',
+ "<div class='whiteBox'>" +
+ __('Could not update headlines (missing XML data)') + "</div>");
}
} else {
if (headlines) {
if (headlines_count > 0) {
console.log("adding some more headlines...");
-
- c = $("headlinesInnerContainer");
+ var c = dijit.byId("headlines-frame");
var ids = getSelectedArticleIds2();
- c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
+ c.attr('content', c.attr('content') +
+ headlines_content.firstChild.nodeValue);
console.log("restore selected ids: " + ids);
markHeadline(ids[i]);
}
+ initHeadlinesMenu();
+
} else {
console.log("no new headlines received");
}
} else {
console.warn("headlines_callback: returned no XML object");
- $('headlinesInnerContainer').innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
+ dijit.byId("headlines-frame").attr('content', "<div class='whiteBox'>" +
+ __('Could not update headlines (missing XML object)') + "</div>");
}
notify("");
- remove_splash();
-
} catch (e) {
exception_error("headlines_callback2", e, transport);
}
function render_article(article) {
try {
- var f = $("content-frame");
- try {
- f.scrollTop = 0;
- } catch (e) { };
-
dijit.byId("headlines-wrap-inner").addChild(
dijit.byId("content-insert"));
- var fi = $("content-insert");
+ var c = dijit.byId("content-insert");
try {
- fi.scrollTop = 0;
+ c.domNode.scrollTop = 0;
} catch (e) { };
- fi.innerHTML = article;
-
-// article.evalScripts();
+ c.attr('content', article);
+
+ correctHeadlinesOffset(getActiveArticleId());
} catch (e) {
exception_error("render_article", e);
cache_inject(cache_prefix + getActiveFeedId(),
$("headlines-frame").innerHTML,
- get_feed_unread(getActiveFeedId()));
+ getFeedUnread(getActiveFeedId()));
} else if (article_is_unread && view_mode == "all_articles") {
cache_inject(cache_prefix + getActiveFeedId(),
$("headlines-frame").innerHTML,
- get_feed_unread(getActiveFeedId())-1);
+ getFeedUnread(getActiveFeedId())-1);
} else if (article_is_unread) {
cache_invalidate(cache_prefix + getActiveFeedId());
}
}
-function selectionRemoveLabel(id) {
+function selectionRemoveLabel(id, ids) {
try {
- var ids = getSelectedArticleIds2();
+ if (!ids) var ids = getSelectedArticleIds2();
if (ids.length == 0) {
alert(__("No articles are selected."));
}
}
-function selectionAssignLabel(id) {
+function selectionAssignLabel(id, ids) {
try {
- var ids = getSelectedArticleIds2();
+ if (!ids) ids = getSelectedArticleIds2();
if (ids.length == 0) {
alert(__("No articles are selected."));
var rv = [];
- $$("#headlinesInnerContainer > div[id*=RROW][class*=Selected]").each(
+ $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
function(child) {
rv.push(child.id.replace("RROW-", ""));
});
function getLoadedArticleIds() {
var rv = [];
- var children = $$("#headlinesInnerContainer > div[id*=RROW-]");
+ var children = $$("#headlines-frame > div[id*=RROW-]");
children.each(function(child) {
rv.push(child.id.replace("RROW-", ""));
function selectArticles(mode) {
try {
- var children = $$("#headlinesInnerContainer > div[id*=RROW]");
+ var children = $$("#headlines-frame > div[id*=RROW]");
children.each(function(child) {
var id = child.id.replace("RROW-", "");
try {
- var ctr = $("headlinesInnerContainer");
+ var ctr = $("headlines-frame");
if (!ctr) return;
}
}
-function headlines_scroll_handler() {
+function headlines_scroll_handler(e) {
try {
- var e = $("headlinesInnerContainer");
-
- var toolbar_form = document.forms["main_toolbar_form"];
-
-// console.log((e.scrollTop + e.offsetHeight) + " vs " + e.scrollHeight + " dis? " +
-// _infscroll_disable);
-
if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
if (!_infscroll_disable) {
viewNextFeedPage();
function zoomToArticle(event, id) {
try {
- /* var w = window.open("backend.php?op=view&mode=zoom&id=" + param_escape(id),
- "ttrss_zoom_" + id,
- "status=0,toolbar=0,location=0,width=450,height=300,scrollbars=1,menubar=0"); */
-
var cached_article = cache_find(id);
if (dijit.byId("ATAB-" + id))
return dijit.byId("content-tabs").selectChild(dijit.byId("ATAB-" + id));
if (cached_article) {
-
+ //closeArticlePanel();
+
var article_pane = new dijit.layout.ContentPane({
title: __("Loading...") , content: cached_article,
style: 'padding : 0px;',
notify('');
if (transport.responseXML) {
- closeArticlePanel();
+ //closeArticlePanel();
var article = transport.responseXML.getElementsByTagName("article")[0];
var content = article.firstChild.nodeValue;
ci.scrollTop += offset;
}
} else {
- var hi = $("headlinesInnerContainer");
+ var hi = $("headlines-frame");
if (hi) {
hi.scrollTop += offset;
}
id = ids.toString();
}
- displayDlg('emailArticle', id,
- function () {
- document.forms['article_email_form'].destination.focus();
+ if (dijit.byId("emailArticleDlg"))
+ dijit.byId("emailArticleDlg").destroyRecursive();
- new Ajax.Autocompleter('destination', 'destination_choices',
- "backend.php?op=rpc&subop=completeEmails",
- { tokens: '', paramName: "search" });
-
- });
+ var query = "backend.php?op=dlg&id=emailArticle¶m=" + param_escape(id);
- } catch (e) {
- exception_error("emailArticle", e);
- }
-}
-
-function emailArticleDo() {
- try {
- var f = document.forms['article_email_form'];
-
- if (f.destination.value == "") {
- alert("Please fill in the destination email.");
- return;
- }
-
- if (f.subject.value == "") {
- alert("Please fill in the subject.");
- return;
- }
+ dialog = new dijit.Dialog({
+ id: "emailArticleDlg",
+ title: __("Forward article by email"),
+ style: "width: 600px",
+ execute: function() {
+ if (this.validate()) {
- var query = Form.serialize("article_email_form");
+ new Ajax.Request("backend.php", {
+ parameters: dojo.objectToQuery(this.attr('value')),
+ onComplete: function(transport) {
+
+ var error = transport.responseXML.getElementsByTagName('error')[0];
+
+ if (error) {
+ alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
+ } else {
+ notify_info('Your message has been sent.');
+ dialog.hide();
+ }
+
+ } });
+ }
+ },
+ href: query});
-// console.log(query);
+ var tmph = dojo.connect(dialog, 'onLoad', function() {
+ dojo.disconnect(tmph);
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- try {
+ new Ajax.Autocompleter('emailArticleDlg_destination', 'emailArticleDlg_dst_choices',
+ "backend.php?op=rpc&subop=completeEmails",
+ { tokens: '', paramName: "search" });
+ });
- var error = transport.responseXML.getElementsByTagName('error')[0];
+ dialog.show();
- if (error) {
- alert(__('Error sending email:') + ' ' + error.firstChild.nodeValue);
- } else {
- notify_info('Your message has been sent.');
- closeInfoBox();
- }
+ /* displayDlg('emailArticle', id,
+ function () {
+ document.forms['article_email_form'].destination.focus();
- } catch (e) {
- exception_error("sendEmailDo", e);
- }
+ new Ajax.Autocompleter('destination', 'destination_choices',
+ "backend.php?op=rpc&subop=completeEmails",
+ { tokens: '', paramName: "search" });
- } });
+ }); */
} catch (e) {
- exception_error("emailArticleDo", e);
+ exception_error("emailArticle", e);
}
}
return false;
}
+function postClicked(event, id) {
+ try {
+
+ if (!event.ctrlKey) {
+ return true;
+ } else {
+ postOpenInNewTab(event, id);
+ return false;
+ }
+
+ } catch (e) {
+ exception_error("postClicked");
+ }
+}
+
+function hlOpenInNewTab(event, id) {
+ toggleUnread(id, 0, false);
+ zoomToArticle(event, id);
+}
+
+function postOpenInNewTab(event, id) {
+ closeArticlePanel(id);
+ zoomToArticle(event, id);
+}
+
function hlClicked(event, id) {
try {
view(id);
return true;
} else {
- selectArticles('none');
toggleSelected(id);
toggleUnread(id, 0, false);
zoomToArticle(event, id);
} catch (e) {
exception_error("hlClicked");
}
-
- return false;
}
function getFirstVisibleHeadlineId() {
}
function openArticleInNewWindow(id) {
- try {
- console.log("openArticleInNewWindow: " + id);
-
- var query = "?op=rpc&subop=getArticleLink&id=" + id;
- var wname = "ttrss_article_" + id;
-
- console.log(query + " " + wname);
-
- var w = window.open("", wname);
-
- if (!w) notify_error("Failed to open window for the article");
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
-
- var link = transport.responseXML.getElementsByTagName("link")[0];
- var id = transport.responseXML.getElementsByTagName("id")[0];
-
- console.log("open_article received link: " + link);
-
- if (link && id) {
-
- var wname = "ttrss_article_" + id.firstChild.nodeValue;
-
- console.log("link url: " + link.firstChild.nodeValue + ", wname " + wname);
-
- var w = window.open(link.firstChild.nodeValue, wname);
-
- if (!w) { notify_error("Failed to load article in new window"); }
-
- if (id) {
- id = id.firstChild.nodeValue;
- window.setTimeout("toggleUnread(" + id + ", 0)", 100);
- }
- } else {
- notify_error("Can't open article: received invalid article link");
- }
- } });
-
- } catch (e) {
- exception_error("openArticleInNewWindow", e);
- }
+ toggleUnread(id, 0, false);
+ window.open("backend.php?op=la&id=" + id);
}
function isCdmMode() {
function headlineActionsChange(elem) {
try {
- var op = elem[elem.selectedIndex].value;
-
- eval(op);
-
+ eval(elem.value);
elem.selectedIndex = 0;
-
} catch (e) {
exception_error("headlineActionsChange", e);
}
dijit.byId("headlines-wrap-inner").removeChild(
dijit.byId("content-insert"));
}
+}
+function initHeadlinesMenu() {
+ try {
+ if (dijit.byId("headlinesMenu"))
+ dijit.byId("headlinesMenu").destroyRecursive();
-/* if (id)
- if (dijit.byId("ATAB-" + id))
- return dijit.byId("content-tabs").removeChild(dijit.byId("ATAB-" + id));
+ 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]);
+
+ });
- if (dijit.byId("content-insert"))
- dijit.byId("headlines-wrap-inner").removeChild(
- dijit.byId("content-insert")); */
+ if (!isCdmMode())
+ menu.addChild(new dijit.MenuItem({
+ label: __("View article"),
+ onClick: function(event) {
+ view(this.getParent().callerRowId);
+ }}));
+
+ menu.addChild(new dijit.MenuItem({
+ label: __("View in a new tab"),
+ onClick: function(event) {
+ hlOpenInNewTab(event, this.getParent().callerRowId);
+ }}));
+
+ menu.addChild(new dijit.MenuSeparator());
+
+ menu.addChild(new dijit.MenuItem({
+ label: __("Open original article"),
+ onClick: function(event) {
+ openArticleInNewWindow(this.getParent().callerRowId);
+ }}));
+
+ var labels = dijit.byId("feedTree").model.getItemsInCategory(-2);
+
+ if (labels) {
+
+ menu.addChild(new dijit.MenuSeparator());
+
+ var labelsMenu = new dijit.Menu({ownerMenu: menu});
+
+ labels.each(function(label) {
+ var id = label.id[0];
+ var bare_id = id.substr(id.indexOf(":")+1);
+ var name = label.name[0];
+
+ bare_id = -11-bare_id;
+
+ labelsMenu.addChild(new dijit.MenuItem({
+ label: name,
+ labelId: bare_id,
+ onClick: function(event) {
+ //console.log(this.labelId);
+ //console.log(this.getParent().ownerMenu.callerRowId);
+ selectionAssignLabel(this.labelId,
+ [this.getParent().ownerMenu.callerRowId]);
+ }}));
+ });
+
+ menu.addChild(new dijit.PopupMenuItem({
+ label: __("Labels"),
+ popup: labelsMenu,
+ }));
+ }
+
+ menu.startup();
+
+ } catch (e) {
+ exception_error("initHeadlinesMenu", e);
+ }
}