Replies array, reply class.

This commit is contained in:
Nicolas Stepien 2012-01-09 11:18:31 +01:00
parent fcb7c20012
commit 962e9d301d
2 changed files with 38 additions and 11 deletions

View File

@ -1299,11 +1299,32 @@
qr.error("" + file.name + ": Unsupported file type.");
break;
}
new qr.reply(file);
}
return $.addClass(qr.el, 'dump');
},
replies: [],
reply: (function() {
function _Class(file) {
var name, _ref;
this.file = file;
this.com = null;
for (name in qr.inputs) {
this[name] = ((_ref = qr.replies[qr.replies.length - 1]) != null ? _ref[name] : void 0) || $.get("qr_" + name, null);
}
qr.replies.push(this);
}
_Class.prototype.load = function() {
return log(this);
};
return _Class;
})(),
dialog: function() {
var input, mimeTypes, name, thread, threads, _i, _len, _ref, _ref2;
var mimeTypes, thread, threads, _i, _len, _ref;
if (!g.REPLY) {
threads = '<option value=new>New thread</option>';
_ref = $$('.op');
@ -1342,11 +1363,7 @@
email: $('[name=email]', qr.el)
};
if (conf['Remember Subject']) qr.inputs.subject = $('[name=subject]', qr.el);
_ref2 = qr.inputs;
for (name in _ref2) {
input = _ref2[name];
input.value = $.get("qr_" + name, null);
}
new qr.reply().load();
$.on(window, 'storage', function(e) {
var match;
if (match = e.key.match(/qr_(.+)$/)) {

View File

@ -950,7 +950,8 @@ qr =
else if -1 is qr.mimeTypes.indexOf file.type
qr.error 'Unsupported file type.'
else
# modify selected reply's file
# set or modify selected reply's file
# qr.replies[?].file = file
return
for file in @files
if file.size > @max
@ -959,10 +960,20 @@ qr =
else if -1 is qr.mimeTypes.indexOf file.type
qr.error "#{file.name}: Unsupported file type."
break
# add new reply
# set reply's file
new qr.reply file
$.addClass qr.el, 'dump'
replies: []
reply: class
constructor: (@file) ->
@com = null
for name of qr.inputs
@[name] = qr.replies[qr.replies.length-1]?[name] or $.get "qr_#{name}", null
qr.replies.push @
load: ->
# load reply's data in the QR dialog
log @
dialog: ->
# create a new thread or select thread to reply to
unless g.REPLY
@ -1094,8 +1105,7 @@ textarea.field {
name: $ '[name=name]', qr.el
email: $ '[name=email]', qr.el
qr.inputs.subject = $ '[name=subject]', qr.el if conf['Remember Subject']
for name, input of qr.inputs
input.value = $.get "qr_#{name}", null
new qr.reply().load()
# sync between tabs
$.on window, 'storage', (e) ->
if match = e.key.match /qr_(.+)$/