1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-21 06:15:47 +02:00

Add column reset functionality when holding Shift to code.js

This commit is contained in:
chylex 2016-12-23 23:52:33 +01:00
parent eb4ce18e31
commit 241f67fd4d

View File

@ -452,6 +452,44 @@
}
});
//
// Block: Hold Shift to reset cleared column.
//
(function(){
var holdingShift = false;
var updateShiftState = (pressed) => {
if (pressed != holdingShift){
holdingShift = pressed;
$("button[data-action='clear']").children("span").text(holdingShift ? "Reset" : "Clear");
}
};
var resetActiveFocus = () => {
document.activeElement.blur();
};
$(document).keydown(function(e){
if (e.shiftKey && (document.activeElement === null || !("value" in document.activeElement))){
updateShiftState(true);
}
}).keyup(function(e){
if (!e.shiftKey){
updateShiftState(false);
}
});
TD.vo.Column.prototype.clear = prependToFunction(TD.vo.Column.prototype.clear, function(){
window.setTimeout(resetActiveFocus, 0); // unfocuses the Clear button, otherwise it steals keyboard input
if (holdingShift){
this.model.setClearedTimestamp(0);
this.reloadTweets();
return true;
}
});
})();
//
// Block: Inject custom CSS and layout into the page.
//