pref helpers: move some methods to their own sections
This commit is contained in:
parent
6af83e3881
commit
481bd76100
|
@ -1394,7 +1394,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
print "<button dojoType='dijit.form.Button' class='alt-primary'
|
print "<button dojoType='dijit.form.Button' class='alt-primary'
|
||||||
onclick='CommonDialogs.generatedFeed(-2, false, \"$rss_url\", \"".__("Published articles")."\")'>".
|
onclick='CommonDialogs.generatedFeed(-2, false, \"$rss_url\", \"".__("Published articles")."\")'>".
|
||||||
__('Display URL')."</button>
|
__('Display URL')."</button>
|
||||||
<button class='alt-danger' dojoType='dijit.form.Button' onclick='return Helpers.clearFeedAccessKeys()'>".
|
<button class='alt-danger' dojoType='dijit.form.Button' onclick='return Helpers.Feeds.clearFeedAccessKeys()'>".
|
||||||
__('Clear all generated URLs')."</button> ";
|
__('Clear all generated URLs')."</button> ";
|
||||||
|
|
||||||
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated");
|
PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB_SECTION, "prefFeedsPublishedGenerated");
|
||||||
|
|
|
@ -715,7 +715,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
print "</select>";
|
print "</select>";
|
||||||
|
|
||||||
print " <button dojoType=\"dijit.form.Button\" class='alt-info'
|
print " <button dojoType=\"dijit.form.Button\" class='alt-info'
|
||||||
onclick=\"Helpers.customizeCSS()\">" . __('Customize') . "</button>";
|
onclick=\"Helpers.Prefs.customizeCSS()\">" . __('Customize') . "</button>";
|
||||||
|
|
||||||
print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'>
|
print " <button dojoType='dijit.form.Button' onclick='window.open(\"https://tt-rss.org/wiki/Themes\")'>
|
||||||
<i class='material-icons'>open_in_new</i> ".__("More themes...")."</button>";
|
<i class='material-icons'>open_in_new</i> ".__("More themes...")."</button>";
|
||||||
|
@ -830,10 +830,10 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
</div>
|
</div>
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.editProfiles()\">".
|
print "<button dojoType=\"dijit.form.Button\" onclick=\"return Helpers.Profiles.edit()\">".
|
||||||
__('Manage profiles')."</button> ";
|
__('Manage profiles')."</button> ";
|
||||||
|
|
||||||
print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.confirmReset()\">".
|
print "<button dojoType=\"dijit.form.Button\" class=\"alt-danger\" onclick=\"return Helpers.Prefs.confirmReset()\">".
|
||||||
__('Reset to defaults')."</button>";
|
__('Reset to defaults')."</button>";
|
||||||
|
|
||||||
print " ";
|
print " ";
|
||||||
|
@ -968,7 +968,7 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
if (count($tmppluginhost->get_all($plugin)) > 0) {
|
if (count($tmppluginhost->get_all($plugin)) > 0) {
|
||||||
if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
|
if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) {
|
||||||
print " <button dojoType='dijit.form.Button'
|
print " <button dojoType='dijit.form.Button'
|
||||||
onclick=\"Helpers.clearPluginData('$name')\">
|
onclick=\"Helpers.Prefs.clearPluginData('$name')\">
|
||||||
<i class='material-icons'>clear</i> ".__("Clear data")."</button>";
|
<i class='material-icons'>clear</i> ".__("Clear data")."</button>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,16 +40,18 @@ const Helpers = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
clearFeedAccessKeys: function() {
|
Feeds: {
|
||||||
if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
|
clearFeedAccessKeys: function() {
|
||||||
Notify.progress("Clearing URLs...");
|
if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
|
||||||
|
Notify.progress("Clearing URLs...");
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => {
|
xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => {
|
||||||
Notify.info("Generated URLs cleared.");
|
Notify.info("Generated URLs cleared.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
System: {
|
System: {
|
||||||
getPHPInfo: function(widget) {
|
getPHPInfo: function(widget) {
|
||||||
|
@ -90,151 +92,155 @@ const Helpers = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
editProfiles: function() {
|
Profiles: {
|
||||||
const dialog = new fox.SingleUseDialog({
|
edit: function() {
|
||||||
id: "profileEditDlg",
|
const dialog = new fox.SingleUseDialog({
|
||||||
title: __("Settings Profiles"),
|
id: "profileEditDlg",
|
||||||
getSelectedProfiles: function () {
|
title: __("Settings Profiles"),
|
||||||
return Tables.getSelected("pref-profiles-list");
|
getSelectedProfiles: function () {
|
||||||
},
|
return Tables.getSelected("pref-profiles-list");
|
||||||
removeSelected: function () {
|
},
|
||||||
const sel_rows = this.getSelectedProfiles();
|
removeSelected: function () {
|
||||||
|
const sel_rows = this.getSelectedProfiles();
|
||||||
|
|
||||||
if (sel_rows.length > 0) {
|
if (sel_rows.length > 0) {
|
||||||
if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) {
|
if (confirm(__("Remove selected profiles? Active and default profiles will not be removed."))) {
|
||||||
Notify.progress("Removing selected profiles...", true);
|
Notify.progress("Removing selected profiles...", true);
|
||||||
|
|
||||||
const query = {
|
const query = {
|
||||||
op: "rpc", method: "remprofiles",
|
op: "rpc", method: "remprofiles",
|
||||||
ids: sel_rows.toString()
|
ids: sel_rows.toString()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xhrPost("backend.php", query, () => {
|
||||||
|
Notify.close();
|
||||||
|
dialog.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(__("No profiles selected."));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
addProfile: function () {
|
||||||
|
if (this.validate()) {
|
||||||
|
Notify.progress("Creating profile...", true);
|
||||||
|
|
||||||
|
const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile};
|
||||||
|
|
||||||
xhrPost("backend.php", query, () => {
|
xhrPost("backend.php", query, () => {
|
||||||
Notify.close();
|
Notify.close();
|
||||||
dialog.refresh();
|
dialog.refresh();
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
} else {
|
refresh: function() {
|
||||||
alert(__("No profiles selected."));
|
xhrPost("backend.php", {op: 'pref-prefs', method: 'editPrefProfiles'}, (transport) => {
|
||||||
}
|
dialog.attr('content', transport.responseText);
|
||||||
},
|
|
||||||
addProfile: function () {
|
|
||||||
if (this.validate()) {
|
|
||||||
Notify.progress("Creating profile...", true);
|
|
||||||
|
|
||||||
const query = {op: "rpc", method: "addprofile", title: dialog.attr('value').newprofile};
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, () => {
|
|
||||||
Notify.close();
|
|
||||||
dialog.refresh();
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
refresh: function() {
|
|
||||||
xhrPost("backend.php", {op: 'pref-prefs', method: 'editPrefProfiles'}, (transport) => {
|
|
||||||
dialog.attr('content', transport.responseText);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
execute: function () {
|
|
||||||
const sel_rows = this.getSelectedProfiles();
|
|
||||||
|
|
||||||
if (sel_rows.length == 1) {
|
|
||||||
if (confirm(__("Activate selected profile?"))) {
|
|
||||||
Notify.progress("Loading, please wait...");
|
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
alert(__("Please choose a profile to activate."));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content: ""
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog.refresh();
|
|
||||||
dialog.show();
|
|
||||||
},
|
|
||||||
customizeCSS: function() {
|
|
||||||
xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => {
|
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
|
||||||
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 () {
|
execute: function () {
|
||||||
Notify.progress('Saving data...', true);
|
const sel_rows = this.getSelectedProfiles();
|
||||||
|
|
||||||
xhrPost("backend.php", this.attr('value'), () => {
|
if (sel_rows.length == 1) {
|
||||||
window.location.reload();
|
if (confirm(__("Activate selected profile?"))) {
|
||||||
});
|
Notify.progress("Loading, please wait...");
|
||||||
|
|
||||||
|
xhrPost("backend.php", {op: "rpc", method: "setprofile", id: sel_rows.toString()}, () => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alert(__("Please choose a profile to activate."));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
content: `
|
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>
|
|
||||||
`
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
dialog.refresh();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Prefs: {
|
||||||
|
customizeCSS: function() {
|
||||||
|
xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => {
|
||||||
|
|
||||||
});
|
const dialog = new fox.SingleUseDialog({
|
||||||
},
|
title: __("Customize stylesheet"),
|
||||||
confirmReset: function() {
|
apply: function() {
|
||||||
if (confirm(__("Reset to defaults?"))) {
|
xhrPost("backend.php", this.attr('value'), () => {
|
||||||
xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => {
|
new Effect.Appear("css_edit_apply_msg");
|
||||||
Helpers.refresh();
|
$("user_css_style").innerText = this.attr('value');
|
||||||
Notify.info(transport.responseText);
|
});
|
||||||
});
|
},
|
||||||
}
|
execute: function () {
|
||||||
},
|
Notify.progress('Saving data...', true);
|
||||||
clearPluginData: function(name) {
|
|
||||||
if (confirm(__("Clear stored data for this plugin?"))) {
|
xhrPost("backend.php", this.attr('value'), () => {
|
||||||
Notify.progress("Loading, please wait...");
|
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>
|
||||||
|
`
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
|
||||||
xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => {
|
|
||||||
Helpers.refresh();
|
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
},
|
confirmReset: function() {
|
||||||
refresh: function() {
|
if (confirm(__("Reset to defaults?"))) {
|
||||||
xhrPost("backend.php", { op: "pref-prefs" }, (transport) => {
|
xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => {
|
||||||
dijit.byId('prefsTab').attr('content', transport.responseText);
|
Helpers.Prefs.refresh();
|
||||||
Notify.close();
|
Notify.info(transport.responseText);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
clearPluginData: function(name) {
|
||||||
|
if (confirm(__("Clear stored data for this plugin?"))) {
|
||||||
|
Notify.progress("Loading, please wait...");
|
||||||
|
|
||||||
|
xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => {
|
||||||
|
Helpers.Prefs.refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
refresh: function() {
|
||||||
|
xhrPost("backend.php", { op: "pref-prefs" }, (transport) => {
|
||||||
|
dijit.byId('prefsTab').attr('content', transport.responseText);
|
||||||
|
Notify.close();
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
OPML: {
|
OPML: {
|
||||||
import: function() {
|
import: function() {
|
||||||
|
|
Loading…
Reference in New Issue