Skip to main content

My suggestion:

$('.footnote[id^="ret_"]')
   .removeAttr('title')
   .removeAttr('alt')
   .mouseenter(function(e) {
      var footnote = $('#footnote_cont_' + this.id.substring(4)).html();  
      $footnoteTooltip.stop(true, false);

      //only completely hide and change text/position if we are hovering over a different footnote
      if($footnoteTooltip.html() != footnote)
         $footnoteTooltip.hide().html(footnote).css({ left: e.pageX + 10, top: e.pageY + 15});
 
      $footnoteTooltip.fadeTo(fadeTime, opacity);
   }).mouseleave(function() {
      $footnoteTooltip.delay(fadeTime).fadeOut(fadeTime);
   });
  • Three or four spaces indetationindentation - your preference. My opinion is that 2two spaces is more difficult to read (although Lisp uses it...).
  • Semicolon on same line as last method call. The only time I approve of having it on it's own line is an empty while.
  • }).mouseLeave() I put the call on the same line as the end of the block to make it clear that you're calling the method of the object returned.

My suggestion:

$('.footnote[id^="ret_"]')
   .removeAttr('title')
   .removeAttr('alt')
   .mouseenter(function(e) {
      var footnote = $('#footnote_cont_' + this.id.substring(4)).html();  
      $footnoteTooltip.stop(true, false);

      //only completely hide and change text/position if we are hovering over a different footnote
      if($footnoteTooltip.html() != footnote)
         $footnoteTooltip.hide().html(footnote).css({ left: e.pageX + 10, top: e.pageY + 15});
 
      $footnoteTooltip.fadeTo(fadeTime, opacity);
   }).mouseleave(function() {
      $footnoteTooltip.delay(fadeTime).fadeOut(fadeTime);
   });
  • Three or four spaces indetation - your preference. My opinion is that 2 spaces is more difficult to read (although Lisp uses it...).
  • Semicolon on same line as last method call. The only time I approve of having it on it's own line is an empty while.
  • }).mouseLeave() I put the call on the same line as the end of the block to make it clear that you're calling the method of the object returned.

My suggestion:

$('.footnote[id^="ret_"]')
   .removeAttr('title')
   .removeAttr('alt')
   .mouseenter(function(e) {
      var footnote = $('#footnote_cont_' + this.id.substring(4)).html();  
      $footnoteTooltip.stop(true, false);

      //only completely hide and change text/position if we are hovering over a different footnote
      if($footnoteTooltip.html() != footnote)
         $footnoteTooltip.hide().html(footnote).css({ left: e.pageX + 10, top: e.pageY + 15});
 
      $footnoteTooltip.fadeTo(fadeTime, opacity);
   }).mouseleave(function() {
      $footnoteTooltip.delay(fadeTime).fadeOut(fadeTime);
   });
  • Three or four spaces indentation - your preference. My opinion is that two spaces is more difficult to read (although Lisp uses it).
  • Semicolon on same line as last method call. The only time I approve of having it on it's own line is an empty while.
  • }).mouseLeave() I put the call on the same line as the end of the block to make it clear that you're calling the method of the object returned.
Source Link
Michael K
  • 2.9k
  • 1
  • 22
  • 24

My suggestion:

$('.footnote[id^="ret_"]')
   .removeAttr('title')
   .removeAttr('alt')
   .mouseenter(function(e) {
      var footnote = $('#footnote_cont_' + this.id.substring(4)).html();  
      $footnoteTooltip.stop(true, false);

      //only completely hide and change text/position if we are hovering over a different footnote
      if($footnoteTooltip.html() != footnote)
         $footnoteTooltip.hide().html(footnote).css({ left: e.pageX + 10, top: e.pageY + 15});
 
      $footnoteTooltip.fadeTo(fadeTime, opacity);
   }).mouseleave(function() {
      $footnoteTooltip.delay(fadeTime).fadeOut(fadeTime);
   });
  • Three or four spaces indetation - your preference. My opinion is that 2 spaces is more difficult to read (although Lisp uses it...).
  • Semicolon on same line as last method call. The only time I approve of having it on it's own line is an empty while.
  • }).mouseLeave() I put the call on the same line as the end of the block to make it clear that you're calling the method of the object returned.