add a applystyle function with saftey checks in header filter (#5380)

This commit is contained in:
Anthony Dresser
2019-05-06 13:43:54 -07:00
committed by GitHub
parent 5c5ee50983
commit 4e5b8ce875

View File

@@ -28,6 +28,7 @@ export class HeaderFilter {
private cancelButton: Button; private cancelButton: Button;
private workingFilters: any; private workingFilters: any;
private columnDef: any; private columnDef: any;
private buttonStyles: IButtonStyles;
constructor(options: any) { constructor(options: any) {
this.options = mixin(options, this.defaults, false); this.options = mixin(options, this.defaults, false);
@@ -220,6 +221,8 @@ export class HeaderFilter {
const cancelElement = jQuery('#filter-cancel-button'); const cancelElement = jQuery('#filter-cancel-button');
cancelElement.bind('click', () => this.hideMenu()); cancelElement.bind('click', () => this.hideMenu());
this.applyStyles();
jQuery(':checkbox', $filter).bind('click', (e) => { jQuery(':checkbox', $filter).bind('click', (e) => {
this.workingFilters = this.changeWorkingFilter(filterItems, this.workingFilters, jQuery(e.target)); this.workingFilters = this.changeWorkingFilter(filterItems, this.workingFilters, jQuery(e.target));
}); });
@@ -237,10 +240,26 @@ export class HeaderFilter {
} }
public style(styles: IButtonStyles): void { public style(styles: IButtonStyles): void {
this.buttonStyles = styles;
this.applyStyles();
}
private applyStyles() {
if (this.buttonStyles) {
const styles = this.buttonStyles;
if (this.okButton) {
this.okButton.style(styles); this.okButton.style(styles);
}
if (this.clearButton) {
this.clearButton.style(styles); this.clearButton.style(styles);
}
if (this.cancelButton) {
this.cancelButton.style(styles); this.cancelButton.style(styles);
} }
}
}
private columnsResized() { private columnsResized() {
this.hideMenu(); this.hideMenu();