]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5333 Add spinners for measure filters
authorStas Vilchik <vilchiks@gmail.com>
Fri, 23 May 2014 15:47:41 +0000 (17:47 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Fri, 23 May 2014 15:47:48 +0000 (17:47 +0200)
sonar-server/src/main/js/widgets/widget.js

index 4c7f3a6a06e6c02640e57335c85eb09d3a32d68c..13e290a3af189ac84381ec5358b955090cbbfe58 100644 (file)
@@ -40,8 +40,10 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
   window.SonarWidgets.Widget.prototype.render = function(container) {
     var that = this;
 
+    this.showSpinner(container);
     d3.json(this.source(), function(error, response) {
       if (response && !error) {
+        that.hideSpinner();
         if (response.components.length > 0) {
           that.widget = new SonarWidgets[that.type()]();
           that.widget
@@ -64,6 +66,18 @@ window.SonarWidgets = window.SonarWidgets == null ? {} : window.SonarWidgets;
   };
 
 
+  window.SonarWidgets.Widget.prototype.showSpinner = function(container) {
+    this.spinner = d3.select(container).append('i').classed('spinner', true);
+  };
+
+
+  window.SonarWidgets.Widget.prototype.hideSpinner = function() {
+    if (this.spinner) {
+      this.spinner.remove();
+    }
+  };
+
+
   window.SonarWidgets.Widget.prototype.update = function(container) {
     return this.widget && this.widget.update(container);
   };