Ajax Updates |
| Multi Select Transfer with jQuery Posted: 25 Aug 2009 10:06 AM PDT I’m sure that at some point or another you’ve encountered a form widget like the one below, allowing options to be traded from one multi select to another. I recently encountered a tutorial over at Quirks Mode on creating such a widget. While not a bad script, when all was said and done it was coming up on 40 lines of JS. I suppose that’s not horrible, but we’re talking about some simple functionality. This struck me as a perfect example to demonstrate the simple and compact nature of jQuery coding. The widget operating above is running off of the following code:
If you'd like to try it out, here's a working test page:
As was mentioned in the comments below, the following (slightly modified) code can be used to automatically select all options in the second select box before submitting (thanks Charlie!).
Just make sure you include that snippet inside the $().ready() method. Demo: http://blog.jeremymartin.name/2008/02/easy-multi-select-transfer-with-jquery.html Source: http://blog.jeremymartin.name/2008/02/easy-multi-select-transfer-with-jquery.html ![]() Related Listings:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Posted: 25 Aug 2009 09:24 AM PDT I built this JavaScript so that I could get a windows like minimize and maximize effect. There are a few things I had to put in that make it a bit more flexible for the web environment. This area can be minimized and maximized from calling the appropriate JavaScript functions. The effect should work on any block element on the page. I have an example below using a div that has been styled to look vaguely like a window. To minimize this div element I just call the minimize method and pass it an object with the relevant details. I need to tell the script the id of the element to minimize, where to minimize it to i.e. x and y coordinates, the width and height of the element and lastly the top left position of the element. Some of this stuff can be missed as the script will find what it can automatically, like width, height, top, left plus it will default the x and y coord’s to zero if they are missed. Another optional variable is the callback method, if you assign a function to this variable it will be called when the animation has finished. So in my example I have called this method to minimize the div element. The callback method I have told it to call just shows a secound styled element on the page that looks like a minimized window.
My minimized looking bar has a link to maximise the element back again. This time we can pass the exact same variables as before but notice I have missed the left and top variables out, this is because I'll just let the script find out where the element is on the page from when it was minimized and maximise it from there.
So you can minimize and maximize an element from any position on the page to any other position on the page just by telling the script where you want things to start and end up. As always I've got a simple test page so that anyone can look at the source to see how it works or just download the source. Tested to work in the following browsers; * IE 7, 6 * FireFox 2.0.0.12 * Opera 9.24 * Safari (for windows) 3.0.4 Demo: http://tomcoote.co.uk/JavaScriptMinMax.aspx Download: http://tomcoote.co.uk/Downloads/MinMax.rar Source: http://tomcoote.co.uk/JavaScriptMinMax.aspx ![]() Related Listings:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Posted: 25 Aug 2009 09:13 AM PDT Smooth Javascript Image Zooming For Your Web Pages This much-requested chunk of Javascript to zoom images inline, originally written for this blog but later rolled out to the Panic website and used for screenshots, is now polished up, bug-fixed, available for you to use on your website! Designed to view full-size photos and images inline without requiring a separate web page load, FancyZoom’s raison d'être (French for “raisin-determination”) is providing a smooth, clean, truly Mac-like effect, almost like it’s a function of Safari itself. Since I originally wrote this script, there are now a lot of image zoomers to choose from (including a similar effect now on Apple’s own site!), such as the popular (and inspiring) Lightbox. So you might be asking: “Cabel, why use FancyZoom?” Well, here’s why! * Focused on the smoothest, most polished zooming animation possible * Automatically scales images from any image link, with no HTML changes * Preloads full-size images in the background on link mouseover * No resource-heavy Javascript libraries — 100% coded from scratch to zoom * Draws a nice drop shadow under the full-size image to offset it from the page * Uses Safari 3’s “box-shadow” feature to draw the drop shadow natively, no images required * Requires only two new lines of code in your HTML * Tested and works with Safari, Firefox, IE7, and IE6. (Looks better in modern browsers.) Since FancyZoom is so easy to add to a web page, I encourage you to give it a try! Instructions 1) Installing FancyZoom on your web pages should be dead simple. 2) Using Transmit (or your favorite FTP client), upload the two folders inside the package to the root of your webserver. 3) Add the following two lines of code to the section at the top of your web page(s):
4) Add onload="setupZoom()" inside your page's existing tag. For example:
Additional Details There are a few extra notes that you might find useful. Demo: http://www.cabel.name/2008/02/fancyzoom-10.html Download: http://www.cabel.name/files/FancyZoom%201.1.zip Source: http://www.cabel.name/2008/02/fancyzoom-10.html ![]() Related Listings:
|
| You are subscribed to email updates from Ajax Updates To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
| Google Inc., 20 West Kinzie, Chicago IL USA 60610 | |


0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.