mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
65 lines
3.1 KiB
JavaScript
65 lines
3.1 KiB
JavaScript
class ConcordanceQueryBuilder {
|
|
|
|
constructor() {
|
|
|
|
this.elements = new ElementReferencesQueryBuilder();
|
|
this.generalFunctions = new GeneralFunctionsQueryBuilder(this.elements);
|
|
this.tokenAttributeBuilderFunctions = new TokenAttributeBuilderFunctionsQueryBuilder(this.elements);
|
|
this.structuralAttributeBuilderFunctions = new StructuralAttributeBuilderFunctionsQueryBuilder(this.elements);
|
|
|
|
// Event listener for structural attribute modal
|
|
document.querySelectorAll('[data-structural-attr-modal-action-button]').forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
this.structuralAttributeBuilderFunctions.actionButtonInStrucAttrModalHandler(button.dataset.structuralAttrModalActionButton);
|
|
});
|
|
});
|
|
|
|
// 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');
|
|
if (event.target.value !== 'empty-token') {
|
|
this.generalFunctions.toggleClass([event.target.value], 'hide', 'remove');
|
|
this.generalFunctions.toggleClass(['incidence-modifiers', 'or', 'and'], 'disabled', 'add');
|
|
this.tokenAttributeBuilderFunctions.resetMaterializeSelection([this.elements.englishPosSelection, this.elements.germanPosSelection, this.elements.simplePosSelection]);
|
|
}
|
|
if (event.target.value === 'word' || event.target.value === 'lemma') {
|
|
this.generalFunctions.toggleClass(['input-field-options'], 'hide', 'remove');
|
|
} else if (event.target.value === 'empty-token'){
|
|
this.tokenAttributeBuilderFunctions.addTokenToQuery();
|
|
} else {
|
|
this.generalFunctions.toggleClass(['input-field-options'], 'hide', 'add');
|
|
}
|
|
});
|
|
// Options for positional attribute selection
|
|
document.querySelectorAll('.positional-attr-options-action-button[data-options-action]').forEach(button => {
|
|
button.addEventListener('click', () => {this.tokenAttributeBuilderFunctions.actionButtonInOptionSectionHandler(button.dataset.optionsAction);});
|
|
});
|
|
document.querySelectorAll('.incidence-modifier-selection[data-incidence-modifier]').forEach(button => {
|
|
button.addEventListener('click', () => {this.tokenAttributeBuilderFunctions.incidenceModifierHandler(button);});
|
|
});
|
|
document.querySelectorAll('.n-m-submit-button').forEach(button => {
|
|
button.addEventListener('click', () => {
|
|
this.tokenAttributeBuilderFunctions.nmSubmitHandler(button.dataset.modalId);
|
|
});
|
|
});
|
|
|
|
// Initializing and styling the Materialize Chip components
|
|
M.Chips.init(
|
|
this.elements.queryInputField,
|
|
{
|
|
placeholder: 'Add your query here'
|
|
}
|
|
);
|
|
document.querySelector('#corpus-analysis-concordance-form-query-builder input').style.setProperty('width', '150px', 'important');
|
|
|
|
this.elements.positionalAttrModal = M.Modal.init(
|
|
document.querySelector('#corpus-analysis-concordance-positional-attr-modal'),
|
|
{
|
|
onOpenStart: () => {
|
|
this.tokenAttributeBuilderFunctions.optionToggleHandler();
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}
|