more dialog-related cleanup
This commit is contained in:
parent
3d11c61f32
commit
3268364693
|
@ -26,7 +26,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
|
|
||||||
function batch_edit_cbox($elem, $label = false) {
|
function batch_edit_cbox($elem, $label = false) {
|
||||||
print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
|
print "<input type=\"checkbox\" title=\"".__("Check to enable field")."\"
|
||||||
onchange=\"dijit.byId('feedEditDlg').toggleField(this, '$elem', '$label')\">";
|
onchange=\"App.dialogOf(this).toggleField(this, '$elem', '$label')\">";
|
||||||
}
|
}
|
||||||
|
|
||||||
function renamecat() {
|
function renamecat() {
|
||||||
|
@ -807,7 +807,8 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
$title = htmlspecialchars($title, ENT_QUOTES);
|
$title = htmlspecialchars($title, ENT_QUOTES);
|
||||||
|
|
||||||
print "<footer>
|
print "<footer>
|
||||||
<button style='float : left' class='alt-danger' dojoType='dijit.form.Button' onclick='return CommonDialogs.unsubscribeFeed($feed_id, \"$title\")'>".
|
<button style='float : left' class='alt-danger' dojoType='dijit.form.Button'
|
||||||
|
onclick='App.dialogOf(this).unsubscribeFeed($feed_id, \"$title\")'>".
|
||||||
__('Unsubscribe')."</button>
|
__('Unsubscribe')."</button>
|
||||||
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>".__('Save')."</button>
|
<button dojoType='dijit.form.Button' class='alt-primary' type='submit'>".__('Save')."</button>
|
||||||
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".__('Cancel')."</button>
|
<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".__('Cancel')."</button>
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
class Pref_Filters extends Handler_Protected {
|
class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
function csrf_ignore($method) {
|
function csrf_ignore($method) {
|
||||||
$csrf_ignored = array("index", "getfiltertree", "newrule",
|
$csrf_ignored = array("index", "getfiltertree", "savefilterorder");
|
||||||
"newaction", "savefilterorder");
|
|
||||||
|
|
||||||
return array_search($method, $csrf_ignored) !== false;
|
return array_search($method, $csrf_ignored) !== false;
|
||||||
}
|
}
|
||||||
|
@ -857,10 +856,10 @@ class Pref_Filters extends Handler_Protected {
|
||||||
print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'>
|
print "<button dojoType='dijit.form.Button' style='float : left' class='alt-info' onclick='window.open(\"https://tt-rss.org/wiki/ContentFilters\")'>
|
||||||
<i class='material-icons'>help</i> ".__("More info...")."</button>";
|
<i class='material-icons'>help</i> ".__("More info...")."</button>";
|
||||||
|
|
||||||
print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewRuleDlg').execute()\">".
|
print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick='App.dialogOf(this).execute()'>".
|
||||||
($rule ? __("Save rule") : __('Add rule'))."</button> ";
|
($rule ? __("Save rule") : __('Add rule'))."</button> ";
|
||||||
|
|
||||||
print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewRuleDlg').hide()\">".
|
print "<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".
|
||||||
__('Cancel')."</button>";
|
__('Cancel')."</button>";
|
||||||
|
|
||||||
print "</footer>";
|
print "</footer>";
|
||||||
|
@ -950,10 +949,10 @@ class Pref_Filters extends Handler_Protected {
|
||||||
|
|
||||||
print "<footer>";
|
print "<footer>";
|
||||||
|
|
||||||
print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick=\"return dijit.byId('filterNewActionDlg').execute()\">".
|
print "<button dojoType='dijit.form.Button' class='alt-primary' type='submit' onclick='App.dialogOf(this).execute()'>".
|
||||||
($action ? __("Save action") : __('Add action'))."</button> ";
|
($action ? __("Save action") : __('Add action'))."</button> ";
|
||||||
|
|
||||||
print "<button dojoType='dijit.form.Button' onclick=\"return dijit.byId('filterNewActionDlg').hide()\">".
|
print "<button dojoType='dijit.form.Button' onclick='App.dialogOf(this).hide()'>".
|
||||||
__('Cancel')."</button>";
|
__('Cancel')."</button>";
|
||||||
|
|
||||||
print "</footer>";
|
print "</footer>";
|
||||||
|
|
19
js/App.js
19
js/App.js
|
@ -99,12 +99,12 @@ const App = {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
link.onload = function () {
|
link.onload = function() {
|
||||||
document.querySelector("body").removeClassName("css_loading");
|
document.querySelector("body").removeClassName("css_loading");
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
|
|
||||||
link.onerror = function(event) {
|
link.onerror = function() {
|
||||||
alert("Fatal error while loading application stylesheet: " + link.getAttribute("href"));
|
alert("Fatal error while loading application stylesheet: " + link.getAttribute("href"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,15 +336,6 @@ const App = {
|
||||||
dialog = new fox.SingleUseDialog({
|
dialog = new fox.SingleUseDialog({
|
||||||
title: title,
|
title: title,
|
||||||
id: 'infoBox',
|
id: 'infoBox',
|
||||||
onCancel: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onExecute: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onClose: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
content: content
|
content: content
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -472,8 +463,6 @@ const App = {
|
||||||
backendSanityCallback: function(transport) {
|
backendSanityCallback: function(transport) {
|
||||||
const reply = JSON.parse(transport.responseText);
|
const reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
/* global ERRORS */
|
|
||||||
|
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
this.Error.fatal(ERRORS[3], {info: transport.responseText});
|
this.Error.fatal(ERRORS[3], {info: transport.responseText});
|
||||||
return;
|
return;
|
||||||
|
@ -677,8 +666,8 @@ const App = {
|
||||||
},
|
},
|
||||||
initSecondStage: function() {
|
initSecondStage: function() {
|
||||||
|
|
||||||
document.onkeydown = (event) => { return this.hotkeyHandler(event) };
|
document.onkeydown = (event) => this.hotkeyHandler(event);
|
||||||
document.onkeypress = (event) => { return this.hotkeyHandler(event) };
|
document.onkeypress = (event) => this.hotkeyHandler(event);
|
||||||
|
|
||||||
if (this.is_prefs) {
|
if (this.is_prefs) {
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect, fox */
|
/* global __, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect, fox */
|
||||||
|
|
||||||
/* exported CommonDialogs */
|
/* exported CommonDialogs */
|
||||||
const CommonDialogs = {
|
const CommonDialogs = {
|
||||||
|
@ -264,8 +264,6 @@ const CommonDialogs = {
|
||||||
const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id};
|
const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id};
|
||||||
|
|
||||||
xhrPost("backend.php", query, () => {
|
xhrPost("backend.php", query, () => {
|
||||||
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
|
|
||||||
|
|
||||||
if (App.isPrefs()) {
|
if (App.isPrefs()) {
|
||||||
dijit.byId("feedTree").reload();
|
dijit.byId("feedTree").reload();
|
||||||
} else {
|
} else {
|
||||||
|
@ -293,6 +291,12 @@ const CommonDialogs = {
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "feedEditDlg",
|
id: "feedEditDlg",
|
||||||
title: __("Edit Feed"),
|
title: __("Edit Feed"),
|
||||||
|
unsubscribeFeed: function(feed_id, title) {
|
||||||
|
if (confirm(__("Unsubscribe from %s?").replace("%s", title))) {
|
||||||
|
dialog.hide();
|
||||||
|
CommonDialogs.unsubscribeFeed(feed_id);
|
||||||
|
}
|
||||||
|
},
|
||||||
execute: function () {
|
execute: function () {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
Notify.progress("Saving data...", true);
|
Notify.progress("Saving data...", true);
|
||||||
|
@ -351,16 +355,6 @@ const CommonDialogs = {
|
||||||
try {
|
try {
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
title: __("Public OPML URL"),
|
title: __("Public OPML URL"),
|
||||||
id: 'publicOPMLDlg',
|
|
||||||
onCancel: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onExecute: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onClose: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
content: `
|
content: `
|
||||||
<header>${__("Your Public OPML URL is:")}</header>
|
<header>${__("Your Public OPML URL is:")}</header>
|
||||||
<section>
|
<section>
|
||||||
|
@ -399,16 +393,6 @@ const CommonDialogs = {
|
||||||
|
|
||||||
const dialog = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
title: __("Show as feed"),
|
title: __("Show as feed"),
|
||||||
id: 'genFeedDlg',
|
|
||||||
onCancel: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onExecute: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
onClose: function () {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
content: `
|
content: `
|
||||||
<header>${__("%s can be accessed via the following secret URL:").replace("%s", feed_title)}</header>
|
<header>${__("%s can be accessed via the following secret URL:").replace("%s", feed_title)}</header>
|
||||||
<section>
|
<section>
|
||||||
|
|
|
@ -90,10 +90,7 @@ const Filters = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addFilterRule: function(replaceNode, ruleStr) {
|
addFilterRule: function(replaceNode, ruleStr) {
|
||||||
if (dijit.byId("filterNewRuleDlg"))
|
const dialog = new fox.SingleUseDialog({
|
||||||
dijit.byId("filterNewRuleDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const rule_dlg = new dijit.Dialog({
|
|
||||||
id: "filterNewRuleDlg",
|
id: "filterNewRuleDlg",
|
||||||
title: ruleStr ? __("Edit rule") : __("Add rule"),
|
title: ruleStr ? __("Edit rule") : __("Add rule"),
|
||||||
execute: function () {
|
execute: function () {
|
||||||
|
@ -105,41 +102,40 @@ const Filters = {
|
||||||
content: __('Loading, please wait...'),
|
content: __('Loading, please wait...'),
|
||||||
});
|
});
|
||||||
|
|
||||||
const tmph = dojo.connect(rule_dlg, "onShow", null, function (/* e */) {
|
const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) {
|
||||||
dojo.disconnect(tmph);
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => {
|
xhrPost("backend.php", {op: 'pref-filters', method: 'newrule', rule: ruleStr}, (transport) => {
|
||||||
rule_dlg.attr('content', transport.responseText);
|
dialog.attr('content', transport.responseText);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
rule_dlg.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
addFilterAction: function(replaceNode, actionStr) {
|
addFilterAction: function(replaceNode, actionStr) {
|
||||||
if (dijit.byId("filterNewActionDlg"))
|
const dialog = new fox.SingleUseDialog({
|
||||||
dijit.byId("filterNewActionDlg").destroyRecursive();
|
|
||||||
|
|
||||||
const query = "backend.php?op=pref-filters&method=newaction&action=" +
|
|
||||||
encodeURIComponent(actionStr);
|
|
||||||
|
|
||||||
const rule_dlg = new dijit.Dialog({
|
|
||||||
id: "filterNewActionDlg",
|
|
||||||
title: actionStr ? __("Edit action") : __("Add action"),
|
title: actionStr ? __("Edit action") : __("Add action"),
|
||||||
execute: function () {
|
execute: function () {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
Filters.createNewActionElement($("filterDlg_Actions"), replaceNode);
|
Filters.createNewActionElement($("filterDlg_Actions"), replaceNode);
|
||||||
this.hide();
|
this.hide();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
href: query
|
|
||||||
});
|
});
|
||||||
|
|
||||||
rule_dlg.show();
|
const tmph = dojo.connect(dialog, "onShow", null, function (/* e */) {
|
||||||
|
dojo.disconnect(tmph);
|
||||||
|
|
||||||
|
xhrPost("backend.php", {op: 'pref-filters', method: 'newaction', action: actionStr}, (transport) => {
|
||||||
|
dialog.attr('content', transport.responseText);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
},
|
},
|
||||||
test: function(params) {
|
test: function(params) {
|
||||||
|
|
||||||
const test_dlg = new fox.SingleUseDialog({
|
const dialog = new fox.SingleUseDialog({
|
||||||
id: "filterTestDlg",
|
|
||||||
title: "Test Filter",
|
title: "Test Filter",
|
||||||
results: 0,
|
results: 0,
|
||||||
limit: 100,
|
limit: 100,
|
||||||
|
@ -147,7 +143,7 @@ const Filters = {
|
||||||
getTestResults: function (params, offset) {
|
getTestResults: function (params, offset) {
|
||||||
params.method = 'testFilterDo';
|
params.method = 'testFilterDo';
|
||||||
params.offset = offset;
|
params.offset = offset;
|
||||||
params.limit = test_dlg.limit;
|
params.limit = dialog.limit;
|
||||||
|
|
||||||
console.log("getTestResults:" + offset);
|
console.log("getTestResults:" + offset);
|
||||||
|
|
||||||
|
@ -155,16 +151,16 @@ const Filters = {
|
||||||
try {
|
try {
|
||||||
const result = JSON.parse(transport.responseText);
|
const result = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
if (result && dijit.byId("filterTestDlg") && dijit.byId("filterTestDlg").open) {
|
if (result && dialog && dialog.open) {
|
||||||
test_dlg.results += result.length;
|
dialog.results += result.length;
|
||||||
|
|
||||||
console.log("got results:" + result.length);
|
console.log("got results:" + result.length);
|
||||||
|
|
||||||
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
$("prefFilterProgressMsg").innerHTML = __("Looking for articles (%d processed, %f found)...")
|
||||||
.replace("%f", test_dlg.results)
|
.replace("%f", dialog.results)
|
||||||
.replace("%d", offset);
|
.replace("%d", offset);
|
||||||
|
|
||||||
console.log(offset + " " + test_dlg.max_offset);
|
console.log(offset + " " + dialog.max_offset);
|
||||||
|
|
||||||
for (let i = 0; i < result.length; i++) {
|
for (let i = 0; i < result.length; i++) {
|
||||||
const tmp = dojo.create("table", { innerHTML: result[i]});
|
const tmp = dojo.create("table", { innerHTML: result[i]});
|
||||||
|
@ -172,11 +168,11 @@ const Filters = {
|
||||||
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
$("prefFilterTestResultList").innerHTML += tmp.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_dlg.results < 30 && offset < test_dlg.max_offset) {
|
if (dialog.results < 30 && offset < dialog.max_offset) {
|
||||||
|
|
||||||
// get the next batch
|
// get the next batch
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
test_dlg.getTestResults(params, offset + test_dlg.limit);
|
dialog.getTestResults(params, offset + dialog.limit);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -184,31 +180,27 @@ const Filters = {
|
||||||
|
|
||||||
Element.hide("prefFilterLoadingIndicator");
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
if (test_dlg.results == 0) {
|
if (dialog.results == 0) {
|
||||||
$("prefFilterTestResultList").innerHTML = `<tr><td align='center'>
|
$("prefFilterTestResultList").innerHTML = `<tr><td align='center'>
|
||||||
${__('No recent articles matching this filter have been found.')}</td></tr>`;
|
${__('No recent articles matching this filter have been found.')}</td></tr>`;
|
||||||
$("prefFilterProgressMsg").innerHTML = "Articles matching this filter:";
|
$("prefFilterProgressMsg").innerHTML = "Articles matching this filter:";
|
||||||
} else {
|
} else {
|
||||||
$("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:")
|
$("prefFilterProgressMsg").innerHTML = __("Found %d articles matching this filter:")
|
||||||
.replace("%d", test_dlg.results);
|
.replace("%d", dialog.results);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!result) {
|
} else if (!result) {
|
||||||
console.log("getTestResults: can't parse results object");
|
console.log("getTestResults: can't parse results object");
|
||||||
|
|
||||||
Element.hide("prefFilterLoadingIndicator");
|
Element.hide("prefFilterLoadingIndicator");
|
||||||
|
|
||||||
Notify.error("Error while trying to get filter test results.");
|
Notify.error("Error while trying to get filter test results.");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("getTestResults: dialog closed, bailing out.");
|
console.log("getTestResults: dialog closed, bailing out.");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
App.Error.report(e);
|
App.Error.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
content: `
|
content: `
|
||||||
|
@ -225,11 +217,11 @@ const Filters = {
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
|
|
||||||
dojo.connect(test_dlg, "onShow", null, function (/* e */) {
|
dojo.connect(dialog, "onShow", null, function (/* e */) {
|
||||||
test_dlg.getTestResults(params, 0);
|
dialog.getTestResults(params, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test_dlg.show();
|
dialog.show();
|
||||||
},
|
},
|
||||||
edit: function(id) { // if no id, new filter dialog
|
edit: function(id) { // if no id, new filter dialog
|
||||||
let query;
|
let query;
|
||||||
|
|
Loading…
Reference in New Issue