Results 1 to 3 of 3

Thread: Switch Content script - how to...

  1. #1
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Switch Content script - how to...

    I have been playing around with the switch content script: http://www.dynamicdrive.com/dynamici...tchcontent.htm and have managed to make the headers into nice css rollovers. What I need to know is if there is a way to alter the 'open' state of the header other than just change the text colour with Instance.setColor(openheaderColor, closedheaderColor).

    Basically, I want the open state to look the same as the hover state (see current css below). Is there some way that I can assign a css class to the open state?

    HTML Code:
    <style type="text/css">
    h3 {
      padding: 9px 0 9px 5px;
      font-size: 14px;
      background-image: url(images/portfolio-rollover2.gif);
      color: #0b2e71;
      cursor:pointer;
      font-weight:bold;
      margin: 5px 0;
    }
    h3:hover {
      color: #fff;
      background-image: url(images/portfolio-rollover2.gif);
      background-position: 0 -34px;
    }
    </style>
    I look forward to your suggestions.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, try the below modified switchcontent.js file. It adds a setClass() function, so you can now toggle the header's CSS class name when initializing the script:

    Code:
    var joeexample=new switchcontent("switchgroup2", "p") //Limit scanning of switch contents to just "p" elements
    joeexample.setStatus('[open] ', '[closed] ')
    joeexample.setColor('green', 'red')
    joeexample.setClass('openclass', 'closedclass')
    joeexample.collapsePrevious(false) //Allow more than 1 content to be open simultanously
    joeexample.setPersist(false)
    joeexample.defaultExpanded(0,1)
    joeexample.init()

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    babyewok (03-05-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Awesome! Thanks - that's exactly what I needed.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •