Add a compose API for starting, canceling, and finishing messages

(imported from commit 372e1c2ae19a72bcbb989fa2be5c510a1278fc69)
This commit is contained in:
Zev Benjamin
2012-10-18 14:16:56 -04:00
parent ab382040c1
commit 746897b36a

View File

@@ -2,6 +2,37 @@ var compose = (function () {
var exports = {}; var exports = {};
exports.start = function (msg_type, opts) {
opts = $.extend({ 'message_type': msg_type,
'stream': '',
'subject': '',
'huddle_recipient': '',
'message': '' },
opts);
$("#stream").val(opts.stream);
$("#subject").val(opts.subject);
$("#huddle_recipient").val(opts.huddle_recipient);
$("#new_message_content").val(opts.message);
$('#sidebar a[href="#home"]').tab('show');
if (msg_type === 'stream') {
exports.show('stream', $("#stream"));
} else {
exports.show('personal', $("#huddle_recipient"));
}
hotkeys.set_compose();
};
exports.cancel = function () {
compose.hide();
};
exports.finish = function () {
$("#compose form").ajaxSubmit();
};
exports.show = function (tabname, focus_area) { exports.show = function (tabname, focus_area) {
if (reloading_app) { if (reloading_app) {
return; return;