#4519 Scroll to textarea when reply button is clicked
Merged 2 years ago by pingou. Opened 2 years ago by jlanda.
jlanda/pagure fix-comment-scrolling  into  master

file modified
+7 -3
@@ -274,9 +274,12 @@ 

      hljs.lineNumbersBlock(block);

      var cls = "highlighted-line";

      var lines = location.hash.substr(2).split('-').map(function (x) { return parseInt(x, 10) });

-     $("#_" + lines[0]).get(0).scrollIntoView();

-     for (var i = lines[lines.length - 1]; i >= lines[0]; i--) {

-       $('#_' + i).parent().parent().addClass(cls);

+     if (! isNaN(lines[0]))

+     {

+       $("#_" + lines[0]).get(0).scrollIntoView();

+       for (var i = lines[lines.length - 1]; i >= lines[0]; i--) {

+         $('#_' + i).parent().parent().addClass(cls);

+       }

      }

    })

  });
@@ -313,6 +316,7 @@ 

      window.location.hash = hash;

      return false;

    });

+ 

  </script>

  

  {% endblock %}

@@ -819,6 +819,7 @@ 

            _prev += "\n\n";

        }

        $( "#comment" ).val(_prev + _output.join("\n"));

+       $( "#comment" ).focus();

      }

    );

  };