summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/FeedStoreModel.js2
-rwxr-xr-xjs/FeedTree.js22
-rw-r--r--js/Feeds.js41
-rw-r--r--js/PluginHost.js7
-rwxr-xr-xjs/Toolbar.js14
-rwxr-xr-xjs/form/ComboButton.js12
-rwxr-xr-xjs/form/DropDownButton.js12
-rwxr-xr-xjs/form/Select.js8
-rwxr-xr-xjs/prefs.js10
-rw-r--r--js/tt-rss.js18
10 files changed, 123 insertions, 23 deletions
diff --git a/js/FeedStoreModel.js b/js/FeedStoreModel.js
index 7f2af22ec..7d8020871 100644
--- a/js/FeedStoreModel.js
+++ b/js/FeedStoreModel.js
@@ -31,7 +31,7 @@ define(["dojo/_base/declare", "dijit/tree/ForestStoreModel"], function (declare)
},
getFeedUnread: function (feed, is_cat) {
const unread = parseInt(this.getFeedValue(feed, is_cat, 'unread'));
- return (isNaN(unread)) ? 0 : unread;
+ return (isNaN(unread)) ? -1 : unread;
},
setFeedUnread: function (feed, is_cat, unread) {
return this.setFeedValue(feed, is_cat, 'unread', parseInt(unread));
diff --git a/js/FeedTree.js b/js/FeedTree.js
index b8e50872a..1dcbae3f9 100755
--- a/js/FeedTree.js
+++ b/js/FeedTree.js
@@ -2,7 +2,10 @@
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"], function (declare, domConstruct) {
return declare("fox.FeedTree", dijit.Tree, {
- _onKeyPress: function(/* Event */ e) {
+ _onContainerKeydown: function(/* Event */ e) {
+ return; // Stop dijit.Tree from interpreting keystrokes
+ },
+ _onContainerKeypress: function(/* Event */ e) {
return; // Stop dijit.Tree from interpreting keystrokes
},
_createTreeNode: function(args) {
@@ -64,6 +67,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
CommonDialogs.editFeed(this.getParent().row_id, false);
}}));
+ menu.addChild(new dijit.MenuItem({
+ label: __("Debug feed"),
+ onClick: function() {
+ window.open("backend.php?op=feeds&method=update_debugger&feed_id=" + this.getParent().row_id +
+ "&csrf_token=" + App.getInitParam("csrf_token"));
+ }}));
+
/* menu.addChild(new dijit.MenuItem({
label: __("Update feed"),
onClick: function() {
@@ -125,7 +135,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
args.item.unread > 0 || args.item.auxcounter > 0 ? Element.show(ctr) : Element.hide(ctr);
- args.item.unread == 0 && args.item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
+ args.item.unread <= 0 && args.item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
domConstruct.place(ctr, tnode.rowNode, 'first');
tnode.counterNode = ctr;
@@ -161,7 +171,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
Element.show(ctr) :
Element.hide(ctr);
- item.unread == 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
+ item.unread <= 0 && item.auxcounter > 0 ? ctr.addClassName("aux") : ctr.removeClassName("aux");
}
}
@@ -174,7 +184,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
return (!item || this.model.mayHaveChildren(item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "feed-icon";
},
getLabelClass: function (item, opened) {
- return (item.unread == 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
+ return (item.unread <= 0) ? "dijitTreeLabel" : "dijitTreeLabel Unread";
},
getRowClass: function (item, opened) {
let rc = (!item.error || item.error == '') ? "dijitTreeRow" :
@@ -343,7 +353,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
if (node) {
const check_unread = tree.model.getFeedUnread(bare_id, true);
- if (hide && cat_unread == 0 && check_unread == 0 && (id != "CAT:-1" || !show_special)) {
+ if (hide && cat_unread <= 0 && check_unread <= 0 && (id != "CAT:-1" || !show_special)) {
Effect.Fade(node[0].rowNode, {duration : 0.3,
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
} else {
@@ -387,7 +397,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "dijit/Tree", "dijit/Menu"],
const node = tree._itemNodesMap[id];
if (node) {
- if (hide && unread == 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
+ if (hide && unread <= 0 && !has_error && (bare_id > 0 || bare_id < _label_base_index || !show_special)) {
Effect.Fade(node[0].rowNode, {duration : 0.3,
queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
} else {
diff --git a/js/Feeds.js b/js/Feeds.js
index ba63aac47..07ec89452 100644
--- a/js/Feeds.js
+++ b/js/Feeds.js
@@ -3,7 +3,7 @@
define(["dojo/_base/declare"], function (declare) {
Feeds = {
counters_last_request: 0,
- _active_feed_id: 0,
+ _active_feed_id: undefined,
_active_feed_is_cat: false,
infscroll_in_progress: 0,
infscroll_disabled: 0,
@@ -44,6 +44,8 @@ define(["dojo/_base/declare"], function (declare) {
this._counters_prev = [];
},
parseCounters: function (elems) {
+ PluginHost.run(PluginHost.HOOK_COUNTERS_RECEIVED, elems);
+
for (let l = 0; l < elems.length; l++) {
if (Feeds._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
@@ -93,11 +95,13 @@ define(["dojo/_base/declare"], function (declare) {
this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1);
this._counters_prev = elems;
+
+ PluginHost.run(PluginHost.HOOK_COUNTERS_PROCESSED);
},
reloadCurrent: function(method) {
- console.log("reloadCurrent: " + method);
-
if (this.getActive() != undefined) {
+ console.log("reloadCurrent: " + method);
+
this.open({feed: this.getActive(), is_cat: this.activeIsCat(), method: method});
}
return false; // block unneeded form submits
@@ -199,10 +203,13 @@ define(["dojo/_base/declare"], function (declare) {
document.onkeypress = (event) => { return App.hotkeyHandler(event) };
window.onresize = () => { Headlines.scrollHandler(); }
- if (!this.getActive()) {
- this.open({feed: -3});
+ const hash_feed_id = hash_get('f');
+ const hash_feed_is_cat = hash_get('c') == "1";
+
+ if (hash_feed_id != undefined) {
+ this.open({feed: hash_feed_id, is_cat: hash_feed_is_cat});
} else {
- this.open({feed: this.getActive(), is_cat: this.activeIsCat()});
+ this.open({feed: -3});
}
this.hideOrShowFeeds(App.getInitParam("hide_read_feeds") == 1);
@@ -246,6 +253,8 @@ define(["dojo/_base/declare"], function (declare) {
return this._active_feed_id;
},
setActive: function(id, is_cat) {
+ console.log('setActive', id, is_cat);
+
hash_set('f', id);
hash_set('c', is_cat ? 1 : 0);
@@ -543,6 +552,11 @@ define(["dojo/_base/declare"], function (declare) {
execute: function () {
if (this.validate()) {
Feeds._search_query = this.attr('value');
+
+ // disallow empty queries
+ if (!Feeds._search_query.query)
+ Feeds._search_query = false;
+
this.hide();
Feeds.reloadCurrent();
}
@@ -550,6 +564,21 @@ define(["dojo/_base/declare"], function (declare) {
href: query
});
+ const tmph = dojo.connect(dialog, 'onLoad', function () {
+ dojo.disconnect(tmph);
+
+ if (Feeds._search_query) {
+ if (Feeds._search_query.query)
+ dijit.byId('search_query')
+ .attr('value', Feeds._search_query.query);
+
+ if (Feeds._search_query.search_language)
+ dijit.byId('search_language')
+ .attr('value', Feeds._search_query.search_language);
+ }
+
+ });
+
dialog.show();
},
updateRandom: function() {
diff --git a/js/PluginHost.js b/js/PluginHost.js
index f76b73464..71596ad31 100644
--- a/js/PluginHost.js
+++ b/js/PluginHost.js
@@ -13,6 +13,8 @@ PluginHost = {
HOOK_FLOATING_TITLE: 10,
HOOK_INIT_COMPLETE: 11,
HOOK_HEADLINE_RENDERED: 12,
+ HOOK_COUNTERS_RECEIVED: 13,
+ HOOK_COUNTERS_PROCESSED: 14,
hooks: [],
register: function (name, callback) {
if (typeof(this.hooks[name]) == 'undefined')
@@ -27,6 +29,11 @@ PluginHost = {
for (let i = 0; i < this.hooks[name].length; i++) {
this.hooks[name][i](args);
}
+ },
+ unregister: function (name, callback) {
+ for (var i = 0; i < this.hooks[name].length; i++)
+ if (this.hooks[name][i] == callback)
+ this.hooks[name].splice(i, 1);
}
};
diff --git a/js/Toolbar.js b/js/Toolbar.js
new file mode 100755
index 000000000..6d2c20058
--- /dev/null
+++ b/js/Toolbar.js
@@ -0,0 +1,14 @@
+/* global dijit */
+define(["dojo/_base/declare", "dijit/Toolbar"], function (declare) {
+ return declare("fox.Toolbar", dijit.Toolbar, {
+ _onContainerKeydown: function(/* Event */ e) {
+ return; // Stop dijit.Toolbar from interpreting keystrokes
+ },
+ _onContainerKeypress: function(/* Event */ e) {
+ return; // Stop dijit.Toolbar from interpreting keystrokes
+ },
+ focus: function() {
+ return; // Stop dijit.Toolbar from focusing the first child on click
+ },
+ });
+});
diff --git a/js/form/ComboButton.js b/js/form/ComboButton.js
new file mode 100755
index 000000000..1084cda9c
--- /dev/null
+++ b/js/form/ComboButton.js
@@ -0,0 +1,12 @@
+/* global dijit */
+define(["dojo/_base/declare", "dijit/form/ComboButton"], function (declare) {
+ return declare("fox.form.ComboButton", dijit.form.ComboButton, {
+ startup: function() {
+ this.inherited(arguments);
+ this.dropDown.autoFocus = true; // Allow dropdown menu to be focused on click
+ },
+ focus: function() {
+ return; // Stop dijit.form.ComboButton from keeping focus after closing the menu
+ },
+ });
+});
diff --git a/js/form/DropDownButton.js b/js/form/DropDownButton.js
new file mode 100755
index 000000000..0c182772a
--- /dev/null
+++ b/js/form/DropDownButton.js
@@ -0,0 +1,12 @@
+/* global dijit */
+define(["dojo/_base/declare", "dijit/form/DropDownButton"], function (declare) {
+ return declare("fox.form.DropDownButton", dijit.form.DropDownButton, {
+ startup: function() {
+ this.inherited(arguments);
+ this.dropDown.autoFocus = true; // Allow dropdown menu to be focused on click
+ },
+ focus: function() {
+ return; // Stop dijit.form.DropDownButton from keeping focus after closing the menu
+ },
+ });
+});
diff --git a/js/form/Select.js b/js/form/Select.js
new file mode 100755
index 000000000..c62db1821
--- /dev/null
+++ b/js/form/Select.js
@@ -0,0 +1,8 @@
+/* global dijit */
+define(["dojo/_base/declare", "dijit/form/Select"], function (declare) {
+ return declare("fox.form.Select", dijit.form.Select, {
+ focus: function() {
+ return; // Stop dijit.form.Select from keeping focus after closing the menu
+ },
+ });
+});
diff --git a/js/prefs.js b/js/prefs.js
index ae6286330..844ce8c8a 100755
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -53,7 +53,11 @@ require(["dojo/_base/kernel",
"fox/PrefFilterStore",
"fox/PrefFeedTree",
"fox/PrefFilterTree",
- "fox/PrefLabelTree"], function (dojo, declare, ready, parser, AppBase) {
+ "fox/PrefLabelTree",
+ "fox/Toolbar",
+ "fox/form/Select",
+ "fox/form/ComboButton",
+ "fox/form/DropDownButton"], function (dojo, declare, ready, parser, AppBase) {
ready(function () {
try {
@@ -118,6 +122,10 @@ require(["dojo/_base/kernel",
hotkeyHandler: function (event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
+ // Arrow buttons and escape are not reported via keypress, handle them via keydown.
+ // escape = 27, left = 37, up = 38, right = 39, down = 40
+ if (event.type == "keydown" && event.which != 27 && (event.which < 37 || event.which > 40)) return;
+
const action_name = App.keyeventToAction(event);
if (action_name) {
diff --git a/js/tt-rss.js b/js/tt-rss.js
index a46fc17e4..a31404426 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -54,7 +54,11 @@ require(["dojo/_base/kernel",
"fox/Headlines",
"fox/Article",
"fox/FeedStoreModel",
- "fox/FeedTree"], function (dojo, declare, ready, parser, AppBase) {
+ "fox/FeedTree",
+ "fox/Toolbar",
+ "fox/form/Select",
+ "fox/form/ComboButton",
+ "fox/form/DropDownButton"], function (dojo, declare, ready, parser, AppBase) {
ready(function () {
try {
@@ -144,13 +148,6 @@ require(["dojo/_base/kernel",
dijit.getEnclosingWidget(toolbar.order_by).attr('value',
App.getInitParam("default_view_order_by"));
- const hash_feed_id = hash_get('f');
- const hash_feed_is_cat = hash_get('c') == "1";
-
- if (hash_feed_id != undefined) {
- Feeds.setActive(hash_feed_id, hash_feed_is_cat);
- }
-
App.setLoadingProgress(50);
this._widescreen_mode = App.getInitParam("widescreen");
@@ -203,7 +200,7 @@ require(["dojo/_base/kernel",
isCombinedMode: function() {
return App.getInitParam("combined_display_mode");
},
- hotkeyHandler(event) {
+ hotkeyHandler: function(event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
// Arrow buttons and escape are not reported via keypress, handle them via keydown.
@@ -416,6 +413,9 @@ require(["dojo/_base/kernel",
dijit.byId("feedTree").collapseCat(Feeds.getActive());
}
};
+ this.hotkey_actions["goto_read"] = function () {
+ Feeds.open({feed: -6});
+ };
this.hotkey_actions["goto_all"] = function () {
Feeds.open({feed: -4});
};