]> source.dussan.org Git - sonarqube.git/commitdiff
Fix issue when rendering Design page
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 5 Mar 2013 11:20:28 +0000 (12:20 +0100)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 5 Mar 2013 11:20:28 +0000 (12:20 +0100)
sonar-server/src/main/webapp/WEB-INF/app/views/resource/index.html.erb
sonar-server/src/main/webapp/javascripts/application.js

index 5f6c175be1d9c9deb3c45fe29f611fde438a60b8..f1ba5bc0a8c397afcc23fb02ec56afda81e6f71b 100644 (file)
@@ -1,3 +1,6 @@
+<%= render :partial => 'gwt/base', :locals => {:resource => @resource, :popup => true, :metric => (@metric ? @metric.key : nil)} -%>
+<%= render :partial => 'gwt/resource_viewers' -%>
+
 <div id="accordion-panel"/>
 
 <script type="text/javascript">
index c72312a32f26432f6da910e712fbcc7d00a29359..c687803fe4b69ec12f7c6915c58b5742bf82acda 100644 (file)
@@ -354,53 +354,55 @@ function openAccordionItem(url, elt, updateCurrentElement) {
   }
 
   // Get content from url
-  var ajaxRequest = $j.get(url,function (html) {
-    if (currentElement.length) {
-      var body = currentElement.find('.accordion-item-body');
-      if (!updateCurrentElement && !body.hasClass('accordion-item-body-medium')) {
-        body.addClass("accordion-item-body-medium");
-        elt.scrollIntoView(false);
-      }
-    } else {
-      $j("#accordion-panel").height('auto');
-    }
-
-    if (updateCurrentElement) {
-      // Fix the height in order to not change the position on the screen
-      var prevHeight = $j("#accordion-panel").height();
-      currentElement.html(html);
-      $j("#accordion-panel").height('auto');
-      var newHeight = $j("#accordion-panel").height();
-      if (prevHeight > newHeight) {
-        $j("#accordion-panel").height(prevHeight);
-      } else {
-        $j("#accordion-panel").height(newHeight);
-      }
-    } else {
-      // Add new item add the end of the panel and restore the height param
-      var nbElement = $j("."+htmlClass).size();
-      var newElement = $j('<div id="'+ htmlClass + nbElement +'" class="'+ htmlClass +'">');
-      newElement.html(html);
-
-      $j("#accordion-panel").append(newElement);
-      $j("#accordion-panel").height('auto');
-
-      // Set the focus on the top of the current item with animation
-      if (currentElement.length) {
-        $j('html, body').animate({
-          scrollTop: currentElement.offset().top}, 500
-        );
-      }
-    }
-  }).fail(function (jqXHR, textStatus) {
+  var ajaxRequest = $j.ajax({
+      url: url
+      }).fail(function (jqXHR, textStatus) {
         alert("Server error. Please contact your administrator. The status of the error is : "+ jqXHR.status);
-      }).done(function () {
+      }).done(function (html) {
+        if (currentElement.length) {
+          var body = currentElement.find('.accordion-item-body');
+          if (!updateCurrentElement && !body.hasClass('accordion-item-body-medium')) {
+            body.addClass("accordion-item-body-medium");
+            elt.scrollIntoView(false);
+          }
+        } else {
+          $j("#accordion-panel").height('auto');
+        }
+
+        if (updateCurrentElement) {
+          // Fix the height in order to not change the position on the screen
+          var prevHeight = $j("#accordion-panel").height();
+          currentElement.html(html);
+          $j("#accordion-panel").height('auto');
+          var newHeight = $j("#accordion-panel").height();
+          if (prevHeight > newHeight) {
+            $j("#accordion-panel").height(prevHeight);
+          } else {
+            $j("#accordion-panel").height(newHeight);
+          }
+        } else {
+          // Add new item add the end of the panel and restore the height param
+          var nbElement = $j("."+htmlClass).size();
+          var newElement = $j('<div id="'+ htmlClass + nbElement +'" class="'+ htmlClass +'">');
+          $j("#accordion-panel").append(newElement);
+
+          // Add html after having adding the new element in the page in order to scripts (for instance for GWT) to be well executed
+          newElement.append(html);
+          $j("#accordion-panel").height('auto');
+
+          // Set the focus on the top of the current item with animation
+          if (currentElement.length) {
+            $j('html, body').animate({
+                  scrollTop: currentElement.offset().top}, 500
+            );
+          }
+        }
         loading.remove();
       });
-
   return ajaxRequest;
 }
 
+
 function expandAccordionItem(elt) {
   var currentElement = $j(elt).closest('.accordion-item');
   currentElement.find('.accordion-item-body').removeClass("accordion-item-body-medium");