Remove reply button is now working.

This commit is contained in:
Nicolas Stepien 2012-01-18 00:02:56 +01:00
parent 050a128aa6
commit deb4742b24
2 changed files with 26 additions and 3 deletions

View File

@ -1333,6 +1333,10 @@
$.on(this.el, 'click', function() {
return _this.select();
});
$.on($('.remove', this.el), 'click', function(e) {
e.stopPropagation();
return _this.rm();
});
if (file) this.setFile(file);
$.before($('#addReply', qr.el), this.el);
qr.replies.push(this);
@ -1367,9 +1371,18 @@
};
_Class.prototype.rm = function() {
var url;
var index, url;
$.rm(this.el);
index = qr.replies.indexOf(this);
if (qr.replies.length === 1) {
new qr.reply().select();
} else if (this.el.id === 'selected') {
(qr.replies[index - 1] || qr.replies[index + 1]).select();
}
qr.replies.splice(index, 1);
url = window.URL || window.webkitURL;
return url.revokeObjectURL(this.url);
url.revokeObjectURL(this.url);
return delete this;
};
return _Class;

View File

@ -1000,6 +1000,9 @@ qr =
href: 'javascript:;'
innerHTML: '<a class=remove title=Remove>x</a><label hidden><input type=checkbox></label><span></span>'
$.on @el, 'click', => @select()
$.on $('.remove', @el), 'click', (e) =>
e.stopPropagation()
@rm()
@setFile file if file
$.before $('#addReply', qr.el), @el
qr.replies.push @
@ -1019,9 +1022,16 @@ qr =
for data in ['name', 'email', 'sub', 'com']
$("[name=#{data}]", qr.el).value = @[data]
rm: ->
# rm reply from qr.replies and the UI
$.rm @el
index = qr.replies.indexOf @
if qr.replies.length is 1
new qr.reply().select()
else if @el.id is 'selected'
(qr.replies[index-1] or qr.replies[index+1]).select()
qr.replies.splice index, 1
url = window.URL or window.webkitURL
url.revokeObjectURL @url
delete @
dialog: ->