Search code examples
javascriptdreamweaverspry

javascsript : adding plus/minus icon to spry collapsible panel in dreamweaver


I'm working on modifying a website which has a chart of FAQs which have has a question link.
If question link is clicked, it reveals the answer in a drop down.

My goal is to swap out a plus icon image with a minus icon next to the linked text for the drop down reveal action.

the FAQs use Spry Collapsible Panel (sprycollapsiblepanel.js) to manage the show/hiding from the link. before I go about modifying the code in the javascript source code, I was wondering if there was an easier way of doing this through dreamweaver someone might be aware of.

thanks in advance.

UPDATE: the html calling the show/reveal actions are:

                        <div class="CollapsiblePanel">
                          <div id="CollapsiblePanel1" class="CollapsiblePanel">
                            <div class="CollapsiblePanelTab" tabindex="1">Fax to E-Mail</div>
                            <div class="CollapsiblePanelContent">Here is the text content as it relates to Fax to E-Mail</div>
                          </div>
                        </div>

The construct the actions for the drop down, Spry requires the following at the bottom of the page:

<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
var CollapsiblePanel3 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel3", {contentIsOpen:false});
</script>

Solution

  • In SpryCollapsiblePanel.css, amend the following style rules:

    .CollapsiblePanelTab {
        font: bold 0.7em sans-serif;
        background-color: #DDD;
        border-bottom: solid 1px #CCC;
        margin: 0px;
        padding: 2px 2px 2px 25px;
        cursor: pointer;
        -moz-user-select: none;
        -khtml-user-select: none;
    }
    

    This increases the padding on the left to make room for the image.

    Then add the images to the following rules:

    .CollapsiblePanelOpen .CollapsiblePanelTab {
        background-color: #EEE;
        background-image: url(images/plus.gif);
        background-position:left top;
        background-repeat: no-repeat;
    }
    
    .CollapsiblePanelClosed .CollapsiblePanelTab {
        background-image: url(images/minus.jpg);
        background-position:left top;
        background-repeat: no-repeat;
        /* background-color: #EFEFEF */
    }