Sign Up! Login: Password: New User? Forgot? Support
Code 
 
 
Forums 
Forums : Tooltips & Popups > Hiding or Popup Comment Links
Mottie (SuperAdmin) 10/6/2008 7:08 AM EST : Hiding or Popup Comment Links
ACK!
Mottie
Posts: 3883

0
Like

0
Dislike

How to Hide Comments

GuildPortal admin site link to original post

This script hides the "[ x Comments ]" see at the bottom of some content boxes. It will also hide the "Add Comment" link in the Calendar.
You can just remove the portion of the script that hides comment links you want to keep. Add the code to your header or footer area.

The Code

<script type="text/javascript">
$(document).ready(function() {
var temp;
 $("a").each(function() {
  temp = ($(this).attr("href") == null) ? " " : $(this).attr("href");

// Hide Calendar Event Comments
  if ($(this).attr("id").match("_lnkAddComment")) {
   $(this).css("display","none")
  }


// Hide Quote Comments
  if (temp.match("Comments.aspx") && temp.match("QUOTESSML")) { hideComments($(this)) }


// Hide Voting Poll Comments
  if (temp.match("Comments.aspx") && temp.match("GUILDPOLL")) { hideComments($(this)) }


// Hide Info Section Comments
 $(document).bind('reveal.facebox', function() {
  $("#facebox").find("a").each(function() {
   if ($(this).attr("target").match("_commentWindow")) { hideComments($(this)) }
  });
 });


  function hideComments (x) {
   x.css("display","none");
   x.parent().html( x.parent().html().replace("[","").replace("]","") );
  }
 });
});
</script>

Customizing

  • Removing the colorized portion of the script will keep your commenting functionality for that type of box. Remove it or comment it out (using double slashes "//" at the beginning of the line)

    • Calendar Events Comments - this portion is in teal,  it only removes the "Add Comments" link.

    • Quotes - this portion is in blue, it removes the "[ x Comments ]" from the Quotes box only.

    • Voting - this portion is in purple, it removes the "[ x Comments ]" from the Voting Polls box only.

    • Info Section - this portion is in green, it removes the "[ x Comments ]" from ALL popup boxes (facebox).


How to Open Comments in a popup window

This script changes all comment links to open a popup window instead of a new tab/window. This includes the information box window (facebox). Add the code to your header or footer area.

The Code

<script type="text/javascript">
$(document).ready(function() {
 $("a").each(function() {
  if ($(this).attr("target").match("_commentWindow")) { makePopupWindow($(this),'_commentWindow',600,300); }
 });
 $(document).bind('reveal.facebox', function() {
  $("#facebox").find("a").each(function() {
   if ($(this).attr("target").match("_commentWindow")) { makePopupWindow($(this),'_commentWindow',600,300); }
  });
 });
 function makePopupWindow (linkEl,pName,pWidth,pHeight) {
  var temp = "toolbar=0,status=0,width=" + pWidth + ",height=" + pHeight;
  linkEl.click (function(){
   var w = window.open (linkEl.attr("href"),pName,temp);
   w.focus();
   return false;
  });
 }
});
</script>

Customizing

  • There isn't a lot to change in this code.

  • If you want to adjust the pop up window size, change the width and height in the code above (in red). Default width is 600 pixels and height is 300 pixels.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

 
 
Key 
New posts No new posts
New posts ( popular ) No new posts ( popular )
New posts ( sticky ) No new posts ( sticky )
New posts ( locked ) No new posts ( locked )
 
 
Who's Online 
There are   members online.
 
 
So-and-so has logged on!
%title%
%message%