Activate your free membership today | Log-in

Thursday, June 11th, 2009

jQuery Tools

Category: JavaScript, jQuery

Tero Piirainen has created a new package of jQuery Tools.

This library contains six of the most useful JavaScript tools available for today’s website. The beauty of this library is that all of these tools can be used together, extended, configured and styled. In the end, you can have hundreds of different widgets and new personal ways of using the library.

This library is open source and dual licensed under MIT and GPL 2+ licenses.

The package contains a slew of demos including:

  • Tabs
  • Tooltips
  • Expose
  • Overlay
  • Scrollable
  • Flashembed

Posted by Dion Almaer at 6:27 am
20 Comments

+++--
3.7 rating from 56 votes

Wednesday, May 20th, 2009

jQuery vs. MooTools

Category: Articles, MooTools, jQuery

Normally when you see a title like jQuery vs. MooTools you get ready for the flame bait. You would expect it even more so if you found out that someone from one of the frameworks wrote the post!

Well, Aaron Newton did just that, and I think he did a very good job at trying to keep as unbiased as possible. He can never be perfect since he has a certain viewpoint, and in fact in some ways when you come from that view you can easily under-share your points.

This isn’t a rushed piece. Aaron has been thinking about these things for quite some time, and has really pondered it.

It is a fairly long piece, and includes:

  • MooTools Makes JavaScript Itself More Fun
  • jQuery Makes the DOM More Fun
  • Anything You Can Do I Can Do Better
  • MooTools Lets You Have It Your Way
  • Chaining as a Design Pattern
  • Reusing Code with jQuery
  • Reusing Code with MooTools
  • Decision Time
  • Discussion
  • Posted by Dion Almaer at 7:31 am
    34 Comments

    ++++-
    4 rating from 56 votes

    Thursday, May 7th, 2009

    Uberplayer shows us what JavaScript media players can look like

    Category: jQuery

    Media Players seem to be a hot topic right now. After the upgrades to Scott Schiller’s SoundManager, Paul Bakaus of the jQuery UI team now puts a firm stake into the ground with the uberplayer.

    Uberplayer Screenshot

    The uberplayer takes a leaf out of the book of the UI of standalone media players. Instead of cluttering the interface with all kind of controls it only shows what is needed on demand. The different menus slide in and out as needed, there is a coverflow menu with video previews and very useful keyboard shortcuts.

    Check it out - I love the amount of detail that went into it and how smooth the overall experience is.

    Posted by Chris Heilmann at 11:24 am
    15 Comments

    +++--
    3.3 rating from 39 votes

    Tuesday, April 28th, 2009

    CSS3 Template Layout through jQuery

    Category: CSS, jQuery

    Alexis Deveria of “When Can I Use…” fame recently told us about his latest project:

    A jQuery plug-in to provide support for the CSS Template Layout Module. For those of you unfamiliar with this specification, it provides a relatively easy way to make a table-like layout using CSS. Until recently it was known as the “CSS Advanced Layout Module”.

    His full blog entry goes into a bit more detail.

    We covered John Resig’s thoughts on the CSS3 Advanced Layout Module before; you know, the idea of visually writing a table layout in your CSS file?

    Alexis’ project is hosted at Google Code, and it includes various examples. Check it out!

    Posted by Ben Galbraith at 8:30 am
    16 Comments

    +++--
    3.3 rating from 41 votes

    Friday, April 24th, 2009

    Blackberry Storm using Raphael (SVG/VML) and SoundManager

    Category: JavaScript, SVG, Showcase, jQuery

    Brad Neuberg pointed me to a Blackberry Storm site that uses Raphael, jQuery, and SoundManager to offer an SVG / VML (for IE) experience.

    HTML:
    1.  
    2. <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.0/jquery-ui.min.js"></script>
    3. <script src="/js/soundmanager2-nodebug-jsmin.js"></script>
    4. <script src="/js/raphael-min.js"></script>
    5. <script src="/js/trig-min.js"></script>
    6.  

    Posted by Dion Almaer at 6:48 am
    2 Comments

    +++--
    3 rating from 22 votes

    Wednesday, April 15th, 2009

    Horizontal Accordion 2.0 for jQuery

    Category: Plugins, UI, jQuery

    Alexander Graef wrote in to tell us about the excellent Horizontal Accordion jQuery plug-in, which takes an unordered list:

    HTML:
    1. <ul class="test">
    2.   <li><div class="handle"><img src='images/title1.png'/></div><img src='images/image_test.gif' align='left'/>
    3.     <h3>Content 1</h3>
    4.     <p>...</p>
    5.   </li>
    6.   <li><div class="handle"><img src='images/title2.png'/></div><img src='images/image_test.gif' align='left'/>
    7.     <h3>Content 2</h3>
    8.     <p>...</p>
    9.   </li>
    10.   <li><div class="handle"><img src='images/title3.png'/></div><img src='images/image_test.gif' align='left'/>
    11.     <h3>Content 3</h3>
    12.     <p>...</p>
    13.   </li>
    14.   <li><div class="handle"><img src='images/title4.png'/></div><img src='images/image_test.gif' align='left'/>
    15.     <h3>Content 4</h3>
    16.     <p>...</p>
    17.   </li>
    18. </ul>

    and transforms it into this:

    It's a complete re-write of the old plug-in and works on Firefox, IE, and Safari. Here's the feature list:

    * No dependencies
    * Optional use of easing plugin (still some work needed)
    * Close and open content one after the other
    * Close and open at the same time
    * Choose trigger (mouseover, click ...)
    * Easily control through external calls
    * Open content on load
    * Open content through hash tags in the url (#tab1, #tab2...)
    * Position of handle (left, right)
    * Mixed handle positions - 2 left , 2 right ...
    * Cycle through content by interval
    * Events when animations starts and ends
    * Hide content until all has been assembled

    Check out the demos.

    Posted by Ben Galbraith at 8:06 am
    7 Comments

    ++---
    2.5 rating from 45 votes

    Thursday, April 9th, 2009

    jQuery Glow

    Category: JavaScript, Library, jQuery

    JAVASCRIPT:
    1.  
    2. $(document).ready(function() {
    3.       $('.white').addGlow({ textColor: 'white', haloColor: '#aaa', radius: 100 });
    4.       $('.blue').addGlow({ textColor: '#00f', haloColor: '#00f', radius: 100 });
    5.       $('.green').addGlow({ textColor: '#0f0', haloColor: '#0f0', radius: 100 });
    6.       $('.red').addGlow({ textColor: '#f00', haloColor: '#f00', radius: 100 });
    7.       $('*').bind('glow:started', console.info);
    8.       $('*').bind('glow:canceled', console.info);
    9. });
    10.  

    The code above, using jQuery Glow by Pat Nakajima, gives you a nice blur error on hover.

    Make sure to mouse over the demo and check out the project.

    Posted by Dion Almaer at 5:57 am
    16 Comments

    ++---
    2.1 rating from 86 votes

    Tuesday, April 7th, 2009

    Text-Overflow for Firefox via jQuery

    Category: Firefox, Plugins, jQuery

    Devon Govett is a fan of the new CSS3 property text-overflow:

    There are a few CSS features that Microsoft pioneered and has had available to developers in Internet Explorer for a long time now. One of those features is the text-overflow property, which is now in CSS3 and has implementations in Safari, and Opera. Firefox still does not support this feature, but I have heard that it will in Firefox 3.1.

    Here is a rundown of what the property does. When text overflows an element’s box, the text-overflow property helps leave a visual hint to the user that there is more text. When a value of ellipsis is used, three dots will be shown before the text is clipped by overflow: hidden.

    Lorem ipsum dolor sit amet, c…

    I wanted to be able to use this feature in all browsers, so I wrote a small jQuery plugin in order to support Firefox. To use, just call ellipsis() on a jQuery object. For example:

    $("span").ellipsis();

    Check out the plug-in, and also a demo of it in action.

    Posted by Ben Galbraith at 9:03 am
    25 Comments

    +++--
    3.2 rating from 23 votes

    Friday, March 13th, 2009

    GX: A new animation framework

    Category: JavaScript, Library, UI, jQuery

    Riccardo Degni has created GX, his latest animation framework. He actually created moo.rd in the past, and this time he is playing on top of jQuery:

    I’ve developed GX keeping in mind mainly two Design Patterns:

    • the “Write Less, Do More” Pattern picked from the jQuery Library. With GX you’ll always write as less code as possible to get the best results.
    • the DRY (Don’t Repeat Yourself) Pattern. If a GX’s functionality is needed more than once, it will be internally reused with no duplicate.

    GX respects the Strict Standards and doesn’t generate CSS/Javscript warnings. Moreover it prevents possible Memory Leaks because it will always use the same instance for a determinate element (say goodbye to “flickering”) to avoid either memory leaks and flickering issues. This technique allows you to always keep track of your animation’s state.

    Although GX is completely cross-browser, it doesn’t contain any Browser sniffing: it’s 100% pure Javascript engine.

    Example

    JAVASCRIPT:
    1.  
    2. // simple animation
    3. $('element').gx({'width':'+=200px', 'height':'4em', 'opacity':0.4, 'color':'#ff0'},
    4. 4000);
    5.  
    6. // queue animations
    7. $('element').gx({width: 0}, 200)
    8.             .gx({width: 200}, 4000)
    9.             .gx({width: 0}, 'verySlow')
    10.             .gx({width: 100}, 'slow');
    11.  
    12. // 'Complete' callback
    13. $('element').gx({width: 200, height: 200}, 2000, 'Bounce', function(el) {
    14.   el.html('The animation is completed!');
    15. });
    16.  
    17. // 'Start' and 'Complete' callbacks
    18. $('element').gx({width: 200, height: 200}, 2000, 'Bounce',
    19.   {'start': function(el) { el.html('The animation is started!'); },
    20.    'complete': function(el) { el.html('The animation is completed!'); } }
    21. );
    22.  

    Posted by Dion Almaer at 7:24 am
    18 Comments

    +----
    1.6 rating from 90 votes

    Thursday, March 12th, 2009

    Object Oriented Event Handling and Widgets

    Category: JavaScript, jQuery

    Paul Chiu, author of Passbook, has written up his thoughts on reuse for widgets in large Ajax applications.

    The solution?

    For Passbook I decided to solve this problem once and for all. The solution I believe is in objectifying page elements as a block so that a panel with an edit and delete button can be duplicated quickly without having the Javascript code keep track of which panel on the page was clicked and trying to modify that page element. An object oriented approach would mean the page object could edit or delete it self because it knows what it is and what it represents.

    While there are some existing solutions that use custom methods to streamline the object oriented process and work around Javascript's event target scoping of "this". I believe a better method existed that did not require so much prototype modification and was more self contained and flexible. My solution is to use jQuery's plugin model to control on page elements, or widgets.

    To see the basic pattern it is easiest to first checkout the functional demo. The demo contains two main elements: a widgets container where an add action exists, and a widget controller that offers the user the ability to submit it or remove it. The demo shows the widget manipulating it self, its parent, as well as using a basic ajax callback within it self.

    Paul then walks through an example, that ends up with the following code.

    JAVASCRIPT:
    1.  
    2. // Widget container
    3. (function($) {
    4. // Widget container plugin
    5. $.fn.widgetContainer = function() {
    6.  this.each(function() {
    7.   // Vars
    8.   var wc = $(this);
    9.  
    10.   // Set events
    11.   wc.find('#add').click(function(e) { if (e) e.preventDefault(); add(wc) });
    12.  });
    13. }
    14.  
    15. // Add a widget to the container
    16. function add(wc) {
    17.  var widget = $($.fn.widget.template);
    18.  widget
    19.   .appendTo(wc)
    20.   .fadeIn('slow')
    21.   .widget(wc);
    22. }
    23.  
    24. // Widget
    25. (function() {
    26.  // Widget plugin
    27.  $.fn.widget = function(container) {
    28.   this.each(function() {
    29.    // Vars
    30.    var w = $(this);
    31.    w.parent = container;
    32.  
    33.    // Set events
    34.    w.find('form').submit(function(e) { if (e) e.preventDefault(); submit(w) });
    35.    w.find('.remove').click(function(e) { if (e) e.preventDefault(); remove(w) });
    36.   });
    37.  }
    38.  $.fn.widget.template = '<div class="widget"><form action="" method="POST"><input type="text" value=""/><input type="submit" value="Action!"/><a href="#" class="remove">Remove</a></form></div>';
    39.  
    40.  // Remove widget
    41.  function remove(w) {
    42.   w.remove();
    43.  }
    44.  
    45.  // Submit widget data
    46.  function submit(w) {
    47.   w.css('background', 'red');
    48.   $.post('/', w.find('form').serialize(), function(data) {
    49.    w.find(':text').val((new Date()).toString());
    50.    w.parent.fadeOut();
    51.    setTimeout(function() { w.parent.fadeIn() }, 500);
    52.   });
    53.  }
    54. })();
    55. })(jQuery);
    56.  
    57. // Main
    58. $(function() {
    59. $('.widgetContainer').widgetContainer();
    60. });
    61.  

    Posted by Dion Almaer at 6:21 am
    Comment here

    +++--
    3.2 rating from 27 votes

    Tuesday, March 10th, 2009

    fontAvailable: Test to see if a font is usable

    Category: jQuery

    Howard Rauscher has wrapped up a little script to test the users browser for a particular font support. fontAvailable is a jQuery plugin, but can easily be tweaked to be independent:

    JAVASCRIPT:
    1.  
    2. /* fontAvailable jQuery Plugin, v1.0
    3. *
    4. * Copyright (c) 2009, Howard Rauscher
    5. * Licensed under the MIT License
    6. */
    7.  
    8. (function($) {
    9.     $.fontAvailable = function(fontName) {
    10.         var element, width;
    11.        
    12.         // prepare element, and append to DOM
    13.         element = $(document.createElement('span'))
    14.             .css('visibility', 'hidden')
    15.             .html('abcdefghijklmnopqrstuvwxyz')
    16.             .appendTo(document.body);
    17.        
    18.         // get the width of element after applying a fake font
    19.         width = element
    20.             .css('font-family', '__FAKEFONT__')
    21.             .width();
    22.        
    23.         element.css('font-family', fontName);
    24.        
    25.         return (width !== element.width());
    26.     }
    27. })(jQuery);
    28.  

    Howard told us about the library:

    The company I work for has been using Tahoma as the default font for about two years now. A couple of months ago I wanted to figure out approximately how many users actually support this font. I decided to convert this code into a jQuery plugin. It is a pretty simple solution and does not require any swf files like other methods I found. I attach an invisible span to the bottom of a document and apply a fake font to the element. I get the width of the element and then compare it to the width of the element after I apply the given font name. If the widths are different, then the font is available.

    Posted by Dion Almaer at 8:58 am
    13 Comments

    +++--
    3.2 rating from 30 votes

    DataTables: Major update to the highly flexible data table component

    Category: JavaScript, jQuery

    Allan Jardine has updated his popular DataTables rich data grid control. Allan told us what his aims were for this 1.4.1 release:

    Being fairly happy with the options that DataTables presents to the end user, I've focused this release on providing tools for the developer. A plug-in API, non-destructive DOM manipulation (the biggest weak point of the old versions) and documentation are the major new features.

    If you take a look at the new rich API you will see that can manipulate the data in the table, build filters, fetch remote data, and more.

    What does DataTables feature again?

    • Variable length pagination
    • On-the-fly filtering
    • Multi-coloum sorting with data type detection
    • Smart handling of column widths
    • Fully internationalisable
      UK, French, German, Spanish, Russian, Norwegian, Portuguese Brazilian (and more) translations provided
    • State saving
    • Hidden columns
    • Dynamic creation of tables
    • Ajax auto loading of data
    • Custom DOM positioning
    • Single column filtering
    • Alternative pagination types
    • Non-destructive DOM interaction
    • Sorting column(s) highlighting
    • Extensive plug-in support
      Sorting, type detection, API functions and pagination
    • Fully themeable by CSS
    • Solid documentation

    Posted by Dion Almaer at 6:46 am
    4 Comments

    +++--
    3.8 rating from 31 votes

    Friday, March 6th, 2009

    jQuery UI 1.7 Released: New CSS Framework & Dramatic Updates to Controls

    Category: jQuery

    The jQuery UI team has announced today, the release of v1.7 of their effects and UI controls framework. The development took awhile going through some bumps in the road and even a major overhaul of how the library was structured. In addition, the team became much more organized adding new team members which greatly enhanced the development process as well as opening up greater communication with the community via the new development wiki.

    There’s a ton of new stuff in 1.7. We’ve fixed hundreds of bugs since 1.5.3 and are introducing many new features, a better core architecture, and major theming improvements.

    The key new features include:

    • A new site dedicated to the jQuery UI project
    • jQuery 1.3 compatibility
    • Revamped and optimized plugins
    • A new extensible CSS framework
    • Major enhancements to the Themeroller theming applicaton
    • Demos & Documentation including offline support
    • Bundled themes

    The introduction of the new ThemeRoller-ready CSS framework is especially important as it not only allows for easy theming of included jQuery UI but also allows plugin developers to create their own extensions that can take advantage of ThemeRoller's visual theming capabilities. Scott Jehl, lead architect of the CSS framework had this to say:

    jQuery UI includes a robust CSS Framework (http://docs.jquery.com/UI/Theming/API) designed specifically for building custom jQuery widgets and user interface components. The framework includes classes and helpers that cover a wide array of common user interface needs, and can be manipulated using jQuery UI ThemeRoller. Although the framework is used by all of jQuery UI's widgets, it is designed to be used in standalone plugin development as well - it'll even work with code that isn't running jQuery UI (or even any JavaScript at all!). By building your UI components using the jQuery UI CSS Framework, you will be adopting shared markup conventions and allowing for ease of code integration across the plugin community at large.

    As a bonus for framework users, we've also created a bookmarklet (http://jqueryui.com/themeroller/developertool/) that allows you to pull ThemeRoller into any page on the web! Just drag it to your Firefox toolbar and you can style away on any page using the jQuery UI CSS Framework. The tool also allows you to download a theme based on your design.

    jQuery UI team member Richard Worth commented on this new release:

    The jQuery UI Team and the unequaled community that supports it has come together and produced something really awesome in jQuery UI 1.7. This release represents not only where we've come today, but gives us a clear vision for where this library is headed. We want to make Rich Internet Applications as easy as jQuery has made Ajax, and that's really starting to happen.

    This new release is immediately available for download and the team has provided a Getting Started with jQuery UI page to help get new users up to speed quickly.

    Disclosure: I am a member of the jQuery project team

    Posted by Rey Bango at 8:07 am
    15 Comments

    +++--
    3.4 rating from 67 votes

    Tuesday, February 24th, 2009

    JavaScript Function Call Profiling with FireUnit

    Category: Performance, jQuery

    John Resig has posted on JavaScript Function Call Profiling and new methods he has added to FireUnit:

    fireunit.getProfile();

    Run this method after you've run console.profile(); and console.profileEnd(); to get a full dump of the profiling information. For example, given the following profile run:

    You'll get the following JavaScript object returned from fireunit.getProfile():

    JAVASCRIPT:
    1.  
    2.  
    3. {
    4.   "time": 8.443,
    5.   "calls": 611,
    6.   "data":[
    7.   {
    8.     "name":"makeArray()",
    9.     "calls":1,
    10.     "percent":23.58,
    11.     "ownTime":1.991,
    12.     "time":1.991,
    13.     "avgTime":1.991,
    14.     "minTime":1.991,
    15.     "maxTime":1.991,
    16.     "fileName":"jquery.js (line 2059)"
    17.   },
    18.   // etc.
    19. ]}
    20.  

    fireunit.profile( fn );

    The second method added to FireUnit provides an easy way to execute and profile a single function. Roughly, this method starts the profiler, executes the function, stops the profiler, and then returns the results from getProfile(). Additionally, it watches for any exceptions that might be thrown and makes sure that the profiler is cleanly turned off anyway (a frequent frustration of mine).

    You would use it like this:

    JAVASCRIPT:
    1.  
    2. fireunit.profile(function(){
    3.   document.getElementsByClassName("foo");
    4. });
    5.  

    John then setup a test page and found out some interesting bottlenecks in jQuery, including the current implementation of remove. He has already submitted a patch that cleans it up.

    This is great stuff. We used Firebug's profiling for Bespin but found it a little hard to extrapolate on the data, and we ended up using Shark on the Mac to get more detail on the application as a whole (not just JavaScript).

    Posted by Dion Almaer at 12:23 am
    Comment here

    +++--
    3.2 rating from 28 votes

    Monday, February 23rd, 2009

    jQuery 1.3.2 and beyond

    Category: jQuery

    jQuery 1.3.2 has been released and although it is mainly a bug fix maintenance release, it does a little more, including:

    • Elements Returned in Document Order
    • .live() Can Now Prevent Bubbling
    • :visible/:hidden Overhauled
    • .height()/.width() Overhauled
    • Selector Speed-up in IE
    • .appendTo()/etc. Now Return Inserted Elements

    It is also fun to look at the grab back of possible features on the table for 1.4 and beyond. Here are just a few:

    • jQuery.require (require JavaScript modules and CSS to load before ready runs)
    • Dynamic loading of modules when they're needed (would require synchronous script loading in core)
    • $.contains (determine if an element is inside another one)
    • Handle HTML injection in XML documents (serialize a DOM then insert)
    • Implement a .extract()/.detach() method (remove the element from the DOM, leaves events and data intact)
    • Use querySelectorAll for element-rooted queries
    • Piggy-back on a central data cache, if one exists.
    • Allowing a function as the "setter" argument for .css() -- like we have in .attr() -- and maybe for .val(), .html(), and .text() as well.
    • Offset: Faster Initialization, use parseFloat, boundingClientRect check
    • Events: Have img.load check for .complete in IE, Multiple binding with namespaces, Event scoping, .live() improvements
    • Ajax: Use JSON API if available to parse JSON, Dynamic loading of stylesheets
    • Effects: Synchronized animations, fadeTo show also show the element, if it's hidden

    Posted by Dion Almaer at 7:01 am
    9 Comments

    ++---
    2.7 rating from 117 votes

    Tuesday, February 17th, 2009

    jQuery Ajax Experience Framework Videos

    Category: The Ajax Experience, Video, jQuery

    Today's post of Ajax Experience videos from our Fall 2008 show features jQuery. Enjoy!

    Intro to jQuery with John Resig

    Advanced jQuery with John Resig

    An In-Depth Look at jQuery UI with Paul Baukus

    Rich Interactivity, Simplified, with jQuery UI with Richard Worth

    jQuery on Rails (The Real Ones) with Jonathan Sharp

    Posted by Ben Galbraith at 10:00 am
    4 Comments

    +++--
    3.9 rating from 44 votes

    Next Page »