mirror of https://github.com/zulip/zulip.git
refactor: new message content -> compose textarea.
This commit is contained in:
parent
e92a8ac8ee
commit
6e22847548
|
@ -205,7 +205,7 @@ exports.turn_off_press_enter_to_send = function () {
|
|||
exports.then_send_message = function (type, params) {
|
||||
casper.then(function () {
|
||||
casper.waitForSelector('#compose-send-button:enabled');
|
||||
casper.waitForSelector('#new_message_content');
|
||||
casper.waitForSelector('#compose-textarea');
|
||||
});
|
||||
|
||||
casper.then(function () {
|
||||
|
|
|
@ -119,8 +119,8 @@ casper.then(function () {
|
|||
casper.then(function () {
|
||||
casper.waitUntilVisible('#compose', function () {
|
||||
casper.evaluate(function () {
|
||||
$('#new_message_content').expectOne().focus();
|
||||
$('#new_message_content').trigger($.Event('keydown', { which: 37 }));
|
||||
$('#compose-textarea').expectOne().focus();
|
||||
$('#compose-textarea').trigger($.Event('keydown', { which: 37 }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -142,8 +142,8 @@ casper.then(function () {
|
|||
casper.then(function () {
|
||||
casper.waitUntilVisible('#compose', function () {
|
||||
casper.evaluate(function () {
|
||||
$('#new_message_content').expectOne().focus().val('test');
|
||||
$('#new_message_content').trigger($.Event('keydown', { which: 37 }));
|
||||
$('#compose-textarea').expectOne().focus().val('test');
|
||||
$('#compose-textarea').trigger($.Event('keydown', { which: 37 }));
|
||||
});
|
||||
casper.test.assertNotVisible('form.message_edit_form', "Last own message edit doesn't open if the compose box not empty");
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ casper.then(function () {
|
|||
subject: 'Test mention all',
|
||||
});
|
||||
});
|
||||
common.select_item_via_typeahead('#new_message_content', '@all', 'all');
|
||||
common.select_item_via_typeahead('#compose-textarea', '@all', 'all');
|
||||
|
||||
casper.then(function () {
|
||||
common.turn_off_press_enter_to_send();
|
||||
|
|
|
@ -144,14 +144,14 @@ people.add(bob);
|
|||
$("#compose-send-button").prop('disabled', false);
|
||||
$("#compose-send-button").focus();
|
||||
$("#sending-indicator").hide();
|
||||
$("#new_message_content").select(noop);
|
||||
$("#compose-textarea").select(noop);
|
||||
assert(!compose.validate());
|
||||
assert(!$("#sending-indicator").visible());
|
||||
assert(!$("#compose-send-button").is_focused());
|
||||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||
assert.equal($('#compose-error-msg').html(), i18n.t('You have nothing to send!'));
|
||||
|
||||
$("#new_message_content").val('foobarfoobar');
|
||||
$("#compose-textarea").val('foobarfoobar');
|
||||
var zephyr_checked = false;
|
||||
$("#zephyr-mirror-error").is = function () {
|
||||
if (!zephyr_checked) {
|
||||
|
@ -259,8 +259,8 @@ people.add(bob);
|
|||
(function test_send_message_success() {
|
||||
blueslip.error = noop;
|
||||
blueslip.log = noop;
|
||||
$("#new_message_content").val('foobarfoobar');
|
||||
$("#new_message_content").blur();
|
||||
$("#compose-textarea").val('foobarfoobar');
|
||||
$("#compose-textarea").blur();
|
||||
$("#compose-send-status").show();
|
||||
$("#compose-send-button").attr('disabled', 'disabled');
|
||||
$("#sending-indicator").show();
|
||||
|
@ -274,8 +274,8 @@ people.add(bob);
|
|||
|
||||
compose.send_message_success(1001, 12, false);
|
||||
|
||||
assert.equal($("#new_message_content").val(), '');
|
||||
assert($("#new_message_content").is_focused());
|
||||
assert.equal($("#compose-textarea").val(), '');
|
||||
assert($("#compose-textarea").is_focused());
|
||||
assert(!$("#compose-send-status").visible());
|
||||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||
assert(!$("#sending-indicator").visible());
|
||||
|
@ -345,9 +345,9 @@ people.add(bob);
|
|||
|
||||
// Setting message content with a host server link and we will assert
|
||||
// later that this has been converted to a relative link.
|
||||
$("#new_message_content").val('[foobar]' +
|
||||
$("#compose-textarea").val('[foobar]' +
|
||||
'(https://foo.com/user_uploads/123456)');
|
||||
$("#new_message_content").blur();
|
||||
$("#compose-textarea").blur();
|
||||
$("#compose-send-status").show();
|
||||
$("#compose-send-button").attr('disabled', 'disabled');
|
||||
$("#sending-indicator").show();
|
||||
|
@ -361,8 +361,8 @@ people.add(bob);
|
|||
send_msg_ajax_post_called: 1,
|
||||
};
|
||||
assert.deepEqual(stub_state, state);
|
||||
assert.equal($("#new_message_content").val(), '');
|
||||
assert($("#new_message_content").is_focused());
|
||||
assert.equal($("#compose-textarea").val(), '');
|
||||
assert($("#compose-textarea").is_focused());
|
||||
assert(!$("#compose-send-status").visible());
|
||||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||
assert(!$("#sending-indicator").visible());
|
||||
|
@ -441,12 +441,12 @@ people.add(bob);
|
|||
|
||||
(function test_error_codepath_local_id_undefined() {
|
||||
stub_state = initialize_state_stub_dict();
|
||||
$("#new_message_content").val('foobarfoobar');
|
||||
$("#new_message_content").blur();
|
||||
$("#compose-textarea").val('foobarfoobar');
|
||||
$("#compose-textarea").blur();
|
||||
$("#compose-send-status").show();
|
||||
$("#compose-send-button").attr('disabled', 'disabled');
|
||||
$("#sending-indicator").show();
|
||||
$("#new_message_content").select(noop);
|
||||
$("#compose-textarea").select(noop);
|
||||
echo_error_msg_checked = false;
|
||||
xhr_error_msg_checked = false;
|
||||
server_error_triggered = false;
|
||||
|
@ -475,8 +475,8 @@ people.add(bob);
|
|||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||
assert.equal($('#compose-error-msg').html(),
|
||||
'Error sending message: Server says 408');
|
||||
assert.equal($("#new_message_content").val(), 'foobarfoobar');
|
||||
assert($("#new_message_content").is_focused());
|
||||
assert.equal($("#compose-textarea").val(), 'foobarfoobar');
|
||||
assert($("#compose-textarea").is_focused());
|
||||
assert($("#compose-send-status").visible());
|
||||
assert.equal($("#compose-send-button").prop('disabled'), false);
|
||||
assert(!$("#sending-indicator").visible());
|
||||
|
@ -485,8 +485,8 @@ people.add(bob);
|
|||
|
||||
(function test_enter_with_preview_open() {
|
||||
// Test sending a message with content.
|
||||
$("#new_message_content").val('message me');
|
||||
$("#new_message_content").hide();
|
||||
$("#compose-textarea").val('message me');
|
||||
$("#compose-textarea").hide();
|
||||
$("#undo_markdown_preview").show();
|
||||
$("#preview_message_area").show();
|
||||
$("#markdown_preview").hide();
|
||||
|
@ -496,19 +496,19 @@ people.add(bob);
|
|||
send_message_called = true;
|
||||
};
|
||||
compose.enter_with_preview_open();
|
||||
assert($("#new_message_content").visible());
|
||||
assert($("#compose-textarea").visible());
|
||||
assert(!$("#undo_markdown_preview").visible());
|
||||
assert(!$("#preview_message_area").visible());
|
||||
assert($("#markdown_preview").visible());
|
||||
assert(send_message_called);
|
||||
|
||||
page_params.enter_sends = false;
|
||||
$("#new_message_content").blur();
|
||||
$("#compose-textarea").blur();
|
||||
compose.enter_with_preview_open();
|
||||
assert($("#new_message_content").is_focused());
|
||||
assert($("#compose-textarea").is_focused());
|
||||
|
||||
// Test sending a message without content.
|
||||
$("#new_message_content").val('');
|
||||
$("#compose-textarea").val('');
|
||||
$("#preview_message_area").show();
|
||||
$("#enter_sends").prop("checked", true);
|
||||
page_params.enter_sends = true;
|
||||
|
@ -525,8 +525,8 @@ people.add(bob);
|
|||
$("#compose-send-button").prop('disabled', false);
|
||||
$("#compose-send-button").focus();
|
||||
$("#sending-indicator").hide();
|
||||
$("#new_message_content").select(noop);
|
||||
$("#new_message_content").val('');
|
||||
$("#compose-textarea").select(noop);
|
||||
$("#compose-textarea").val('');
|
||||
var res = compose.finish();
|
||||
assert.equal(res, false);
|
||||
assert(!$("#compose_invite_users").visible());
|
||||
|
@ -537,11 +537,11 @@ people.add(bob);
|
|||
}());
|
||||
|
||||
(function test_when_compose_validation_succeed() {
|
||||
$("#new_message_content").hide();
|
||||
$("#compose-textarea").hide();
|
||||
$("#undo_markdown_preview").show();
|
||||
$("#preview_message_area").show();
|
||||
$("#markdown_preview").hide();
|
||||
$("#new_message_content").val('foobarfoobar');
|
||||
$("#compose-textarea").val('foobarfoobar');
|
||||
compose_state.set_message_type('private');
|
||||
compose_state.recipient('bob@example.com');
|
||||
var compose_finished_event_checked = false;
|
||||
|
@ -556,7 +556,7 @@ people.add(bob);
|
|||
send_message_called = true;
|
||||
};
|
||||
assert(compose.finish());
|
||||
assert($("#new_message_content").visible());
|
||||
assert($("#compose-textarea").visible());
|
||||
assert(!$("#undo_markdown_preview").visible());
|
||||
assert(!$("#preview_message_area").visible());
|
||||
assert($("#markdown_preview").visible());
|
||||
|
@ -610,7 +610,7 @@ function test_raw_file_drop(raw_drop_func) {
|
|||
compose_actions_start_checked = true;
|
||||
},
|
||||
};
|
||||
$("#new_message_content").val('Old content ');
|
||||
$("#compose-textarea").val('Old content ');
|
||||
var compose_ui_autosize_textarea_checked = false;
|
||||
compose_ui.autosize_textarea = function () {
|
||||
compose_ui_autosize_textarea_checked = true;
|
||||
|
@ -620,7 +620,7 @@ function test_raw_file_drop(raw_drop_func) {
|
|||
raw_drop_func('new contents');
|
||||
|
||||
assert(compose_actions_start_checked);
|
||||
assert.equal($("#new_message_content").val(), 'Old content new contents');
|
||||
assert.equal($("#compose-textarea").val(), 'Old content new contents');
|
||||
assert(compose_ui_autosize_textarea_checked);
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ function test_raw_file_drop(raw_drop_func) {
|
|||
|
||||
var resize_watch_manual_resize_checked = false;
|
||||
resize.watch_manual_resize = function (elem) {
|
||||
assert.equal('#new_message_content', elem);
|
||||
assert.equal('#compose-textarea', elem);
|
||||
resize_watch_manual_resize_checked = true;
|
||||
};
|
||||
global.window = {
|
||||
|
@ -1138,31 +1138,31 @@ function test_with_mock_socket(test_params) {
|
|||
(function test_video_link_compose_clicked() {
|
||||
// Hackishly pretend caret is the same as val, since we don't
|
||||
// have a cursor anyway.
|
||||
$('#new_message_content').caret = function (x) {
|
||||
$('#new_message_content').val(x);
|
||||
$('#compose-textarea').caret = function (x) {
|
||||
$('#compose-textarea').val(x);
|
||||
};
|
||||
|
||||
var handler = $("#compose").get_on_handler("click", "#video_link");
|
||||
assert.equal($('#new_message_content').val(), '');
|
||||
assert.equal($('#compose-textarea').val(), '');
|
||||
|
||||
handler(event);
|
||||
|
||||
// video link ids consist of 15 random digits
|
||||
var video_link_regex = /\[Click to join video call\]\(https:\/\/meet.jit.si\/\d{15}\)/;
|
||||
assert(video_link_regex.test($('#new_message_content').val()));
|
||||
assert(video_link_regex.test($('#compose-textarea').val()));
|
||||
}());
|
||||
|
||||
(function test_markdown_preview_compose_clicked() {
|
||||
// Tests setup
|
||||
function setup_visibilities() {
|
||||
$("#new_message_content").show();
|
||||
$("#compose-textarea").show();
|
||||
$("#markdown_preview").show();
|
||||
$("#undo_markdown_preview").hide();
|
||||
$("#preview_message_area").hide();
|
||||
}
|
||||
|
||||
function assert_visibilities() {
|
||||
assert(!$("#new_message_content").visible());
|
||||
assert(!$("#compose-textarea").visible());
|
||||
assert(!$("#markdown_preview").visible());
|
||||
assert($("#undo_markdown_preview").visible());
|
||||
assert($("#preview_message_area").visible());
|
||||
|
@ -1219,7 +1219,7 @@ function test_with_mock_socket(test_params) {
|
|||
.get_on_handler("click", "#markdown_preview");
|
||||
|
||||
// Tests start here
|
||||
$("#new_message_content").val('');
|
||||
$("#compose-textarea").val('');
|
||||
setup_visibilities();
|
||||
|
||||
handler(event);
|
||||
|
@ -1229,7 +1229,7 @@ function test_with_mock_socket(test_params) {
|
|||
assert_visibilities();
|
||||
|
||||
var make_indicator_called = false;
|
||||
$("#new_message_content").val('```foobarfoobar```');
|
||||
$("#compose-textarea").val('```foobarfoobar```');
|
||||
setup_visibilities();
|
||||
setup_mock_markdown_contains_backend_only_syntax('```foobarfoobar```', true);
|
||||
loading.make_indicator = function (spinner) {
|
||||
|
@ -1244,7 +1244,7 @@ function test_with_mock_socket(test_params) {
|
|||
assert_visibilities();
|
||||
|
||||
var apply_markdown_called = false;
|
||||
$("#new_message_content").val('foobarfoobar');
|
||||
$("#compose-textarea").val('foobarfoobar');
|
||||
setup_visibilities();
|
||||
setup_mock_markdown_contains_backend_only_syntax('foobarfoobar', false);
|
||||
mock_channel_post('foobarfoobar');
|
||||
|
@ -1266,14 +1266,14 @@ function test_with_mock_socket(test_params) {
|
|||
var handler = $("#compose")
|
||||
.get_on_handler("click", "#undo_markdown_preview");
|
||||
|
||||
$("#new_message_content").hide();
|
||||
$("#compose-textarea").hide();
|
||||
$("#undo_markdown_preview").show();
|
||||
$("#preview_message_area").show();
|
||||
$("#markdown_preview").hide();
|
||||
|
||||
handler(event);
|
||||
|
||||
assert($("#new_message_content").visible());
|
||||
assert($("#compose-textarea").visible());
|
||||
assert(!$("#undo_markdown_preview").visible());
|
||||
assert(!$("#preview_message_area").visible());
|
||||
assert($("#markdown_preview").visible());
|
||||
|
@ -1292,7 +1292,7 @@ function test_with_mock_socket(test_params) {
|
|||
var page = {
|
||||
'#stream': 'social',
|
||||
'#subject': 'lunch',
|
||||
'#new_message_content': 'burrito',
|
||||
'#compose-textarea': 'burrito',
|
||||
'#private_message_recipient': 'alice@example.com, bob@example.com',
|
||||
};
|
||||
|
||||
|
|
|
@ -119,14 +119,14 @@ function assert_hidden(sel) {
|
|||
content: 'hello',
|
||||
};
|
||||
|
||||
$('#new_message_content').trigger = noop;
|
||||
$('#compose-textarea').trigger = noop;
|
||||
start('private', opts);
|
||||
|
||||
assert_hidden('#stream-message');
|
||||
assert_visible('#private-message');
|
||||
|
||||
assert.equal($('#private_message_recipient').val(), 'foo@example.com');
|
||||
assert.equal($('#new_message_content').val(), 'hello');
|
||||
assert.equal($('#compose-textarea').val(), 'hello');
|
||||
assert.equal(compose_state.get_message_type(), 'private');
|
||||
assert(compose_state.composing());
|
||||
|
||||
|
@ -191,20 +191,20 @@ function assert_hidden(sel) {
|
|||
|
||||
reply_with_mention(opts);
|
||||
assert.equal($('#stream').val(), 'devel');
|
||||
assert.equal($('#new_message_content').val(), '@**Bob Roberts** ');
|
||||
assert.equal($('#compose-textarea').val(), '@**Bob Roberts** ');
|
||||
assert(compose_state.has_message_content());
|
||||
}());
|
||||
|
||||
(function test_get_focus_area() {
|
||||
assert.equal(get_focus_area('private', {}), 'private_message_recipient');
|
||||
assert.equal(get_focus_area('private', {
|
||||
private_message_recipient: 'bob@example.com'}), 'new_message_content');
|
||||
private_message_recipient: 'bob@example.com'}), 'compose-textarea');
|
||||
assert.equal(get_focus_area('stream', {}), 'stream');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun'}),
|
||||
'subject');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun',
|
||||
subject: 'more'}),
|
||||
'new_message_content');
|
||||
'compose-textarea');
|
||||
assert.equal(get_focus_area('stream', {stream: 'fun',
|
||||
subject: 'more',
|
||||
trigger: 'new topic button'}),
|
||||
|
@ -212,22 +212,22 @@ function assert_hidden(sel) {
|
|||
}());
|
||||
|
||||
(function test_focus_in_empty_compose() {
|
||||
$('#new_message_content').is = function (attr) {
|
||||
$('#compose-textarea').is = function (attr) {
|
||||
assert.equal(attr, ':focus');
|
||||
return $('#new_message_content').is_focused;
|
||||
return $('#compose-textarea').is_focused;
|
||||
};
|
||||
|
||||
compose_state.composing = return_true;
|
||||
$('#new_message_content').val('');
|
||||
$('#new_message_content').focus();
|
||||
$('#compose-textarea').val('');
|
||||
$('#compose-textarea').focus();
|
||||
assert(compose_state.focus_in_empty_compose());
|
||||
|
||||
compose_state.composing = return_false;
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
|
||||
$('#new_message_content').val('foo');
|
||||
$('#compose-textarea').val('foo');
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
|
||||
$('#new_message_content').blur();
|
||||
$('#compose-textarea').blur();
|
||||
assert(!compose_state.focus_in_empty_compose());
|
||||
}());
|
||||
|
|
|
@ -510,8 +510,8 @@ global.user_groups.add(backend);
|
|||
pm_recipient_typeahead_called = true;
|
||||
};
|
||||
|
||||
var new_message_content_typeahead_called = false;
|
||||
$('#new_message_content').typeahead = function (options) {
|
||||
var compose_textarea_typeahead_called = false;
|
||||
$('#compose-textarea').typeahead = function (options) {
|
||||
// options.source()
|
||||
//
|
||||
// For now we only test that compose_contents_begins_typeahead has been
|
||||
|
@ -603,7 +603,7 @@ global.user_groups.add(backend);
|
|||
fake_this = { completing: 'non-existing-completion' };
|
||||
assert.equal(options.sorter.call(fake_this), undefined);
|
||||
|
||||
new_message_content_typeahead_called = true;
|
||||
compose_textarea_typeahead_called = true;
|
||||
};
|
||||
|
||||
var pm_recipient_blur_called = false;
|
||||
|
@ -652,7 +652,7 @@ global.user_groups.add(backend);
|
|||
$('#subject').data = stub_typeahead_hidden;
|
||||
$('#stream').data = stub_typeahead_hidden;
|
||||
$('#private_message_recipient').data = stub_typeahead_hidden;
|
||||
$('#new_message_content').data = stub_typeahead_hidden;
|
||||
$('#compose-textarea').data = stub_typeahead_hidden;
|
||||
$('form#send_message_form').keydown(event);
|
||||
|
||||
event.keyCode = undefined;
|
||||
|
@ -660,16 +660,16 @@ global.user_groups.add(backend);
|
|||
event.shiftKey = false;
|
||||
event.target.id = 'subject';
|
||||
$('form#send_message_form').keydown(event);
|
||||
event.target.id = 'new_message_content';
|
||||
event.target.id = 'compose-textarea';
|
||||
$('form#send_message_form').keydown(event);
|
||||
event.target.id = 'some_non_existing_id';
|
||||
$('form#send_message_form').keydown(event);
|
||||
|
||||
|
||||
// Setup jquery functions used in new_message_content enter
|
||||
// Setup jquery functions used in compose_textarea enter
|
||||
// handler.
|
||||
var range_length = 0;
|
||||
$('#new_message_content').range = function () {
|
||||
$('#compose-textarea').range = function () {
|
||||
return {
|
||||
length: range_length,
|
||||
range: noop,
|
||||
|
@ -677,12 +677,12 @@ global.user_groups.add(backend);
|
|||
end: 0 + range_length,
|
||||
};
|
||||
};
|
||||
$('#new_message_content').caret = noop;
|
||||
$('#compose-textarea').caret = noop;
|
||||
|
||||
event.keyCode = 13;
|
||||
event.target.id = 'subject';
|
||||
$('form#send_message_form').keydown(event);
|
||||
event.target.id = 'new_message_content';
|
||||
event.target.id = 'compose-textarea';
|
||||
page_params.enter_sends = false;
|
||||
event.metaKey = true;
|
||||
var compose_finish_called = false;
|
||||
|
@ -776,7 +776,7 @@ global.user_groups.add(backend);
|
|||
assert(pm_recipient_typeahead_called);
|
||||
assert(pm_recipient_blur_called);
|
||||
assert(channel_post_called);
|
||||
assert(new_message_content_typeahead_called);
|
||||
assert(compose_textarea_typeahead_called);
|
||||
assert(focus_handler_called);
|
||||
assert(stream_one_called);
|
||||
}());
|
||||
|
|
|
@ -129,7 +129,7 @@ var draft_2 = {
|
|||
}());
|
||||
|
||||
(function test_initialize() {
|
||||
var message_content = $("#new_message_content");
|
||||
var message_content = $("#compose-textarea");
|
||||
message_content.focusout = function (f) {
|
||||
assert.equal(f, drafts.update_draft);
|
||||
f();
|
||||
|
|
|
@ -107,7 +107,7 @@ zrequire('upload');
|
|||
var compose_actions_start_checked = false;
|
||||
|
||||
function setup() {
|
||||
$("#new_message_content").val('');
|
||||
$("#compose-textarea").val('');
|
||||
compose_ui.autosize_textarea = function () {
|
||||
compose_ui_autosize_textarea_checked = true;
|
||||
};
|
||||
|
@ -128,7 +128,7 @@ zrequire('upload');
|
|||
}
|
||||
|
||||
function assert_side_effects() {
|
||||
assert.equal($("#new_message_content").val(), textbox_val);
|
||||
assert.equal($("#compose-textarea").val(), textbox_val);
|
||||
if (response.uri) {
|
||||
assert(compose_actions_start_checked);
|
||||
assert(compose_ui_autosize_textarea_checked);
|
||||
|
|
|
@ -730,7 +730,7 @@ $(function () {
|
|||
if (compose_state.composing()) {
|
||||
if ($(e.target).is("a")) {
|
||||
// Refocus compose message text box if link is clicked
|
||||
$("#new_message_content").focus();
|
||||
$("#compose-textarea").focus();
|
||||
} else if (!$(e.target).closest(".overlay").length &&
|
||||
!window.getSelection().toString() &&
|
||||
!$(e.target).closest('.popover-content').length) {
|
||||
|
|
|
@ -60,7 +60,7 @@ exports.reset_user_acknowledged_all_everyone_flag = function () {
|
|||
};
|
||||
|
||||
exports.clear_preview_area = function () {
|
||||
$("#new_message_content").show();
|
||||
$("#compose-textarea").show();
|
||||
$("#undo_markdown_preview").hide();
|
||||
$("#preview_message_area").hide();
|
||||
$("#preview_content").empty();
|
||||
|
@ -185,7 +185,7 @@ function send_message_socket(request, success, error) {
|
|||
}
|
||||
|
||||
function clear_compose_box() {
|
||||
$("#new_message_content").val('').focus();
|
||||
$("#compose-textarea").val('').focus();
|
||||
drafts.delete_draft_after_send();
|
||||
compose_ui.autosize_textarea();
|
||||
$("#compose-send-status").hide(0);
|
||||
|
@ -266,7 +266,7 @@ exports.send_message = function send_message(request) {
|
|||
// If we're not local echo'ing messages, or if this message was not
|
||||
// locally echoed, show error in compose box
|
||||
if (!locally_echoed) {
|
||||
compose_error(response, $('#new_message_content'));
|
||||
compose_error(response, $('#compose-textarea'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ exports.enter_with_preview_open = function () {
|
|||
exports.finish();
|
||||
} else {
|
||||
// Otherwise, we return to the compose box and focus it
|
||||
$("#new_message_content").focus();
|
||||
$("#compose-textarea").focus();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -469,7 +469,7 @@ exports.validate = function () {
|
|||
$("#sending-indicator").show();
|
||||
|
||||
if (/^\s*$/.test(compose_state.message_content())) {
|
||||
compose_error(i18n.t("You have nothing to send!"), $("#new_message_content"));
|
||||
compose_error(i18n.t("You have nothing to send!"), $("#compose-textarea"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ exports.initialize = function () {
|
|||
compose.finish();
|
||||
});
|
||||
|
||||
resize.watch_manual_resize("#new_message_content");
|
||||
resize.watch_manual_resize("#compose-textarea");
|
||||
|
||||
// Run a feature test and decide whether to display
|
||||
// the "Attach files" button
|
||||
|
@ -702,8 +702,8 @@ exports.initialize = function () {
|
|||
|
||||
$("#compose").on("click", "#markdown_preview", function (e) {
|
||||
e.preventDefault();
|
||||
var content = $("#new_message_content").val();
|
||||
$("#new_message_content").hide();
|
||||
var content = $("#compose-textarea").val();
|
||||
$("#compose-textarea").hide();
|
||||
$("#markdown_preview").hide();
|
||||
$("#undo_markdown_preview").show();
|
||||
$("#preview_message_area").show();
|
||||
|
@ -757,7 +757,7 @@ exports.initialize = function () {
|
|||
var options = {
|
||||
// Required. Called when a user selects an item in the Chooser.
|
||||
success: function (files) {
|
||||
var textbox = $("#new_message_content");
|
||||
var textbox = $("#compose-textarea");
|
||||
var links = _.map(files, function (file) { return '[' + file.name + '](' + file.link +')'; })
|
||||
.join(' ') + ' ';
|
||||
textbox.val(textbox.val() + links);
|
||||
|
|
|
@ -38,7 +38,7 @@ function get_focus_area(msg_type, opts) {
|
|||
if (opts.trigger === "new topic button") {
|
||||
return 'subject';
|
||||
}
|
||||
return 'new_message_content';
|
||||
return 'compose-textarea';
|
||||
}
|
||||
|
||||
if (msg_type === 'stream') {
|
||||
|
@ -96,13 +96,13 @@ function clear_box() {
|
|||
compose.reset_user_acknowledged_all_everyone_flag();
|
||||
|
||||
exports.clear_textarea();
|
||||
$("#new_message_content").removeData("draft-id");
|
||||
$("#compose-textarea").removeData("draft-id");
|
||||
compose_ui.autosize_textarea();
|
||||
$("#compose-send-status").hide(0);
|
||||
}
|
||||
|
||||
exports.autosize_message_content = function () {
|
||||
$("#new_message_content").autosize();
|
||||
$("#compose-textarea").autosize();
|
||||
};
|
||||
|
||||
exports.expand_compose_box = function () {
|
||||
|
@ -221,7 +221,7 @@ exports.start = function (msg_type, opts) {
|
|||
};
|
||||
|
||||
exports.cancel = function () {
|
||||
$("#new_message_content").height(40 + "px");
|
||||
$("#compose-textarea").height(40 + "px");
|
||||
|
||||
if (page_params.narrow !== undefined) {
|
||||
// Never close the compose box in narrow embedded windows, but
|
||||
|
@ -307,7 +307,7 @@ exports.reply_with_mention = function (opts) {
|
|||
exports.respond_to_message(opts);
|
||||
var message = current_msg_list.selected_message();
|
||||
var mention = '@**' + message.sender_full_name + '**';
|
||||
$('#new_message_content').val(mention + ' ');
|
||||
$('#compose-textarea').val(mention + ' ');
|
||||
};
|
||||
|
||||
exports.on_topic_narrow = function () {
|
||||
|
@ -349,7 +349,7 @@ exports.on_topic_narrow = function () {
|
|||
// See #3300 for context--a couple users specifically asked
|
||||
// for this convenience.
|
||||
compose_state.subject(narrow_state.topic());
|
||||
$('#new_message_content').focus().select();
|
||||
$('#compose-textarea').focus().select();
|
||||
};
|
||||
|
||||
exports.on_narrow = function () {
|
||||
|
|
|
@ -22,7 +22,7 @@ exports.focus_in_empty_compose = function () {
|
|||
return (
|
||||
exports.composing() &&
|
||||
exports.message_content() === "" &&
|
||||
$('#new_message_content').is(':focus'));
|
||||
$('#compose-textarea').is(':focus'));
|
||||
};
|
||||
|
||||
function get_or_set(fieldname, keep_leading_whitespace) {
|
||||
|
@ -42,9 +42,9 @@ function get_or_set(fieldname, keep_leading_whitespace) {
|
|||
// TODO: Break out setters and getter into their own functions.
|
||||
exports.stream_name = get_or_set('stream');
|
||||
exports.subject = get_or_set('subject');
|
||||
// We can't trim leading whitespace in `new_message_content` because
|
||||
// We can't trim leading whitespace in `compose_textarea` because
|
||||
// of the indented syntax for multi-line code blocks.
|
||||
exports.message_content = get_or_set('new_message_content', true);
|
||||
exports.message_content = get_or_set('compose-textarea', true);
|
||||
exports.recipient = get_or_set('private_message_recipient');
|
||||
|
||||
exports.has_message_content = function () {
|
||||
|
|
|
@ -3,7 +3,7 @@ var compose_ui = (function () {
|
|||
var exports = {};
|
||||
|
||||
exports.autosize_textarea = function () {
|
||||
$("#new_message_content").trigger("autosize.resize");
|
||||
$("#compose-textarea").trigger("autosize.resize");
|
||||
};
|
||||
|
||||
exports.smart_insert = function (textarea, syntax) {
|
||||
|
@ -38,7 +38,7 @@ 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 smart_insert.
|
||||
var textarea = $('#new_message_content');
|
||||
var textarea = $('#compose-textarea');
|
||||
exports.smart_insert(textarea, syntax);
|
||||
};
|
||||
|
||||
|
|
|
@ -95,8 +95,8 @@ function handle_keydown(e) {
|
|||
e.preventDefault();
|
||||
}
|
||||
|
||||
// In the new_message_content box, preventDefault() for tab but not for enter
|
||||
if (e.target.id === "new_message_content" && code !== 13) {
|
||||
// In the compose_textarea box, preventDefault() for tab but not for enter
|
||||
if (e.target.id === 'compose-textarea' && code !== 13) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
|
@ -106,10 +106,10 @@ function handle_keydown(e) {
|
|||
if (code === 13) {
|
||||
e.preventDefault();
|
||||
}
|
||||
nextFocus = "new_message_content";
|
||||
nextFocus = 'compose-textarea';
|
||||
} else if (e.target.id === "private_message_recipient") {
|
||||
nextFocus = "new_message_content";
|
||||
} else if (e.target.id === "new_message_content") {
|
||||
nextFocus = 'compose-textarea';
|
||||
} else if (e.target.id === 'compose-textarea') {
|
||||
if (code === 13) {
|
||||
nextFocus = false;
|
||||
} else {
|
||||
|
@ -123,7 +123,7 @@ function handle_keydown(e) {
|
|||
if (!($("#subject").data().typeahead.shown ||
|
||||
$("#stream").data().typeahead.shown ||
|
||||
$("#private_message_recipient").data().typeahead.shown ||
|
||||
$("#new_message_content").data().typeahead.shown)) {
|
||||
$("#compose-textarea").data().typeahead.shown)) {
|
||||
|
||||
// If no typeaheads are shown and the user is tabbing from the message content box,
|
||||
// then there's no need to wait and we can change the focus right away.
|
||||
|
@ -137,7 +137,7 @@ function handle_keydown(e) {
|
|||
nextFocus = false;
|
||||
}
|
||||
|
||||
if (e.target.id === "new_message_content" && code === 13) {
|
||||
if (e.target.id === 'compose-textarea' && code === 13) {
|
||||
var has_non_shift_modifier_key = e.ctrlKey || e.metaKey || e.altKey;
|
||||
var has_modifier_key = e.shiftKey || has_non_shift_modifier_key;
|
||||
var this_enter_sends;
|
||||
|
@ -176,7 +176,7 @@ function handle_keydown(e) {
|
|||
//
|
||||
// We do this using caret and range from jquery-caret.
|
||||
if (has_non_shift_modifier_key) {
|
||||
var textarea = $("#new_message_content");
|
||||
var textarea = $("#compose-textarea");
|
||||
|
||||
// To properly emulate browser "enter", if the
|
||||
// user had selected something in the compose box,
|
||||
|
@ -546,7 +546,7 @@ exports.initialize = function () {
|
|||
|
||||
// Refocus in the content box so you can continue typing or
|
||||
// press Enter to send.
|
||||
$("#new_message_content").focus();
|
||||
$("#compose-textarea").focus();
|
||||
|
||||
return channel.post({
|
||||
url: '/json/users/me/enter-sends',
|
||||
|
@ -637,7 +637,7 @@ exports.initialize = function () {
|
|||
stopAdvance: true, // Do not advance to the next field on a tab or enter
|
||||
});
|
||||
|
||||
exports.initialize_compose_typeahead("#new_message_content");
|
||||
exports.initialize_compose_typeahead("#compose-textarea");
|
||||
|
||||
$("#private_message_recipient").blur(function () {
|
||||
var val = $(this).val();
|
||||
|
|
|
@ -182,7 +182,7 @@ exports.paste_handler = function (event) {
|
|||
|
||||
$(function () {
|
||||
$(document).on('copy', copy_handler);
|
||||
$("#new_message_content").bind('paste', exports.paste_handler);
|
||||
$("#compose-textarea").bind('paste', exports.paste_handler);
|
||||
});
|
||||
|
||||
return exports;
|
||||
|
|
|
@ -88,7 +88,7 @@ exports.snapshot_message = function () {
|
|||
|
||||
exports.update_draft = function () {
|
||||
var draft = drafts.snapshot_message();
|
||||
var draft_id = $("#new_message_content").data("draft-id");
|
||||
var draft_id = $("#compose-textarea").data("draft-id");
|
||||
|
||||
if (draft_id !== undefined) {
|
||||
if (draft !== undefined) {
|
||||
|
@ -99,17 +99,17 @@ exports.update_draft = function () {
|
|||
} else {
|
||||
if (draft !== undefined) {
|
||||
var new_draft_id = draft_model.addDraft(draft);
|
||||
$("#new_message_content").data("draft-id", new_draft_id);
|
||||
$("#compose-textarea").data("draft-id", new_draft_id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.delete_draft_after_send = function () {
|
||||
var draft_id = $("#new_message_content").data("draft-id");
|
||||
var draft_id = $("#compose-textarea").data("draft-id");
|
||||
if (draft_id) {
|
||||
draft_model.deleteDraft(draft_id);
|
||||
}
|
||||
$("#new_message_content").removeData("draft-id");
|
||||
$("#compose-textarea").removeData("draft-id");
|
||||
};
|
||||
|
||||
exports.restore_draft = function (draft_id) {
|
||||
|
@ -148,7 +148,7 @@ exports.restore_draft = function (draft_id) {
|
|||
}
|
||||
compose_actions.start(draft_copy.type, draft_copy);
|
||||
compose_ui.autosize_textarea();
|
||||
$("#new_message_content").data("draft-id", draft_id);
|
||||
$("#compose-textarea").data("draft-id", draft_id);
|
||||
};
|
||||
|
||||
exports.setup_page = function (callback) {
|
||||
|
@ -403,7 +403,7 @@ exports.initialize = function () {
|
|||
exports.update_draft();
|
||||
});
|
||||
|
||||
$("#new_message_content").focusout(exports.update_draft);
|
||||
$("#compose-textarea").focusout(exports.update_draft);
|
||||
};
|
||||
|
||||
return exports;
|
||||
|
|
|
@ -531,11 +531,11 @@ exports.process_hotkey = function (e, hotkey) {
|
|||
compose_actions.cancel();
|
||||
// don't return, as we still want it to be picked up by the code below
|
||||
} else if (event_name === "page_up") {
|
||||
$("#new_message_content").caret(0);
|
||||
$("#compose-textarea").caret(0);
|
||||
return true;
|
||||
} else if (event_name === "page_down") {
|
||||
// so that it always goes to the end of the compose box.
|
||||
$("#new_message_content").caret(Infinity);
|
||||
$("#compose-textarea").caret(Infinity);
|
||||
return true;
|
||||
} else {
|
||||
// Let the browser handle the key normally.
|
||||
|
|
|
@ -390,7 +390,7 @@ exports.register_click_handlers = function () {
|
|||
var user_id = $(e.target).parents('ul').attr('data-user-id');
|
||||
compose_actions.start('stream', {trigger: 'sidebar user actions'});
|
||||
var name = people.get_person_from_user_id(user_id).full_name;
|
||||
var textarea = $("#new_message_content");
|
||||
var textarea = $("#compose-textarea");
|
||||
textarea.val('@**' + name + '** ');
|
||||
popovers.hide_user_sidebar_popover();
|
||||
e.stopPropagation();
|
||||
|
@ -419,7 +419,7 @@ exports.register_click_handlers = function () {
|
|||
compose_actions.respond_to_message({trigger: 'user sidebar popover'});
|
||||
var user_id = $(e.target).parents('ul').attr('data-user-id');
|
||||
var name = people.get_person_from_user_id(user_id).full_name;
|
||||
var textarea = $("#new_message_content");
|
||||
var textarea = $("#compose-textarea");
|
||||
textarea.val('@**' + name + '** ');
|
||||
popovers.hide_message_info_popover();
|
||||
e.stopPropagation();
|
||||
|
@ -480,7 +480,7 @@ exports.register_click_handlers = function () {
|
|||
});
|
||||
|
||||
$('body').on('click', '.respond_button', function (e) {
|
||||
var textarea = $("#new_message_content");
|
||||
var textarea = $("#compose-textarea");
|
||||
var msgid = $(e.currentTarget).data("message-id");
|
||||
|
||||
compose_actions.respond_to_message({trigger: 'popover respond'});
|
||||
|
@ -493,7 +493,7 @@ exports.register_click_handlers = function () {
|
|||
} else {
|
||||
textarea.val(textarea.val() + "\n```quote\n" + data.raw_content +"\n```\n");
|
||||
}
|
||||
$("#new_message_content").trigger("autosize.resize");
|
||||
$("#compose-textarea").trigger("autosize.resize");
|
||||
},
|
||||
});
|
||||
popovers.hide_actions_popover();
|
||||
|
|
|
@ -404,7 +404,7 @@ function _set_up() {
|
|||
// grab the first alert available and use it for the status.
|
||||
var status = $("#admin-realm-notifications-stream-status");
|
||||
|
||||
var new_message_content_edit_limit_minutes = $("#id_realm_message_content_edit_limit_minutes").val();
|
||||
var compose_textarea_edit_limit_minutes = $("#id_realm_message_content_edit_limit_minutes").val();
|
||||
var new_allow_message_editing = $("#id_realm_allow_message_editing").prop("checked");
|
||||
|
||||
// If allow_message_editing is unchecked, message_content_edit_limit_minutes
|
||||
|
@ -412,11 +412,11 @@ function _set_up() {
|
|||
// message_content_edit_limit_minutes is poorly formed, we set the latter to
|
||||
// a default value to prevent the server from returning an error.
|
||||
if (!new_allow_message_editing) {
|
||||
if ((parseInt(new_message_content_edit_limit_minutes, 10).toString() !==
|
||||
new_message_content_edit_limit_minutes) ||
|
||||
new_message_content_edit_limit_minutes < 0) {
|
||||
if ((parseInt(compose_textarea_edit_limit_minutes, 10).toString() !==
|
||||
compose_textarea_edit_limit_minutes) ||
|
||||
compose_textarea_edit_limit_minutes < 0) {
|
||||
// Realm.DEFAULT_MESSAGE_CONTENT_EDIT_LIMIT_SECONDS / 60
|
||||
new_message_content_edit_limit_minutes = 10;
|
||||
compose_textarea_edit_limit_minutes = 10;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ function _set_up() {
|
|||
data = populate_data_for_request({
|
||||
allow_message_editing: JSON.stringify(new_allow_message_editing),
|
||||
message_content_edit_limit_seconds:
|
||||
JSON.stringify(parseInt(new_message_content_edit_limit_minutes, 10) * 60),
|
||||
JSON.stringify(parseInt(compose_textarea_edit_limit_minutes, 10) * 60),
|
||||
}, 'settings');
|
||||
|
||||
channel.patch({
|
||||
|
|
|
@ -81,7 +81,7 @@ var worker = {
|
|||
notify_server_stop: notify_server_stop,
|
||||
};
|
||||
|
||||
$(document).on('input', '#new_message_content', function () {
|
||||
$(document).on('input', '#compose-textarea', function () {
|
||||
// If our previous state was no typing notification, send a
|
||||
// start-typing notice immediately.
|
||||
typing_status.handle_text_input(worker);
|
||||
|
|
|
@ -250,7 +250,7 @@ $(function () {
|
|||
scroll_finish();
|
||||
}));
|
||||
|
||||
$('#new_message_content').blur(function () {
|
||||
$('#compose-textarea').blur(function () {
|
||||
saved_compose_cursor = $(this).caret();
|
||||
});
|
||||
|
||||
|
@ -262,7 +262,7 @@ $(function () {
|
|||
});
|
||||
|
||||
exports.restore_compose_cursor = function () {
|
||||
$('#new_message_content')
|
||||
$('#compose-textarea')
|
||||
.focus()
|
||||
.caret(saved_compose_cursor);
|
||||
};
|
||||
|
@ -272,7 +272,7 @@ $(function () {
|
|||
// Disable "spellchecking" in our desktop app. The "spellchecking"
|
||||
// in our Mac app is actually autocorrect, and frustrates our
|
||||
// users.
|
||||
$("#new_message_content").attr('spellcheck', 'false');
|
||||
$("#compose-textarea").attr('spellcheck', 'false');
|
||||
// Modify the zephyr mirroring error message in our desktop
|
||||
// app, since it doesn't work from the desktop version.
|
||||
$("#webathena_login_menu").hide();
|
||||
|
|
|
@ -74,7 +74,7 @@ exports.uploadFinished = function (i, file, response) {
|
|||
if (response.uri === undefined) {
|
||||
return;
|
||||
}
|
||||
var textbox = $("#new_message_content");
|
||||
var textbox = $("#compose-textarea");
|
||||
var split_uri = response.uri.split("/");
|
||||
var filename = split_uri[split_uri.length - 1];
|
||||
// Urgh, yet another hack to make sure we're "composing"
|
||||
|
@ -120,7 +120,7 @@ exports.initialize = function () {
|
|||
error: exports.uploadError,
|
||||
uploadFinished: exports.uploadFinished,
|
||||
rawDrop: function (contents) {
|
||||
var textbox = $("#new_message_content");
|
||||
var textbox = $("#compose-textarea");
|
||||
if (!compose_state.composing()) {
|
||||
compose_actions.start('stream');
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="messagebox" colspan="2">
|
||||
<textarea class="new_message_textarea" name="content" id="new_message_content"
|
||||
<textarea class="new_message_textarea" name="content" id='compose-textarea'
|
||||
value="" placeholder="{{ _('Compose your message here...') }}" tabindex="0" maxlength="10000" aria-label="{{ _('Compose your message here...') }}"></textarea>
|
||||
<div class="scrolling_list" id="preview_message_area" style="display:none;">
|
||||
<div id="markdown_preview_spinner"></div>
|
||||
|
|
Loading…
Reference in New Issue