diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index efc76701e..0a7fed7b2 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1412,9 +1412,9 @@ class Pref_Feeds extends Handler_Protected { print "
". "" . __('Select').""; print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; print "
"; print ""; #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 ""; + print ""; - # id needed for selectTableRows() print ""; + type=\"checkbox\">"; print ""; print "". "" . __('Select').""; print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; print "
"; print ""; #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 ""; + print ""; - # id needed for selectTableRows() print ""; + type=\"checkbox\">"; print ""; print "
". "" . __('Select').""; print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; print "
"; @@ -1019,10 +1019,9 @@ class Pref_Prefs extends Handler_Protected { print ""; - print ""; #odd + print ""; # data-row-id='0' <-- no point, shouldn't be removed print ""; @@ -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 ""; + print ""; $edit_title = htmlspecialchars($line["title"]); print ""; diff --git a/classes/pref/users.php b/classes/pref/users.php index eda3e1a0e..fb7afcf04 100644 --- a/classes/pref/users.php +++ b/classes/pref/users.php @@ -354,9 +354,9 @@ class Pref_Users extends Handler_Protected { print "
". "" . __('Select').""; print "
"; - print "
".__('All')."
"; - print "
".__('None')."
"; print "
"; @@ -412,7 +412,7 @@ class Pref_Users extends Handler_Protected { $uid = $line["id"]; - print ""; + print ""; $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 ""; + dojoType=\"dijit.form.CheckBox\" type=\"checkbox\">"; $onclick = "onclick='editUser($uid, event)' title='".__('Click to edit')."'"; diff --git a/js/functions.js b/js/functions.js index 6e61f4c9f..673e0e8f1 100755 --- a/js/functions.js +++ b/js/functions.js @@ -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); diff --git a/js/prefs.js b/js/prefs.js index 3b9e090cc..c2ff01d47 100755 --- a/js/prefs.js +++ b/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"); - const method = Utils.urlParam('method'); + if (tab) { + tab = dijit.byId(tab); + if (tab) { + dijit.byId("pref-tabs").selectChild(tab); + } + } + } - if (method == 'editFeed') { - const param = Utils.urlParam('methodparam'); + dojo.connect(dijit.byId("pref-tabs"), "selectChild", function (elem) { + localStorage.setItem("ttrss:prefs-tab", elem.id); + }); - 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); - } }