Results 1 to 8 of 8

Thread: New Switch Content vs. Old Switch Content

  1. #1
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default New Switch Content vs. Old Switch Content

    1) Script Title: Switch Content Script

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

    3) Describe problem: Can't mimic old expandcontent() function.

    I'm using this script on my page, and updated to the new script to improve the selectability of several expand content areas. I also used it to show/hide multiple images on the page with several calls in a paragraph (actually in <span>), for example:
    Code:
    <span onClick="expandcontent(this, 'image1')" style="cursor:hand; cursor:pointer; color: rgb(102, 51, 102);"><u>1064 nm</u>.</a>
    and below it, where the image will appear this:
    Code:
    <div id="image1" class="switchcontent" style="border: 0px;" align="left" hspace="10" vspace="10"><img src="some.jpg" onClick="expandcontent(this, 'image1')" style="width: 600px; height: 450px;"></div>
    Of course, this doesn't work anymore. But if I change the function name to the new one, it still doesn't work. What am I missing? I thought it was the block of javascript that's inserted after the tag, but this doesn't seem to help. Can you give me some advice, please?

  2. #2
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Use the sweepToggle() function, in replacement for that expandcontent() function. You don't have to use the first argument either, so:
    Code:
    <span onClick="sweepToggle('image1')" style="cursor:hand; cursor:pointer; color: rgb(102, 51, 102);"><u>1064 nm</u>.</a>
    - Mike

  3. #3
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    Thanks for your reply. It gave me hope that I could get it going. It didn't work. So, looking through the code, I came to the conclusion that it hinged on the id, so I did this:
    Code:
    <span id="image1-title" onClick="sweepToggle()" style="cursor:hand; cursor:pointer; color: rgb(102, 51, 102);"><u>355 nm</u>,</span>
    The sweepToggle function argument is irrevelant; the control is all in the id. Just to clean the post up for those who want to use this on images as well, the <div> is like this:
    Code:
    <div id="image1" class="switchimage" style="border: 0px;" align="left" hspace="10" vspace="10"><img src="some.jpg" style="width: 600px; height: 450px;"></div>
    I eliminated the onClick call to close the image because it cannot work: No id without a conflict. And the setup is this:
    Code:
    var image=new switchcontent("switchimage","div") //Limit scanning of switch contents to just "div" elements
    image.setPersist(false)
    image.collapsePrevious(false) //Multiple images open at any given time
    image.init()
    collapsePrevious is set to 'false' because I have multiple images, and the other declarations are not wanted.

    Still wish I could close the image by clicking in it, but, so what.

    Thanks for your help.
    Last edited by Strangeplant; 04-11-2007 at 01:29 PM. Reason: wrong wording

  4. #4
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    I guess the title of this thread should be changed. Maybe 'Switching images with Switch Content Script'.

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

    Default

    I don't even quite understand the question, actually. You've posted bits of code that only makes things more confusing. Can you rephrase what you're trying to accomplish?

  6. #6
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    The question was how to implement this script for a one-word link to images: I used the old version of this script to expand/contract (show/hide) blocks of text and also individual images on several pages. I extensively modified one of the pages, and so updated the javascript for this tool.

    In the old implementation for images, it was a simple onClick event added to the <span> tag, and I tried a simple replacement of that function, which didn't work. It's a new function in the new code, so just outlined how you could use this for images because there is no image demo shown on the script page and no mention of using the sweepToggle() function for the image control (since no one wants the little [open] box in the middle of a sentence, where a colored key word is the clickable link). I can now click on a word link and show/hide blocks of text with images either inside (with text wrap) or outside the text area simultaneously. Very nice, almost like the old one.

    BTW, the new code is great for expanding/contracting multiple sections of galleries of images. Now I have the new script working for the images (example in above post) as well as the text, with the only new/old difference being that you cannot click on the image to hide it, that's all, and I'm not sure that you would want it anyway. I'm now experimenting with it to see if I can't do more with dynamic pages. The new script is really a super-great design, and is an education to read and understand.

    That's what I was up to, and the reason for my post was to show others how they could do it too. I suppose that it could be added as a demo to a sentence on the script page - just thought it would be of some help.

  7. #7
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    I used the old version of this script to expand/contract (show/hide) blocks of text and also individual images on several pages.
    There's your problem, you tried to implement older functions, on a new script in which the functions didn't even exist.
    - Mike

  8. #8
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    Well, it's an oversight not to work with images too. And so this thread tells how to work with them.

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
  •