emoji_picker: Extract `register_popover_events()` function.

This commit is contained in:
Harshit Bansal 2017-08-29 20:59:25 +00:00 committed by Tim Abbott
parent aebb49b18c
commit c864816f64
1 changed files with 12 additions and 7 deletions

View File

@ -476,6 +476,17 @@ exports.emoji_select_tab = function (elt) {
} }
}; };
function register_popover_events(popover) {
var $emoji_map = popover.find('.emoji-popover-emoji-map');
$emoji_map.on("scroll", function () {
emoji_picker.emoji_select_tab($emoji_map);
});
$('.emoji-popover-filter').on('input', filter_emojis);
$('.emoji-popover-filter').keydown(maybe_select_emoji);
}
exports.render_emoji_popover = function (elt, id) { exports.render_emoji_popover = function (elt, id) {
var template_args = { var template_args = {
class: "emoji-info-popover", class: "emoji-info-popover",
@ -505,10 +516,7 @@ exports.render_emoji_popover = function (elt, id) {
var popover = elt.data('popover').$tip; var popover = elt.data('popover').$tip;
refill_section_head_offsets(popover); refill_section_head_offsets(popover);
var $emoji_map = popover.find('.emoji-popover-emoji-map'); register_popover_events(popover);
$emoji_map.on("scroll", function () {
emoji_picker.emoji_select_tab($emoji_map);
});
}; };
exports.toggle_emoji_popover = function (element, id) { exports.toggle_emoji_popover = function (element, id) {
@ -589,9 +597,6 @@ exports.register_click_handlers = function () {
emoji_picker.toggle_emoji_popover($(".selected_message .icon-vector-chevron-down")[0], msgid); emoji_picker.toggle_emoji_popover($(".selected_message .icon-vector-chevron-down")[0], msgid);
}); });
$(document).on('input', '.emoji-popover-filter', filter_emojis);
$(document).on('keydown', '.emoji-popover-filter', maybe_select_emoji);
$("body").on("click", ".emoji-popover-tab-item", function (e) { $("body").on("click", ".emoji-popover-tab-item", function (e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();