diff options
author | Andrew Dolgov <[email protected]> | 2021-02-12 09:02:44 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-12 09:02:44 +0300 |
commit | d466284fabe945dbc3c8034ac1468bf97b38ed94 (patch) | |
tree | c500c2f43d8f6dae470072febe9177339c0c3bc3 /js | |
parent | cb7c075cd2db606f251b852342c2ed90ac591252 (diff) |
* customizeCSS: client dialog
* remove hardcoded width from most dialogs (move to css)
* add helper to easily get dialog from its widget
* rework some dialog buttons to use current object instead of calling dialog by name
Diffstat (limited to 'js')
-rw-r--r-- | js/App.js | 33 | ||||
-rw-r--r-- | js/Article.js | 1 | ||||
-rw-r--r-- | js/CommonDialogs.js | 5 | ||||
-rw-r--r-- | js/CommonFilters.js | 4 | ||||
-rw-r--r-- | js/Feeds.js | 3 | ||||
-rw-r--r-- | js/PrefFeedTree.js | 3 | ||||
-rw-r--r-- | js/PrefFilterTree.js | 2 | ||||
-rw-r--r-- | js/PrefHelpers.js | 75 | ||||
-rw-r--r-- | js/PrefUsers.js | 1 |
9 files changed, 66 insertions, 61 deletions
@@ -16,6 +16,11 @@ const App = { hotkey_actions: {}, is_prefs: false, LABEL_BASE_INDEX: -1024, + FormFields: { + hidden: function(name, value) { + return `<input dojoType="dijit.form.TextBox" style="display : none" name="${name}" value="${value}"></input>` + } + }, Scrollable: { scrollByPages: function (elem, page_offset) { if (!elem) return; @@ -49,6 +54,9 @@ const App = { elem.offsetTop >= ctr.scrollTop; } }, + dialogOf: function (widget) { + return dijit.getEnclosingWidget(widget.domNode.closest('.dijitDialog')); + }, label_to_feed_id: function(label) { return this.LABEL_BASE_INDEX - 1 - Math.abs(label); }, @@ -300,20 +308,15 @@ const App = { } }, helpDialog: function(topic) { - if (dijit.byId("helpDlg")) - dijit.byId("helpDlg").destroyRecursive(); - - xhrPost("backend.php", {op: "backend", method: "help", topic: topic}, (transport) => { - const dialog = new dijit.Dialog({ - id: "helpDlg", - title: __("Help"), - style: "width: 600px", - content: transport.responseText, - }); - - dialog.show(); - }); - }, + xhrPost("backend.php", {op: "backend", method: "help", topic: topic}, (transport) => { + const dialog = new dijit.Dialog({ + title: __("Help"), + content: transport.responseText, + }); + + dialog.show(); + }); + }, displayDlg: function(title, id, param, callback) { Notify.progress("Loading, please wait...", true); @@ -329,7 +332,6 @@ const App = { dialog = new dijit.Dialog({ title: title, id: 'infoBox', - style: "width: 600px", onCancel: function () { return true; }, @@ -596,7 +598,6 @@ const App = { const dialog = new dijit.Dialog({ id: "exceptionDlg", title: params.title || __("Unhandled exception"), - style: "width: 600px", content: content }); diff --git a/js/Article.js b/js/Article.js index a075e321f..538377f45 100644 --- a/js/Article.js +++ b/js/Article.js @@ -258,7 +258,6 @@ const Article = { const dialog = new dijit.Dialog({ id: "editTagsDlg", title: __("Edit article Tags"), - style: "width: 600px", content: transport.responseText, execute: function () { if (this.validate()) { diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 72c3653b3..b41065c63 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -87,7 +87,6 @@ const CommonDialogs = { const dialog = new dijit.Dialog({ id: "feedAddDlg", title: __("Subscribe to Feed"), - style: "width: 600px", content: transport.responseText, show_error: function (msg) { const elem = $("fadd_error_message"); @@ -199,7 +198,6 @@ const CommonDialogs = { const dialog = new dijit.Dialog({ id: "errorFeedsDlg", title: __("Feeds with update errors"), - style: "width: 600px", getSelectedFeeds: function () { return Tables.getSelected("error-feeds-list"); }, @@ -309,7 +307,6 @@ const CommonDialogs = { const dialog = new dijit.Dialog({ id: "feedEditDlg", title: __("Edit Feed"), - style: "width: 600px", execute: function () { if (this.validate()) { Notify.progress("Saving data...", true); @@ -372,7 +369,6 @@ const CommonDialogs = { const dialog = new dijit.Dialog({ title: __("Public OPML URL"), id: 'publicOPMLDlg', - style: "width: 600px", onCancel: function () { return true; }, @@ -425,7 +421,6 @@ const CommonDialogs = { const dialog = new dijit.Dialog({ title: __("Show as feed"), id: 'genFeedDlg', - style: "width: 600px", onCancel: function () { return true; }, diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 9676abe9e..27bf78a02 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -130,7 +130,6 @@ const Filters = { const rule_dlg = new dijit.Dialog({ id: "filterNewRuleDlg", title: ruleStr ? __("Edit rule") : __("Add rule"), - style: "width: 600px", execute: function () { if (this.validate()) { Filters.createNewRuleElement($("filterDlg_Matches"), replaceNode); @@ -160,7 +159,6 @@ const Filters = { const rule_dlg = new dijit.Dialog({ id: "filterNewActionDlg", title: actionStr ? __("Edit action") : __("Add action"), - style: "width: 600px", execute: function () { if (this.validate()) { Filters.createNewActionElement($("filterDlg_Actions"), replaceNode); @@ -180,7 +178,6 @@ const Filters = { const test_dlg = new dijit.Dialog({ id: "filterTestDlg", title: "Test Filter", - style: "width: 600px", results: 0, limit: 100, max_offset: 10000, @@ -283,7 +280,6 @@ const Filters = { const dialog = new dijit.Dialog({ id: "filterEditDlg", title: __("Create Filter"), - style: "width: 600px", test: function () { Filters.editFilterTest(dojo.formToObject("filter_new_form")); }, diff --git a/js/Feeds.js b/js/Feeds.js index 1e476dd98..10677f641 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -241,7 +241,6 @@ const Feeds = { </button> </footer>`, id: 'defaultPasswordDlg', - style: "width: 600px", onCancel: function () { return true; }, @@ -273,7 +272,6 @@ const Feeds = { </footer> `, id: 'safeModeDlg', - style: "width: 600px", onCancel: function () { return true; }, @@ -608,7 +606,6 @@ const Feeds = { id: "searchDlg", content: transport.responseText, title: __("Search"), - style: "width: 600px", execute: function () { if (this.validate()) { Feeds._search_query = this.attr('value'); diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js index acd410a2c..4c8c25d0e 100644 --- a/js/PrefFeedTree.js +++ b/js/PrefFeedTree.js @@ -259,7 +259,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio const dialog = new dijit.Dialog({ id: "feedEditDlg", title: __("Edit Multiple Feeds"), - style: "width: 600px", getChildByName: function (name) { let rv = null; this.getChildren().each( @@ -346,7 +345,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio const dialog = new dijit.Dialog({ id: "batchSubDlg", title: __("Batch subscribe"), - style: "width: 600px", execute: function () { if (this.validate()) { Notify.progress(__("Subscribing to feeds..."), true); @@ -372,7 +370,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio const dialog = new dijit.Dialog({ id: "inactiveFeedsDlg", title: __("Feeds without recent updates"), - style: "width: 600px", getSelectedFeeds: function () { return Tables.getSelected("inactive-feeds-list"); }, diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index b2041d182..a2e625bc1 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -147,8 +147,6 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio const dialog = new dijit.Dialog({ id: "filterEditDlg", title: __("Edit Filter"), - style: "width: 600px", - test: function () { Filters.editFilterTest(dojo.formToObject("filter_edit_form")); }, diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 4edb3eb4d..966e8151e 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,6 +1,6 @@ 'use strict'; -/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson */ +/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App */ const Helpers = { AppPasswords: { @@ -93,7 +93,6 @@ const Helpers = { const dialog = new dijit.Dialog({ id: "profileEditDlg", title: __("Settings Profiles"), - style: "width: 600px", getSelectedProfiles: function () { return Tables.getSelected("pref-profiles-list"); }, @@ -159,33 +158,58 @@ const Helpers = { dialog.show(); }, customizeCSS: function() { - const query = "backend.php?op=pref-prefs&method=customizeCSS"; - - if (dijit.byId("cssEditDlg")) - dijit.byId("cssEditDlg").destroyRecursive(); + xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => { + + const dialog = new dijit.Dialog({ + title: __("Customize stylesheet"), + apply: function() { + xhrPost("backend.php", this.attr('value'), () => { + new Effect.Appear("css_edit_apply_msg"); + $("user_css_style").innerText = this.attr('value'); + }); + }, + execute: function () { + Notify.progress('Saving data...', true); - const dialog = new dijit.Dialog({ - id: "cssEditDlg", - title: __("Customize stylesheet"), - style: "width: 600px", - apply: function() { - xhrPost("backend.php", this.attr('value'), () => { - new Effect.Appear("css_edit_apply_msg"); - $("user_css_style").innerText = this.attr('value'); - }); - }, - execute: function () { - Notify.progress('Saving data...', true); + xhrPost("backend.php", this.attr('value'), () => { + window.location.reload(); + }); + }, + content: ` + <div class='alert alert-info'> + ${__("You can override colors, fonts and layout of your currently selected theme with custom CSS declarations here.")} + </div> + + ${App.FormFields.hidden('op', 'rpc')} + ${App.FormFields.hidden('method', 'setpref')} + ${App.FormFields.hidden('key', 'USER_STYLESHEET')} + + <div id='css_edit_apply_msg' style='display : none'> + <div class='alert alert-warning'> + ${__("User CSS has been applied, you might need to reload the page to see all changes.")} + </div> + </div> + + <textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea' + style='font-size : 12px;' name='value'>${reply.value}</textarea> + + <footer> + <button dojoType='dijit.form.Button' class='alt-success' onclick="App.dialogOf(this).apply()"> + ${__('Apply')} + </button> + <button dojoType='dijit.form.Button' class='alt-primary' type='submit'> + ${__('Save and reload')} + </button> + <button dojoType='dijit.form.Button' onclick="App.dialogOf(this).hide()"> + ${__('Cancel')} + </button> + </footer> + ` + }); - xhrPost("backend.php", this.attr('value'), () => { - window.location.reload(); - }); + dialog.show(); - }, - href: query }); - - dialog.show(); }, confirmReset: function() { if (confirm(__("Reset to defaults?"))) { @@ -228,7 +252,6 @@ const Helpers = { const dialog = new dijit.Dialog({ title: __("OPML Import"), - style: "width: 600px", onCancel: function () { window.location.reload(); }, diff --git a/js/PrefUsers.js b/js/PrefUsers.js index 2cebce6ef..a332a9140 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -36,7 +36,6 @@ const Users = { const dialog = new dijit.Dialog({ id: "userEditDlg", title: __("User Editor"), - style: "width: 600px", execute: function () { if (this.validate()) { Notify.progress("Saving data...", true); |