Pure Creativity > The Coders' Quarter :: The Arsenal :: > Buttons to Text

Buttons to Text - Posted By webmaren (webmaren) on 2nd May 10 at 3:17pm
This code will convert all of the default virtualForums buttons into text links.

Global Footers:
Code:
 
  1. <script type="text/javascript">
  2. // Buttons to Text - virtualForums; Public Code 02 (c)2010 Webmaren
  3. window.onload=function(){var wm_pc02_i=document.getElementsByTagName('img');for(a in wm_pc02_i){if(wm_pc02_i[a].src.match(/virtualforums/)&&wm_pc02_i[a].width>35&&wm_pc02_i[a].parentNode.childNodes.length==1&&!wm_pc02_i[a].src.match(/uploads/)){var wm_pc02_s=document.createElement('span');wm_pc02_s.className='vf-btn';wm_pc02_s.appendChild(document.createTextNode(wm_pc02_i[a].alt.toUpperCase()));wm_pc02_i[a].parentNode.appendChild(wm_pc02_s);wm_pc02_i[a].parentNode.style.textDecoration='none';wm_pc02_i[a].style.display='none';}}}
  4. </script>
 


CSS:
Code:
 
  1. .vf-btn { margin: 2px; font: bold 7px; text-decoration: none; }
 


This code may be used in any virtualForums forum free of charge. It is being made available under the terms of the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License


Unminified Code:
Code:
 
  1. <script type="text/javascript">
  2. // Buttons to Text - virtualForums
  3. // Public Code 02 (c)2010 Webmaren
  4. window.onload = function() {
  5. var pcImg = document.getElementsByTagName('img');
  6. for (a in pcImg) {
  7.     if (pcImg[a].src.match(/virtualforums/) && pcImg[a].width > 35 && pcImg[a].parentNode.childNodes.length == 1 && !pcImg[a].src.match(/uploads/)) {
  8.         var text = pcImg[a].alt.toUpperCase();
  9.         var span = document.createElement('span');
  10.         span.className = 'pc-button';
  11.         span.appendChild(document.createTextNode(text));
  12.         pcImg[a].parentNode.appendChild(span);
  13.         pcImg[a].parentNode.style.textDecoration = 'none';
  14.         pcImg[a].style.display = 'none';
  15.     }
  16. }
  17. }
  18. </script>
 

Re: Buttons to Text - Posted By Michael (wrighty) on 2nd May 10 at 5:10pm
I'm sure there is an admin option to do this... {Tongue Out}

Re: Buttons to Text - Posted By webmaren (webmaren) on 2nd May 10 at 5:29pm
So it appears there is. This brings me to a point: the admin interface for vF, while overflowing with useful features, is not very easy to manipulate.



For example, there is no way to style the text mode buttons because they have no classes.

Re: Buttons to Text - Posted By Michael (wrighty) on 3rd May 10 at 3:38am
.title1 a

Is what I'd use a selector, would probably be good enough. {Smile}

Re: Buttons to Text - Posted By xcessive (xcessive) on 3rd May 10 at 7:22am
Arnt you a coder for vF Michael?

Re: Buttons to Text - Posted By webmaren (webmaren) on 3rd May 10 at 10:41am
 
.title1 a

Is what I'd use a selector, would probably be good enough. {Smile}


And "quote", "modify", et al. in the post? I wouldn't be getting them all in one go.


EDIT: Okay, it's doable, but requires more complex CSS rules.

Re: Buttons to Text - Posted By ElseAndrew (elseandrew) on 3rd May 10 at 1:07pm
 
Arnt you a coder for vF Michael?


I think he's a member of the support team. But also helps out with coding.

Re: Buttons to Text - Posted By Michael (wrighty) on 5th May 10 at 3:46pm
I am indeed a vF coder, and a vF coding moderator. I'll drop Ross this as a suggestion to give all of the text equivalents a unique class "button", and I'm sure he can get it out for us.

{Smile}

Re: Buttons to Text - Posted By webmaren (webmaren) on 5th May 10 at 8:39pm
Thanks Michael.

Re: Buttons to Text - Posted By Michael (wrighty) on 6th May 10 at 12:01am
For many, Ross has suggested that you look at the template (Manage Templates), and change them in there, as ultimately it's the same.

Some are unable to be templated, and he will look at those. {Smile}