Simplify & fix bugs with select all functionality
This commit is contained in:
parent
6a6ea3e63b
commit
2bef9425fb
3 changed files with 10 additions and 43 deletions
|
@ -1,24 +1,10 @@
|
||||||
(function() {
|
const check_all = document.getElementById("action-checkbox-all");
|
||||||
var sheet = document.styleSheets[0];
|
if (check_all) {
|
||||||
var addCSSRule = function(selector, rules, index) {
|
check_all.style.display = "inherit";
|
||||||
if ("insertRule" in sheet) {
|
check_all.addEventListener("click", ev => {
|
||||||
sheet.insertRule(selector + "{" + rules + "}", index);
|
const inputs = document.querySelectorAll(".message-list-checkbox input");
|
||||||
return;
|
for (let i = 0; i < inputs.length; i++) {
|
||||||
|
inputs[i].checked = ev.target.checked;
|
||||||
}
|
}
|
||||||
if ("addRule" in sheet) {
|
});
|
||||||
sheet.addRule(selector, rules, index);
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var checkboxAll = document.getElementById("action-checkbox-all");
|
|
||||||
if (checkboxAll) {
|
|
||||||
addCSSRule(".message-list-checkbox", "display: table-cell !important;");
|
|
||||||
checkboxAll.addEventListener("click", function(ev) {
|
|
||||||
var allChecked = this.checked;
|
|
||||||
var inputs = document.querySelectorAll("tr .message-list-checkbox input");
|
|
||||||
Array.prototype.slice.apply().forEach(function(cb) {
|
|
||||||
cb.checked = allChecked;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
|
@ -2,25 +2,6 @@
|
||||||
{{template "nav.html" .}}
|
{{template "nav.html" .}}
|
||||||
{{template "util.html" .}}
|
{{template "util.html" .}}
|
||||||
|
|
||||||
{{ define "mbox-link" }}
|
|
||||||
{{ if not (.HasAttr "\\Noselect") }}
|
|
||||||
<a href="{{.URL}}" {{ if .Active }}class="active"{{ end }}>
|
|
||||||
{{- if eq .Name "INBOX" -}}
|
|
||||||
Inbox
|
|
||||||
{{- else -}}
|
|
||||||
{{ .Name }}
|
|
||||||
{{- end -}}
|
|
||||||
{{- if .HasAttr "\\HasChildren" }}/{{ end }}
|
|
||||||
|
|
||||||
{{ if and (ne .Unseen -1) (ne .Unseen 0) }}({{ .Unseen }}){{ end }}
|
|
||||||
</a>
|
|
||||||
{{ else }}
|
|
||||||
<span class="noselect">
|
|
||||||
{{.Name}}{{- if .HasAttr "\\HasChildren" }}/{{ end }}
|
|
||||||
</span>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<div class="page-wrap">
|
<div class="page-wrap">
|
||||||
{{ template "aside" . }}
|
{{ template "aside" . }}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="message-list-checkbox">
|
<div class="message-list-checkbox">
|
||||||
<input type="checkbox" id="action-checkbox-all"/>
|
<input type="checkbox" id="action-checkbox-all" style="display: none"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions-wrap">
|
<div class="actions-wrap">
|
||||||
<div class="actions-message">
|
<div class="actions-message">
|
||||||
|
|
Loading…
Reference in a new issue