Skip to content

Commit

Permalink
Prevent exclude .tag and .gloss-link from website
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitruong922 committed Sep 24, 2024
1 parent cb0afec commit 9ed80f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ext/js/app/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,13 +518,16 @@ export class Frontend {
});
this._updateTextScannerEnabled();

const touchEventExcludeSelectors = ['a', 'a *']

Check failure on line 521 in ext/js/app/frontend.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Missing semicolon
if (this._pageType !== 'web') {
const excludeSelectors = ['.scan-disable', '.scan-disable *'];
if (!scanningOptions.enableOnPopupExpressions) {
excludeSelectors.push('.source-text', '.source-text *');
}
touchEventExcludeSelectors.push('.gloss-link', '.gloss-link *', '.tag', '.tag *');
this._textScanner.excludeSelector = excludeSelectors.join(',');
}
this._textScanner.touchEventExcludeSelector = touchEventExcludeSelectors.join(',');

this._updateContentScale();

Expand Down
1 change: 1 addition & 0 deletions ext/js/display/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -1993,6 +1993,7 @@ export class Display extends EventDispatcher {
});
this._contentTextScanner.includeSelector = '.click-scannable,.click-scannable *';
this._contentTextScanner.excludeSelector = '.scan-disable,.scan-disable *';
this._contentTextScanner.touchEventExcludeSelector = 'a,.a *'

Check failure on line 1996 in ext/js/display/display.js

View workflow job for this annotation

GitHub Actions / Static Analysis

Missing semicolon
this._contentTextScanner.prepare();
this._contentTextScanner.on('clear', this._onContentTextScannerClear.bind(this));
this._contentTextScanner.on('searchSuccess', this._onContentTextScannerSearchSuccess.bind(this));
Expand Down
15 changes: 12 additions & 3 deletions ext/js/language/text-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class TextScanner extends EventDispatcher {
/** @type {?string} */
this._excludeSelector = null;
/** @type {?string} */
this._touchExcludeSelector = null;
/** @type {?string} */
this._language = null;

/** @type {?import('text-scanner').InputInfo} */
Expand Down Expand Up @@ -197,6 +199,15 @@ export class TextScanner extends EventDispatcher {
this._excludeSelector = value;
}

/** @type {?string} */
get touchEventExcludeSelector() {
return this._touchExcludeSelector;
}

set touchEventExcludeSelector(value) {
this._touchExcludeSelector = value;
}

/** @type {?string} */
get language() { return this._language; }
set language(value) { this._language = value; }
Expand Down Expand Up @@ -1657,9 +1668,7 @@ export class TextScanner extends EventDispatcher {
*/
_getExcludeSelectorForPointerType(pointerType) {
if (pointerType === 'touch') {
// Avoid trigger search with tapping on interactive elements.
const popupClickableSelector = '.gloss-link,.gloss-link *,.tag, .tag *, .inflection, a, a *';
return this._excludeSelector ? `${this._excludeSelector},${popupClickableSelector}` : popupClickableSelector;
return this._excludeSelector ? `${this._excludeSelector},${this.touchEventExcludeSelector}` : this.touchEventExcludeSelector;
}
return this._excludeSelector;
}
Expand Down

0 comments on commit 9ed80f6

Please sign in to comment.