OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/frontend/app/components/wp-fast-table/handlers/click-or-enter-handler.ts

25 lines
698 B

import {keyCodes} from "../../common/keyCodes.enum";
import {WorkPackageTable} from "../wp-fast-table";
/**
* Execute the callback if the given JQuery Event is either an ENTER key or a click
*/
export function onClickOrEnter(evt:JQueryEventObject, callback:() => void) {
if (evt.type === 'click' || (evt.type === 'keydown' && evt.which === keyCodes.ENTER)) {
callback();
return false;
}
return true;
}
export abstract class ClickOrEnterHandler {
public handleEvent(table: WorkPackageTable, evt:JQueryEventObject) {
onClickOrEnter(evt, () => this.processEvent(table, evt));
}
protected abstract processEvent(table:WorkPackageTable, evt:JQueryEventObject):boolean;
}