blob: 6259d484d50d15ef276ed3bac1e5eddd09477dae [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 {
25 create : function (vc) {
26 return Object.create(panelClass)._init(['vcinfo']).upgradeTo(this)._init(vc);
27 },
28
29 _init : function(vc){
30 this.vc = vc;
Akron14f3ee92020-10-19 11:59:40 +020031 const actions = this.actions;
Akron792b1a42020-09-14 18:56:38 +020032 actions.add(loc.SHOW_STAT, {'cls':['statistic']}, function() {
Akron14f3ee92020-10-19 11:59:40 +020033 this.addCorpStat();
34 }.bind(this));
hebasta2535c762018-11-21 16:27:33 +010035 return this;
36 },
37
38
39 /**
40 * Add corpus statistic view to panel
41 */
42 addCorpStat: function(){
Akron14f3ee92020-10-19 11:59:40 +020043 const t = this;
44
hebasta8cab44b2019-12-16 13:50:32 +010045 //Refreshes corpus statistic
Akron14f3ee92020-10-19 11:59:40 +020046 if (t.statView !== undefined && t.statView.shown()){
47 let statt = t.statView.show();
hebasta8cab44b2019-12-16 13:50:32 +010048 if (statt.classList.contains('stdisabled')){
Akron14f3ee92020-10-19 11:59:40 +020049 t.reloadCorpStat();
hebasta8cab44b2019-12-16 13:50:32 +010050 statt.classList.remove('stdisabled');
51 }
Akron14f3ee92020-10-19 11:59:40 +020052 };
hebasta8cab44b2019-12-16 13:50:32 +010053
54 //Add corpus statistic
Akron14f3ee92020-10-19 11:59:40 +020055 if (t.statView === undefined || !t.statView.shown()) {
56 t.statView = corpStatVClass.create(t.vc,t);
57 t.add(t.statView);
58 t.vc.oldvcQuery = KorAP.vc.toQuery();
59 };
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();
Akron14f3ee92020-10-19 11:59:40 +020069 }
hebasta2535c762018-11-21 16:27:33 +010070 }
71});