mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-14 06:15:54 +00:00
rework headlines menu and openArticleInNewWindow()
This commit is contained in:
17
backend.php
17
backend.php
@@ -201,6 +201,23 @@
|
|||||||
|
|
||||||
break; // feeds
|
break; // feeds
|
||||||
|
|
||||||
|
case "la":
|
||||||
|
$id = db_escape_string($_REQUEST['id']);
|
||||||
|
|
||||||
|
$result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries
|
||||||
|
WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'");
|
||||||
|
|
||||||
|
if (db_num_rows($result) == 1) {
|
||||||
|
$article_url = db_fetch_result($result, 0, 'link');
|
||||||
|
|
||||||
|
header("Location: $article_url");
|
||||||
|
return;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
print_error(__("Article not found."));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "view":
|
case "view":
|
||||||
|
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
$id = db_escape_string($_REQUEST["id"]);
|
||||||
|
|||||||
@@ -4127,9 +4127,8 @@
|
|||||||
"</option>";
|
"</option>";
|
||||||
|
|
||||||
# print "<optgroup label=\"".__("Assign label:")."\">";
|
# print "<optgroup label=\"".__("Assign label:")."\">";
|
||||||
print "<option>----------</option>";
|
//print "<option>----------</option>";
|
||||||
|
//print_labels_headlines_dropdown($link, $feed_id);
|
||||||
print_labels_headlines_dropdown($link, $feed_id);
|
|
||||||
|
|
||||||
print "<option>----------</option>";
|
print "<option>----------</option>";
|
||||||
|
|
||||||
@@ -5048,17 +5047,6 @@
|
|||||||
|
|
||||||
print "<div class='$class' id='RROW-$id' $mouseover_attrs>";
|
print "<div class='$class' id='RROW-$id' $mouseover_attrs>";
|
||||||
|
|
||||||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\"
|
|
||||||
targetNodeIds=\"RROW-$id\">";
|
|
||||||
print "<div onclick=\"view($id)\"
|
|
||||||
dojoType=\"dijit.MenuItem\">".__('View article')."</div>";
|
|
||||||
print "<div onclick=\"hlOpenInNewTab(event, $id)\"
|
|
||||||
dojoType=\"dijit.MenuItem\">".__('View in a new tab')."</div>";
|
|
||||||
print "<div dojoType=\"dijit.MenuSeparator\"></div>";
|
|
||||||
print "<div onclick=\"openArticleInNewWindow($id)\"
|
|
||||||
dojoType=\"dijit.MenuItem\">".__('Open original article')."</div>";
|
|
||||||
print "</div>";
|
|
||||||
|
|
||||||
print "<div class='hlUpdPic'>$update_pic</div>";
|
print "<div class='hlUpdPic'>$update_pic</div>";
|
||||||
|
|
||||||
print "<div class='hlLeft'>";
|
print "<div class='hlLeft'>";
|
||||||
|
|||||||
@@ -380,23 +380,6 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($subop == "getArticleLink") {
|
|
||||||
|
|
||||||
$id = db_escape_string($_REQUEST["id"]);
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT link FROM ttrss_entries, ttrss_user_entries
|
|
||||||
WHERE id = '$id' AND id = ref_id AND owner_uid = '".$_SESSION['uid']."'");
|
|
||||||
|
|
||||||
if (db_num_rows($result) == 1) {
|
|
||||||
$link = htmlspecialchars(strip_tags(db_fetch_result($result, 0, "link")));
|
|
||||||
print "<rpc-reply><link>$link</link><id>$id</id></rpc-reply>";
|
|
||||||
} else {
|
|
||||||
print "<rpc-reply><error>Article not found</error></rpc-reply>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($subop == "setArticleTags") {
|
if ($subop == "setArticleTags") {
|
||||||
|
|
||||||
global $memcache;
|
global $memcache;
|
||||||
|
|||||||
104
viewfeed.js
104
viewfeed.js
@@ -104,6 +104,8 @@ function headlines_callback2(transport, feed_cur_page) {
|
|||||||
dijit.byId("headlines-toolbar").attr('content',
|
dijit.byId("headlines-toolbar").attr('content',
|
||||||
headlines_toolbar.firstChild.nodeValue);
|
headlines_toolbar.firstChild.nodeValue);
|
||||||
|
|
||||||
|
initHeadlinesMenu();
|
||||||
|
|
||||||
var cache_prefix = "";
|
var cache_prefix = "";
|
||||||
|
|
||||||
if (is_cat) {
|
if (is_cat) {
|
||||||
@@ -143,6 +145,8 @@ function headlines_callback2(transport, feed_cur_page) {
|
|||||||
markHeadline(ids[i]);
|
markHeadline(ids[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initHeadlinesMenu();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("no new headlines received");
|
console.log("no new headlines received");
|
||||||
}
|
}
|
||||||
@@ -2113,49 +2117,8 @@ function getLastVisibleHeadlineId() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function openArticleInNewWindow(id) {
|
function openArticleInNewWindow(id) {
|
||||||
try {
|
toggleUnread(id, 0, false);
|
||||||
console.log("openArticleInNewWindow: " + id);
|
window.open("backend.php?op=la&id=" + 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCdmMode() {
|
function isCdmMode() {
|
||||||
@@ -2256,3 +2219,58 @@ function closeArticlePanel() {
|
|||||||
dijit.byId("content-insert"));
|
dijit.byId("content-insert"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initHeadlinesMenu() {
|
||||||
|
try {
|
||||||
|
if (dijit.byId("headlinesMenu"))
|
||||||
|
dijit.byId("headlinesMenu").destroyRecursive();
|
||||||
|
|
||||||
|
var ids = [];
|
||||||
|
var nodes = $$("#headlines-frame > div[id*=RROW]");
|
||||||
|
|
||||||
|
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]);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
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.MenuItem({
|
||||||
|
label: __("Open original article"),
|
||||||
|
onClick: function(event) {
|
||||||
|
openArticleInNewWindow(this.getParent().callerRowId);
|
||||||
|
}}));
|
||||||
|
|
||||||
|
menu.startup();
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("initHeadlinesMenu", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user