Rafał Pitoń 10 лет назад
Родитель
Сommit
8cec4d9bbc

+ 6 - 2
misago/static/misago/js/misago-posting.js

@@ -272,7 +272,7 @@ $(function() {
                 _this.$ajax_complete.addClass('in');
 
                 var past_location = String(window.location.href);
-                window.location.href = data.post_url;
+                window.location.href = data.post_url.replace('#post', '#goto-post');
 
                 if (past_location.indexOf(window.location.href)) {
                   window.location.reload();
@@ -372,7 +372,6 @@ $(function() {
 
       var $textarea = this.$form.find('textarea');
       $textarea.val($.trim($.trim($textarea.val()) + '\n\n' + text));
-      console.log($textarea.prop("scrollHeight"));
       $textarea.scrollTop($textarea.prop("scrollHeight"));
       this.$preview.update();
 
@@ -387,4 +386,9 @@ $(function() {
       return lang_dismiss_editor;
     }
   })
+
+  // we are meddling in window.location, which means we need js to fix scrolls to fragments
+  if(window.location.hash.indexOf('#goto-post-') == 0) {
+    window.location.hash = window.location.hash.replace('#goto-post', '#post');
+  }
 });

+ 2 - 8
misago/static/misago/js/misago-scrolling.js

@@ -1,13 +1,6 @@
 // Scrolling behaviour fixes
 $(function() {
 
-  // we are meddling in window.location, which means we need js fix scrolls to fragments
-  if(window.location.hash) {
-      $(document.body).animate({
-        'scrollTop': $(window.location.hash).offset().top
-      }, 500);
-  }
-
   // scrolling enhancement for overflow: scroll elements
   function handle_scroll($element, e) {
     var scroll = $element.scrollTop();
@@ -40,8 +33,9 @@ $(function() {
   MisagoScroll = function() {
 
     this.scrollTo = function($element) {
+      var scroll_offset = $('.misago-alerts').height() + 12;
       $(document.body).animate({
-        'scrollTop': $element.offset().top
+        'scrollTop': $element.offset().top - scroll_offset
       }, 500);
     }