From 0882e085a35c3071bd0a1db95a3c932d99775d14 Mon Sep 17 00:00:00 2001 From: Inga Kirschnick Date: Mon, 13 Nov 2023 14:46:19 +0100 Subject: [PATCH] Function renaming --- .../query-builder/query-builder.js | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/static/js/corpus-analysis/query-builder/query-builder.js b/app/static/js/corpus-analysis/query-builder/query-builder.js index 04f4a3ac..d248cbb1 100644 --- a/app/static/js/corpus-analysis/query-builder/query-builder.js +++ b/app/static/js/corpus-analysis/query-builder/query-builder.js @@ -68,7 +68,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { }) } - submitQueryChipElement(dataType = undefined, prettyQueryText = undefined, queryText = undefined, index = null, isClosingTag = false, isEditable = false) { + submitQueryChipElement(dataType=undefined, prettyQueryText=undefined, queryText=undefined, index=null, isClosingTag=false, isEditable=false) { if (this.elements.editingModusOn) { let editedQueryChipElement = this.elements.queryChipElements[this.elements.editedQueryChipElementIndex]; editedQueryChipElement.dataset.type = dataType; @@ -81,7 +81,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { } } - queryChipFactory(dataType, prettyQueryText, queryText, index = null, isClosingTag = false, isEditable = false) { + queryChipFactory(dataType, prettyQueryText, queryText, index=null, isClosingTag=false, isEditable=false) { // Creates a new query chip element, adds Eventlisteners for selection, deletion and drag and drop and appends it to the query input field. queryText = nopaque.Utils.escape(queryText); prettyQueryText = nopaque.Utils.escape(prettyQueryText); @@ -93,7 +93,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { ` ); - this.actionListeners(queryChipElement); + this.addActionListeners(queryChipElement); queryChipElement.addEventListener('dragstart', this.handleDragStart.bind(this, queryChipElement)); queryChipElement.addEventListener('dragend', this.handleDragEnd); @@ -119,7 +119,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { this.queryPreviewBuilder(); } - actionListeners(queryChipElement) { + addActionListeners(queryChipElement) { let notQuantifiableDataTypes = ['start-sentence', 'end-sentence', 'start-entity', 'start-empty-entity', 'end-entity', 'token-incidence-modifier']; queryChipElement.addEventListener('click', (event) => { if (event.target.classList.contains('chip')) { @@ -129,8 +129,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { } }); let chipActionButtons = queryChipElement.querySelectorAll('.chip-action-button'); - // chipActionButtons.forEach(button => { - for (let button of chipActionButtons) { + chipActionButtons.forEach(button => { button.addEventListener('click', (event) => { if (event.target.dataset.chipAction === 'delete') { this.deleteChipElement(queryChipElement); @@ -140,8 +139,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { this.lockClosingChipElement(queryChipElement); } }); - } - // }); + }); } editChipElement(queryChipElement) { @@ -175,10 +173,10 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { let elementIndex = Array.from(this.elements.queryInputField.children).indexOf(attr); switch (attr.dataset.type) { case 'start-sentence': - this.deletingClosingTagHandler(elementIndex, 'end-sentence'); + this.deleteClosingTagHandler(elementIndex, 'end-sentence'); break; case 'start-entity': - this.deletingClosingTagHandler(elementIndex, 'end-entity'); + this.deleteClosingTagHandler(elementIndex, 'end-entity'); break; case 'token': let nextElement = Array.from(this.elements.queryInputField.children)[elementIndex+1]; @@ -196,7 +194,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { this.queryPreviewBuilder(); } - deletingClosingTagHandler(elementIndex, closingTagType) { + deleteClosingTagHandler(elementIndex, closingTagType) { let closingTags = this.elements.queryInputField.querySelectorAll(`[data-type="${closingTagType}"]`); for (let i = 0; i < closingTags.length; i++) { let closingTag = closingTags[i]; @@ -208,7 +206,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { } } - handleDragStart(queryChipElement, event) { + handleDragStart(queryChipElement) { // is called when a query chip is dragged. It creates a dropzone (in form of a chip) for the dragged chip and adds it to the query input field. let queryChips = this.elements.queryInputField.querySelectorAll('.query-component'); if (queryChipElement.dataset.type === 'token-incidence-modifier') { @@ -232,7 +230,7 @@ nopaque.corpus_analysis.query_builder.QueryBuilder = class QueryBuilder { }, 0); } - handleDragEnd(event) { + handleDragEnd() { document.querySelectorAll('.drop-target').forEach(target => target.remove()); }