Added EventListener for graying corpus statistic(plus renaming)

Change-Id: I41da48f92a9f5abccb6a64a9a4f2c1192e713327
(cherry picked from commit b990f6ad18afb79e10e4c88b505e4429aeaa07e2)
diff --git a/dev/js/spec/statSpec.js b/dev/js/spec/statSpec.js
index f0e4b8b..864a8ca 100644
--- a/dev/js/spec/statSpec.js
+++ b/dev/js/spec/statSpec.js
@@ -130,7 +130,7 @@
   checkStatActive = function(view, div){   
     // corpus statistic exists, it is active and reloadStatButton is shown
     if ((view.firstChild.classList.contains("stattable") === true) 
-      && (view.firstChild.classList.contains("greyOut") === false)
+      && (view.firstChild.classList.contains("stdisabled") === false)
       && (div.getElementsByClassName("reloadStatB").length == 0) ) { 
       return true;
     } 
@@ -143,7 +143,7 @@
    */
   checkStatDisabled = function(view, div){
     if ((view.firstChild.classList.contains("stattable") === true) 
-        && (view.firstChild.classList.contains("greyOut") === true)
+        && (view.firstChild.classList.contains("stdisabled") === true)
         && (div.getElementsByClassName("reloadStatB").length === 1) ) {
       return true;
     }   
@@ -318,7 +318,11 @@
      * in vc builder through user-interaction
      */
 	describe ('KorAP.CorpusStat.Disable', function(){
-	
+	  
+	  document.addEventListener('vcChange', function (e) {
+        KorAP.vc.checkStatActive(e.detail);
+        }, false);
+	    
 	  /**
 	   * If the user defines a new vc, the statistic should be disabled,
 	   * because it is out-of-date.
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 34a838a..d94b1b5 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -90,6 +90,10 @@
     var input = d.getElementById('collection');
 
     var vc = KorAP.vc;
+    
+    document.addEventListener('vcChange', function (e) {
+      vc.checkStatActive(e.detail);
+      }, false);
 
     // Add vc name object
     if (input) {
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index af09132..4bc5e13 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -367,7 +367,9 @@
      */    
     update : function() {
       this._root.update();
-      this.checkGrayingStat();
+      var vcchevent = new CustomEvent('vcChange', {'detail':this});
+      document.dispatchEvent(vcchevent);
+      
       return this;
     },
     /**
@@ -485,12 +487,12 @@
     },
     
     /**
-     * Checks if corpus statistic has to be greyOut,
+     * Checks if corpus statistic has to be disabled,
      * and to be updated after clicking at the "reload-button"
      */
-    checkGrayingStat : function(){
+    checkStatActive : function(){
       if(this.panel !== undefined && this.panel.statView !==undefined){
-        this.panel.statView.checkGrayingStatistic();
+        this.panel.statView.checkStatActive();
       }
     }
   };
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index 2a0e872..132c4a8 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -150,7 +150,10 @@
       };
       
       if(KorAP.vc){
-        KorAP.vc.checkGrayingStat();
+      //Replaced through Event
+      //KorAP.vc.checkGrayingStat(this); 
+      var vcchevent = new CustomEvent('vcChange', {'detail':this});
+      document.dispatchEvent(vcchevent);
       }
       
       return e;
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
index fa82a4b..3b7bd6d 100644
--- a/dev/js/src/vc/docgroupref.js
+++ b/dev/js/src/vc/docgroupref.js
@@ -109,7 +109,10 @@
         // Append new operators
         e.appendChild(op.element());
       };  
-      KorAP.vc.checkGrayingStat();
+
+      var vcchevent = new CustomEvent('vcChange', {'detail':this});
+      document.dispatchEvent(vcchevent);
+      
       return this.element();
     },
 
diff --git a/dev/js/src/view/corpstatv.js b/dev/js/src/view/corpstatv.js
index 8e7b965..a566287 100644
--- a/dev/js/src/view/corpstatv.js
+++ b/dev/js/src/view/corpstatv.js
@@ -105,9 +105,9 @@
 
     
     /**
-     * Checks if graying necessary
+     * Checks if statistic has to be disabled
      */
-    checkGrayingStatistic : function (){
+    checkStatActive : function (){
      var newString = KorAP.vc.toQuery();
      var oldString = this.vc.oldvcQuery;
      /*
@@ -123,17 +123,17 @@
          newString = newString.slice(1, newString.length-1);
        }
        if(newString != oldString) {
-        this.grayingStat();
+        this.disableStat();
       }  
      }
      
    },
    
     /**
-     * Graying corpus statistic if in vc builder a different vc is choosen.
+     * Disabling corpus statistic if in vc builder a different vc is choosen.
      * After clicking at the reload-button the up-to-date corpus statistic is displayed.
      */   
-    grayingStat : function(){
+    disableStat : function(){
       var statt = this._show;
       
       if(statt.getElementsByClassName('reloadStatB').length == 0){
@@ -145,15 +145,15 @@
           var that = this;
           
           reloadb.addEventListener("click", function (e){    
-          statt.classList.remove('greyOut');
-          that.panel.actions.element().querySelector(".statistic").classList.remove('greyOut');
+          statt.classList.remove('stdisabled');
+          that.panel.actions.element().querySelector(".statistic").classList.remove('stdisabled');
           that.panel.reloadCorpStat(); 
              });
           
  
         statt.appendChild(reloadspan);
-        statt.classList.add('greyOut');        
-        this.panel.actions.element().querySelector(".statistic").classList.add('greyOut');
+        statt.classList.add('stdisabled');        
+        this.panel.actions.element().querySelector(".statistic").classList.add('stdisabled');
         
         console.log("Corpus statistic DISABLED");
         }