Commits

Anonymous committed 20691b5

fix bug in autoscroll

  • Participants
  • Parent commits 2bcfddc

Comments (0)

Files changed (2)

File static/js/src/friendpaste.js

     },
 
     _edit: function() {
+        this.ghostReview = document.querySelector('#ghost-reviewflag');
+        if (this.ghostReview)
+            this.ghostReview.classList.add('hidden');
+
         this.snippet.classList.add("hidden");
         this.snippet_edit.classList.remove("hidden");
+
         this.editing = true;
     },
 
 
     _cancel: function() {
         this.editing = false;
+        if (this.ghostReview) {
+            this.ghostReview.classList.remove('hidden');
+            this.ghostReview = null;
+        }
         if (this.snippet_edit && !this.snippet_edit.classList.has('hidden'))
             this.snippet_edit.classList.add("hidden");
 
 
     do_history: function(e) {
         e.preventDefault();
+        this.ghostReview = document.querySelector('#ghost-reviewflag');
+        if (this.ghostReview)
+            this.ghostReview.classList.add('hidden');
+
         this.show_history = true;
         url = "/" + snippet_id + "/revisions";
         if (typeof(revid) != "undefined") {

File static/js/src/review.js

     
     _sourceRow: function(lineNumber) {
         var rows = document.querySelector('td.lines table').rows
-        // Line numbers are a 1-based index, but the rows collection is 0-based.
+        
         --lineNumber;
 
         return base2.DOM.bind(rows[lineNumber]);
                 this.sourceRow.classList.remove('selected');
             }
             
-
             this.nb_line = nb_line;
             this.numRow = row;
             this.sourceRow = this._sourceRow(nb_line);
             T = document.body.scrollTop;
             L = document.body.scrolLeft;
         
-            if (bottom > document.body.offsetHeight - 15)
+            if (bottom > document.body.offsetHeight -15)
                 window.scrollBy(0, bottom); 
-            else if (bottom < 15)
-                window.scrollBy(0, right);
-            if (right > document.body.offsetWidth)
+            else if (bottom < 0)
+                window.scrollBy(0, -bottom);
+            if (right > document.body.offsetWidth -15)
                  window.scrollBy(right, 0);
-            else if (right < 15)
+            else if (right < 0)
                 window.scrollBy(-right, 0);
 
         }, 10);