jquery

Fancy jQuery Slide-Out Effects for Large Page Elements

Wed, Aug 25, 2010 - 9:04am -- Isaac Sukin

Sometimes, there are things in my blog posts that just don't fit nicely into the width of the content area. This is a problem with code snippets and images in particular; I only have a certain amount of horizontal space, but often that's not enough.

Inspired by a solution I witnessed in action at Lullabot.com (and the place Lullabot discovered it, Viget.com) I finally decided to solve this problem using some fancy jQuery. Now, all code blocks on this site fit correctly into the content area, with any excess text hidden until your mouse hovers over the code block. All images are automatically shrunk, until your mouse hovers over them, at which point they will enlarge to their original size. Pretty sweet! And it's all cross-browser-compatible.

Destination parameter rewriting with jQuery: fixing the AHAH link destination bug

Tue, Apr 20, 2010 - 7:59pm -- Isaac Sukin

Soon after I first implemented AHAH-based form refreshing in my Facebook-style Statuses module for the Drupal content management system, I realized that the process created something of a workflow problem. Users would go and post a message like normal, and then the form -- and the links on it -- would refresh via AHAH. Essentially, when a user clicked the submit button on the form, some JavaScript would silently open another page (the "callback" page) in the background. That page would generate a new copy of the form, which would then be copied and pasted over the form that had just been submitted.

The problem was, that new copy of the form was generated on the callback page, and it had no way of knowing from what page it had been called. In other words, if the script generating the form wanted to know what the current page was, instead of getting the URL of the page on which the form originally appeared, it would get the URL of the callback page. This became a problem when dealing with links, because links often include a "destination" parameter so that when a user takes an action after clicking the link they will be returned to the appropriate place. For example, an "edit" link for a message would typically have a "destination" parameter in the URL so that when a user saved the edits, the browser would automatically send the user back to the page on which the edit link was clicked. In HTML, such a link would look like this:

Subscribe to RSS - jquery