Sign Up! Login: Password: New User? Forgot? Support
Code 
 
 
Forums 
Forums : Layout & Theme > Hiding the Admin Edit button
Mottie (SuperAdmin) 7/8/2008 8:38 AM EST : Hiding the admin Edit button
ACK!
Mottie
Posts: 3883

0
Like

0
Dislike

Hiding the admin Edit button

GuildPortal admin site link to original post

This script will hide the annoying admin "Edit" button that appears in every content box.

If you have a paid site, add the script to your footer to cover every page on your site. If you have a free site, you'll need to add this script to a content box near the bottom of the page (just one) on every page of your site to have it work.

I added a variable set to either true or false in the script to make it easier to turn the function on and off. You can still edit any content box from the control panel:
Control Panel > Site Pages > Click the desired tab > "Edit Content" of the content box

Footer or Content Box

<script type="text/javascript">
function hideEditButtons() {
// true = hide all edit buttons
// false = show all edit buttons
var hideButtons = true;

// Don't change anything below!
// *****************************
if (!hideButtons) return;
x = document.getElementsByTagName("input");
 try {
  for (j=0; j < x.length; j++) {
   if( x[j].value == "Edit" ) {
    x[j].style.display = "none";
   }
  }
 } catch (err) {}
}
setTimeout("hideEditButtons();", 1);
</script>
Edit: Removed the need for extra CSS.
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

Mottie (SuperAdmin) 11/15/2008 2:52 AM EST : RE: Hiding the admin Edit button
ACK!
Mottie
Posts: 3883

0
Like

0
Dislike

The version above hides ALL the edit buttons, but there was a request to leave some in place like on the calendar to make updating easier. Use this updated script instead of the one above

The Code

<script type="text/javascript">
function hideEditButtons() {
// true = hide all edit buttons
// false = show all edit buttons
var hideButtons = true;
var dontHide = "monthlyCalendar";
// Don't change anything below!
// *****************************
if (!hideButtons) return;
x = document.getElementsByTagName("input");
 try {
  for (j=0; j < x.length; j++) {
   if( x[j].value == "Edit" && !(x[j].parentNode.innerHTML.match(dontHide)) ) {
    x[j].style.display = "none";
   }
  }
 } catch (err) {}
}
setTimeout("hideEditButtons();", 1);
</script>
Ifit doesn't work for the calendar, try replacing the text in red with "Prev Month"..."monthlyCalendar" is within the ID of the calendar table.

Also,this script isn't perfect, it looks for text INSIDE the content box(NOT the title of the box). If you want to show other edit buttons,just add a "|" (shift-\) between the key words. Example: On my test site calendar page, if I wanted to show the edit button in my "How to" box and the Event Calendar, I would use:
var dontHide = "monthlyCalendar|Modify";
Note: Those are key words INSIDE the content box (NOT the title).
Characters: Mottie Motty Mortie Ooshiny Mot Fudgems
TopBottom

Mottie (SuperAdmin) 11/13/2009 7:54 AM EST : RE: Hiding the admin Edit button
ACK!
Mottie
Posts: 3883

0
Like

0
Dislike


This is now a Mod
Control Panel > Site Mods > Get Site Mods >
Look for "Hide Admin Edit Buttons"


Here is an updated version of this code that uses jQuery and allows you to use the widget title instead of box IDs. Add this code to your footer HTML.

Code
<script type="text/javascript">
$(function(){
 var dontHide = "Calendar|Quotes|Guild Info|Gallery|Random Images";
  $('.adminButton,button:contains("Edit")').each(function(){
  if (!$(this).closest('.gpWidget').find('.ContentBoxTitle,.ContentBoxTitleNoBackground').text().match(dontHide)) {
   $(this).remove();
  }
 })
})
</script>
Notes
  • The dontHide variable contains the title of the widget where you don't want the edit button hidden.
  • You must separate these titles with a pipe "|" (shift-\, above the enter key).
  • These titles can contain spaces and apostrophes.
  • All words are case sensitive.
Edit (11/15/2009): Updated script to include all types of admin edit buttons (hopefully).
Edit (11/21/2009): Updated to hide the widget container.
Edit (11/21/2009): Modified the code to completely remove the edit button, to prevent the button from fading back in.
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%