Commits

Roger Haase  committed 00ac542

fix trivial javascript and jslint issues

  • Participants
  • Parent commits 8994863

Comments (0)

Files changed (1)

File MoinMoin/static/js/common.js

         pageComments.hide();
         buttons.attr('title', _("Show comments"));
     }
+    return false;  // do not scroll to top of page
 };
 
 // Comments initialization is executed once after document ready.
         if (!document.getElementById('moin-show-comments')) {
             this.toggleComments();
         }
-        else {
-            var commentButton = $('.moin-toggle-comments-button');
-            commentButton.button('toggle');
-            {{ "commentButton.attr('title', '%s');" % _("Hide comments") }}
-        }
     }
     $('.moin-toggle-comments-button').click(this.toggleComments);
 };
             buttons.attr('title', _("Hide transclusions"));
         }
     }
+    return false;  // do not scroll to top of page
 };
 
 // Transclusion initialization is executed once after document ready.
 
 
 // OnMouseOver show the fqname of the item else only show the value/id.
-function togglefqname(){
+function togglefqname() {
     "use strict";
     var fullname, value;
     $(".moin-fqname").hover(function () {
         fullname = $(this).attr('data-fqname');
         value = $(this).html();
         $(this).html(fullname);
-    },function () {
+    }, function () {
         $(this).html(value);
     });
 }
         titles.append(li);
         // add click handler to show this form and hide all others
         aTagClone.click(function (ev) {
-            var tab = this.hash;
+            tab = this.hash;
             window.location.hash = tab;
             $('.moin-current-tab').removeClass('moin-current-tab');
             $(ev.target).addClass('moin-current-tab');
             }
         }
         // scroll element into view and then back off 100 pixels
-        // TODO: does not scroll when user setting for show comments is off; user toggles show comments on; user doubleclicks and updates comments; (elem has display:none)
         elem.scrollIntoView();
         window.scrollTo(window.pageXOffset, window.pageYOffset - 100);
         // highlight background of selected element for a second or so
 
     // called after user doubleclicks, return a line number close to doubleclick point
     function findLineNo(elem) {
-        var lineno;
+        var dataLineno;
         // first try easy way via jquery checking event node and all parent nodes
-        lineno = $(elem).closest("[" + LINENOATTR + "]");
-        if (lineno.length) { return $(lineno).attr(LINENOATTR); }
+        dataLineno = $(elem).closest("[" + LINENOATTR + "]");
+        if (dataLineno.length) { return $(dataLineno).attr(LINENOATTR); }
         // walk DOM backward looking for a lineno attr among siblings, cousins, uncles...
         while (elem.id !== TOPID) {
             if (elem.hasAttribute && elem.hasAttribute(LINENOATTR)) {
             caretPoint = textArea.selectionStart;
         } else {
             // IE7, IE8 or
-            // IE9 - user has clicked ouside of textarea and textarea focus and caret position has been lost
+            // IE9 - user has clicked ouside of textarea causing loss of textarea focus and caret position
             return 0;
         }
         // get textarea text, split at caret, return number of lines before caret
     var moin = new MoinMoin();
 
     moin.selected_link();
-    moin.initToggleComments();
     moin.initTransclusionOverlays();
     moin.QuicklinksExpander();
 
         moin.InsertName(fullname);
     });
 
-    $('.expander').click(function() {
+    $('.expander').click(function () {
         moin.toggleSubtree(this);
     });
 
     moin.enhanceUserSettings();
     moin.enhanceEdit();
+    // placing initToggleComments after enhanceEdit prevents odd autoscroll issue when editing hidden comments
+    moin.initToggleComments();
 });