From 3d11c61f326ef133427f6f37de4429e879c725f2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 12 Feb 2021 15:22:10 +0300 Subject: * 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 --- js/Feeds.js | 112 +++++++++++++++++++++++------------------------------------- 1 file changed, 42 insertions(+), 70 deletions(-) (limited to 'js/Feeds.js') diff --git a/js/Feeds.js b/js/Feeds.js index 45b8193e4..986936285 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,6 +1,6 @@ 'use strict' -/* global __, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$ */ +/* global __, App, Headlines, xhrPost, dojo, dijit, Form, fox, PluginHost, Notify, $$, fox */ const Feeds = { counters_last_request: 0, @@ -223,10 +223,7 @@ const Feeds = { if (App.getInitParam("is_default_pw")) { console.warn("user password is at default value"); - if (dijit.byId("defaultPasswordDlg")) - dijit.byId("defaultPasswordDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Your password is at default value"), content: `
${__("You are using default tt-rss password. Please change it in the Preferences (Personal data / Authentication).")} @@ -236,51 +233,26 @@ const Feeds = { - - `, - id: 'defaultPasswordDlg', - onCancel: function () { - return true; - }, - onExecute: function () { - return true; - }, - onClose: function () { - return true; - } + ` }); dialog.show(); } - if (dijit.byId("safeModeDlg")) - dijit.byId("safeModeDlg").destroyRecursive(); - if (App.getInitParam("safe_mode")) { - const dialog = new dijit.Dialog({ + const dialog = new fox.SingleUseDialog({ title: __("Safe mode"), - content: ` -
+ content: `
${__('Tiny Tiny RSS is running in safe mode. All themes and plugins are disabled. You will need to log out and back in to disable it.')}
- `, - id: 'safeModeDlg', - onCancel: function () { - return true; - }, - onExecute: function () { - return true; - }, - onClose: function () { - return true; - } + ` }); dialog.show(); @@ -598,43 +570,43 @@ const Feeds = { {op: "feeds", method: "search", param: Feeds.getActive() + ":" + Feeds.activeIsCat()}, (transport) => { - if (dijit.byId("searchDlg")) - dijit.byId("searchDlg").destroyRecursive(); - - const dialog = new dijit.Dialog({ - id: "searchDlg", - content: transport.responseText, - title: __("Search"), - 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(); + try { + const dialog = new fox.SingleUseDialog({ + id: "searchDlg", + content: transport.responseText, + title: __("Search"), + 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(); + } + }, + }); + + const tmph = dojo.connect(dialog, 'onShow', 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); } - }, - }); - - const tmph = dojo.connect(dialog, 'onShow', 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(); + dialog.show(); + } catch (e) { + App.Error.report(e); + } }); }, -- cgit v1.2.3