mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +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);
 | 
					    stub_selected_message(msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var syntax_to_insert;
 | 
				
			||||||
 | 
					    compose_ui.insert_syntax_and_focus = function (syntax) {
 | 
				
			||||||
 | 
					        syntax_to_insert = syntax;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var opts = {
 | 
					    var opts = {
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    reply_with_mention(opts);
 | 
					    reply_with_mention(opts);
 | 
				
			||||||
    assert.equal($('#stream').val(), 'devel');
 | 
					    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());
 | 
					    assert(compose_state.has_message_content());
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -320,7 +320,7 @@ exports.reply_with_mention = function (opts) {
 | 
				
			|||||||
    exports.respond_to_message(opts);
 | 
					    exports.respond_to_message(opts);
 | 
				
			||||||
    var message = current_msg_list.selected_message();
 | 
					    var message = current_msg_list.selected_message();
 | 
				
			||||||
    var mention = '@**' + message.sender_full_name + '**';
 | 
					    var mention = '@**' + message.sender_full_name + '**';
 | 
				
			||||||
    $('#compose-textarea').val(mention + ' ');
 | 
					    compose_ui.insert_syntax_and_focus(mention);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.on_topic_narrow = function () {
 | 
					exports.on_topic_narrow = function () {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -555,8 +555,7 @@ exports.register_click_handlers = function () {
 | 
				
			|||||||
        compose_actions.start('stream', {trigger: 'sidebar user actions'});
 | 
					        compose_actions.start('stream', {trigger: 'sidebar user actions'});
 | 
				
			||||||
        var user_id = $(e.target).parents('ul').attr('data-user-id');
 | 
					        var user_id = $(e.target).parents('ul').attr('data-user-id');
 | 
				
			||||||
        var name = people.get_person_from_user_id(user_id).full_name;
 | 
					        var name = people.get_person_from_user_id(user_id).full_name;
 | 
				
			||||||
        var textarea = $("#compose-textarea");
 | 
					        compose_ui.insert_syntax_and_focus('@**' + name + '**');
 | 
				
			||||||
        textarea.val('@**' + name + '** ');
 | 
					 | 
				
			||||||
        popovers.hide_user_sidebar_popover();
 | 
					        popovers.hide_user_sidebar_popover();
 | 
				
			||||||
        e.stopPropagation();
 | 
					        e.stopPropagation();
 | 
				
			||||||
        e.preventDefault();
 | 
					        e.preventDefault();
 | 
				
			||||||
@@ -566,8 +565,7 @@ exports.register_click_handlers = function () {
 | 
				
			|||||||
        compose_actions.respond_to_message({trigger: 'user sidebar popover'});
 | 
					        compose_actions.respond_to_message({trigger: 'user sidebar popover'});
 | 
				
			||||||
        var user_id = $(e.target).parents('ul').attr('data-user-id');
 | 
					        var user_id = $(e.target).parents('ul').attr('data-user-id');
 | 
				
			||||||
        var name = people.get_person_from_user_id(user_id).full_name;
 | 
					        var name = people.get_person_from_user_id(user_id).full_name;
 | 
				
			||||||
        var textarea = $("#compose-textarea");
 | 
					        compose_ui.insert_syntax_and_focus('@**' + name + '**');
 | 
				
			||||||
        textarea.val('@**' + name + '** ');
 | 
					 | 
				
			||||||
        popovers.hide_message_info_popover();
 | 
					        popovers.hide_message_info_popover();
 | 
				
			||||||
        e.stopPropagation();
 | 
					        e.stopPropagation();
 | 
				
			||||||
        e.preventDefault();
 | 
					        e.preventDefault();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user