Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.

Commit 5c81d30

Browse files
okerekechinweotitoCopilot
andauthored
eslint: enforce no-jquery/no-global-selector
Fix JS lint issues to make the `no-jquery/no-global-selector` rule pass. Co-authored-by: Copilot <copilot@github.com>
1 parent 9824881 commit 5c81d30

2 files changed

Lines changed: 26 additions & 26 deletions

File tree

.eslintrc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
"sourceType": "module"
1313
},
1414
"rules": {
15-
"no-jquery/no-global-selector": "warn"
1615
}
1716
}

assets/app.js

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import './styles/app.css';
33
import 'select2';
44

55
const $ = require( 'jquery' );
6+
// eslint-disable-next-line no-jquery/no-global-selector
67
const $select2 = $( '#lang' );
78
let selectedLanguages = [];
9+
// eslint-disable-next-line no-jquery/no-global-selector
810
const $lineDetectionSelect = $( '#line-id' );
911
let lineModels = null;
1012

@@ -86,7 +88,7 @@ $( () => {
8688
fetchLineModelsJSON();
8789

8890
// Remove nojs class, for styling non-Javascript users.
89-
$( 'html' ).removeClass( 'nojs' );
91+
document.documentElement.classList.remove( 'nojs' );
9092

9193
// Initiate Select2, which allows dynamic entry of languages.
9294
$select2.select2( {
@@ -109,70 +111,71 @@ $( () => {
109111
} );
110112

111113
const previousDataPlaceholder = $select2.attr( 'data-placeholder' );
114+
const $form = $select2.closest( 'form' );
112115

113116
// Show engine-specific options.
114-
$( '[name=engine]' ).on( 'change', ( e ) => {
117+
$form.find( '[name=engine]' ).on( 'change', ( e ) => {
115118
const engine = e.target.value;
116119
updateSelect2Options( engine );
117-
$( '.engine-options' ).addClass( 'hidden' );
118-
$( `#${ engine }-options` ).removeClass( 'hidden' );
120+
$form.find( '.engine-options' ).addClass( 'hidden' );
121+
$form.find( `#${ engine }-options` ).removeClass( 'hidden' );
119122
if ( engine === 'tesseract' || engine === 'google' ) {
120123
$select2.prop( 'required', false );
121124
$select2.attr( 'data-placeholder', previousDataPlaceholder );
122125
$select2.data( 'select2' ).selection.placeholder.text = previousDataPlaceholder;
123-
$( '#transkribus-lang-label' ).addClass( 'hidden' );
124-
$( '#optional-lang-label' ).removeClass( 'hidden' );
126+
$form.find( '#transkribus-lang-label' ).addClass( 'hidden' );
127+
$form.find( '#optional-lang-label' ).removeClass( 'hidden' );
125128
} else {
126129
updateLineModelOptions();
127-
$( '#transkribus-help' ).removeClass( 'hidden' );
130+
$form.find( '#transkribus-help' ).removeClass( 'hidden' );
128131
$select2.prop( 'required', true );
129132
$select2.attr( 'data-placeholder', '' );
130133
$select2.data( 'select2' ).selection.placeholder.text = '';
131-
$( '#optional-lang-label' ).addClass( 'hidden' );
132-
$( '#transkribus-lang-label' ).removeClass( 'hidden' );
134+
$form.find( '#optional-lang-label' ).addClass( 'hidden' );
135+
$form.find( '#transkribus-lang-label' ).removeClass( 'hidden' );
133136
}
134137
} );
135138

136139
// modify selected engine after loading the page with preselected engine
137-
const $engineRadioFields = $( '[name=engine]:checked' );
140+
const $engineRadioFields = $form.find( '[name=engine]:checked' );
138141
if ( $engineRadioFields.val() === 'transkribus' ) {
139142
$select2.attr( 'data-placeholder', '' );
140143
} else {
141144
$select2.attr( 'data-placeholder', previousDataPlaceholder );
142145
}
143146

144147
// For the result page. Makes the 'Copy' button copy the transcription to the clipboard.
145-
const $copyButton = $( '.copy-button' );
148+
const $copyButton = $form.find( '.copy-button' );
146149
if ( $copyButton.length ) {
147150
$copyButton.on( 'click', ( e ) => {
148151
e.preventDefault();
149-
const $textarea = $( '#text' );
150-
$textarea.trigger( 'select' );
152+
document.getElementById( 'text' ).select();
151153
document.execCommand( 'copy' );
152154
$copyButton.text( $copyButton.data( 'copied-text' ) );
153155
} );
154156
}
155157

156-
const $submitBtns = $( '.submit-full, .submit-crop' );
157-
$submitBtns.closest( 'form' ).on( 'submit', () => {
158+
const $submitBtns = $form.find( '.submit-full, .submit-crop' );
159+
const $loader = $form.find( '.loader' );
160+
$form.on( 'submit', () => {
158161
$submitBtns.attr( 'disabled', true );
159-
$( '.loader' ).removeClass( 'hidden' );
162+
$loader.removeClass( 'hidden' );
160163
} );
161164
// Re-enable submit buttons on pagehide, so that they are re-enabled if returned to via browser history
162165
$( window ).on( 'pagehide', () => {
163166
$submitBtns.attr( 'disabled', false );
164-
$( '.loader' ).addClass( 'hidden' );
167+
$loader.addClass( 'hidden' );
165168
} );
166169

167-
const $ocrOutputDiv = $( '.ocr-output' );
170+
const $ocrOutputDiv = $form.find( '.ocr-output' );
168171
if ( $ocrOutputDiv.length ) {
169172
// Cropper.
170173
const img = document.getElementById( 'source-image' ),
171174
x = document.querySelector( '[name="crop[x]"]' ),
172175
y = document.querySelector( '[name="crop[y]"]' ),
173176
width = document.querySelector( '[name="crop[width]"]' ),
174177
height = document.querySelector( '[name="crop[height]"]' ),
175-
$modeButtons = $( '.drag-mode' );
178+
$modeButtons = $form.find( '.drag-mode' );
176179
const cropper = new Cropper( img, {
177180
viewMode: 2,
178181
dragMode: 'move',
@@ -183,9 +186,7 @@ $( () => {
183186
responsive: true,
184187
ready() {
185188
// Make textarea match height of image.
186-
$( '#text' ).css( {
187-
height: cropper.getContainerData().height
188-
} );
189+
document.getElementById( 'text' ).style.height = cropper.getContainerData().height + 'px';
189190
// React to changes in the crop-mode buttons.
190191
$modeButtons.on( 'click', ( event ) => {
191192
const $button = $( event.currentTarget );
@@ -206,18 +207,18 @@ $( () => {
206207
width.value = Math.round( event.detail.width );
207208
height.value = Math.round( event.detail.height );
208209
// Enable the cropping buttons. No need to disable them ever because there's no way to remove the crop box.
209-
$( '.btn.submit-crop' ).attr( 'disabled', false ).removeClass( 'disabled' );
210+
$form.find( '.btn.submit-crop' ).attr( 'disabled', false ).removeClass( 'disabled' );
210211
$modeButtons.attr( 'disabled', false );
211212
}
212213
} );
213214

214215
// When setting a new image URL, remove the preview and the crop dimensions.
215-
$( '[name=image]' ).on( 'change', () => {
216+
$form.find( '[name=image]' ).on( 'change', () => {
216217
$ocrOutputDiv.remove();
217218
} );
218219

219220
// When submitting the main 'transcribe' button, do not send crop dimensions.
220-
$( '.submit-full' ).on( 'click', () => {
221+
$form.find( '.submit-full' ).on( 'click', () => {
221222
x.value = null;
222223
y.value = null;
223224
width.value = null;

0 commit comments

Comments
 (0)