nopaque/app/static/js/CorpusAnalysis/QueryBuilder.js

55 lines
2.4 KiB
JavaScript
Raw Normal View History

2022-07-13 12:06:22 +00:00
class ConcordanceQueryBuilder {
2022-09-07 07:06:21 +00:00
constructor() {
2023-08-02 12:14:46 +00:00
this.elements = new ElementReferencesQueryBuilder();
this.generalFunctions = new GeneralFunctionsQueryBuilder(this.elements);
this.tokenAttributeBuilder = new TokenAttributeBuilderFunctionsQueryBuilder(this.elements);
this.structuralAttributeBuilder = new StructuralAttributeBuilderFunctionsQueryBuilder(this.elements);
2022-09-07 07:06:21 +00:00
// Event listener for structural attribute modal
document.querySelectorAll('[data-structural-attr-modal-action-button]').forEach(button => {
button.addEventListener('click', () => {
this.structuralAttributeBuilder.actionButtonHandler(button.dataset.structuralAttrModalActionButton);
});
});
2022-09-07 07:06:21 +00:00
// Event listener for token attribute modal
this.elements.positionalAttrSelection.addEventListener('change', (event) => {
this.generalFunctions.toggleClass(['word', 'lemma', 'english-pos', 'german-pos', 'simple-pos'], 'hide', 'add');
this.generalFunctions.toggleClass([event.target.value], 'hide', 'remove');
this.generalFunctions.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'add');
});
// Options for positional attribute selection
document.querySelectorAll('.positional-attr-options-action-button[data-options-action]').forEach(button => {
button.addEventListener('click', () => {this.tokenAttributeBuilder.actionButtonHandler(button.dataset.optionsAction);});
});
document.querySelectorAll('.incidence-modifier-selection[data-incidence-modifier]').forEach(button => {
button.addEventListener('click', () => {this.tokenAttributeBuilder.incidenceModifierHandler(button);});
});
document.querySelectorAll('.n-m-submit-button').forEach(button => {
button.addEventListener('click', () => {
this.tokenAttributeBuilder.nmSubmitHandler(button.dataset.modalId);
});
});
2022-07-13 12:06:22 +00:00
// Initializing and styling the Materialize Chip components
M.Chips.init(
this.elements.queryInputField,
{
placeholder: 'Add your query here'
}
);
2023-08-08 14:00:30 +00:00
document.querySelector('#corpus-analysis-concordance-form-query-builder input').style.setProperty('width', '150px', 'important');
2023-08-08 12:33:07 +00:00
this.elements.positionalAttrModal = M.Modal.init(
2023-08-08 14:00:30 +00:00
document.querySelector('#corpus-analysis-concordance-positional-attr-modal'),
2023-07-25 12:56:07 +00:00
{
onOpenStart: () => {
this.tokenAttributeBuilder.optionToggleHandler();
2023-07-25 12:56:07 +00:00
}
}
);
2022-09-07 07:06:21 +00:00
}
2022-07-13 12:06:22 +00:00
}