Move insert_syntax_and_focus() to compose_ui.js.

This change also removes a couple lines of test code that
weren't really testing anything.
This commit is contained in:
Steve Howell
2017-11-09 07:57:58 -08:00
committed by Tim Abbott
parent 19bc55aa45
commit 12dc567a89
5 changed files with 11 additions and 15 deletions

View File

@@ -621,10 +621,6 @@ function test_raw_file_drop(raw_drop_func) {
assert(compose_actions_start_checked);
assert.equal($("#new_message_content").val(), 'Old content new contents');
assert(compose_ui_autosize_textarea_checked);
// Now test the insert syntax code
$('#new_message_content').caret = noop;
compose_state.insert_syntax_and_focus('funtimes');
}
(function test_initialize() {

View File

@@ -656,7 +656,7 @@ exports.initialize = function () {
var video_call_id = util.random_int(100000000000000, 999999999999999);
var video_call_link = 'https://meet.jit.si/' + video_call_id;
var video_call_link_text = '[' + _('Click to join video call') + '](' + video_call_link + ')';
compose_state.insert_syntax_and_focus(video_call_link_text);
compose_ui.insert_syntax_and_focus(video_call_link_text);
});
$("#compose").on("click", "#markdown_preview", function (e) {

View File

@@ -51,15 +51,6 @@ exports.has_message_content = function () {
return exports.message_content() !== "";
};
exports.insert_syntax_and_focus = function (syntax) {
// Generic helper for inserting syntax into the main compose box
// where the cursor was and focusing the area. Mostly a thin
// wrapper around $.caret.
var textarea = $('#new_message_content');
textarea.caret(syntax);
textarea.focus();
};
return exports;
}());

View File

@@ -6,6 +6,15 @@ exports.autosize_textarea = function () {
$("#new_message_content").trigger("autosize.resize");
};
exports.insert_syntax_and_focus = function (syntax) {
// Generic helper for inserting syntax into the main compose box
// where the cursor was and focusing the area. Mostly a thin
// wrapper around $.caret.
var textarea = $('#new_message_content');
textarea.caret(syntax);
textarea.focus();
};
return exports;
}());

View File

@@ -678,7 +678,7 @@ exports.register_click_handlers = function () {
$(document).on('click', '.emoji-popover-emoji.composition', function (e) {
var emoji_name = $(this).data("emoji-name");
var emoji_text = ':' + emoji_name + ':';
compose_state.insert_syntax_and_focus(emoji_text);
compose_ui.insert_syntax_and_focus(emoji_text);
e.stopPropagation();
emoji_picker.hide_emoji_popover();
});