diff --git a/4chan_x.user.js b/4chan_x.user.js index 272864146..dc6597850 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -5727,7 +5727,6 @@ } QR.cooldown.auto = false; QR.status(); - QR.resetFileInput(); if (!Conf['Remember Spoiler'] && QR.nodes.spoiler.checked) { QR.nodes.spoiler.click(); } @@ -5982,8 +5981,9 @@ fileInput: function(files) { var file, length, max, _i, _len, _ref, _ref1; if (!(files instanceof FileList)) { - files = this.files; + files = Array.prototype.slice.call(this.files); } + QR.nodes.fileInput.value = null; length = files.length; if (!length) { return; @@ -5994,10 +5994,8 @@ file = files[0]; if (file.size > max) { QR.error("File too large (file: " + ($.bytesToString(file.size)) + ", max: " + ($.bytesToString(max)) + ")."); - QR.resetFileInput(); } else if (_ref = file.type, __indexOf.call(QR.mimeTypes, _ref) < 0) { QR.error('Unsupported file type.'); - QR.resetFileInput(); } else { QR.selected.setFile(file); } @@ -6016,11 +6014,7 @@ new QR.reply().setFile(file); } } - $.addClass(QR.nodes.el, 'dump'); - return QR.resetFileInput(); - }, - resetFileInput: function() { - return QR.nodes.fileInput.value = null; + return $.addClass(QR.nodes.el, 'dump'); }, resetThreadSelector: function() { if (g.BOARD.ID === 'f') { @@ -6087,10 +6081,12 @@ var fileURL, img, _this = this; this.file = file; - this.nodes.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")"; + this.filename = "" + file.name + " (" + ($.bytesToString(file.size)) + ")"; + this.nodes.el.title = this.filename; if (QR.spoiler) { this.nodes.label.hidden = false; } + this.showFileData(); if (!/^image/.test(file.type)) { this.el.style.backgroundImage = null; return; @@ -6143,19 +6139,33 @@ }; _Class.prototype.rmFile = function() { - QR.resetFileInput(); delete this.file; + delete this.filename; this.nodes.el.title = null; this.nodes.el.style.backgroundImage = null; if (QR.spoiler) { this.nodes.label.hidden = true; } + this.showFileData(); if (!window.URL) { return; } return URL.revokeObjectURL(this.url); }; + _Class.prototype.showFileData = function(hide) { + if (this.file) { + QR.nodes.filename.textContent = this.filename; + QR.nodes.filename.title = this.filename; + if (QR.spoiler) { + QR.nodes.spoiler.checked = this.spoiler; + } + return $.addClass(QR.nodes.fileSubmit, 'has-file'); + } else { + return $.rmClass(QR.nodes.fileSubmit, 'has-file'); + } + }; + _Class.prototype.select = function() { var name, rectEl, rectList, _i, _len, _ref; if (QR.selected) { @@ -6172,8 +6182,8 @@ name = _ref[_i]; QR.nodes[name].value = this[name]; } - QR.characterCount(); - return QR.nodes.spoiler.checked = this.spoiler; + this.showFileData(); + return QR.characterCount(); }; _Class.prototype.save = function(input) { @@ -6243,7 +6253,6 @@ _Class.prototype.rm = function() { var index; - QR.resetFileInput(); $.rm(this.nodes.el); index = QR.replies.indexOf(this); if (QR.replies.length === 1) { @@ -6408,7 +6417,7 @@ }, dialog: function() { var dialog, key, mimeTypes, name, nodes, thread, threads, _i, _len, _ref, _ref1; - dialog = UI.dialog('qr', 'top:0;right:0;', "