diff options
author | Andrew Dolgov <[email protected]> | 2019-12-06 14:02:30 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2019-12-06 14:02:30 +0300 |
commit | ac95ab4a659c56afee048923883fe9ee1491c35b (patch) | |
tree | 736db91a39634a2e2c8ab8349f4d95526a486571 | |
parent | 0697eca0e111a194f15f12025ee1859b0f32843b (diff) |
user css dialog: allow saving and applying CSS without closing the dialog
-rw-r--r-- | classes/pref/prefs.php | 10 | ||||
-rw-r--r-- | include/functions.php | 2 | ||||
-rw-r--r-- | js/PrefHelpers.js | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index e66052657..b00c4c83f 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -1132,12 +1132,18 @@ class Pref_Prefs extends Handler_Protected { print_hidden("method", "setpref"); print_hidden("key", "USER_STYLESHEET"); + print "<div id='css_edit_apply_msg' style='display : none'>"; + print_warning(__("User CSS has been applied, you might need to reload the page to see all changes.")); + print "</div>"; + print "<textarea class='panel user-css-editor' dojoType='dijit.form.SimpleTextarea' style='font-size : 12px;' name='value'>$value</textarea>"; print "<footer>"; - print "<button dojoType='dijit.form.Button' - onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save')."</button> "; + print "<button dojoType='dijit.form.Button' class='alt-success' + onclick=\"dijit.byId('cssEditDlg').apply()\">".__('Apply')."</button> "; + print "<button dojoType='dijit.form.Button' class='alt-primary' + onclick=\"dijit.byId('cssEditDlg').execute()\">".__('Save and reload')."</button> "; print "<button dojoType='dijit.form.Button' onclick=\"dijit.byId('cssEditDlg').hide()\">".__('Cancel')."</button>"; print "</footer>"; diff --git a/include/functions.php b/include/functions.php index b4e91fe9c..153a96698 100644 --- a/include/functions.php +++ b/include/functions.php @@ -1584,7 +1584,7 @@ $value = get_pref('USER_STYLESHEET'); if ($value) { - print "<style type=\"text/css\">"; + print "<style type='text/css' id='user_css_style'>"; print str_replace("<br/>", "\n", $value); print "</style>"; } diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index 6a62cb593..4b908204c 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -150,6 +150,12 @@ define(["dojo/_base/declare"], function (declare) { 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); |