diff --git a/.eslintrc.json b/.eslintrc.json index 9825db73ce..e08e788bfa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -144,7 +144,8 @@ "katex": false, "Clipboard": false, "emoji_picker": false, - "hotspots": false + "hotspots": false, + "compose_ui": false }, "rules": { "no-restricted-syntax": 0, diff --git a/frontend_tests/node_tests/compose_actions.js b/frontend_tests/node_tests/compose_actions.js index 81ab39d0c6..0d3e675321 100644 --- a/frontend_tests/node_tests/compose_actions.js +++ b/frontend_tests/node_tests/compose_actions.js @@ -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'); diff --git a/static/js/compose.js b/static/js/compose.js index ec09caa371..64278c0556 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -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(); }, }); diff --git a/static/js/compose_actions.js b/static/js/compose_actions.js index e0f156ac40..d5effe9c08 100644 --- a/static/js/compose_actions.js +++ b/static/js/compose_actions.js @@ -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); } diff --git a/static/js/compose_ui.js b/static/js/compose_ui.js new file mode 100644 index 0000000000..19b32a9482 --- /dev/null +++ b/static/js/compose_ui.js @@ -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; +} diff --git a/static/js/composebox_typeahead.js b/static/js/composebox_typeahead.js index 8f68e1dfab..cfbfa3f52e 100644 --- a/static/js/composebox_typeahead.js +++ b/static/js/composebox_typeahead.js @@ -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; }; diff --git a/static/js/drafts.js b/static/js/drafts.js index b370d9a926..c0f2c5d025 100644 --- a/static/js/drafts.js +++ b/static/js/drafts.js @@ -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); }; diff --git a/zproject/settings.py b/zproject/settings.py index 54c507bf34..72ed1332c2 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -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'