37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import WuhuBase from "../WuhuBase";
|
|
import TornStyleBlock from "../utils/TornStyleBlock";
|
|
import TornStyleSwitch from "../utils/TornStyleSwitch";
|
|
import CommonUtils from "../utils/CommonUtils";
|
|
import WuhuConfig from "../WuhuConfig";
|
|
|
|
export default class SearchHelper extends WuhuBase {
|
|
className = 'SearchHelper';
|
|
|
|
constructor() {
|
|
super();
|
|
}
|
|
|
|
public init(): void {
|
|
let block = new TornStyleBlock('搜索助手');
|
|
let placeholderSwitch = new TornStyleSwitch('底部空白占位区');
|
|
block.append(placeholderSwitch.getBase()).insert2Dom();
|
|
CommonUtils.addStyle('body.WHSearchPagePlaceholder .content.logged-in {margin-bottom: 340px;}');
|
|
let config = WuhuConfig.get('SearchPagePlaceholder');
|
|
placeholderSwitch.getInput().checked = config || false;
|
|
config ? this.enable() : this.disable();
|
|
placeholderSwitch.getInput().addEventListener('change', () => {
|
|
placeholderSwitch.getInput().checked ? this.enable() : this.disable();
|
|
});
|
|
}
|
|
|
|
private enable(): void {
|
|
document.body.classList.add('WHSearchPagePlaceholder');
|
|
WuhuConfig.set('SearchPagePlaceholder', true);
|
|
}
|
|
|
|
private disable(): void {
|
|
document.body.classList.remove('WHSearchPagePlaceholder');
|
|
WuhuConfig.set('SearchPagePlaceholder', false);
|
|
}
|
|
}
|