blob: 978c44224bea757baeadd28f639454affe3960e2 [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
10define([
11 'panel',
Akronaa613222019-11-19 13:57:12 +010012 'view/vc/corpstatv'
hebasta2535c762018-11-21 16:27:33 +010013], function (panelClass, corpStatVClass) {
14
15 const d = document;
16
17 // Localization values
18 const loc = KorAP.Locale;
19 loc.SHOW_STAT= loc.SHOW_STAT || 'Statistics';
20 loc.VERB_SHOWSTAT = loc.VERB_SHOWSTAT || 'Corpus Statistics';
21
22 return {
23 create : function (vc) {
24 return Object.create(panelClass)._init(['vcinfo']).upgradeTo(this)._init(vc);
25 },
26
27 _init : function(vc){
28 this.vc = vc;
29 var actions = this.actions;
30 var that = this;
Akron792b1a42020-09-14 18:56:38 +020031 actions.add(loc.SHOW_STAT, {'cls':['statistic']}, function() {
hebasta2535c762018-11-21 16:27:33 +010032 that.addCorpStat();
33 });
34
35 return this;
36 },
37
38
39 /**
40 * Add corpus statistic view to panel
41 */
42 addCorpStat: function(){
hebasta8cab44b2019-12-16 13:50:32 +010043
44 //Refreshes corpus statistic
45 if(this.statView !== undefined && this.statView.shown()){
46 let statt = this.statView.show();
47 if (statt.classList.contains('stdisabled')){
48 this.reloadCorpStat();
49 statt.classList.remove('stdisabled');
50 }
51 }
52
53 //Add corpus statistic
hebasta2535c762018-11-21 16:27:33 +010054 if (this.statView === undefined || !this.statView.shown()) {
55 this.statView = corpStatVClass.create(this.vc, this);
56 this.add(this.statView);
hebastaa0282be2018-12-05 16:58:00 +010057 this.vc.oldvcQuery = KorAP.vc.toQuery();
hebasta2535c762018-11-21 16:27:33 +010058 }
hebasta8cab44b2019-12-16 13:50:32 +010059
hebasta2535c762018-11-21 16:27:33 +010060 },
61
hebastaa0282be2018-12-05 16:58:00 +010062 /**
63 * Reload corpus statistic
64 *
65 */
66 reloadCorpStat: function(){
67 this.statView.close();
68 this.addCorpStat();
69 }
hebasta2535c762018-11-21 16:27:33 +010070
71 }
72});