hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 1 | /** |
| 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 | |
| 10 | define([ |
| 11 | 'panel', |
Akron | aa61322 | 2019-11-19 13:57:12 +0100 | [diff] [blame] | 12 | 'view/vc/corpstatv' |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 13 | ], 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; |
Akron | 792b1a4 | 2020-09-14 18:56:38 +0200 | [diff] [blame] | 31 | actions.add(loc.SHOW_STAT, {'cls':['statistic']}, function() { |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 32 | that.addCorpStat(); |
| 33 | }); |
| 34 | |
| 35 | return this; |
| 36 | }, |
| 37 | |
| 38 | |
| 39 | /** |
| 40 | * Add corpus statistic view to panel |
| 41 | */ |
| 42 | addCorpStat: function(){ |
hebasta | 8cab44b | 2019-12-16 13:50:32 +0100 | [diff] [blame] | 43 | |
| 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 |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 54 | if (this.statView === undefined || !this.statView.shown()) { |
| 55 | this.statView = corpStatVClass.create(this.vc, this); |
| 56 | this.add(this.statView); |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 57 | this.vc.oldvcQuery = KorAP.vc.toQuery(); |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 58 | } |
hebasta | 8cab44b | 2019-12-16 13:50:32 +0100 | [diff] [blame] | 59 | |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 60 | }, |
| 61 | |
hebasta | a0282be | 2018-12-05 16:58:00 +0100 | [diff] [blame] | 62 | /** |
| 63 | * Reload corpus statistic |
| 64 | * |
| 65 | */ |
| 66 | reloadCorpStat: function(){ |
| 67 | this.statView.close(); |
| 68 | this.addCorpStat(); |
| 69 | } |
hebasta | 2535c76 | 2018-11-21 16:27:33 +0100 | [diff] [blame] | 70 | |
| 71 | } |
| 72 | }); |