mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	compose: Use insert_syntax_and_focus to insert text in compose textarea.
Use compose_ui.insert_syntax_and_focus() when we need to insert text inline-ly followed by the focus to compose textarea because it does this job more smartly(it take cares of spaces).
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							c995c1a36a
						
					
				
				
					commit
					dcac002213
				
			@@ -190,12 +190,17 @@ function assert_hidden(sel) {
 | 
			
		||||
    };
 | 
			
		||||
    stub_selected_message(msg);
 | 
			
		||||
 | 
			
		||||
    var syntax_to_insert;
 | 
			
		||||
    compose_ui.insert_syntax_and_focus = function (syntax) {
 | 
			
		||||
        syntax_to_insert = syntax;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    var opts = {
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    reply_with_mention(opts);
 | 
			
		||||
    assert.equal($('#stream').val(), 'devel');
 | 
			
		||||
    assert.equal($('#compose-textarea').val(), '@**Bob Roberts** ');
 | 
			
		||||
    assert.equal(syntax_to_insert, '@**Bob Roberts**');
 | 
			
		||||
    assert(compose_state.has_message_content());
 | 
			
		||||
}());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -320,7 +320,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 + '**';
 | 
			
		||||
    $('#compose-textarea').val(mention + ' ');
 | 
			
		||||
    compose_ui.insert_syntax_and_focus(mention);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
exports.on_topic_narrow = function () {
 | 
			
		||||
 
 | 
			
		||||
@@ -555,8 +555,7 @@ exports.register_click_handlers = function () {
 | 
			
		||||
        compose_actions.start('stream', {trigger: 'sidebar user actions'});
 | 
			
		||||
        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 = $("#compose-textarea");
 | 
			
		||||
        textarea.val('@**' + name + '** ');
 | 
			
		||||
        compose_ui.insert_syntax_and_focus('@**' + name + '**');
 | 
			
		||||
        popovers.hide_user_sidebar_popover();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
@@ -566,8 +565,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 = $("#compose-textarea");
 | 
			
		||||
        textarea.val('@**' + name + '** ');
 | 
			
		||||
        compose_ui.insert_syntax_and_focus('@**' + name + '**');
 | 
			
		||||
        popovers.hide_message_info_popover();
 | 
			
		||||
        e.stopPropagation();
 | 
			
		||||
        e.preventDefault();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user