blob: 08f51d385e3e1e39742e1fc1fb7866e8f63bdb1e [file] [log] [blame]
Akron2d0d96d2019-11-18 19:49:50 +01001/**
2 * The query panel
3 *
4 * @author Nils Diewald
5 */
Akron14f3ee92020-10-19 11:59:40 +02006"use strict";
7
Akron2d0d96d2019-11-18 19:49:50 +01008define([
Akrondac5f132024-12-11 14:33:23 +01009 'panel',
10 'state'
11], function (panelClass, stateClass) {
Akron2d0d96d2019-11-18 19:49:50 +010012
13 const d = document;
14
15 // Localization values
16 const loc = KorAP.Locale;
17
18 return {
Akron386f1222022-12-21 16:26:11 +010019 type : 'query',
20
Akron2d0d96d2019-11-18 19:49:50 +010021 create : function (opened) {
22 return Object.create(panelClass)._init(['query']).upgradeTo(this)._init(opened);
23 },
24
25 // Initialize panel
26 _init : function (opened) {
27 this._opened = opened;
Akron37ea1192021-07-28 10:40:14 +020028 const a = this.actions();
Akrondac5f132024-12-11 14:33:23 +010029
Akron13dd5c52026-03-05 17:54:12 +010030
31 // If plugins are enabled, add all buttons for the query panel
32 if (KorAP.Plugin) {
33
34 // Add all matchbuttons in order
35 KorAP.Plugin
36 .buttonGroup("query")
37 .forEach(i => a.add.apply(a, i));
38
39 KorAP.Plugin.clearButtonGroup("query")
40 };
41
42 let colabel = document.getElementById("glimpse");
43
44 if (colabel == undefined) {
45 return this;
46 }
47
48 colabel = colabel.parentNode;
49
50 if (colabel == undefined) {
51 return this;
52 };
53
Akrondac5f132024-12-11 14:33:23 +010054 // Add glimpse button
55 const s = stateClass.create([true,false]);
56 const cof = document.getElementById("q-cutoff-field");
Akron13dd5c52026-03-05 17:54:12 +010057
Akrondac5f132024-12-11 14:33:23 +010058 let glimpseChange = {
59 setState : function (val) {
60 cof.checked = val;
61 }
62 };
63 s.associate(glimpseChange);
64 s.set(cof.checked);
65
66 a.addToggle(
67 "Glimpse", {
68 'cls':['glimpse'],
69 'desc':colabel.getAttribute('title')
70 },
71 s
72 );
Akron13dd5c52026-03-05 17:54:12 +010073
Akrondac5f132024-12-11 14:33:23 +010074 // Don't show default glimpse
75 colabel.style.display = "none";
Akron13dd5c52026-03-05 17:54:12 +010076
Akron2d0d96d2019-11-18 19:49:50 +010077 return this;
78 }
79 }
80});