0

On my site I supply code samples for both C# and Visual Basic in articles. By default, I want only the C# brushes to display on page load (vb samples would be set display: none;

In the past I've accomplished this by waiting for all the content to load and then hiding the VB samples:

$(document).ready(function() {
    setTimeout(function() {
        $(".vb").hide();
    }, 500);
});

But this is sketchy at best, so it occurred to me: why not just set a default style for those brushes so that they're hidden in the stylsheet?

Unfortunately, I've looked and I can't find any brush specific style rules in syntaxhighlighter that I can play around with...

Can anyone suggest a solution here because I'm very confused...

Here are two pages on my site. The .hide() works in the 1st, but not in the 2nd..

Forms Authentication in ASP.NET
Basic CRUD in LINQ To SQL

Ortund
  • 8,095
  • 18
  • 71
  • 139
  • does you tried using height and width to zero?? it also equivalent to hide().. changing the height and width as needed using script.. – sam Dec 09 '13 at 14:30
  • how would I implement it in a way that'd work better than what I'm using already? It doesn't seem as though the .hide() isn't working but rather that the timeout delay is off the mark – Ortund Dec 09 '13 at 14:36
  • I don't understand. Why doesn't a stylesheet rule (.vb { display: none; }) do the job? Also, it works on both pages in Chrome. – Remy Porter Dec 09 '13 at 16:06
  • Remy Porter, for some reason I didn't think that'd work... Write an answer and I'll give credit – Ortund Dec 09 '13 at 16:46
  • FYI `.hide()` actually just sets `display: none`. Your timeout wasn't working consistantly because either jQuery wasn't loaded or the `.vb` class hadn't yet been applied to the element. – Zach Lysobey Dec 10 '13 at 01:54

1 Answers1

1

It should work just using it as a css rule

.vb { display:none }

On a side note, if none of the article content is changing and you are only flipping the code, then it might be better UX design to make each of the code blocks a tabbed interface. Yes it will mean duplicating the buttons but it will make a lot more sense to the end user and will be more immediately available. You will notice that most coding sites will do this if they show examples for more than one language.

And another note: most users don't like it when you change the scroll bars of the window frame. Most people find it similar to marquee and blink and if you notice your scroll bar disappears when you hover/drag it which makes it extra frustrating.

David Duncan
  • 1,858
  • 17
  • 21
  • I considered making them tabbed (MSDN does it that way) but I couldn't figure out a logical way to make it work... – Ortund Dec 10 '13 at 15:39