Skip to content

Commit 4e15bcb

Browse files
committed
style: align/reading as checkbox
1 parent 258d7d0 commit 4e15bcb

File tree

5 files changed

+21
-32
lines changed

5 files changed

+21
-32
lines changed

app/scripts/components/kwic.ts

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type KwicController = IController & {
4141
active: boolean
4242
hitsInProgress: number
4343
hits: number
44-
isReading: boolean
44+
aligned: boolean
4545
page: number
4646
pageEvent: (page: number) => void
4747
onReadingChange: () => void
@@ -78,8 +78,8 @@ type KwicScope = IScope & {
7878
hpp: string
7979
hppOptions: string[]
8080
updateHpp: () => void
81-
isReading: boolean
82-
updateReading: () => void
81+
aligned: boolean
82+
updateAligned: () => void
8383
sort: SortMethod
8484
sortOptions: Record<SortMethod, string>
8585
updateSort: () => void
@@ -97,17 +97,10 @@ const UPDATE_DELAY = 500
9797
angular.module("korpApp").component("kwic", {
9898
template: html`
9999
<div class="flex flex-wrap items-baseline mb-4 gap-4 bg-gray-100 p-2">
100-
<div class="flex flex-wrap gap-2">
101-
{{ "context" | loc:$root.lang }}:
102-
<label>
103-
<input type="radio" ng-model="isReading" ng-value="false" ng-change="updateReading()" />
104-
{{'context_kwic' | loc:$root.lang}}
105-
</label>
106-
<label>
107-
<input type="radio" ng-model="isReading" ng-value="true" ng-change="updateReading()" />
108-
{{'context_reading' | loc:$root.lang}}
109-
</label>
110-
</div>
100+
<label>
101+
<input type="checkbox" ng-model="aligned" ng-value="false" ng-change="updateAligned()" />
102+
{{'context_kwic' | loc:$root.lang}} (<abbr title="keyword in context">KWIC</abbr>)
103+
</label>
111104
<div ng-show="$ctrl.showSearchOptions">
112105
<label>
113106
{{ "hits_per_page" | loc:$root.lang }}:
@@ -263,11 +256,11 @@ angular.module("korpApp").component("kwic", {
263256
`,
264257
bindings: {
265258
aborted: "<",
259+
aligned: "<",
266260
loading: "<",
267261
active: "<",
268262
hitsInProgress: "<",
269263
hits: "<",
270-
isReading: "<",
271264
page: "<",
272265
pageEvent: "<",
273266
onReadingChange: "<",
@@ -314,8 +307,8 @@ angular.module("korpApp").component("kwic", {
314307
$ctrl.$onChanges = (changeObj) => {
315308
if ("kwicInput" in changeObj && $ctrl.kwicInput != undefined) {
316309
$ctrl.kwic = massageData($ctrl.kwicInput)
317-
$ctrl.useContext = $ctrl.isReading || $location.search()["in_order"] != null
318-
if (!$ctrl.isReading) {
310+
$ctrl.useContext = !$ctrl.aligned || $location.search()["in_order"] != null
311+
if ($ctrl.aligned) {
319312
$timeout(() => {
320313
centerScrollbar()
321314
$element.find(".match").children().first().click()
@@ -330,7 +323,7 @@ angular.module("korpApp").component("kwic", {
330323
}
331324

332325
// TODO Do this when shown the first time (e.g. not if loading with stats tab active)
333-
if (settings.parallel && !$ctrl.isReading) {
326+
if (settings.parallel && $ctrl.aligned) {
334327
$timeout(() => alignParallelSentences())
335328
}
336329
if ($ctrl.kwic.length == 0) {
@@ -371,7 +364,7 @@ angular.module("korpApp").component("kwic", {
371364
}
372365
}
373366

374-
if ("isReading" in changeObj) $scope.isReading = !!$ctrl.isReading
367+
if ("aligned" in changeObj) $scope.aligned = !!$ctrl.aligned
375368
}
376369

377370
$ctrl.onKwicClick = (event) => {
@@ -405,8 +398,8 @@ angular.module("korpApp").component("kwic", {
405398
(val) => ($scope.sort = val || "")
406399
)
407400

408-
$scope.updateReading = _.debounce(() => {
409-
if ($scope.isReading != $ctrl.isReading) $ctrl.onReadingChange()
401+
$scope.updateAligned = _.debounce(() => {
402+
if ($scope.aligned != $ctrl.aligned) $ctrl.onReadingChange()
410403
}, UPDATE_DELAY)
411404

412405
$scope.updateHpp = () => {
@@ -821,9 +814,9 @@ angular.module("korpApp").component("kwic", {
821814
function selectUpOrDown($neighborSentence: JQLite, $searchwords: JQLite): JQLite {
822815
const fallback = $neighborSentence.find(".word:last")
823816
const currentX = selectionManager.selected.offset()!.left + selectionManager.selected.width()! / 2
824-
return $ctrl.isReading
825-
? getFirstAtCoor(currentX, $searchwords, fallback)
826-
: getWordAt(currentX, $neighborSentence)
817+
return $ctrl.aligned
818+
? getWordAt(currentX, $neighborSentence)
819+
: getFirstAtCoor(currentX, $searchwords, fallback)
827820
}
828821

829822
function getFirstAtCoor(x: number, words: JQLite, fallback: JQLite) {

app/scripts/components/results-examples.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ angular.module("korpApp").component("resultsExamples", {
4242
<div class="results-kwic" ng-if="!error" ng-class="{reading_mode: isReading, loading: $ctrl.loading}">
4343
<kwic
4444
aborted="aborted"
45+
aligned="!isReading"
4546
loading="$ctrl.loading"
4647
active="$ctrl.isActive"
4748
hits-in-progress="hitsInProgress"
4849
hits="hits"
4950
kwic-input="kwic"
5051
corpus-hits="corpusHits"
51-
is-reading="isReading"
5252
page="page"
5353
page-event="pageChange"
5454
on-reading-change="toggleReading"

app/scripts/components/results-hits.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ angular.module("korpApp").component("resultsHits", {
4848
<kwic
4949
ng-if="!error"
5050
aborted="aborted"
51+
aligned="!isReading"
5152
loading="$ctrl.loading"
5253
active="$ctrl.isActive"
5354
hits-in-progress="hitsInProgress"
5455
hits="hits"
5556
kwic-input="kwic"
5657
corpus-hits="corpusHits"
57-
is-reading="isReading"
5858
page="page"
5959
page-event="pageChange"
6060
on-reading-change="toggleReading"

app/translations/locale-eng.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@
6767
"min": "at least",
6868
"and": "and",
6969
"or": "or",
70-
"context": "Context",
71-
"context_reading": "reading",
72-
"context_kwic": "aligned",
70+
"context_kwic": "Align keywords",
7371
"log_in": "Log in",
7472
"username": "Email",
7573
"password": "Password",

app/translations/locale-swe.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@
6767
"min": "minst",
6868
"and": "och",
6969
"or": "eller",
70-
"context": "Kontext",
71-
"context_reading": "läsvänlig",
72-
"context_kwic": "centrerad",
70+
"context_kwic": "Centrera träffar",
7371
"log_in": "Logga in",
7472
"username": "Epostadress",
7573
"password": "Lösenord",

0 commit comments

Comments
 (0)