Skip to content

Commit 129ca39

Browse files
committed
style: rephrase aligned as context, add help
1 parent 4e15bcb commit 129ca39

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

app/scripts/components/kwic.ts

+21-17
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ type KwicController = IController & {
4141
active: boolean
4242
hitsInProgress: number
4343
hits: number
44-
aligned: boolean
44+
context: boolean
45+
onContextChange: () => void
4546
page: number
4647
pageEvent: (page: number) => void
47-
onReadingChange: () => void
4848
hitsPerPage: number
4949
prevParams: any
5050
prevUrl?: string
@@ -78,8 +78,8 @@ type KwicScope = IScope & {
7878
hpp: string
7979
hppOptions: string[]
8080
updateHpp: () => void
81-
aligned: boolean
82-
updateAligned: () => void
81+
context: boolean
82+
updateContext: () => void
8383
sort: SortMethod
8484
sortOptions: Record<SortMethod, string>
8585
updateSort: () => void
@@ -98,8 +98,12 @@ 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">
100100
<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>)
101+
<input type="checkbox" ng-model="context" ng-value="false" ng-change="updateContext()" />
102+
{{'show_context' | loc:$root.lang}}
103+
<i
104+
class="fa fa-info-circle text-gray-400 table-cell align-middle mb-0.5"
105+
uib-tooltip="{{'show_context_help' | loc:$root.lang}}"
106+
></i>
103107
</label>
104108
<div ng-show="$ctrl.showSearchOptions">
105109
<label>
@@ -256,14 +260,14 @@ angular.module("korpApp").component("kwic", {
256260
`,
257261
bindings: {
258262
aborted: "<",
259-
aligned: "<",
263+
context: "<",
260264
loading: "<",
261265
active: "<",
262266
hitsInProgress: "<",
263267
hits: "<",
268+
onContextChange: "<",
264269
page: "<",
265270
pageEvent: "<",
266-
onReadingChange: "<",
267271
hitsPerPage: "<",
268272
prevParams: "<",
269273
prevUrl: "<",
@@ -307,8 +311,8 @@ angular.module("korpApp").component("kwic", {
307311
$ctrl.$onChanges = (changeObj) => {
308312
if ("kwicInput" in changeObj && $ctrl.kwicInput != undefined) {
309313
$ctrl.kwic = massageData($ctrl.kwicInput)
310-
$ctrl.useContext = !$ctrl.aligned || $location.search()["in_order"] != null
311-
if ($ctrl.aligned) {
314+
$ctrl.useContext = $ctrl.context || $location.search()["in_order"] != null
315+
if (!$ctrl.context) {
312316
$timeout(() => {
313317
centerScrollbar()
314318
$element.find(".match").children().first().click()
@@ -323,7 +327,7 @@ angular.module("korpApp").component("kwic", {
323327
}
324328

325329
// TODO Do this when shown the first time (e.g. not if loading with stats tab active)
326-
if (settings.parallel && $ctrl.aligned) {
330+
if (settings.parallel && !$ctrl.context) {
327331
$timeout(() => alignParallelSentences())
328332
}
329333
if ($ctrl.kwic.length == 0) {
@@ -364,7 +368,7 @@ angular.module("korpApp").component("kwic", {
364368
}
365369
}
366370

367-
if ("aligned" in changeObj) $scope.aligned = !!$ctrl.aligned
371+
if ("context" in changeObj) $scope.context = !!$ctrl.context
368372
}
369373

370374
$ctrl.onKwicClick = (event) => {
@@ -398,8 +402,8 @@ angular.module("korpApp").component("kwic", {
398402
(val) => ($scope.sort = val || "")
399403
)
400404

401-
$scope.updateAligned = _.debounce(() => {
402-
if ($scope.aligned != $ctrl.aligned) $ctrl.onReadingChange()
405+
$scope.updateContext = _.debounce(() => {
406+
if ($scope.context != $ctrl.context) $ctrl.onContextChange()
403407
}, UPDATE_DELAY)
404408

405409
$scope.updateHpp = () => {
@@ -814,9 +818,9 @@ angular.module("korpApp").component("kwic", {
814818
function selectUpOrDown($neighborSentence: JQLite, $searchwords: JQLite): JQLite {
815819
const fallback = $neighborSentence.find(".word:last")
816820
const currentX = selectionManager.selected.offset()!.left + selectionManager.selected.width()! / 2
817-
return $ctrl.aligned
818-
? getWordAt(currentX, $neighborSentence)
819-
: getFirstAtCoor(currentX, $searchwords, fallback)
821+
return $ctrl.context
822+
? getFirstAtCoor(currentX, $searchwords, fallback)
823+
: getWordAt(currentX, $neighborSentence)
820824
}
821825

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

app/scripts/components/results-examples.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ 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"
45+
context="isReading"
4646
loading="$ctrl.loading"
4747
active="$ctrl.isActive"
4848
hits-in-progress="hitsInProgress"
4949
hits="hits"
5050
kwic-input="kwic"
5151
corpus-hits="corpusHits"
52+
on-context-change="toggleReading"
5253
page="page"
5354
page-event="pageChange"
54-
on-reading-change="toggleReading"
5555
hits-per-page="hitsPerPage"
5656
prev-params="proxy.prevParams"
5757
prev-url="proxy.prevUrl"

app/scripts/components/results-hits.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ angular.module("korpApp").component("resultsHits", {
4848
<kwic
4949
ng-if="!error"
5050
aborted="aborted"
51-
aligned="!isReading"
51+
context="isReading"
5252
loading="$ctrl.loading"
5353
active="$ctrl.isActive"
5454
hits-in-progress="hitsInProgress"
5555
hits="hits"
5656
kwic-input="kwic"
5757
corpus-hits="corpusHits"
58+
on-context-change="toggleReading"
5859
page="page"
5960
page-event="pageChange"
60-
on-reading-change="toggleReading"
6161
hits-per-page="hitsPerPage"
6262
prev-params="proxy.prevParams"
6363
prev-url="proxy.prevUrl"

app/translations/locale-eng.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"min": "at least",
6868
"and": "and",
6969
"or": "or",
70-
"context_kwic": "Align keywords",
70+
"show_context": "Show context",
71+
"show_context_help": "By default, search hits are listed in a keywords-in-context layout (KWIC). Enabling this option will instead show them with wrapped lines, suitable for reading. For some corpora, this also retrieves more of the context, such as a full paragraph.",
7172
"log_in": "Log in",
7273
"username": "Email",
7374
"password": "Password",

app/translations/locale-swe.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"min": "minst",
6868
"and": "och",
6969
"or": "eller",
70-
"context_kwic": "Centrera träffar",
70+
"show_context": "Visa kontext",
71+
"show_context_help": "Som standard visas sökträffar med träfforden centrerade (keyword in context, KWIC). Med detta alternativ påslaget visas de istället med radbrytningar för bättre läsbarhet. Vissa korpusar ger också mer kontext i det läget, typiskt ett helt stycke.",
7172
"log_in": "Logga in",
7273
"username": "Epostadress",
7374
"password": "Lösenord",

0 commit comments

Comments
 (0)