Advanced Search

Results 1 to 2 of 2

Thread: Switch Content Expand Single Group

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

    Default Switch Content Expand Single Group

    1) Script Title: Switch Content Script II (icon based)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...chcontent2.htm

    3) Describe problem: I see there is a 'instance.sweepToggle('contract/expand')' function to expand all contents within a switch group but I only wish to expand on a certain section within the switch group. How do I do this? I can do the basics in javascript but that is about it.

    Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    9,864
    Thanks
    3
    Thanked 960 Times in 949 Posts
    Blog Entries
    15

    Default

    It really depends on the details as far as which contents you wish to exclude from contracting/ expanding within the group when calling sweepToggle(). The pertaining function inside switchcontent.js FYI is:

    Code:
    switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")
    	if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page
    		for (var i=0; i<this.headers.length; i++){
    			if (setting=="expand")
    				this.expandcontent(this.headers[i]) //expand each content
    			else if (setting=="contract")
    				this.contractcontent(this.headers[i]) //contract each content
    		}
    	}
    }
    Lets say you're able to label the target icons manually using a "title" attribute like so:

    Code:
    What is JavaScript? <span id="faq1-title" class="iconspan"><img src="minus.gif" /></span>
    <div id="faq1" class="icongroup1" title="exclude">
    JavaScript is a scripting language originally developed by Netscape to add interactivity and power to web documents.
    </div>
    
    What is DHTML? <span id="faq2-title" class="iconspan" title="exclude"><img src="minus.gif" /></span>
    <div id="faq2" class="icongroup1">
    DHTML is the embodiment of a combination of technologies
    </div>
    Then you can modify the pertaining function above to ignore those icons' contents by doing:

    Code:
    switchcontent.prototype.sweepToggle=function(setting){ //PUBLIC: Expand/ contract all contents method. (Values: "contract"|"expand")
    	if (typeof this.headers!="undefined" && this.headers.length>0){ //if there are switch contents defined on the page
    		for (var i=0; i<this.headers.length; i++){
    			if (setting=="expand" && this.headers[i].title!="exclude")
    				this.expandcontent(this.headers[i]) //expand each content
    			else if (setting=="contract" && this.headers[i].title!="exclude")
    				this.contractcontent(this.headers[i]) //contract each content
    		}
    	}
    }
    DD Admin

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
  •