migrate tt-rss.js contents to App

This commit is contained in:
Andrew Dolgov 2018-12-01 21:51:00 +03:00
parent ab0fadf60d
commit cc26be0793
8 changed files with 654 additions and 678 deletions

View File

@ -190,7 +190,7 @@ class Dlg extends Handler_Protected {
print_warning(__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication)."));
print "<div align='center'>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"gotoPreferences()\">".
print "<button dojoType=\"dijit.form.Button\" onclick=\"document.location.href = 'prefs.php'\">".
__('Open Preferences')."</button> ";
print "<button dojoType=\"dijit.form.Button\"
onclick=\"return closeInfoBox()\">".

View File

@ -95,7 +95,7 @@ class Feeds extends Handler_Protected {
$reply .= "</span> "; */
$reply .= "<select dojoType=\"dijit.form.Select\"
onchange=\"headlineActionsChange(this)\">";
onchange=\"Headlines.onActionChanged(this)\">";
$reply .= "<option value=\"0\" disabled='1'>".__('Select...')."</option>";
@ -299,7 +299,7 @@ class Feeds extends Handler_Protected {
$label_cache = $line["label_cache"];
$labels = false;
$mouseover_attrs = "onmouseover='postMouseIn(event, $id)' onmouseout='postMouseOut($id)'";
$mouseover_attrs = "onmouseover='Article.mouseIn($id)' onmouseout='Article.mouseOut($id)'";
if ($label_cache) {
$label_cache = json_decode($label_cache, true);

View File

@ -240,18 +240,18 @@
<div dojoType="dijit.form.DropDownButton">
<span><?php echo __('Actions...') ?></span>
<div dojoType="dijit.Menu" style="display: none">
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcPrefs')"><?php echo __('Preferences...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcSearch')"><?php echo __('Search...') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcPrefs')"><?php echo __('Preferences...') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcSearch')"><?php echo __('Search...') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
<div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
<?php
foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
@ -260,7 +260,7 @@
?>
<?php if (!$_SESSION["hide_logout"]) { ?>
<div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout') ?></div>
<div dojoType="dijit.MenuItem" onclick="App.onActionSelected('qmcLogout')"><?php echo __('Logout') ?></div>
<?php } ?>
</div>
</div>

View File

@ -6,6 +6,7 @@ const Feeds = {
infscroll_disabled: 0,
_infscroll_timeout: false,
_search_query: false,
last_search_query: [],
_viewfeed_wait_timeout: false,
_counters_prev: [],
// NOTE: this implementation is incomplete
@ -206,7 +207,7 @@ const Feeds = {
Utils.setLoadingProgress(50);
document.onkeydown = App.hotkeyHandler;
document.onkeydown = () => { App.hotkeyHandler(event) };
window.setInterval(() => { hotkeyPrefixTimeout() }, 3 * 1000);
window.setInterval(() => { Headlines.catchupBatchedArticles() }, 10 * 1000);
@ -436,7 +437,7 @@ const Feeds = {
str = __("Mark %w in %s as read?");
}
const mark_what = last_search_query && last_search_query[0] ? __("search results") : __("all articles");
const mark_what = this.last_search_query && this.last_search_query[0] ? __("search results") : __("all articles");
const fn = this.getFeedName(feed, is_cat);
str = str.replace("%s", fn)
@ -448,8 +449,8 @@ const Feeds = {
const catchup_query = {
op: 'rpc', method: 'catchupFeed', feed_id: feed,
is_cat: is_cat, mode: mode, search_query: last_search_query[0],
search_lang: last_search_query[1]
is_cat: is_cat, mode: mode, search_query: this.last_search_query[0],
search_lang: this.last_search_query[1]
};
notify_progress("Loading, please wait...", true);

View File

@ -1025,7 +1025,7 @@ function uploadIconHandler(rc) {
switch (rc) {
case 0:
notify_info("Upload complete.");
if (inPreferences()) {
if (App.isPrefs()) {
Feeds.reload();
} else {
setTimeout('Feeds.reload(false, false)', 50);
@ -1050,7 +1050,7 @@ function removeFeedIcon(id) {
xhrPost("backend.php", query, (transport) => {
notify_info("Feed icon removed.");
if (inPreferences()) {
if (App.isPrefs()) {
Feeds.reload();
} else {
setTimeout('Feeds.reload(false, false)', 50);
@ -1090,7 +1090,7 @@ function addLabel(select, callback) {
xhrPost("backend.php", query, (transport) => {
if (callback) {
callback(transport);
} else if (inPreferences()) {
} else if (App.isPrefs()) {
updateLabelList();
} else {
Feeds.reload();
@ -1317,7 +1317,7 @@ function editFilterTest(query) {
function quickAddFilter() {
let query;
if (!inPreferences()) {
if (!App.isPrefs()) {
query = { op: "pref-filters", method: "newfilter",
feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat() };
} else {
@ -1385,7 +1385,7 @@ function quickAddFilter() {
const query = dojo.formToQuery("filter_new_form");
xhrPost("backend.php", query, (transport) => {
if (inPreferences()) {
if (App.isPrefs()) {
updateFilterList();
}
@ -1395,7 +1395,7 @@ function quickAddFilter() {
},
href: "backend.php?" + dojo.objectToQuery(query)});
if (!inPreferences()) {
if (!App.isPrefs()) {
const selectedText = getSelectionText();
const lh = dojo.connect(dialog, "onLoad", function(){
@ -1453,7 +1453,7 @@ function unsubscribeFeed(feed_id, title) {
xhrPost("backend.php", query, (transport) => {
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
if (inPreferences()) {
if (App.isPrefs()) {
Feeds.reload();
} else {
if (feed_id == Feeds.getActiveFeedId())

View File

@ -65,7 +65,7 @@ const App = {
});
},
initSecondStage: function() {
document.onkeydown = this.hotkeyHandler;
document.onkeydown = () => { App.hotkeyHandler(event) };
Utils.setLoadingProgress(50);
notify("");
@ -111,8 +111,11 @@ const App = {
console.log("unhandled action: " + action_name + "; keycode: " + event.which);
}
}
},
isPrefs: function() {
return true;
}
}
};
function notify_callback2(transport, sticky) {
notify_info(transport.responseText, sticky);
@ -909,10 +912,6 @@ function labelColorReset() {
}
}
function inPreferences() {
return true;
}
function editProfiles() {
if (dijit.byId("profileEditDlg"))

View File

@ -1,10 +1,9 @@
/* global dijit, __ */
let hotkey_actions = {};
const App = {
global_unread: -1,
_widescreen_mode: false,
hotkey_actions: {},
init: function() {
window.onerror = function (message, filename, lineno, colno, error) {
@ -57,7 +56,7 @@ const App = {
return false;
Utils.setLoadingProgress(30);
init_hotkey_actions();
App.initHotkeyActions();
const a = document.createElement('audio');
const hasAudio = !!a.canPlayType;
@ -179,7 +178,7 @@ const App = {
const action_name = Utils.keyeventToAction(event);
if (action_name) {
const action_func = hotkey_actions[action_name];
const action_func = this.hotkey_actions[action_name];
if (action_func != null) {
action_func();
@ -233,331 +232,328 @@ const App = {
xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
},
};
initHotkeyActions: function() {
this.hotkey_actions["next_feed"] = function () {
const rv = dijit.byId("feedTree").getNextFeed(
Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
function init_hotkey_actions() {
hotkey_actions["next_feed"] = function () {
const rv = dijit.byId("feedTree").getNextFeed(
Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
};
this.hotkey_actions["prev_feed"] = function () {
const rv = dijit.byId("feedTree").getPreviousFeed(
Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
};
hotkey_actions["prev_feed"] = function () {
const rv = dijit.byId("feedTree").getPreviousFeed(
Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
};
hotkey_actions["next_article"] = function () {
Headlines.moveToPost('next');
};
hotkey_actions["prev_article"] = function () {
Headlines.moveToPost('prev');
};
hotkey_actions["next_article_noscroll"] = function () {
Headlines.moveToPost('next', true);
};
hotkey_actions["prev_article_noscroll"] = function () {
Headlines.moveToPost('prev', true);
};
hotkey_actions["next_article_noexpand"] = function () {
Headlines.moveToPost('next', true, true);
};
hotkey_actions["prev_article_noexpand"] = function () {
Headlines.moveToPost('prev', true, true);
};
hotkey_actions["search_dialog"] = function () {
Feeds.search();
};
hotkey_actions["toggle_mark"] = function () {
Headlines.selectionToggleMarked();
};
hotkey_actions["toggle_publ"] = function () {
Headlines.selectionTogglePublished();
};
hotkey_actions["toggle_unread"] = function () {
Headlines.selectionToggleUnread({no_error: 1});
};
hotkey_actions["edit_tags"] = function () {
const id = Article.getActiveArticleId();
if (id) {
Article.editArticleTags(id);
}
}
hotkey_actions["open_in_new_window"] = function () {
if (Article.getActiveArticleId()) {
Article.openArticleInNewWindow(Article.getActiveArticleId());
}
};
hotkey_actions["catchup_below"] = function () {
catchupRelativeToArticle(1);
};
hotkey_actions["catchup_above"] = function () {
catchupRelativeToArticle(0);
};
hotkey_actions["article_scroll_down"] = function () {
scrollArticle(40);
};
hotkey_actions["article_scroll_up"] = function () {
scrollArticle(-40);
};
hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) {
Article.cdmCollapseActive();
} else {
Article.closeArticlePanel();
}
};
hotkey_actions["email_article"] = function () {
if (typeof emailArticle != "undefined") {
emailArticle();
} else if (typeof mailtoArticle != "undefined") {
mailtoArticle();
} else {
alert(__("Please enable mail plugin first."));
}
};
hotkey_actions["select_all"] = function () {
Headlines.selectArticles('all');
};
hotkey_actions["select_unread"] = function () {
Headlines.selectArticles('unread');
};
hotkey_actions["select_marked"] = function () {
Headlines.selectArticles('marked');
};
hotkey_actions["select_published"] = function () {
Headlines.selectArticles('published');
};
hotkey_actions["select_invert"] = function () {
Headlines.selectArticles('invert');
};
hotkey_actions["select_none"] = function () {
Headlines.selectArticles('none');
};
hotkey_actions["feed_refresh"] = function () {
if (Feeds.getActiveFeedId() != undefined) {
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat()});
}
};
hotkey_actions["feed_unhide_read"] = function () {
Feeds.toggleDispRead();
};
hotkey_actions["feed_subscribe"] = function () {
CommonDialogs.quickAddFeed();
};
hotkey_actions["feed_debug_update"] = function () {
if (!Feeds.activeFeedIsCat() && parseInt(Feeds.getActiveFeedId()) > 0) {
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActiveFeedId() +
"&csrf_token=" + getInitParam("csrf_token"));
} else {
alert("You can't debug this kind of feed.");
}
};
hotkey_actions["feed_debug_viewfeed"] = function () {
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), viewfeed_debug: true});
};
hotkey_actions["feed_edit"] = function () {
if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed."));
else
editFeed(Feeds.getActiveFeedId());
};
hotkey_actions["feed_catchup"] = function () {
if (Feeds.getActiveFeedId() != undefined) {
Feeds.catchupCurrentFeed();
}
};
hotkey_actions["feed_reverse"] = function () {
Headlines.reverseHeadlineOrder();
};
hotkey_actions["feed_toggle_vgroup"] = function () {
xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
Feeds.viewCurrentFeed();
})
};
hotkey_actions["catchup_all"] = function () {
Feeds.catchupAllFeeds();
};
hotkey_actions["cat_toggle_collapse"] = function () {
if (Feeds.activeFeedIsCat()) {
dijit.byId("feedTree").collapseCat(Feeds.getActiveFeedId());
}
};
hotkey_actions["goto_all"] = function () {
Feeds.viewfeed({feed: -4});
};
hotkey_actions["goto_fresh"] = function () {
Feeds.viewfeed({feed: -3});
};
hotkey_actions["goto_marked"] = function () {
Feeds.viewfeed({feed: -1});
};
hotkey_actions["goto_published"] = function () {
Feeds.viewfeed({feed: -2});
};
hotkey_actions["goto_tagcloud"] = function () {
Utils.displayDlg(__("Tag cloud"), "printTagCloud");
};
hotkey_actions["goto_prefs"] = function () {
gotoPreferences();
};
hotkey_actions["select_article_cursor"] = function () {
const id = getArticleUnderPointer();
if (id) {
const row = $("RROW-" + id);
if (row) {
const cb = dijit.getEnclosingWidget(
row.select(".rchk")[0]);
if (cb) {
if (!row.hasClassName("active"))
cb.attr("checked", !cb.attr("checked"));
toggleSelectRowById(cb, "RROW-" + id);
return false;
}
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
};
this.hotkey_actions["next_article"] = function () {
Headlines.moveToPost('next');
};
this.hotkey_actions["prev_article"] = function () {
Headlines.moveToPost('prev');
};
this.hotkey_actions["next_article_noscroll"] = function () {
Headlines.moveToPost('next', true);
};
this.hotkey_actions["prev_article_noscroll"] = function () {
Headlines.moveToPost('prev', true);
};
this.hotkey_actions["next_article_noexpand"] = function () {
Headlines.moveToPost('next', true, true);
};
this.hotkey_actions["prev_article_noexpand"] = function () {
Headlines.moveToPost('prev', true, true);
};
this.hotkey_actions["search_dialog"] = function () {
Feeds.search();
};
this.hotkey_actions["toggle_mark"] = function () {
Headlines.selectionToggleMarked();
};
this.hotkey_actions["toggle_publ"] = function () {
Headlines.selectionTogglePublished();
};
this.hotkey_actions["toggle_unread"] = function () {
Headlines.selectionToggleUnread({no_error: 1});
};
this.hotkey_actions["edit_tags"] = function () {
const id = Article.getActiveArticleId();
if (id) {
Article.editArticleTags(id);
}
}
};
hotkey_actions["create_label"] = function () {
addLabel();
};
hotkey_actions["create_filter"] = function () {
quickAddFilter();
};
hotkey_actions["collapse_sidebar"] = function () {
Feeds.viewCurrentFeed();
};
hotkey_actions["toggle_embed_original"] = function () {
if (typeof embedOriginalArticle != "undefined") {
if (Article.getActiveArticleId())
embedOriginalArticle(Article.getActiveArticleId());
} else {
alert(__("Please enable embed_original plugin first."));
}
};
hotkey_actions["toggle_widescreen"] = function () {
if (!App.isCombinedMode()) {
App._widescreen_mode = !App._widescreen_mode;
this.hotkey_actions["open_in_new_window"] = function () {
if (Article.getActiveArticleId()) {
Article.openArticleInNewWindow(Article.getActiveArticleId());
}
};
this.hotkey_actions["catchup_below"] = function () {
Headlines.catchupRelativeToArticle(1);
};
this.hotkey_actions["catchup_above"] = function () {
Headlines.catchupRelativeToArticle(0);
};
this.hotkey_actions["article_scroll_down"] = function () {
Article.scrollArticle(40);
};
this.hotkey_actions["article_scroll_up"] = function () {
Article.scrollArticle(-40);
};
this.hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) {
Article.cdmCollapseActive();
} else {
Article.closeArticlePanel();
}
};
this.hotkey_actions["email_article"] = function () {
if (typeof emailArticle != "undefined") {
emailArticle();
} else if (typeof mailtoArticle != "undefined") {
mailtoArticle();
} else {
alert(__("Please enable mail plugin first."));
}
};
this.hotkey_actions["select_all"] = function () {
Headlines.selectArticles('all');
};
this.hotkey_actions["select_unread"] = function () {
Headlines.selectArticles('unread');
};
this.hotkey_actions["select_marked"] = function () {
Headlines.selectArticles('marked');
};
this.hotkey_actions["select_published"] = function () {
Headlines.selectArticles('published');
};
this.hotkey_actions["select_invert"] = function () {
Headlines.selectArticles('invert');
};
this.hotkey_actions["select_none"] = function () {
Headlines.selectArticles('none');
};
this.hotkey_actions["feed_refresh"] = function () {
if (Feeds.getActiveFeedId() != undefined) {
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat()});
}
};
this.hotkey_actions["feed_unhide_read"] = function () {
Feeds.toggleDispRead();
};
this.hotkey_actions["feed_subscribe"] = function () {
CommonDialogs.quickAddFeed();
};
this.hotkey_actions["feed_debug_update"] = function () {
if (!Feeds.activeFeedIsCat() && parseInt(Feeds.getActiveFeedId()) > 0) {
window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + Feeds.getActiveFeedId() +
"&csrf_token=" + getInitParam("csrf_token"));
} else {
alert("You can't debug this kind of feed.");
}
};
// reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0);
this.hotkey_actions["feed_debug_viewfeed"] = function () {
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), viewfeed_debug: true});
};
App.switchPanelMode(App._widescreen_mode);
} else {
alert(__("Widescreen is not available in combined mode."));
}
};
hotkey_actions["help_dialog"] = function () {
Utils.helpDialog("main");
};
hotkey_actions["toggle_combined_mode"] = function () {
notify_progress("Loading, please wait...");
this.hotkey_actions["feed_edit"] = function () {
if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed."));
else
editFeed(Feeds.getActiveFeedId());
};
this.hotkey_actions["feed_catchup"] = function () {
if (Feeds.getActiveFeedId() != undefined) {
Feeds.catchupCurrentFeed();
}
};
this.hotkey_actions["feed_reverse"] = function () {
Headlines.reverseHeadlineOrder();
};
this.hotkey_actions["feed_toggle_vgroup"] = function () {
xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
Feeds.viewCurrentFeed();
})
};
this.hotkey_actions["catchup_all"] = function () {
Feeds.catchupAllFeeds();
};
this.hotkey_actions["cat_toggle_collapse"] = function () {
if (Feeds.activeFeedIsCat()) {
dijit.byId("feedTree").collapseCat(Feeds.getActiveFeedId());
}
};
this.hotkey_actions["goto_all"] = function () {
Feeds.viewfeed({feed: -4});
};
this.hotkey_actions["goto_fresh"] = function () {
Feeds.viewfeed({feed: -3});
};
this.hotkey_actions["goto_marked"] = function () {
Feeds.viewfeed({feed: -1});
};
this.hotkey_actions["goto_published"] = function () {
Feeds.viewfeed({feed: -2});
};
this.hotkey_actions["goto_tagcloud"] = function () {
Utils.displayDlg(__("Tag cloud"), "printTagCloud");
};
this.hotkey_actions["goto_prefs"] = function () {
document.location.href = "prefs.php";
};
this.hotkey_actions["select_article_cursor"] = function () {
const id = Article.getArticleUnderPointer();
if (id) {
const row = $("RROW-" + id);
const value = App.isCombinedMode() ? "false" : "true";
if (row) {
const cb = dijit.getEnclosingWidget(
row.select(".rchk")[0]);
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
setInitParam("combined_display_mode",
!getInitParam("combined_display_mode"));
if (cb) {
if (!row.hasClassName("active"))
cb.attr("checked", !cb.attr("checked"));
Article.closeArticlePanel();
toggleSelectRowById(cb, "RROW-" + id);
return false;
}
}
}
};
this.hotkey_actions["create_label"] = function () {
addLabel();
};
this.hotkey_actions["create_filter"] = function () {
quickAddFilter();
};
this.hotkey_actions["collapse_sidebar"] = function () {
Feeds.viewCurrentFeed();
})
};
hotkey_actions["toggle_cdm_expanded"] = function () {
notify_progress("Loading, please wait...");
};
this.hotkey_actions["toggle_embed_original"] = function () {
if (typeof embedOriginalArticle != "undefined") {
if (Article.getActiveArticleId())
embedOriginalArticle(Article.getActiveArticleId());
} else {
alert(__("Please enable embed_original plugin first."));
}
};
this.hotkey_actions["toggle_widescreen"] = function () {
if (!App.isCombinedMode()) {
App._widescreen_mode = !App._widescreen_mode;
const value = getInitParam("cdm_expanded") ? "false" : "true";
// reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0);
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
Feeds.viewCurrentFeed();
});
};
}
App.switchPanelMode(App._widescreen_mode);
} else {
alert(__("Widescreen is not available in combined mode."));
}
};
this.hotkey_actions["help_dialog"] = function () {
Utils.helpDialog("main");
};
this.hotkey_actions["toggle_combined_mode"] = function () {
notify_progress("Loading, please wait...");
function quickMenuGo(opid) {
switch (opid) {
case "qmcPrefs":
gotoPreferences();
break;
case "qmcLogout":
document.location.href = "backend.php?op=logout";
break;
case "qmcTagCloud":
Utils.displayDlg(__("Tag cloud"), "printTagCloud");
break;
case "qmcSearch":
Feeds.search();
break;
case "qmcAddFeed":
CommonDialogs.quickAddFeed();
break;
case "qmcDigest":
window.location.href = "backend.php?op=digest";
break;
case "qmcEditFeed":
if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed."));
else
editFeed(Feeds.getActiveFeedId());
break;
case "qmcRemoveFeed":
var actid = Feeds.getActiveFeedId();
const value = App.isCombinedMode() ? "false" : "true";
if (Feeds.activeFeedIsCat()) {
alert(__("You can't unsubscribe from the category."));
return;
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
setInitParam("combined_display_mode",
!getInitParam("combined_display_mode"));
Article.closeArticlePanel();
Feeds.viewCurrentFeed();
})
};
this.hotkey_actions["toggle_cdm_expanded"] = function () {
notify_progress("Loading, please wait...");
const value = getInitParam("cdm_expanded") ? "false" : "true";
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
setInitParam("cdm_expanded", !getInitParam("cdm_expanded"));
Feeds.viewCurrentFeed();
});
};
},
onActionSelected: function(opid) {
switch (opid) {
case "qmcPrefs":
gotoPreferences();
break;
case "qmcLogout":
document.location.href = "backend.php?op=logout";
break;
case "qmcTagCloud":
Utils.displayDlg(__("Tag cloud"), "printTagCloud");
break;
case "qmcSearch":
Feeds.search();
break;
case "qmcAddFeed":
CommonDialogs.quickAddFeed();
break;
case "qmcDigest":
window.location.href = "backend.php?op=digest";
break;
case "qmcEditFeed":
if (Feeds.activeFeedIsCat())
alert(__("You can't edit this kind of feed."));
else
editFeed(Feeds.getActiveFeedId());
break;
case "qmcRemoveFeed":
var actid = Feeds.getActiveFeedId();
if (Feeds.activeFeedIsCat()) {
alert(__("You can't unsubscribe from the category."));
return;
}
if (!actid) {
alert(__("Please select some feed first."));
return;
}
var fn = Feeds.getFeedName(actid);
var pr = __("Unsubscribe from %s?").replace("%s", fn);
if (confirm(pr)) {
unsubscribeFeed(actid);
}
break;
case "qmcCatchupAll":
Feeds.catchupAllFeeds();
break;
case "qmcShowOnlyUnread":
Feeds.toggleDispRead();
break;
case "qmcToggleWidescreen":
if (!App.isCombinedMode()) {
App._widescreen_mode = !App._widescreen_mode;
// reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0);
App.switchPanelMode(App._widescreen_mode);
} else {
alert(__("Widescreen is not available in combined mode."));
}
break;
case "qmcHKhelp":
Utils.helpDialog("main");
break;
default:
console.log("quickMenuGo: unknown action: " + opid);
}
if (!actid) {
alert(__("Please select some feed first."));
return;
}
var fn = Feeds.getFeedName(actid);
var pr = __("Unsubscribe from %s?").replace("%s", fn);
if (confirm(pr)) {
unsubscribeFeed(actid);
}
break;
case "qmcCatchupAll":
Feeds.catchupAllFeeds();
break;
case "qmcShowOnlyUnread":
Feeds.toggleDispRead();
break;
case "qmcToggleWidescreen":
if (!App.isCombinedMode()) {
App._widescreen_mode = !App._widescreen_mode;
// reset stored sizes because geometry changed
setCookie("ttrss_ci_width", 0);
setCookie("ttrss_ci_height", 0);
App.switchPanelMode(App._widescreen_mode);
} else {
alert(__("Widescreen is not available in combined mode."));
}
break;
case "qmcHKhelp":
Utils.helpDialog("main");
break;
default:
console.log("quickMenuGo: unknown action: " + opid);
},
isPrefs: function() {
return false;
}
}
function inPreferences() {
return false;
}
};
function hash_get(key) {
const kv = window.location.hash.substring(1).toQueryParams();
@ -569,7 +565,3 @@ function hash_set(key, value) {
kv[key] = value;
window.location.hash = $H(kv).toQueryString();
}
function gotoPreferences() {
document.location.href = "prefs.php";
}

View File

@ -1,8 +1,5 @@
/* global dijit, __, ngettext */
let post_under_pointer = false;
let last_search_query;
const ArticleCache = {
has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null,
set: function(id, obj) {
@ -118,7 +115,7 @@ const Article = {
c.attr('content', article);
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode);
correctHeadlinesOffset(Article.getActiveArticleId());
Headlines.correctHeadlinesOffset(Article.getActiveArticleId());
try {
c.focus();
@ -126,7 +123,7 @@ const Article = {
}
},
view: function(id, noexpand) {
Article.setActiveArticleId(id);
this.setActiveArticleId(id);
if (!noexpand) {
console.log("loading article", id);
@ -135,7 +132,7 @@ const Article = {
/* only request uncached articles */
getRelativePostIds(id).each((n) => {
this.getRelativePostIds(id).each((n) => {
if (!ArticleCache.get(n))
cids.push(n);
});
@ -313,6 +310,49 @@ const Article = {
},
getActiveArticleId: function() {
return this._active_article_id;
},
scrollArticle: function(offset) {
if (!App.isCombinedMode()) {
const ci = $("content-insert");
if (ci) {
ci.scrollTop += offset;
}
} else {
const hi = $("headlines-frame");
if (hi) {
hi.scrollTop += offset;
}
}
},
getRelativePostIds: function(id, limit) {
const tmp = [];
if (!limit) limit = 6; //3
const ids = Headlines.getLoadedArticleIds();
for (let i = 0; i < ids.length; i++) {
if (ids[i] == id) {
for (let k = 1; k <= limit; k++) {
//if (i > k-1) tmp.push(ids[i-k]);
if (i < ids.length - k) tmp.push(ids[i + k]);
}
break;
}
}
return tmp;
},
mouseIn: function(id) {
this.post_under_pointer = id;
},
mouseOut: function(id) {
this.post_under_pointer = false;
},
getArticleUnderPointer: function() {
return this.post_under_pointer;
}
};
@ -485,7 +525,7 @@ const Headlines = {
ft.firstChild.innerHTML = "<img class='anchor marked-pic' src='images/page_white_go.png' " +
"onclick=\"Article.cdmScrollToArticleId(" + id + ", true)\">" + ft.firstChild.innerHTML;
initFloatingMenu();
this.initFloatingMenu();
const cb = ft.select(".rchk")[0];
@ -546,7 +586,7 @@ const Headlines = {
is_cat = reply['headlines']['is_cat'];
feed_id = reply['headlines']['id'];
last_search_query = reply['headlines']['search_query'];
Feeds.last_search_query = reply['headlines']['search_query'];
if (feed_id != -7 && (feed_id != Feeds.getActiveFeedId() || is_cat != Feeds.activeFeedIsCat()))
return;
@ -602,7 +642,7 @@ const Headlines = {
if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
dijit.byId('headlines-frame').domNode.appendChild(hsp);
initHeadlinesMenu();
this.initHeadlinesMenu();
if (Feeds.infscroll_disabled)
hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnreadFeed()'>" +
@ -646,7 +686,7 @@ const Headlines = {
markHeadline(ids[i]);
} */
initHeadlinesMenu();
this.initHeadlinesMenu();
if (Feeds.infscroll_disabled) {
hsp.innerHTML = "<a href='#' onclick='Feeds.openNextUnreadFeed()'>" +
@ -894,7 +934,7 @@ const Headlines = {
if (!noscroll && article && article.offsetTop + article.offsetHeight >
ctr.scrollTop + ctr.offsetHeight) {
scrollArticle(ctr.offsetHeight / 4);
Article.scrollArticle(ctr.offsetHeight / 4);
} else if (next_id) {
Article.setActiveArticleId(next_id);
@ -902,7 +942,7 @@ const Headlines = {
}
} else if (next_id) {
correctHeadlinesOffset(next_id);
Headlines.correctHeadlinesOffset(next_id);
Article.view(next_id, noexpand);
}
}
@ -917,17 +957,17 @@ const Headlines = {
const ctr = $("headlines-frame");
if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight / 3);
Article.scrollArticle(-ctr.offsetHeight / 3);
} else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) {
scrollArticle(-ctr.offsetHeight / 4);
Article.scrollArticle(-ctr.offsetHeight / 4);
} else if (prev_id) {
Article.setActiveArticleId(prev_id);
Article.cdmScrollToArticleId(prev_id, noscroll);
}
} else if (prev_id) {
correctHeadlinesOffset(prev_id);
Headlines.correctHeadlinesOffset(prev_id);
Article.view(prev_id, noexpand);
}
}
@ -986,7 +1026,7 @@ const Headlines = {
xhrPost("backend.php", query, (transport) => {
Utils.handleRpcJson(transport);
updateHeadlineLabels(transport);
this.onLabelsUpdated(transport);
});
},
selectionAssignLabel: function(id, ids) {
@ -1004,7 +1044,7 @@ const Headlines = {
xhrPost("backend.php", query, (transport) => {
Utils.handleRpcJson(transport);
updateHeadlineLabels(transport);
this.onLabelsUpdated(transport);
});
},
deleteSelection: function() {
@ -1212,362 +1252,306 @@ const Headlines = {
} else {
if (callback) callback();
}
}
};
},
catchupRelativeToArticle: function(below, id) {
function postMouseIn(e, id) {
post_under_pointer = id;
}
if (!id) id = Article.getActiveArticleId();
function postMouseOut(id) {
post_under_pointer = false;
}
if (!id) {
alert(__("No article is selected."));
return;
}
function catchupRelativeToArticle(below, id) {
const visible_ids = this.getLoadedArticleIds();
if (!id) id = Article.getActiveArticleId();
const ids_to_mark = [];
if (!id) {
alert(__("No article is selected."));
return;
}
if (!below) {
for (let i = 0; i < visible_ids.length; i++) {
if (visible_ids[i] != id) {
const e = $("RROW-" + visible_ids[i]);
const visible_ids = Headlines.getLoadedArticleIds();
const ids_to_mark = [];
if (!below) {
for (let i = 0; i < visible_ids.length; i++) {
if (visible_ids[i] != id) {
const e = $("RROW-" + visible_ids[i]);
if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]);
if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]);
}
} else {
break;
}
}
} else {
for (let i = visible_ids.length - 1; i >= 0; i--) {
if (visible_ids[i] != id) {
const e = $("RROW-" + visible_ids[i]);
if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]);
}
} else {
break;
}
} else {
break;
}
}
} else {
for (let i = visible_ids.length - 1; i >= 0; i--) {
if (visible_ids[i] != id) {
const e = $("RROW-" + visible_ids[i]);
if (e && e.hasClassName("Unread")) {
ids_to_mark.push(visible_ids[i]);
if (ids_to_mark.length == 0) {
alert(__("No articles found to mark"));
} else {
const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
for (var i = 0; i < ids_to_mark.length; i++) {
var e = $("RROW-" + ids_to_mark[i]);
e.removeClassName("Unread");
}
} else {
break;
const query = {
op: "rpc", method: "catchupSelected",
cmode: 0, ids: ids_to_mark.toString()
};
xhrPost("backend.php", query, (transport) => {
Utils.handleRpcJson(transport);
});
}
}
}
},
onLabelsUpdated: function(transport) {
const data = JSON.parse(transport.responseText);
if (ids_to_mark.length == 0) {
alert(__("No articles found to mark"));
} else {
const msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
for (var i = 0; i < ids_to_mark.length; i++) {
var e = $("RROW-" + ids_to_mark[i]);
e.removeClassName("Unread");
}
const query = { op: "rpc", method: "catchupSelected",
cmode: 0, ids: ids_to_mark.toString() };
xhrPost("backend.php", query, (transport) => {
Utils.handleRpcJson(transport);
if (data) {
data['info-for-headlines'].each(function (elem) {
$$(".HLLCTR-" + elem.id).each(function (ctr) {
ctr.innerHTML = elem.labels;
});
});
}
}
}
},
onActionChanged: function(elem) {
eval(elem.value);
elem.attr('value', 'false');
},
correctHeadlinesOffset: function(id) {
const container = $("headlines-frame");
const row = $("RROW-" + id);
function getArticleUnderPointer() {
return post_under_pointer;
}
if (!container || !row) return;
function scrollArticle(offset) {
if (!App.isCombinedMode()) {
const ci = $("content-insert");
if (ci) {
ci.scrollTop += offset;
}
} else {
const hi = $("headlines-frame");
if (hi) {
hi.scrollTop += offset;
const viewport = container.offsetHeight;
const rel_offset_top = row.offsetTop - container.scrollTop;
const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
//console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
//console.log("Vport: " + viewport);
if (rel_offset_top <= 0 || rel_offset_top > viewport) {
container.scrollTop = row.offsetTop;
} else if (rel_offset_bottom > viewport) {
container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
}
},
initFloatingMenu: function() {
if (!dijit.byId("floatingMenu")) {
}
}
function updateHeadlineLabels(transport) {
const data = JSON.parse(transport.responseText);
if (data) {
data['info-for-headlines'].each(function (elem) {
$$(".HLLCTR-" + elem.id).each(function (ctr) {
ctr.innerHTML = elem.labels;
const menu = new dijit.Menu({
id: "floatingMenu",
targetNodeIds: ["floatingTitle"]
});
});
}
}
function getRelativePostIds(id, limit) {
this.headlinesMenuCommon(menu);
const tmp = [];
menu.startup();
}
},
headlinesMenuCommon: function(menu) {
if (!limit) limit = 6; //3
const ids = Headlines.getLoadedArticleIds();
for (let i = 0; i < ids.length; i++) {
if (ids[i] == id) {
for (let k = 1; k <= limit; k++) {
//if (i > k-1) tmp.push(ids[i-k]);
if (i < ids.length - k) tmp.push(ids[i + k]);
menu.addChild(new dijit.MenuItem({
label: __("Open original article"),
onClick: function (event) {
Article.openArticleInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
}
break;
}
}
}));
return tmp;
}
function correctHeadlinesOffset(id) {
const container = $("headlines-frame");
const row = $("RROW-" + id);
if (!container || !row) return;
const viewport = container.offsetHeight;
const rel_offset_top = row.offsetTop - container.scrollTop;
const rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
//console.log("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
//console.log("Vport: " + viewport);
if (rel_offset_top <= 0 || rel_offset_top > viewport) {
container.scrollTop = row.offsetTop;
} else if (rel_offset_bottom > viewport) {
container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
}
}
function headlineActionsChange(elem) {
eval(elem.value);
elem.attr('value', 'false');
}
function initFloatingMenu() {
if (!dijit.byId("floatingMenu")) {
const menu = new dijit.Menu({
id: "floatingMenu",
targetNodeIds: ["floatingTitle"]
});
headlinesMenuCommon(menu);
menu.startup();
}
}
function headlinesMenuCommon(menu) {
menu.addChild(new dijit.MenuItem({
label: __("Open original article"),
onClick: function (event) {
Article.openArticleInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Display article URL"),
onClick: function (event) {
Article.displayArticleUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
menu.addChild(new dijit.MenuSeparator());
menu.addChild(new dijit.MenuItem({
label: __("Toggle unread"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionToggleUnread({ids: ids, no_error: 1});
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Toggle starred"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionToggleMarked(ids);
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Toggle published"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionTogglePublished(ids);
}
}));
menu.addChild(new dijit.MenuSeparator());
menu.addChild(new dijit.MenuItem({
label: __("Mark above as read"),
onClick: function () {
catchupRelativeToArticle(0, this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Mark below as read"),
onClick: function () {
catchupRelativeToArticle(1, this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
const labels = getInitParam("labels");
if (labels && labels.length) {
menu.addChild(new dijit.MenuItem({
label: __("Display article URL"),
onClick: function (event) {
Article.displayArticleUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
menu.addChild(new dijit.MenuSeparator());
const labelAddMenu = new dijit.Menu({ownerMenu: menu});
const labelDelMenu = new dijit.Menu({ownerMenu: menu});
menu.addChild(new dijit.MenuItem({
label: __("Toggle unread"),
onClick: function () {
labels.each(function (label) {
const bare_id = label.id;
const name = label.caption;
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
labelAddMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
onClick: function () {
Headlines.selectionToggleUnread({ids: ids, no_error: 1});
}
}));
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
menu.addChild(new dijit.MenuItem({
label: __("Toggle starred"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionToggleMarked(ids);
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Toggle published"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionTogglePublished(ids);
}
}));
menu.addChild(new dijit.MenuSeparator());
menu.addChild(new dijit.MenuItem({
label: __("Mark above as read"),
onClick: function () {
Headlines.catchupRelativeToArticle(0, this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Mark below as read"),
onClick: function () {
Headlines.catchupRelativeToArticle(1, this.getParent().currentTarget.getAttribute("data-article-id"));
}
}));
const labels = getInitParam("labels");
if (labels && labels.length) {
menu.addChild(new dijit.MenuSeparator());
const labelAddMenu = new dijit.Menu({ownerMenu: menu});
const labelDelMenu = new dijit.Menu({ownerMenu: menu});
labels.each(function (label) {
const bare_id = label.id;
const name = label.caption;
labelAddMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionAssignLabel(this.labelId, ids);
}
}));
labelDelMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionRemoveLabel(this.labelId, ids);
}
}));
});
menu.addChild(new dijit.PopupMenuItem({
label: __("Assign label"),
popup: labelAddMenu
}));
menu.addChild(new dijit.PopupMenuItem({
label: __("Remove label"),
popup: labelDelMenu
}));
}
},
initHeadlinesMenu: function() {
if (!dijit.byId("headlinesMenu")) {
const menu = new dijit.Menu({
id: "headlinesMenu",
targetNodeIds: ["headlines-frame"],
selector: ".hlMenuAttach"
});
this.headlinesMenuCommon(menu);
menu.startup();
}
/* vgroup feed title menu */
if (!dijit.byId("headlinesFeedTitleMenu")) {
const menu = new dijit.Menu({
id: "headlinesFeedTitleMenu",
targetNodeIds: ["headlines-frame"],
selector: "div.cdmFeedTitle"
});
menu.addChild(new dijit.MenuItem({
label: __("Select articles in group"),
onClick: function (event) {
Headlines.selectArticles("all",
"#headlines-frame > div[id*=RROW]" +
"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");
Headlines.selectionAssignLabel(this.labelId, ids);
}
}));
labelDelMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
menu.addChild(new dijit.MenuItem({
label: __("Mark group as read"),
onClick: function () {
let ids = Headlines.getSelectedArticleIds2();
// cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
Headlines.selectArticles("none");
Headlines.selectArticles("all",
"#headlines-frame > div[id*=RROW]" +
"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
Headlines.selectionRemoveLabel(this.labelId, ids);
Headlines.catchupSelection();
}
}));
});
menu.addChild(new dijit.MenuItem({
label: __("Mark feed as read"),
onClick: function () {
Feeds.catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id"));
}
}));
menu.addChild(new dijit.PopupMenuItem({
label: __("Assign label"),
popup: labelAddMenu
}));
menu.addChild(new dijit.PopupMenuItem({
label: __("Remove label"),
popup: labelDelMenu
}));
menu.addChild(new dijit.MenuItem({
label: __("Edit feed"),
onClick: function () {
editFeed(this.getParent().currentTarget.getAttribute("data-feed-id"));
}
}));
menu.startup();
}
}
}
function initHeadlinesMenu() {
if (!dijit.byId("headlinesMenu")) {
const menu = new dijit.Menu({
id: "headlinesMenu",
targetNodeIds: ["headlines-frame"],
selector: ".hlMenuAttach"
});
headlinesMenuCommon(menu);
menu.startup();
}
/* vgroup feed title menu */
if (!dijit.byId("headlinesFeedTitleMenu")) {
const menu = new dijit.Menu({
id: "headlinesFeedTitleMenu",
targetNodeIds: ["headlines-frame"],
selector: "div.cdmFeedTitle"
});
menu.addChild(new dijit.MenuItem({
label: __("Select articles in group"),
onClick: function (event) {
Headlines.selectArticles("all",
"#headlines-frame > div[id*=RROW]" +
"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Mark group as read"),
onClick: function () {
Headlines.selectArticles("none");
Headlines.selectArticles("all",
"#headlines-frame > div[id*=RROW]" +
"[data-orig-feed-id='" + this.getParent().currentTarget.getAttribute("data-feed-id") + "']");
Headlines.catchupSelection();
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Mark feed as read"),
onClick: function () {
Feeds.catchupFeedInGroup(this.getParent().currentTarget.getAttribute("data-feed-id"));
}
}));
menu.addChild(new dijit.MenuItem({
label: __("Edit feed"),
onClick: function () {
editFeed(this.getParent().currentTarget.getAttribute("data-feed-id"));
}
}));
menu.startup();
}
}
};