Help - Search - Members - Calendar
Full Version: Expand/Collapse Extended Entry Text Inline
Movable Type Community Forum > Additional Resources > Tips and Tricks
TweezerMan
Building on the script and code posted by ScriptyGoddess, I've made some improvements to the code for expanding/collapsing extended entry text inline:

1. Corrected invalid HTML/XHTML in template code.
2. Corrected a design bug that caused the "read more" link to change from an inline element to a block-level element when "read more" then "hide more" is clicked.
3. Mouse wheel will now scroll page after clicking "read more" link without having to click in page first. (Mozilla Firebird known to be affected by this.)
4. Browser jumps back to "read more" link rather than beginning of post when "hide more" link is clicked.
5. Used meaningful variable and div id names.
6. Applied line formatting to script and code to make it easier to read.

The new javascript and template code, along with documentation of the above changes and the reasons they were made, can be seen on my weblog.
maddy
When I click the Read More... link in Opera 7.23, the entry opens, but the page jumps to a background tab, rather than staying active. huh.gif
TweezerMan
Hmm...looks like I should have done more testing. huh.gif

I have Mozilla Firebird and Internet Explorer here to test on. I use Firebird as my primary browser, and it was with Firebird that I had the problem with the mouse wheel not scrolling the page after clicking the "read more" link. The mouse wheel worked fine with Internet Explorer.

I just retested the code I posted under both browsers. Firebird works as I expected it to, but when I click the "read more" link in IE, the extended text displays but my Firebird browser comes into the foreground. No page tries to load in the Firebird browser window.

Donna, if you remove the "this.blur();" line from the javascript code, does that make things work correctly in your Opera browser? Removing it made the mouse wheel not work again for me in Firebird, but it did fix Internet Explorer's odd behavior.
maddy
You mean me? I didn't install it, I was just testing on your page. smile.gif I don't use the script anymore, I like to make people go to the individual entry page. wink.gif

But I'd be happy to test it for you, if you want to put up a test page. smile.gif
TweezerMan
I've removed the "this.blur ();" line on my weblog's home page - feel free to test it again.
maddy
Yes, that works fine now. smile.gif I tested in Opera 7.23, Mozilla 1.4, Netscape 7.01 and IE6. smile.gif
TweezerMan
I've put in a little better script code so that the mouse wheel scrolling is still fixed in Mozilla Firebird but doesn't do odd things in other browsers. My blog post has been updated with the new code as well. I have a feeling that you actually tested the new code with some or most of the browsers you listed, which would be a good thing. smile.gif
spyke
Tweezerman this script is just DELICIOUS - thanks!! smile.gif

I was wondering if there was a way the script could be modified so that only ONE expanded link at a time (aka. the other expanded links would close when I click to expand another...)

Ok, I'm not fantastic at explaining myself - a guy using a tool called simply "blog" (not MT) did this on his site, you can see what i mean there: http://www.bloghole.net/index.php?crap=arc...rc20031026.html

click one "expand" link and it opens - click another "expand link further down and the first one closes and the second one opens........

So you know how this could be done?
TweezerMan
In a word, no. The code used on the blog you linked to is significantly more complex. In the process of "modifying" my code to make it do what the other code does, most if not all of my code would end up being tossed out. The scripts just don't have that much in common.

The author of that blog has a post ("Expandable / collapsible text") explaining how he created his expanding / collapsing links. He modified code provided by Dynamic Drive ("Switch Content Script"). If you prefer to use a script with that kind of functionality, I would suggest looking at both of those llinks.
spyke
Thanks for your quick reply -

RIght now I've got your script set up on my site, it's working fine and I'm happy with it

If I have to switch to the other guy's script in order to get the extra functionality, I'm gonna say "pass" - I would have NO idea how to impliment it smile.gif

So your script it is - thanks!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.