support headlines context menu in floating title

master
Andrew Dolgov 11 years ago
parent abb04b76a5
commit 65f0eb01aa

@ -316,7 +316,7 @@ class Feeds extends Handler_Protected {
if (!is_array($labels)) $labels = get_article_labels($id);
$labels_str = "<span id=\"HLLCTR-$id\">";
$labels_str = "<span class=\"HLLCTR-$id\">";
$labels_str .= format_article_labels($labels, $id);
$labels_str .= "</span>";

@ -1599,9 +1599,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) {
@ -1916,58 +1916,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]");
}
nodes.each(function(node) {
ids.push(node.id);
});
if (dijit.byId("floatingMenu"))
dijit.byId("floatingMenu").destroyRecursive();
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());
@ -1977,7 +1958,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);
@ -1988,7 +1969,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);
@ -1999,7 +1980,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);
@ -2010,13 +1991,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);
}}));
@ -2042,7 +2023,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];
@ -2055,7 +2036,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];
@ -2076,6 +2057,49 @@ 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();
} catch (e) {
@ -2252,6 +2276,8 @@ function updateFloatingTitle() {
$("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();
PluginHost.run(PluginHost.HOOK_FLOATING_TITLE, child);
}

Loading…
Cancel
Save