@skerbis/nativecss 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +28 -0
- package/README.md +145 -2
- package/dist/base.css +225 -0
- package/dist/browser-fixes.css +32 -0
- package/dist/colors.css +288 -0
- package/dist/components/accordion-split.css +269 -0
- package/dist/components/alert.css +179 -0
- package/dist/components/app-shell.css +266 -0
- package/dist/components/audio-player.css +697 -0
- package/dist/components/audio.css +35 -0
- package/dist/components/aurora.css +132 -0
- package/dist/components/avatar.css +102 -0
- package/dist/components/back-to-top.css +120 -0
- package/dist/components/backdrop.css +94 -0
- package/dist/components/badge.css +95 -0
- package/dist/components/breadcrumb.css +58 -0
- package/dist/components/card.css +721 -0
- package/dist/components/code-block.css +234 -0
- package/dist/components/combobox.css +103 -0
- package/dist/components/command-palette.css +351 -0
- package/dist/components/comments.css +243 -0
- package/dist/components/compare.css +218 -0
- package/dist/components/count-up.css +140 -0
- package/dist/components/countdown.css +74 -0
- package/dist/components/cover.css +45 -0
- package/dist/components/curtain.css +116 -0
- package/dist/components/dialog-close.css +44 -0
- package/dist/components/disclosure.css +37 -0
- package/dist/components/downloads.css +47 -0
- package/dist/components/dropdown.css +260 -0
- package/dist/components/dropzone.css +181 -0
- package/dist/components/effects.css +236 -0
- package/dist/components/empty-state.css +74 -0
- package/dist/components/events.css +165 -0
- package/dist/components/expand-panels.css +220 -0
- package/dist/components/filter.css +179 -0
- package/dist/components/floating-label.css +69 -0
- package/dist/components/footer.css +56 -0
- package/dist/components/hero.css +139 -0
- package/dist/components/hovercard.css +146 -0
- package/dist/components/input-group.css +67 -0
- package/dist/components/kbd.css +44 -0
- package/dist/components/leaders.css +99 -0
- package/dist/components/lightbox.css +165 -0
- package/dist/components/lists.css +221 -0
- package/dist/components/livesearch.css +106 -0
- package/dist/components/map.css +245 -0
- package/dist/components/marginnote.css +109 -0
- package/dist/components/marquee.css +119 -0
- package/dist/components/modal.css +385 -0
- package/dist/components/morph.css +317 -0
- package/dist/components/nav-drilldown.css +190 -0
- package/dist/components/nav-priority.css +157 -0
- package/dist/components/nav.css +600 -0
- package/dist/components/notification.css +290 -0
- package/dist/components/off-canvas.css +107 -0
- package/dist/components/overlay.css +122 -0
- package/dist/components/pagination.css +139 -0
- package/dist/components/pill-group.css +143 -0
- package/dist/components/placeholder.css +28 -0
- package/dist/components/preferences-fonts.css +65 -0
- package/dist/components/preferences.css +283 -0
- package/dist/components/pricing.css +220 -0
- package/dist/components/rating.css +121 -0
- package/dist/components/reveal-pin.css +165 -0
- package/dist/components/roadmap.css +173 -0
- package/dist/components/scroll-frames.css +97 -0
- package/dist/components/scroll-horizontal.css +141 -0
- package/dist/components/scroll-progress.css +63 -0
- package/dist/components/scroll-stack.css +363 -0
- package/dist/components/scroll-video.css +172 -0
- package/dist/components/scrolly.css +190 -0
- package/dist/components/search.css +52 -0
- package/dist/components/segmented.css +209 -0
- package/dist/components/select.css +186 -0
- package/dist/components/slideshow.css +441 -0
- package/dist/components/sortable.css +186 -0
- package/dist/components/sparkline.css +50 -0
- package/dist/components/spinner.css +50 -0
- package/dist/components/split.css +85 -0
- package/dist/components/spotlight.css +111 -0
- package/dist/components/stat.css +82 -0
- package/dist/components/stepper.css +217 -0
- package/dist/components/subnav.css +151 -0
- package/dist/components/table-sort.css +111 -0
- package/dist/components/tabs.css +304 -0
- package/dist/components/tag.css +130 -0
- package/dist/components/testimonial.css +188 -0
- package/dist/components/text-reveal.css +141 -0
- package/dist/components/theme-toggle.css +62 -0
- package/dist/components/tile.css +53 -0
- package/dist/components/timeline.css +211 -0
- package/dist/components/toolbar.css +139 -0
- package/dist/components/tooltip.css +89 -0
- package/dist/components/topbar.css +92 -0
- package/dist/components/video-bg.css +176 -0
- package/dist/components/video-card.css +145 -0
- package/dist/components/video-float.css +142 -0
- package/dist/components/video-player.css +1116 -0
- package/dist/components/video-text.css +91 -0
- package/dist/components/video.css +65 -0
- package/dist/fonts/README.md +29 -0
- package/dist/fonts/atkinson-hyperlegible-next/OFL.txt +93 -0
- package/dist/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next.woff2 +0 -0
- package/dist/fonts/lexend/OFL.txt +93 -0
- package/dist/fonts/lexend/lexend.woff2 +0 -0
- package/dist/fonts/opendyslexic/OFL.txt +94 -0
- package/dist/fonts/opendyslexic/OpenDyslexic-Bold.woff2 +0 -0
- package/dist/fonts/opendyslexic/OpenDyslexic-Regular.woff2 +0 -0
- package/dist/helpers/a11y.css +71 -0
- package/dist/helpers/animations.css +206 -0
- package/dist/helpers/elevation.css +87 -0
- package/dist/helpers/float.css +135 -0
- package/dist/helpers/forms.css +503 -0
- package/dist/helpers/icons.css +130 -0
- package/dist/helpers/layout.css +549 -0
- package/dist/helpers/media.css +77 -0
- package/dist/helpers/reveal.css +172 -0
- package/dist/helpers/scroll-shadow.css +129 -0
- package/dist/helpers/scroll.css +163 -0
- package/dist/helpers/surfaces.css +87 -0
- package/dist/helpers/tables.css +85 -0
- package/dist/helpers/typography.css +347 -0
- package/dist/helpers/visibility.css +134 -0
- package/dist/integrations/fontawesome-font-display-fix.css +67 -0
- package/dist/integrations/webawesome-bridge.css +195 -0
- package/dist/js/audio-player.js +942 -0
- package/dist/js/backdrop.js +119 -0
- package/dist/js/code-block.js +238 -0
- package/dist/js/combobox.js +382 -0
- package/dist/js/command-fallback.js +35 -0
- package/dist/js/command-palette.js +477 -0
- package/dist/js/compare.js +73 -0
- package/dist/js/content-observer.js +82 -0
- package/dist/js/count-up.js +150 -0
- package/dist/js/countdown.js +185 -0
- package/dist/js/dialog-light-dismiss.js +123 -0
- package/dist/js/dismiss.js +144 -0
- package/dist/js/downloads.js +181 -0
- package/dist/js/dropdown.js +300 -0
- package/dist/js/dropzone.js +304 -0
- package/dist/js/events.js +501 -0
- package/dist/js/filter.js +177 -0
- package/dist/js/hero-video-motion.js +37 -0
- package/dist/js/hide-on-scroll-fallback.js +102 -0
- package/dist/js/hovercard.js +228 -0
- package/dist/js/icon.js +166 -0
- package/dist/js/ics.js +290 -0
- package/dist/js/lightbox.js +144 -0
- package/dist/js/livesearch.js +253 -0
- package/dist/js/map.js +625 -0
- package/dist/js/marquee.js +108 -0
- package/dist/js/modal-router.js +298 -0
- package/dist/js/nav-drilldown.js +250 -0
- package/dist/js/nav-priority.js +221 -0
- package/dist/js/nav.js +242 -0
- package/dist/js/ncss-container.js +117 -0
- package/dist/js/notification.js +372 -0
- package/dist/js/page-transitions-quiet.js +44 -0
- package/dist/js/preferences-early.js +51 -0
- package/dist/js/preferences.js +346 -0
- package/dist/js/reveal.js +79 -0
- package/dist/js/scroll-frames.js +284 -0
- package/dist/js/scroll-horizontal.js +121 -0
- package/dist/js/scroll-stack-fallback.js +250 -0
- package/dist/js/scroll-video.js +332 -0
- package/dist/js/scrolly.js +109 -0
- package/dist/js/slideshow.js +416 -0
- package/dist/js/sortable.js +530 -0
- package/dist/js/sparkline.js +199 -0
- package/dist/js/spotlight.js +104 -0
- package/dist/js/subnav.js +163 -0
- package/dist/js/table-sort.js +312 -0
- package/dist/js/tabs.js +243 -0
- package/dist/js/text-reveal.js +108 -0
- package/dist/js/theme-toggle-early.js +28 -0
- package/dist/js/theme-toggle.js +135 -0
- package/dist/js/toolbar.js +130 -0
- package/dist/js/tooltip.js +214 -0
- package/dist/js/video-bg.js +193 -0
- package/dist/js/video-card.js +80 -0
- package/dist/js/video-float.js +119 -0
- package/dist/js/video-player.js +1267 -0
- package/dist/js/view-transitions.js +118 -0
- package/dist/js/wa-close-on-scroll.js +56 -0
- package/dist/ncss.css +165 -0
- package/dist/page-transitions.css +150 -0
- package/dist/reset.css +196 -0
- package/dist/theme.css +112 -0
- package/dist/tokens.css +238 -0
- package/package.json +52 -4
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ncss - <ncss-dropzone>: Drag & Drop + Dateiliste für ein ECHTES <input type="file">
|
|
3
|
+
* (Markup/Optik siehe components/dropzone.css). Reines Light-DOM-Custom-Element, kein
|
|
4
|
+
* Upload: das Script verwaltet nur die AUSWAHL clientseitig - übertragen wird wie immer
|
|
5
|
+
* über das native Feld beim Formular-Versand (oder eigenes fetch() mit FormData).
|
|
6
|
+
*
|
|
7
|
+
* Kern-Trick: input.files lässt sich nur über ein DataTransfer-Objekt neu setzen. Fehlt
|
|
8
|
+
* der DataTransfer-Konstruktor (sehr alte Browser), wird das Element GAR NICHT
|
|
9
|
+
* registriert (Guard um customElements.define, siehe Skill) - es bleibt :not(:defined),
|
|
10
|
+
* das native Feld bleibt sichtbar und funktioniert normal.
|
|
11
|
+
*
|
|
12
|
+
* Attribute (alle optional):
|
|
13
|
+
* data-ncss-max-size="10MB" Höchstgröße je Datei (Zahl = Bytes, oder kB/MB/GB)
|
|
14
|
+
* data-ncss-text-* eigene Texte (remove, status, type, size), {name}/{n}/{max}
|
|
15
|
+
* als Platzhalter - Default deutsch/englisch nach lang
|
|
16
|
+
* Accept-Filter: das accept-Attribut des Inputs gilt auch für GEZOGENE Dateien (der
|
|
17
|
+
* Browser prüft es nur im Auswahldialog).
|
|
18
|
+
*
|
|
19
|
+
* Event: "ncss-dropzone-change" (bubbles) mit detail.files (Array<File>) nach jeder
|
|
20
|
+
* Änderung - zusätzlich feuert das native Feld "change"/"input", damit bestehende
|
|
21
|
+
* Formular-Logik (Validierung, htmx etc.) die neue Auswahl mitbekommt.
|
|
22
|
+
*/
|
|
23
|
+
(function () {
|
|
24
|
+
"use strict";
|
|
25
|
+
|
|
26
|
+
if (typeof customElements === "undefined" || customElements.get("ncss-dropzone")) return;
|
|
27
|
+
try {
|
|
28
|
+
new DataTransfer();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var TEXT = {
|
|
34
|
+
de: {
|
|
35
|
+
remove: "{name} entfernen",
|
|
36
|
+
status: "{n} Datei(en) ausgewählt",
|
|
37
|
+
list: "Ausgewählte Dateien",
|
|
38
|
+
type: "{name}: Dateityp nicht erlaubt",
|
|
39
|
+
size: "{name}: größer als {max}"
|
|
40
|
+
},
|
|
41
|
+
en: {
|
|
42
|
+
remove: "Remove {name}",
|
|
43
|
+
status: "{n} file(s) selected",
|
|
44
|
+
list: "Selected files",
|
|
45
|
+
type: "{name}: file type not allowed",
|
|
46
|
+
size: "{name}: larger than {max}"
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function langOf(el) {
|
|
51
|
+
var host = el.closest("[lang]");
|
|
52
|
+
return (host && host.getAttribute("lang")) || document.documentElement.lang || "de";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function fill(template, values) {
|
|
56
|
+
return template.replace(/\{(\w+)\}/g, function (m, key) {
|
|
57
|
+
return key in values ? values[key] : m;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// "10MB" / "500 kB" / "2048" -> Bytes (SI-Faktor 1000, passend zur Anzeige unten).
|
|
62
|
+
function parseSize(value) {
|
|
63
|
+
var m = /^\s*([\d.,]+)\s*(b|kb|mb|gb)?\s*$/i.exec(value || "");
|
|
64
|
+
if (!m) return 0;
|
|
65
|
+
var n = parseFloat(m[1].replace(",", "."));
|
|
66
|
+
var unit = (m[2] || "b").toLowerCase();
|
|
67
|
+
return n * ({ b: 1, kb: 1e3, mb: 1e6, gb: 1e9 })[unit];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function formatSize(bytes, lang) {
|
|
71
|
+
var units = ["byte", "kilobyte", "megabyte", "gigabyte"];
|
|
72
|
+
var i = 0;
|
|
73
|
+
while (bytes >= 1000 && i < units.length - 1) {
|
|
74
|
+
bytes /= 1000;
|
|
75
|
+
i++;
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
return new Intl.NumberFormat(lang, {
|
|
79
|
+
style: "unit", unit: units[i], unitDisplay: "short",
|
|
80
|
+
maximumFractionDigits: i === 0 ? 0 : 1
|
|
81
|
+
}).format(bytes);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
return Math.round(bytes * 10) / 10 + " " + ["B", "kB", "MB", "GB"][i];
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// accept-Liste wie im Browser-Dialog: ".pdf", "image/*", "application/pdf".
|
|
88
|
+
function accepts(input, file) {
|
|
89
|
+
var accept = (input.getAttribute("accept") || "").trim();
|
|
90
|
+
if (!accept) return true;
|
|
91
|
+
var name = file.name.toLowerCase();
|
|
92
|
+
var type = (file.type || "").toLowerCase();
|
|
93
|
+
return accept.split(",").some(function (rule) {
|
|
94
|
+
rule = rule.trim().toLowerCase();
|
|
95
|
+
if (!rule) return false;
|
|
96
|
+
if (rule.charAt(0) === ".") return name.slice(-rule.length) === rule;
|
|
97
|
+
if (rule.slice(-2) === "/*") return type.indexOf(rule.slice(0, -1)) === 0;
|
|
98
|
+
return type === rule;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function sameFile(a, b) {
|
|
103
|
+
return a.name === b.name && a.size === b.size && a.lastModified === b.lastModified;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
customElements.define(
|
|
107
|
+
"ncss-dropzone",
|
|
108
|
+
class extends HTMLElement {
|
|
109
|
+
connectedCallback() {
|
|
110
|
+
if (this._ready) return;
|
|
111
|
+
this._input = this.querySelector('input[type="file"]');
|
|
112
|
+
this._area = this.querySelector(".ncss-dropzone-area") || this;
|
|
113
|
+
if (!this._input) return;
|
|
114
|
+
this._ready = true;
|
|
115
|
+
this._files = [];
|
|
116
|
+
this._urls = [];
|
|
117
|
+
this._depth = 0;
|
|
118
|
+
this._lang = langOf(this);
|
|
119
|
+
this._text = TEXT[this._lang.slice(0, 2)] || TEXT.en;
|
|
120
|
+
|
|
121
|
+
this._list = this.querySelector(".ncss-dropzone-list");
|
|
122
|
+
if (!this._list) {
|
|
123
|
+
this._list = document.createElement("ul");
|
|
124
|
+
this._list.className = "ncss-dropzone-list";
|
|
125
|
+
this._list.setAttribute("role", "list");
|
|
126
|
+
this._list.setAttribute("aria-label", this._t("list"));
|
|
127
|
+
this.appendChild(this._list);
|
|
128
|
+
}
|
|
129
|
+
this._error = document.createElement("p");
|
|
130
|
+
this._error.className = "ncss-dropzone-error";
|
|
131
|
+
this.appendChild(this._error);
|
|
132
|
+
this._status = document.createElement("p");
|
|
133
|
+
this._status.className = "ncss-dropzone-status";
|
|
134
|
+
this._status.setAttribute("role", "status");
|
|
135
|
+
this.appendChild(this._status);
|
|
136
|
+
|
|
137
|
+
var self = this;
|
|
138
|
+
this._input.addEventListener("change", function () {
|
|
139
|
+
if (self._silent) return;
|
|
140
|
+
self._add(Array.prototype.slice.call(self._input.files || []));
|
|
141
|
+
});
|
|
142
|
+
this._area.addEventListener("dragenter", function (e) {
|
|
143
|
+
if (!self._hasFiles(e)) return;
|
|
144
|
+
e.preventDefault();
|
|
145
|
+
self._depth++;
|
|
146
|
+
self.setAttribute("data-ncss-dragover", "");
|
|
147
|
+
});
|
|
148
|
+
this._area.addEventListener("dragover", function (e) {
|
|
149
|
+
if (!self._hasFiles(e)) return;
|
|
150
|
+
e.preventDefault();
|
|
151
|
+
e.dataTransfer.dropEffect = self._input.disabled ? "none" : "copy";
|
|
152
|
+
});
|
|
153
|
+
this._area.addEventListener("dragleave", function () {
|
|
154
|
+
self._depth = Math.max(0, self._depth - 1);
|
|
155
|
+
if (!self._depth) self.removeAttribute("data-ncss-dragover");
|
|
156
|
+
});
|
|
157
|
+
this._area.addEventListener("drop", function (e) {
|
|
158
|
+
if (!self._hasFiles(e)) return;
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
self._depth = 0;
|
|
161
|
+
self.removeAttribute("data-ncss-dragover");
|
|
162
|
+
if (self._input.disabled) return;
|
|
163
|
+
self._add(Array.prototype.slice.call(e.dataTransfer.files));
|
|
164
|
+
});
|
|
165
|
+
this._list.addEventListener("click", function (e) {
|
|
166
|
+
var btn = e.target.closest(".ncss-dropzone-remove");
|
|
167
|
+
if (!btn) return;
|
|
168
|
+
var index = Number(btn.getAttribute("data-ncss-index"));
|
|
169
|
+
self._files.splice(index, 1);
|
|
170
|
+
self._commit();
|
|
171
|
+
// Fokus nicht ins Leere fallen lassen: nächster Entfernen-Button oder die Fläche.
|
|
172
|
+
var next = self._list.querySelectorAll(".ncss-dropzone-remove")[Math.min(index, self._files.length - 1)];
|
|
173
|
+
(next || self._input).focus();
|
|
174
|
+
});
|
|
175
|
+
var form = this._input.form;
|
|
176
|
+
if (form) {
|
|
177
|
+
form.addEventListener("reset", function () {
|
|
178
|
+
self._files = [];
|
|
179
|
+
// Nach dem nativen Zurücksetzen rendern (reset läuft vor dem Leeren der Felder).
|
|
180
|
+
setTimeout(function () { self._render(); }, 0);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// Bereits vorbelegte Auswahl (z.B. Zurück-Navigation mit erhaltenem Formularzustand)
|
|
184
|
+
if (this._input.files && this._input.files.length) {
|
|
185
|
+
this._add(Array.prototype.slice.call(this._input.files));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
disconnectedCallback() {
|
|
190
|
+
this._revoke();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
get files() {
|
|
194
|
+
return this._files ? this._files.slice() : [];
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
clear() {
|
|
198
|
+
this._files = [];
|
|
199
|
+
this._commit();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
_hasFiles(e) {
|
|
203
|
+
var types = e.dataTransfer && e.dataTransfer.types;
|
|
204
|
+
return !!types && Array.prototype.indexOf.call(types, "Files") !== -1;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
_add(incoming) {
|
|
208
|
+
var self = this;
|
|
209
|
+
var errors = [];
|
|
210
|
+
var max = parseSize(this.getAttribute("data-ncss-max-size"));
|
|
211
|
+
var ok = incoming.filter(function (file) {
|
|
212
|
+
if (!accepts(self._input, file)) {
|
|
213
|
+
errors.push(fill(self._t("type"), { name: file.name }));
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
if (max && file.size > max) {
|
|
217
|
+
errors.push(fill(self._t("size"), { name: file.name, max: formatSize(max, self._lang) }));
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return true;
|
|
221
|
+
});
|
|
222
|
+
if (this._input.multiple) {
|
|
223
|
+
ok.forEach(function (file) {
|
|
224
|
+
if (!self._files.some(function (f) { return sameFile(f, file); })) self._files.push(file);
|
|
225
|
+
});
|
|
226
|
+
} else if (ok.length) {
|
|
227
|
+
this._files = [ok[0]];
|
|
228
|
+
}
|
|
229
|
+
// Einzel-Feld mit nur abgelehnten Dateien: alte, gültige Auswahl bleibt bestehen.
|
|
230
|
+
this._error.textContent = errors.join(" · ");
|
|
231
|
+
this._pendingErrors = errors;
|
|
232
|
+
this._commit();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
_t(key) {
|
|
236
|
+
return this.getAttribute("data-ncss-text-" + key) || this._text[key];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
_commit() {
|
|
240
|
+
var dt = new DataTransfer();
|
|
241
|
+
this._files.forEach(function (f) { dt.items.add(f); });
|
|
242
|
+
this._silent = true;
|
|
243
|
+
this._input.files = dt.files;
|
|
244
|
+
this._input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
245
|
+
this._input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
246
|
+
this._silent = false;
|
|
247
|
+
this._render();
|
|
248
|
+
this.dispatchEvent(new CustomEvent("ncss-dropzone-change", {
|
|
249
|
+
bubbles: true,
|
|
250
|
+
detail: { files: this._files.slice() }
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
_revoke() {
|
|
255
|
+
(this._urls || []).forEach(function (u) { URL.revokeObjectURL(u); });
|
|
256
|
+
this._urls = [];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
_render() {
|
|
260
|
+
var self = this;
|
|
261
|
+
this._revoke();
|
|
262
|
+
this._list.textContent = "";
|
|
263
|
+
this._files.forEach(function (file, i) {
|
|
264
|
+
var li = document.createElement("li");
|
|
265
|
+
li.className = "ncss-dropzone-file";
|
|
266
|
+
var thumb = document.createElement("span");
|
|
267
|
+
thumb.className = "ncss-dropzone-thumb";
|
|
268
|
+
thumb.setAttribute("aria-hidden", "true");
|
|
269
|
+
if (/^image\//.test(file.type) && typeof URL.createObjectURL === "function") {
|
|
270
|
+
var url = URL.createObjectURL(file);
|
|
271
|
+
self._urls.push(url);
|
|
272
|
+
var img = document.createElement("img");
|
|
273
|
+
img.src = url;
|
|
274
|
+
img.alt = "";
|
|
275
|
+
thumb.appendChild(img);
|
|
276
|
+
} else {
|
|
277
|
+
var ext = file.name.lastIndexOf(".") > 0 ? file.name.split(".").pop() : "?";
|
|
278
|
+
thumb.textContent = ext.slice(0, 4);
|
|
279
|
+
}
|
|
280
|
+
var name = document.createElement("span");
|
|
281
|
+
name.className = "ncss-dropzone-name";
|
|
282
|
+
name.textContent = file.name;
|
|
283
|
+
name.title = file.name;
|
|
284
|
+
var size = document.createElement("span");
|
|
285
|
+
size.className = "ncss-dropzone-size";
|
|
286
|
+
size.textContent = formatSize(file.size, self._lang);
|
|
287
|
+
var remove = document.createElement("button");
|
|
288
|
+
remove.type = "button";
|
|
289
|
+
remove.className = "ncss-dropzone-remove";
|
|
290
|
+
remove.setAttribute("data-ncss-index", String(i));
|
|
291
|
+
remove.setAttribute("aria-label", fill(self._t("remove"), { name: file.name }));
|
|
292
|
+
remove.textContent = "×";
|
|
293
|
+
li.append(thumb, name, size, remove);
|
|
294
|
+
self._list.appendChild(li);
|
|
295
|
+
});
|
|
296
|
+
// EINE Live-Region für alles: abgelehnte Dateien + neuer Stand. Die sichtbare
|
|
297
|
+
// Fehlerzeile selbst ist bewusst KEINE zweite Live-Region (sonst Doppelansage).
|
|
298
|
+
var said = (this._pendingErrors || []).concat(fill(this._t("status"), { n: this._files.length }));
|
|
299
|
+
this._pendingErrors = [];
|
|
300
|
+
this._status.textContent = said.join(". ");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
);
|
|
304
|
+
})();
|