Break compose.js and drafts.js dependency.

This commit is contained in:
Mahim Goyal 2017-04-23 12:21:26 +05:30 committed by showell
parent b609911656
commit 6464514ca9
8 changed files with 24 additions and 11 deletions

View File

@ -144,7 +144,8 @@
"katex": false,
"Clipboard": false,
"emoji_picker": false,
"hotspots": false
"hotspots": false,
"compose_ui": false
},
"rules": {
"no-restricted-syntax": 0,

View File

@ -18,6 +18,7 @@ add_dependencies({
compose_state: 'js/compose_state',
people: 'js/people',
util: 'js/util',
compose_ui: 'js/compose_ui',
});
var compose_actions = require('js/compose_actions.js');

View File

@ -42,10 +42,6 @@ function clear_out_file_list(jq_file_list) {
// $("#file_input").val("");
}
exports.autosize_textarea = function () {
$("#new_message_content").trigger("autosize.resize");
};
function show_all_everyone_warnings() {
var current_stream = stream_data.get_sub(compose_state.stream_name());
var stream_count = current_stream.subscribers.num_items();
@ -292,7 +288,7 @@ function process_send_time(message_id, start_time, locally_echoed) {
function clear_compose_box() {
$("#new_message_content").val('').focus();
drafts.delete_draft_after_send();
exports.autosize_textarea();
compose_ui.autosize_textarea();
$("#send-status").hide(0);
$("#compose-send-button").removeAttr('disabled');
$("#sending-indicator").hide();
@ -891,7 +887,7 @@ $(function () {
// This is a dropped file, so make the filename a link to the image
textbox.val(textbox.val() + "[" + filename + "](" + uri + ")" + " ");
}
exports.autosize_textarea();
compose_ui.autosize_textarea();
$("#compose-send-button").removeAttr("disabled");
$("#send-status").removeClass("alert-info")
.hide();
@ -933,7 +929,7 @@ $(function () {
compose_actions.start('stream');
}
textbox.val(textbox.val() + contents);
exports.autosize_textarea();
compose_ui.autosize_textarea();
},
});

View File

@ -96,7 +96,7 @@ function clear_box() {
exports.clear_textarea();
$("#new_message_content").removeData("draft-id");
compose.autosize_textarea();
compose_ui.autosize_textarea();
$("#send-status").hide(0);
}

14
static/js/compose_ui.js Normal file
View File

@ -0,0 +1,14 @@
var compose_ui = (function () {
var exports = {};
exports.autosize_textarea = function () {
$("#new_message_content").trigger("autosize.resize");
};
return exports;
}());
if (typeof module !== 'undefined') {
module.exports = compose_ui;
}

View File

@ -382,7 +382,7 @@ exports.content_typeahead_selected = function (item) {
setTimeout(function () {
$('#new_message_content').caret(beginning.length, beginning.length);
// Also, trigger autosize to check if compose box needs to be resized.
compose.autosize_textarea();
compose_ui.autosize_textarea();
}, 0);
return beginning + rest;
};

View File

@ -134,7 +134,7 @@ exports.restore_draft = function (draft_id) {
draft_copy.subject = "";
}
compose_actions.start(draft_copy.type, draft_copy);
compose.autosize_textarea();
compose_ui.autosize_textarea();
$("#new_message_content").data("draft-id", draft_id);
};

View File

@ -949,6 +949,7 @@ JS_SPECS = {
'js/typing_events.js',
'js/ui_init.js',
'js/emoji_picker.js',
'js/compose_ui.js',
# JS bundled by webpack is also included here if PIPELINE_ENABLED setting is true
],
'output_filename': 'min/app.js'