blob: 4ce7a5dca56e7e4ad693972d2df04d5ff9529290 [file] [log] [blame]
hebasta2535c762018-11-21 16:27:33 +01001/**
2 * The vc info panel
3 *
4 * The vc info panel displays information about the virtual corpus,
5 * for example the corpus statistic
6 *
7 * @author Helge Stallkamp
8 */
9
Akron14f3ee92020-10-19 11:59:40 +020010"use strict";
11
hebasta2535c762018-11-21 16:27:33 +010012define([
13 'panel',
Akronaa613222019-11-19 13:57:12 +010014 'view/vc/corpstatv'
hebasta2535c762018-11-21 16:27:33 +010015], function (panelClass, corpStatVClass) {
16
17 const d = document;
18
19 // Localization values
20 const loc = KorAP.Locale;
21 loc.SHOW_STAT= loc.SHOW_STAT || 'Statistics';
22 loc.VERB_SHOWSTAT = loc.VERB_SHOWSTAT || 'Corpus Statistics';
23
24 return {
Akron386f1222022-12-21 16:26:11 +010025 type : 'vc',
26
hebasta2535c762018-11-21 16:27:33 +010027 create : function (vc) {
28 return Object.create(panelClass)._init(['vcinfo']).upgradeTo(this)._init(vc);
29 },
30
31 _init : function(vc){
32 this.vc = vc;
Akron37ea1192021-07-28 10:40:14 +020033 const actions = this.actions();
Akron792b1a42020-09-14 18:56:38 +020034 actions.add(loc.SHOW_STAT, {'cls':['statistic']}, function() {
Akron14f3ee92020-10-19 11:59:40 +020035 this.addCorpStat();
36 }.bind(this));
hebasta2535c762018-11-21 16:27:33 +010037 return this;
38 },
39
40
41 /**
42 * Add corpus statistic view to panel
43 */
44 addCorpStat: function(){
Akron14f3ee92020-10-19 11:59:40 +020045 const t = this;
46
hebasta8cab44b2019-12-16 13:50:32 +010047 //Refreshes corpus statistic
Akron14f3ee92020-10-19 11:59:40 +020048 if (t.statView !== undefined && t.statView.shown()){
49 let statt = t.statView.show();
hebasta8cab44b2019-12-16 13:50:32 +010050 if (statt.classList.contains('stdisabled')){
Akron14f3ee92020-10-19 11:59:40 +020051 t.reloadCorpStat();
hebasta8cab44b2019-12-16 13:50:32 +010052 statt.classList.remove('stdisabled');
53 }
Akron14f3ee92020-10-19 11:59:40 +020054 };
hebasta8cab44b2019-12-16 13:50:32 +010055
56 //Add corpus statistic
Akron14f3ee92020-10-19 11:59:40 +020057 if (t.statView === undefined || !t.statView.shown()) {
58 t.statView = corpStatVClass.create(t.vc,t);
59 t.add(t.statView);
60 t.vc.oldvcQuery = KorAP.vc.toQuery();
61 };
hebasta2535c762018-11-21 16:27:33 +010062 },
63
hebastaa0282be2018-12-05 16:58:00 +010064 /**
65 * Reload corpus statistic
66 *
67 */
68 reloadCorpStat: function(){
69 this.statView.close();
70 this.addCorpStat();
Akron14f3ee92020-10-19 11:59:40 +020071 }
hebasta2535c762018-11-21 16:27:33 +010072 }
73});