mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-18 15:15:48 +02:00
Tweak emoji search to only select query on click and refocus it after clicking emoji
This commit is contained in:
parent
8db6e8a090
commit
3d642d8ad2
@ -72,6 +72,8 @@ enabled(){
|
|||||||
this.currentKeyboard = null;
|
this.currentKeyboard = null;
|
||||||
this.currentSpanner = null;
|
this.currentSpanner = null;
|
||||||
|
|
||||||
|
var wasSearchFocused = false;
|
||||||
|
|
||||||
var hideKeyboard = (refocus) => {
|
var hideKeyboard = (refocus) => {
|
||||||
$(this.currentKeyboard).remove();
|
$(this.currentKeyboard).remove();
|
||||||
this.currentKeyboard = null;
|
this.currentKeyboard = null;
|
||||||
@ -193,16 +195,24 @@ enabled(){
|
|||||||
var searchInput = search.children[0];
|
var searchInput = search.children[0];
|
||||||
searchInput.focus();
|
searchInput.focus();
|
||||||
|
|
||||||
|
wasSearchFocused = false;
|
||||||
|
|
||||||
searchInput.addEventListener("input", function(e){
|
searchInput.addEventListener("input", function(e){
|
||||||
me.currentKeywords = e.target.value.split(" ").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
|
me.currentKeywords = e.target.value.split(" ").filter(kw => kw.length > 0).map(kw => kw.toLowerCase());
|
||||||
updateFilters();
|
updateFilters();
|
||||||
|
|
||||||
|
wasSearchFocused = $(this).val().length > 0;
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
});
|
});
|
||||||
|
|
||||||
searchInput.addEventListener("focus", function(){
|
searchInput.addEventListener("click", function(){
|
||||||
$(this).select();
|
$(this).select();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
searchInput.addEventListener("focus", function(){
|
||||||
|
wasSearchFocused = true;
|
||||||
|
});
|
||||||
|
|
||||||
this.currentKeyboard = outer;
|
this.currentKeyboard = outer;
|
||||||
selectSkinTone(this.selectedSkinTone);
|
selectSkinTone(this.selectedSkinTone);
|
||||||
|
|
||||||
@ -227,10 +237,16 @@ enabled(){
|
|||||||
|
|
||||||
input.val(val.slice(0, posStart)+alt+val.slice(posEnd));
|
input.val(val.slice(0, posStart)+alt+val.slice(posEnd));
|
||||||
input.trigger("change");
|
input.trigger("change");
|
||||||
input.focus();
|
|
||||||
|
|
||||||
input[0].selectionStart = posStart+alt.length;
|
input[0].selectionStart = posStart+alt.length;
|
||||||
input[0].selectionEnd = posStart+alt.length;
|
input[0].selectionEnd = posStart+alt.length;
|
||||||
|
|
||||||
|
if (wasSearchFocused){
|
||||||
|
$(".emoji-keyboard-search").children("input").focus();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// general event handlers
|
// general event handlers
|
||||||
@ -254,6 +270,10 @@ enabled(){
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.composeInputFocusEvent = function(e){
|
||||||
|
wasSearchFocused = false;
|
||||||
|
};
|
||||||
|
|
||||||
this.composerSendingEvent = function(e){
|
this.composerSendingEvent = function(e){
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
};
|
};
|
||||||
@ -285,6 +305,7 @@ ready(){
|
|||||||
this.composePanelScroller.on("scroll", this.composerScrollEvent);
|
this.composePanelScroller.on("scroll", this.composerScrollEvent);
|
||||||
|
|
||||||
$(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent);
|
$(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent);
|
||||||
|
$(".js-compose-text", ".js-docked-compose").on("focus", this.composeInputFocusEvent);
|
||||||
$(document).on("click", this.documentClickEvent);
|
$(document).on("click", this.documentClickEvent);
|
||||||
$(document).on("keydown", this.documentKeyEvent);
|
$(document).on("keydown", this.documentKeyEvent);
|
||||||
$(document).on("uiComposeImageAdded", this.uploadFilesEvent);
|
$(document).on("uiComposeImageAdded", this.uploadFilesEvent);
|
||||||
@ -408,6 +429,7 @@ disabled(){
|
|||||||
$(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent);
|
$(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent);
|
||||||
$(".emoji-keyboard-popup-btn").remove();
|
$(".emoji-keyboard-popup-btn").remove();
|
||||||
|
|
||||||
|
$(".js-compose-text", ".js-docked-compose").off("focus", this.composeInputFocusEvent);
|
||||||
$(document).off("click", this.documentClickEvent);
|
$(document).off("click", this.documentClickEvent);
|
||||||
$(document).off("keydown", this.documentKeyEvent);
|
$(document).off("keydown", this.documentKeyEvent);
|
||||||
$(document).off("uiComposeImageAdded", this.uploadFilesEvent);
|
$(document).off("uiComposeImageAdded", this.uploadFilesEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user