Archive for category Prototype
Scrolling to an element when outside of the viewport with prototypejs
Often times you’ll have be playing, say, videos with a list of videos down the page. If the list gets too long the video player becomes out of sight as the user scrolls down. This can be a big confuser to users: they click on a link to see a video and they don’t see anything happen because the video player is out of sight. Here’s what you can do: scroll to the video player if it is out of sight like so:
if ($("videoplayer").viewportOffset()[1] < 0) {
Effect.ScrollTo('videoplayer', {duration: 0.2});
}
Requires both prototype and effects.js in scriptaculous.
Stylize the last element in prototype
Posted by grandecomplex in JavaScript, Prototype on June 12, 2008
Here is an example of removing the last border in a list of elements.
Event.observe(window, "load", function() {
$$(".homepageContainer .upcomingEvents").last().setStyle({
border: 0
});
}); Read the rest of this entry »
Truncating Text with JavaScript
Since Alex posted an article on truncating text with Prototype, I thought I would write an article on truncating text without the help of a JavaScript framework. Read the rest of this entry »
How to Truncate in Prototype
Posted by grandecomplex in Prototype on May 5, 2008
This is to truncate multiple items in the javascript library Prototype. If it has the class=”truncate” it will be truncated! Read the rest of this entry »

Activity
Geir Freysson
Andrew DiFiore
zeming
Arun, Neil, shashwat
Eric, Fernando Zanatta, Jörn Zaefferer