1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-13 18:15:48 +02:00

Make searching while holding Ctrl or middle-clicking search icon open search externally

This commit is contained in:
chylex 2017-11-02 09:46:33 +01:00
parent 108cf8923e
commit c83b62ebaa

View File

@ -1072,6 +1072,43 @@
}
});
//
// Block: Make submitting search queries while holding Ctrl or middle-clicking the search icon open the search externally.
//
onAppReady.push(function(){
let openSearchExternally = function(event, input){
$TD.openBrowser("https://twitter.com/search/?q="+encodeURIComponent(input.val() || ""));
event.preventDefault();
event.stopPropagation();
input.val("");
app.click(); // unfocus everything
};
$(".js-app-search-input").keydown(function(e){
(e.ctrlKey && e.keyCode === 13) && openSearchExternally(e, $(this)); // enter
});
$(".js-perform-search").on("click auxclick", function(e){
(e.ctrlKey || e.button === 1) && openSearchExternally(e, $(".js-app-search-input:visible"));
}).each(function(){
let events = $._data($(this)[0], "events"); // TODO move this hackery to a global function
var handlers = events["click"];
var newHandler = handlers[handlers.length-1];
for(var index = handlers.length-1; index > 0; index--){
handlers[index] = handlers[index-1];
}
handlers[0] = newHandler;
});
$("[data-action='show-search']").on("click auxclick", function(e){
(e.ctrlKey || e.button === 1) && openSearchExternally(e, $());
});
});
//
// Block: Allow applying ROT13 to input selection.
//