Commits

Andreas Schuh committed 67a3dde

Compatibility with ChiliProject. Fixed positioning of code review popup dialog.

  • Participants
  • Parent commits b30d275

Comments (0)

Files changed (2)

File app/views/code_review/_update_diff_view.html.erb

 <div class="code_review">
 
 </div>
+
 <div id="review-form-frame">
   <div id="review-form">
 
   </div>
 </div>
 
-<div id="code-review-assign-form"/>
+<div id="code-review-assign-form" />
 
 <div id="code-review-assign-link" style="text-align: right;">
   <%
   -%>
 
   <%= show_assignments assignments, @project, {:action_type => @action_type, :rev => @rev, :rev_to => @rev_to, :path => @path, :change_id => change_id, :attachment_id => attachment_id} -%>
-  
 </div>
 
 <script type="text/javascript">
   add_form_title = "<%= l(:label_add_review) %>";
   review_dialog_title = "<%= l(:code_review) %>";
-  var addReviewUrl = '<%= url_for :controller => 'code_review', :action => 'new', :id=>@project %>';
+  var addReviewUrl = '<%= url_for :controller => 'code_review', :action => 'new', :id => @project %>';
   var is_readonly = true;
-<% if authorize_for('code_review', 'new') -%>
+  <% if authorize_for('code_review', 'new') -%>
     is_readonly = false;
-<% end %>
+  <% end %>
   var is_diff = false;
-<% if @action_type == 'diff' or (@attachment and @attachment.is_diff?) -%>
+  <% if @action_type == 'diff' or (@attachment and @attachment.is_diff?) -%>
     is_diff = true;
-<% end %>
+  <% end %>
   action_type = '<%= @action_type %>';
   rev = '<%= @rev %>';
   rev_to = '<%= @rev_to %>';
   showReviewImageTag = '<%= image_tag('review.png', :plugin => 'redmine_code_review', :alt => l(:label_show_review), :title => l(:label_show_review)) %>';
   showClosedReviewImageTag = '<%= image_tag('closed_review.png', :plugin => 'redmine_code_review', :alt => l(:label_show_review), :title => l(:label_show_review)) %>';
 
-<% for review in @reviews do %>
-      setShowReviewButton(<%= review.line %>, <%= review.id %>, <%= review.is_closed?%>, <%= review.file_count %> );
+  <% for review in @reviews do %>
+    setShowReviewButton(<%= review.line %>, <%= review.id %>, <%= review.is_closed? %>, <%= review.file_count %> );
   <% end %>
 
   <% if @show_review_id -%>
-      popupReview(<%= @show_review.line %>, <%= @show_review_id %>);
+    popupReview(<%= @show_review_id %>);
   <% end -%>
 
-   var tables = $$('#content table.filecontent');
-   if (tables.length > 0) {
-     var table = tables[0];
-     new Insertion.Before(table, $('code-review-assign-link'));
-   }
-
-  </script>
+  var tables = $$('#content table.filecontent');
+  if (tables.length > 0) {
+    var table = tables[0];
+    new Insertion.Before(table, $('code-review-assign-link'));
+  }
+</script>

File assets/javascripts/code_review.js

     });
 }
 
-function popupReview(line, review_id) {
-    var target = $('show_review_' + review_id);
-    var span = $('review_' + review_id);
-
+function popupReview(review_id) {
+    var span   = $('review_'      + review_id); // span element of view review button
+    var target = $('show_review_' + review_id); // target element for popup dialog
+    // create popup dialog
     var win = showReview(showReviewUrl, review_id, target);
-  
-    win.setLocation(span.positionedOffset().top, span.positionedOffset().left + 10 + 5);
+    // position and show popup dialog
+    var pos_top  = 0;
+    var pos_left = 0;
+    var element  = span;
+    if (element.offsetParent) {
+        while (1) { // work-around for Safari
+            pos_top  = pos_top  + element.offsetTop;
+            pos_left = pos_left + element.offsetLeft;
+            if (!element.offsetParent) {
+                break;
+            }
+            element = element.offsetParent;
+        };
+    } else {
+        pos_top  = element.x;
+        pos_left = element.y;
+    }
+    win.setLocation(pos_top + 25, pos_left + 10 + 5);
     win.toFront();
     win.show();
+    // scroll to line
     span.scrollTo();
-    
 }
 
 function showReview(url, review_id, element) {