blob: d3eef46a40e97ddbaa8e4e2ef8f69ab1ad940cb0 [file] [log] [blame]
Akron5cb9b2b2018-07-24 17:01:09 +02001/**
2 * The result panel
3 *
4 * @author Nils Diewald
5 */
6define([
7 'panel',
8 'view/result/koralquery'
9], function (panelClass, kqViewClass) {
10
11 const d = document;
12
13 // Localization values
14 const loc = KorAP.Locale;
15 loc.TOGGLE_ALIGN = loc.TOGGLE_ALIGN || 'toggle alignment';
16 loc.SHOW_KQ = loc.SHOW_KQ || 'show KoralQuery';
17
18 return {
19 create : function (show) {
20 return Object.create(panelClass)._init(['result']).upgradeTo(this)._init(show);
21 },
22
23 // Initialize panel
24 _init : function (show) {
25
26 return this;
27 },
28
29
30 /**
31 * Add KoralQuery action to panel
32 */
33 addKqAction : function () {
34
35 // Open KoralQuery view
36 var kqButton = this.actions.add(loc.SHOW_KQ, ['show-kq','button-icon'], function () {
37
38 // Show only once - otherwise toggle
39 if (this._kq && this._kq.shown()) {
40 this._kq.close();
41 return;
42 };
43
44 this._kq = kqViewClass.create();
45
46 // On close, remove session info on KQ
47 this._kq.onClose = function () {
48 delete show['kq'];
49 };
50
51 show['kq'] = true;
52 this.add(this._kq);
53 });
54
55 // Show KoralQuery in case it's meant to be shown
56 if (show['kq'])
57 kqButton.click();
58 },
59
60 /**
61 * Add align action to panel
62 */
63 addAlignAction : function () {
64 /**
65 * Toggle the alignment (left <=> right)
66 */
67 this.actions.add(loc.TOGGLE_ALIGN, ['align','right','button-icon'], function (e) {
68 var ol = d.querySelector('#search > ol');
69 ol.toggleClass("align-left", "align-right");
70 this.button.toggleClass("left", "right");
71 });
72 }
73 }
74});