Use shift+click to remove the selected file. Close #281.

This commit is contained in:
Nicolas Stepien 2012-03-06 20:29:13 +01:00
parent afcc55b2c8
commit f3e4c5b64a
3 changed files with 24 additions and 3 deletions

View File

@ -1602,6 +1602,15 @@
return img.src = fileUrl;
};
_Class.prototype.rmFile = function() {
qr.resetFileInput();
delete this.file;
this.el.title = null;
this.el.style.backgroundImage = null;
if (qr.spoiler) $('label', this.el).hidden = true;
return (window.URL || window.webkitURL).revokeObjectURL(this.url);
};
_Class.prototype.select = function() {
var data, rectEl, rectList, _i, _len, _ref, _ref2;
if ((_ref = qr.selected) != null) _ref.el.id = null;
@ -1760,7 +1769,7 @@
<div><textarea name=com title=Comment placeholder=Comment class=field></textarea></div>\
<div class=captcha title=Reload><img></div>\
<div><input title=Verification class=field autocomplete=off size=1></div>\
<div><input type=file multiple size=16><input type=submit></div>\
<div><input type=file title="Shift+Click to remove the selected file." multiple size=16><input type=submit></div>\
<label id=spoilerLabel><input type=checkbox id=spoiler> Spoiler Image</label>\
<div class=warning></div>\
</form>');
@ -1816,6 +1825,9 @@
return qr.selected.el.lastChild.textContent = this.value;
});
$.on(fileInput, 'change', qr.fileInput);
$.on(fileInput, 'click', function(e) {
if (e.shiftKey) return qr.selected.rmFile() || e.preventDefault();
});
$.on(spoiler.firstChild, 'change', function() {
return $('input', qr.selected.el).click();
});

View File

@ -3,7 +3,8 @@ master
General performance improvements.
Threads will now be updated instantly after posting through the QR.
Your own posts will not count toward the unread count after posting through the QR.
QR thumbnails of high-res pictures will not slow down anymore.
Performance issues are now lessened with QR thumbnails of high-res pictures.
You can now use Shift+Click on the file input to remove the selected reply's file.
Reply navigation keybinds will now scroll as you navigate.
- noface
Add unique ID to filter.

View File

@ -1327,6 +1327,13 @@ qr =
url.revokeObjectURL fileUrl
img.src = fileUrl
rmFile: ->
qr.resetFileInput()
delete @file
@el.title = null
@el.style.backgroundImage = null
$('label', @el).hidden = true if qr.spoiler
(window.URL or window.webkitURL).revokeObjectURL @url
select: ->
qr.selected?.el.id = null
qr.selected = @
@ -1442,7 +1449,7 @@ qr =
<div><textarea name=com title=Comment placeholder=Comment class=field></textarea></div>
<div class=captcha title=Reload><img></div>
<div><input title=Verification class=field autocomplete=off size=1></div>
<div><input type=file multiple size=16><input type=submit></div>
<div><input type=file title="Shift+Click to remove the selected file." multiple size=16><input type=submit></div>
<label id=spoilerLabel><input type=checkbox id=spoiler> Spoiler Image</label>
<div class=warning></div>
</form>'
@ -1488,6 +1495,7 @@ qr =
$.on $('form', qr.el), 'submit', qr.submit
$.on $('textarea', qr.el), 'keyup', -> qr.selected.el.lastChild.textContent = @value
$.on fileInput, 'change', qr.fileInput
$.on fileInput, 'click', (e) -> if e.shiftKey then qr.selected.rmFile() or e.preventDefault()
$.on spoiler.firstChild, 'change', -> $('input', qr.selected.el).click()
$.on $('.warning', qr.el), 'click', qr.cleanError