prefs: store active tab for reload, remove most old table row functions
This commit is contained in:
parent
aa2f119eb6
commit
e23b6e397d
|
@ -1412,9 +1412,9 @@ class Pref_Feeds extends Handler_Protected {
|
|||
print "<div dojoType=\"dijit.form.DropDownButton\">".
|
||||
"<span>" . __('Select')."</span>";
|
||||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
||||
print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'all')\"
|
||||
print "<div onclick=\"Tables.select('prefInactiveFeedList', true)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('All')."</div>";
|
||||
print "<div onclick=\"selectTableRows('prefInactiveFeedList', 'none')\"
|
||||
print "<div onclick=\"Tables.select('prefInactiveFeedList', false)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('None')."</div>";
|
||||
print "</div></div>";
|
||||
print "</div>"; #toolbar
|
||||
|
@ -1428,15 +1428,12 @@ class Pref_Feeds extends Handler_Protected {
|
|||
while ($line = $sth->fetch()) {
|
||||
|
||||
$feed_id = $line["id"];
|
||||
$this_row_id = "id=\"FUPDD-$feed_id\"";
|
||||
|
||||
# class needed for selectTableRows()
|
||||
print "<tr class=\"placeholder\" $this_row_id>";
|
||||
print "<tr class=\"placeholder\" data-row-id='$feed_id'>";
|
||||
|
||||
# id needed for selectTableRows()
|
||||
print "<td width='5%' align='center'><input
|
||||
onclick='Tables.onRowChecked(this);' dojoType=\"dijit.form.CheckBox\"
|
||||
type=\"checkbox\" id=\"FUPDC-$feed_id\"></td>";
|
||||
type=\"checkbox\"></td>";
|
||||
print "<td>";
|
||||
|
||||
print "<a class=\"visibleLink\" href=\"#\" ".
|
||||
|
@ -1477,9 +1474,9 @@ class Pref_Feeds extends Handler_Protected {
|
|||
print "<div dojoType=\"dijit.form.DropDownButton\">".
|
||||
"<span>" . __('Select')."</span>";
|
||||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
||||
print "<div onclick=\"selectTableRows('prefErrorFeedList', 'all')\"
|
||||
print "<div onclick=\"Tables.select('prefErrorFeedList', true)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('All')."</div>";
|
||||
print "<div onclick=\"selectTableRows('prefErrorFeedList', 'none')\"
|
||||
print "<div onclick=\"Tables.select('prefErrorFeedList', false)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('None')."</div>";
|
||||
print "</div></div>";
|
||||
print "</div>"; #toolbar
|
||||
|
@ -1493,15 +1490,12 @@ class Pref_Feeds extends Handler_Protected {
|
|||
while ($line = $sth->fetch()) {
|
||||
|
||||
$feed_id = $line["id"];
|
||||
$this_row_id = "id=\"FERDD-$feed_id\"";
|
||||
|
||||
# class needed for selectTableRows()
|
||||
print "<tr class=\"placeholder\" $this_row_id>";
|
||||
print "<tr class=\"placeholder\" data-row-id='$feed_id'>";
|
||||
|
||||
# id needed for selectTableRows()
|
||||
print "<td width='5%' align='center'><input
|
||||
onclick='Tables.onRowChecked(this);' dojoType=\"dijit.form.CheckBox\"
|
||||
type=\"checkbox\" id=\"FERDC-$feed_id\"></td>";
|
||||
type=\"checkbox\"></td>";
|
||||
print "<td>";
|
||||
|
||||
print "<a class=\"visibleLink\" href=\"#\" ".
|
||||
|
|
|
@ -992,9 +992,9 @@ class Pref_Prefs extends Handler_Protected {
|
|||
print "<div dojoType=\"dijit.form.DropDownButton\">".
|
||||
"<span>" . __('Select')."</span>";
|
||||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
||||
print "<div onclick=\"selectTableRows('prefFeedProfileList', 'all')\"
|
||||
print "<div onclick=\"Tables.select('prefFeedProfileList', true)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('All')."</div>";
|
||||
print "<div onclick=\"selectTableRows('prefFeedProfileList', 'none')\"
|
||||
print "<div onclick=\"Tables.select('prefFeedProfileList', false)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('None')."</div>";
|
||||
print "</div></div>";
|
||||
|
||||
|
@ -1019,10 +1019,9 @@ class Pref_Prefs extends Handler_Protected {
|
|||
print "<table width=\"100%\" class=\"prefFeedProfileList\"
|
||||
cellspacing=\"0\" id=\"prefFeedProfileList\">";
|
||||
|
||||
print "<tr class=\"placeholder\" id=\"FCATR-0\">"; #odd
|
||||
print "<tr class=\"placeholder\">"; # data-row-id='0' <-- no point, shouldn't be removed
|
||||
|
||||
print "<td width='5%' align='center'><input
|
||||
id='FCATC-0'
|
||||
onclick='Tables.onRowChecked(this);'
|
||||
dojoType=\"dijit.form.CheckBox\"
|
||||
type=\"checkbox\"></td>";
|
||||
|
@ -1043,15 +1042,13 @@ class Pref_Prefs extends Handler_Protected {
|
|||
while ($line = $sth->fetch()) {
|
||||
|
||||
$profile_id = $line["id"];
|
||||
$this_row_id = "id=\"FCATR-$profile_id\"";
|
||||
|
||||
print "<tr class=\"placeholder\" $this_row_id>";
|
||||
print "<tr class=\"placeholder\" data-row-id='$profile_id'>";
|
||||
|
||||
$edit_title = htmlspecialchars($line["title"]);
|
||||
|
||||
print "<td width='5%' align='center'><input
|
||||
onclick='Tables.onRowChecked(this);'
|
||||
id='FCATC-$profile_id'
|
||||
dojoType=\"dijit.form.CheckBox\"
|
||||
type=\"checkbox\"></td>";
|
||||
|
||||
|
|
|
@ -354,9 +354,9 @@ class Pref_Users extends Handler_Protected {
|
|||
print "<div dojoType=\"dijit.form.DropDownButton\">".
|
||||
"<span>" . __('Select')."</span>";
|
||||
print "<div dojoType=\"dijit.Menu\" style=\"display: none;\">";
|
||||
print "<div onclick=\"selectTableRows('prefUserList', 'all')\"
|
||||
print "<div onclick=\"Tables.select('prefUserList', true)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('All')."</div>";
|
||||
print "<div onclick=\"selectTableRows('prefUserList', 'none')\"
|
||||
print "<div onclick=\"Tables.select('prefUserList', false)\"
|
||||
dojoType=\"dijit.MenuItem\">".__('None')."</div>";
|
||||
print "</div></div>";
|
||||
|
||||
|
@ -412,7 +412,7 @@ class Pref_Users extends Handler_Protected {
|
|||
|
||||
$uid = $line["id"];
|
||||
|
||||
print "<tr id=\"UMRR-$uid\">";
|
||||
print "<tr data-row-id=\"$uid\">";
|
||||
|
||||
$line["login"] = htmlspecialchars($line["login"]);
|
||||
|
||||
|
@ -420,8 +420,7 @@ class Pref_Users extends Handler_Protected {
|
|||
$line["last_login"] = make_local_datetime($line["last_login"], false);
|
||||
|
||||
print "<td align='center'><input onclick='Tables.onRowChecked(this);'
|
||||
dojoType=\"dijit.form.CheckBox\" type=\"checkbox\"
|
||||
id=\"UMCHK-$uid\"></td>";
|
||||
dojoType=\"dijit.form.CheckBox\" type=\"checkbox\"></td>";
|
||||
|
||||
$onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'";
|
||||
|
||||
|
|
|
@ -55,10 +55,14 @@ Array.prototype.remove = function(s) {
|
|||
|
||||
const Lists = {
|
||||
onRowChecked: function(elem) {
|
||||
const checked = elem.domNode ? elem.attr("checked") : elem.checked;
|
||||
// account for dojo checkboxes
|
||||
elem = elem.domNode || elem;
|
||||
|
||||
elem.up("li").toggleClassName("Selected");
|
||||
const row = elem.up("li");
|
||||
|
||||
if (row)
|
||||
checked ? row.addClassName("Selected") : row.removeClassName("Selected");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -66,9 +70,30 @@ const Lists = {
|
|||
const Tables = {
|
||||
onRowChecked: function(elem) {
|
||||
// account for dojo checkboxes
|
||||
const checked = elem.domNode ? elem.attr("checked") : elem.checked;
|
||||
elem = elem.domNode || elem;
|
||||
|
||||
elem.up("tr").toggleClassName("Selected");
|
||||
const row = elem.up("tr");
|
||||
|
||||
if (row)
|
||||
checked ? row.addClassName("Selected") : row.removeClassName("Selected");
|
||||
|
||||
},
|
||||
select: function(elemId, selected) {
|
||||
$(elemId).select("tr").each((row) => {
|
||||
const checkNode = row.select(".dijitCheckBox,input[type=checkbox]")[0];
|
||||
if (checkNode) {
|
||||
const widget = dijit.getEnclosingWidget(checkNode);
|
||||
|
||||
if (widget) {
|
||||
widget.attr("checked", selected);
|
||||
} else {
|
||||
checkNode.checked = selected;
|
||||
}
|
||||
|
||||
this.onRowChecked(widget);
|
||||
}
|
||||
});
|
||||
},
|
||||
getSelected: function(elemId) {
|
||||
const rv = [];
|
||||
|
@ -1532,60 +1557,6 @@ function uploadFeedIcon() {
|
|||
return false;
|
||||
}
|
||||
|
||||
// mode = all, none, invert
|
||||
function selectTableRows(id, mode) {
|
||||
const rows = $(id).rows;
|
||||
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const row = rows[i];
|
||||
let cb = false;
|
||||
let dcb = false;
|
||||
|
||||
if (row.id && row.className) {
|
||||
const bare_id = row.id.replace(/^[A-Z]*?-/, "");
|
||||
const inputs = rows[i].getElementsByTagName("input");
|
||||
|
||||
for (let j = 0; j < inputs.length; j++) {
|
||||
const input = inputs[j];
|
||||
|
||||
if (input.getAttribute("type") == "checkbox" &&
|
||||
input.id.match(bare_id)) {
|
||||
|
||||
cb = input;
|
||||
dcb = dijit.getEnclosingWidget(cb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cb || dcb) {
|
||||
const issel = row.hasClassName("Selected");
|
||||
|
||||
if (mode == "all" && !issel) {
|
||||
row.addClassName("Selected");
|
||||
cb.checked = true;
|
||||
if (dcb) dcb.set("checked", true);
|
||||
} else if (mode == "none" && issel) {
|
||||
row.removeClassName("Selected");
|
||||
cb.checked = false;
|
||||
if (dcb) dcb.set("checked", false);
|
||||
|
||||
} else if (mode == "invert") {
|
||||
|
||||
if (issel) {
|
||||
row.removeClassName("Selected");
|
||||
cb.checked = false;
|
||||
if (dcb) dcb.set("checked", false);
|
||||
} else {
|
||||
row.addClassName("Selected");
|
||||
cb.checked = true;
|
||||
if (dcb) dcb.set("checked", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
function label_to_feed_id(label) {
|
||||
return _label_base_index - 1 - Math.abs(label);
|
||||
|
|
39
js/prefs.js
39
js/prefs.js
|
@ -73,18 +73,34 @@ const App = {
|
|||
|
||||
if (tab) {
|
||||
tab = dijit.byId(tab + "Tab");
|
||||
if (tab) dijit.byId("pref-tabs").selectChild(tab);
|
||||
if (tab) {
|
||||
dijit.byId("pref-tabs").selectChild(tab);
|
||||
|
||||
switch (Utils.urlParam('method')) {
|
||||
case "editfeed":
|
||||
window.setTimeout(function () {
|
||||
CommonDialogs.editFeed(Utils.urlParam('methodparam'))
|
||||
}, 100);
|
||||
break;
|
||||
default:
|
||||
console.warn("initSecondStage, unknown method:", Utils.urlParam("method"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let tab = localStorage.getItem("ttrss:prefs-tab");
|
||||
|
||||
if (tab) {
|
||||
tab = dijit.byId(tab);
|
||||
if (tab) {
|
||||
dijit.byId("pref-tabs").selectChild(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const method = Utils.urlParam('method');
|
||||
dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) {
|
||||
localStorage.setItem("ttrss:prefs-tab", elem.id);
|
||||
});
|
||||
|
||||
if (method == 'editFeed') {
|
||||
const param = Utils.urlParam('methodparam');
|
||||
|
||||
window.setTimeout(function () {
|
||||
CommonDialogs.editFeed(param)
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
hotkeyHandler: function (event) {
|
||||
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;
|
||||
|
@ -725,8 +741,8 @@ function updateSystemList() {
|
|||
});
|
||||
}
|
||||
|
||||
function selectTab(id, noupdate) {
|
||||
if (!noupdate) {
|
||||
function selectTab(id, selectOnly) {
|
||||
if (!selectOnly) {
|
||||
notify_progress("Loading, please wait...");
|
||||
|
||||
switch (id) {
|
||||
|
@ -754,7 +770,6 @@ function selectTab(id, noupdate) {
|
|||
|
||||
const tab = dijit.byId(id + "Tab");
|
||||
dijit.byId("pref-tabs").selectChild(tab);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue