Skip to content

Commit a525e9b

Browse files
committed
refactor(defaultTheme): remove legacy compat API guard
1 parent ef01be5 commit a525e9b

File tree

3 files changed

+14
-97
lines changed

3 files changed

+14
-97
lines changed

src/tpl/defaultTheme/frontend/index.css

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ em {
9191
border-radius: 3px;
9292
}
9393

94-
.none, :root body .none {
94+
.none {
9595
display: none;
9696
}
9797

@@ -382,14 +382,6 @@ html.dragging::before {
382382
padding-right: 0.5em;
383383
}
384384

385-
.filter {
386-
display: none;
387-
}
388-
389-
:root .filter {
390-
display: block;
391-
}
392-
393385
.filter .form {
394386
position: relative;
395387
display: flex;
@@ -630,15 +622,7 @@ html.dragging::before {
630622
}
631623

632624
@media print {
633-
.panel, .archive {
634-
display: none;
635-
}
636-
637-
:root .panel {
638-
display: none;
639-
}
640-
641-
.tab {
625+
.panel, .tab, .archive {
642626
display: none;
643627
}
644628

src/tpl/defaultTheme/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
{{end}}
9191
{{end}}
9292
{{if .SubItemsHtml}}
93-
<div class="panel filter" id="panel-filter">
93+
<div class="panel filter">
9494
<div class="form">
9595
<input type="text" accesskey="r" placeholder="{{.Trans.FilterLabel}}"/>
9696
<button type="reset">X</button>

src/tpl/defaultTheme/frontend/index.js

Lines changed: 11 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,11 @@
3939
var lastFocused;
4040

4141
function enableFilter() {
42-
if (!document.querySelector) {
43-
var filter = document.getElementById && document.getElementById('panel-filter');
44-
if (filter) {
45-
filter.className += ' none';
46-
}
47-
return;
48-
}
49-
5042
// pre check
5143
var filter = document.body.querySelector('.filter');
5244
if (!filter) {
5345
return;
5446
}
55-
if (!filter.addEventListener) {
56-
filter.className += ' none';
57-
return;
58-
}
5947

6048
var input = filter.querySelector('input');
6149
if (!input) {
@@ -187,8 +175,6 @@
187175
}
188176

189177
function keepFocusOnBackwardForward() {
190-
if (window.onpageshow === undefined || !document.querySelector) return;
191-
192178
function onFocus(e) {
193179
var link = e.target;
194180
while (link && !(link instanceof HTMLAnchorElement)) {
@@ -210,8 +196,6 @@
210196
}
211197

212198
function focusChildOnNavUp() {
213-
if (!document.querySelector) return;
214-
215199
function extractCleanUrl(url) {
216200
var sepIndex = url.indexOf('?');
217201
if (sepIndex < 0) sepIndex = url.indexOf('#');
@@ -261,14 +245,6 @@
261245
}
262246

263247
function enableKeyboardNavigate() {
264-
if (
265-
!document.querySelector ||
266-
!document.addEventListener ||
267-
!document.body.parentElement
268-
) {
269-
return;
270-
}
271-
272248
var pathList = document.body.querySelector('.path-list');
273249
var itemList = document.body.querySelector('.item-list');
274250
if (!pathList && !itemList) {
@@ -536,10 +512,6 @@
536512
}
537513

538514
function enhanceUpload() {
539-
if (!document.querySelector || !document.addEventListener) {
540-
return;
541-
}
542-
543515
var upload = document.body.querySelector('.upload');
544516
if (!upload) {
545517
return;
@@ -597,7 +569,7 @@
597569
}).then(function (file) {
598570
var relativePath = dirPath + file.name;
599571
files.push({file: file, relativePath: relativePath});
600-
})['catch'](function (err) { // workaround IE8- syntax error for ".catch"(reserved keyword)
572+
}).catch(function (err) {
601573
logError(err);
602574
});
603575
} else if (handle.kind === handleKindDir) {
@@ -632,7 +604,6 @@
632604

633605
var files = [];
634606
var hasDir = false;
635-
if (!dataTransferItems || !dataTransferItems.length) return onDone(files, hasDir);
636607

637608
var items = Array.prototype.slice.call(dataTransferItems);
638609
Promise.all(items.map(function (item) {
@@ -698,7 +669,6 @@
698669

699670
var files = [];
700671
var hasDir = false;
701-
if (!dataTransferItems || !dataTransferItems.length || !dataTransferItems[0].webkitGetAsEntry) return onDone(files, hasDir);
702672

703673
var entries = [];
704674
for (var i = 0, len = dataTransferItems.length; i < len; i++) {
@@ -798,10 +768,6 @@
798768
}
799769
}
800770

801-
if (typeof fileInput.webkitdirectory === strUndef) {
802-
uploadType.className += ' ' + classNone;
803-
return;
804-
}
805771
optDirFile && optDirFile.classList.remove(classHidden);
806772
optInnerDirFile && optInnerDirFile.classList.remove(classHidden);
807773

@@ -844,12 +810,12 @@
844810
return;
845811
}
846812
var files = e.target.files;
847-
if (!files || !files.length) {
813+
if (!files.length) {
848814
return;
849815
}
850816

851817
var nodir = Array.prototype.slice.call(files).every(function (file) {
852-
return !file.webkitRelativePath || file.webkitRelativePath.indexOf('/') < 0;
818+
return file.webkitRelativePath.indexOf('/') < 0;
853819
});
854820
if (nodir) {
855821
onClickOptFile(); // prevent clear input files
@@ -879,10 +845,6 @@
879845
}
880846

881847
function enableUploadProgress() { // also fix Safari upload filename has no path info
882-
if (typeof FormData === strUndef) {
883-
return;
884-
}
885-
886848
var uploading = false;
887849
var batches = [];
888850
var classUploading = 'uploading';
@@ -932,7 +894,7 @@
932894
}
933895

934896
function uploadProgressively(files) {
935-
if (!files || !files.length) {
897+
if (!files.length) {
936898
return;
937899
}
938900

@@ -1031,22 +993,17 @@
1031993
e.currentTarget.classList.remove(classDragging);
1032994
fileInput.value = '';
1033995

1034-
if (!e.dataTransfer || !e.dataTransfer.files || !e.dataTransfer.files.length) {
996+
if (!e.dataTransfer.files.length) {
1035997
return;
1036998
}
1037999

1038-
dataTransferToFiles(e.dataTransfer, canMkdir && Boolean(uploadProgressively), function (files, hasDir) {
1000+
dataTransferToFiles(e.dataTransfer, canMkdir, function (files, hasDir) {
10391001
if (hasDir) {
10401002
switchToDirMode();
10411003
uploadProgressively(files);
10421004
} else {
10431005
switchToFileMode();
1044-
if (uploadProgressively) {
1045-
uploadProgressively(files);
1046-
} else {
1047-
fileInput.files = files;
1048-
form.submit();
1049-
}
1006+
uploadProgressively(files);
10501007
}
10511008
}, function () {
10521009
typeof showUploadDirFailMessage !== strUndef && showUploadDirFailMessage();
@@ -1135,12 +1092,9 @@
11351092
return;
11361093
}
11371094
var data = e.clipboardData;
1138-
if (!data) {
1139-
return;
1140-
}
11411095

11421096
var items = data.items;
1143-
if (!items || !items.length) {
1097+
if (!items.length) {
11441098
generatePastedFiles(data);
11451099
return;
11461100
}
@@ -1174,37 +1128,16 @@
11741128
});
11751129
}
11761130

1177-
function enableAddPasteFormSubmit() {
1178-
document.documentElement.addEventListener('paste', function (e) {
1179-
var data = e.clipboardData;
1180-
if (data && data.files && data.files.length) {
1181-
switchToFileMode();
1182-
fileInput.files = data.files;
1183-
form.submit();
1184-
}
1185-
});
1186-
}
1187-
11881131
enableAddDirFile();
11891132
var uploadProgressively = enableUploadProgress();
1190-
if (uploadProgressively) {
1191-
enableFormUploadProgress(uploadProgressively);
1192-
enableAddPasteProgressively(uploadProgressively);
1193-
} else {
1194-
enableAddPasteFormSubmit();
1195-
}
1133+
enableFormUploadProgress(uploadProgressively);
1134+
enableAddPasteProgressively(uploadProgressively);
11961135
enableAddDragDrop(uploadProgressively);
11971136
}
11981137

11991138
function enableNonRefreshDelete() {
1200-
if (!document.querySelector) {
1201-
return;
1202-
}
1203-
12041139
var itemList = document.body.querySelector('.item-list');
1205-
if (!itemList || !itemList.addEventListener) {
1206-
return;
1207-
}
1140+
if (!itemList) return;
12081141
if (!itemList.classList.contains('has-deletable')) return;
12091142

12101143
itemList.addEventListener('submit', function (e) {

0 commit comments

Comments
 (0)