summaryrefslogtreecommitdiff
path: root/js/PrefFeedTree.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-12 15:22:10 +0300
committerAndrew Dolgov <[email protected]>2021-02-12 15:22:10 +0300
commit3d11c61f326ef133427f6f37de4429e879c725f2 (patch)
tree472a31623e184383ae61d189662fb29a3808f454 /js/PrefFeedTree.js
parent219cc9a0ab0da20cb82df2647508e29f7f9d1515 (diff)
* OPML import: don't reload everything, just feed tree
* dialogs: use auto-destroying dialog for almost all dialogs instead of destroying them manually * some general dialog-related cleanup
Diffstat (limited to 'js/PrefFeedTree.js')
-rw-r--r--js/PrefFeedTree.js134
1 files changed, 60 insertions, 74 deletions
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js
index 21b8ee272..c8c8118c1 100644
--- a/js/PrefFeedTree.js
+++ b/js/PrefFeedTree.js
@@ -1,4 +1,4 @@
-/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost */
+/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, fox, App */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
@@ -250,64 +250,65 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
Notify.progress("Loading, please wait...");
- if (dijit.byId("feedEditDlg"))
- dijit.byId("feedEditDlg").destroyRecursive();
-
xhrPost("backend.php", {op: "pref-feeds", method: "editfeeds", ids: rows.toString()}, (transport) => {
Notify.close();
- const dialog = new dijit.Dialog({
- id: "feedEditDlg",
- title: __("Edit Multiple Feeds"),
- getChildByName: function (name) {
- let rv = null;
- this.getChildren().each(
- function (child) {
- if (child.name == name) {
- rv = child;
- return;
- }
- });
- return rv;
- },
- toggleField: function (checkbox, elem, label) {
- this.getChildByName(elem).attr('disabled', !checkbox.checked);
-
- if ($(label))
- if (checkbox.checked)
- $(label).removeClassName('text-muted');
- else
- $(label).addClassName('text-muted');
-
- },
- execute: function () {
- if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
- const query = this.attr('value');
-
- /* normalize unchecked checkboxes because [] is not serialized */
-
- Object.keys(query).each((key) => {
- let val = query[key];
-
- if (typeof val == "object" && val.length == 0)
- query[key] = ["off"];
- });
-
- Notify.progress("Saving data...", true);
-
- xhrPost("backend.php", query, () => {
- dialog.hide();
-
- const tree = dijit.byId("feedTree");
-
- if (tree) tree.reload();
- });
- }
- },
- content: transport.responseText
- });
+ try {
+ const dialog = new fox.SingleUseDialog({
+ id: "feedEditDlg",
+ title: __("Edit Multiple Feeds"),
+ getChildByName: function (name) {
+ let rv = null;
+ this.getChildren().each(
+ function (child) {
+ if (child.name == name) {
+ rv = child;
+ return;
+ }
+ });
+ return rv;
+ },
+ toggleField: function (checkbox, elem, label) {
+ this.getChildByName(elem).attr('disabled', !checkbox.checked);
+
+ if ($(label))
+ if (checkbox.checked)
+ $(label).removeClassName('text-muted');
+ else
+ $(label).addClassName('text-muted');
+
+ },
+ execute: function () {
+ if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
+ const query = this.attr('value');
+
+ /* normalize unchecked checkboxes because [] is not serialized */
+
+ Object.keys(query).each((key) => {
+ let val = query[key];
+
+ if (typeof val == "object" && val.length == 0)
+ query[key] = ["off"];
+ });
+
+ Notify.progress("Saving data...", true);
+
+ xhrPost("backend.php", query, () => {
+ dialog.hide();
+
+ const tree = dijit.byId("feedTree");
+
+ if (tree) tree.reload();
+ });
+ }
+ },
+ content: transport.responseText
+ });
- dialog.show();
+ dialog.show();
+ } catch (e) {
+ App.Error.report(e);
+ }
});
},
editCategory: function(id, item) {
@@ -339,13 +340,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
}
},
batchSubscribe: function() {
- const query = "backend.php?op=pref-feeds&method=batchSubscribe";
-
- // overlapping widgets
- if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
- if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
-
- const dialog = new dijit.Dialog({
+ const dialog = new fox.SingleUseDialog({
id: "batchSubDlg",
title: __("Batch subscribe"),
execute: function () {
@@ -362,18 +357,13 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
});
}
},
- href: query
+ href: "backend.php?" + dojo.objectToQuery({op: 'pref-feeds', method: 'batchSubscribe'})
});
dialog.show();
},
showInactiveFeeds: function() {
- const query = "backend.php?op=pref-feeds&method=inactiveFeeds";
-
- if (dijit.byId("inactiveFeedsDlg"))
- dijit.byId("inactiveFeedsDlg").destroyRecursive();
-
- const dialog = new dijit.Dialog({
+ const dialog = new fox.SingleUseDialog({
id: "inactiveFeedsDlg",
title: __("Feeds without recent updates"),
getSelectedFeeds: function () {
@@ -405,11 +395,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
alert(__("No feeds selected."));
}
},
- execute: function () {
- if (this.validate()) {
- }
- },
- href: query
+ href: 'backend.php?' + dojo.objectToQuery({op: 'pref-feeds', method: 'inactiveFeeds'})
});
dialog.show();