Activate your free membership today | Log-in

Monday, February 16th, 2009

xLazyLoader: Lazy loader callback framework

Category: JavaScript, Library, jQuery

Oleg Slobodskoi, guru behind jimdo.com, has open sourced xLazyLoader a jQuery plugin that lets you asynchronously load resources such as JavaScript, CSS, and images. Quite useful if you want to head of and load some CSS to do something custom and you need the callback.

Example

JAVASCRIPT:
  1.  
  2.  $.xLazyLoader({
  3.      js: ['ui.core.js','ui.dialog.js'],
  4.      css: ['ui.core.css', 'ui.dialog.css'],
  5.      image: ['your_image.jpg', 'your_image1.jpg', 'your_image2.jpg'],
  6.      name: 'dialog',
  7.      load: function(){
  8.          alert('All files are loaded');
  9.      }
  10.  });
  11.  

Features

  • load one or multiple files for each type
  • onload callback for javascript, CSS and images
  • prevents double loaded scripts or css files
  • method to remove scripts/css by using group name
  • method to disable/enable css files by using group name, so you can use this plugin like a css switcher
  • Tested in IE6, IE7, FF2/3, Opera 9, Safari 3, Chrome

Posted by Dion Almaer at 6:55 am
Comment here

+++--
3.6 rating from 44 votes

Friday, January 30th, 2009

w00t! Feeling Chatty

Category: Aptana, JavaScript, Showcase, jQuery

Live Ajax chat is one of those Comet 101 kind of examples (as RSS readers were to Ajax back in the day!).

We saw a couple of items from this meme recently.

First, jChat, a showcase chat application using Jaxer:

Jaxer ships with a number of basic samples, but I've seen quite a few people online in search of more complex examples and specifically ones that make use of the new ActiveRecord.js library. The extended example I developed is called jChat. jChat is fully functional chatroom application that demonstrates integration of the following web related technologies; HTML, CSS, JavaScript, MySQL, YUI, Jaxer, and Activerecord.js.

jChat's DOM access/manipulation, event handling, and animation code makes heavy use of YUI. The YUI Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, DHTML and AJAX.

Then we get to Red tag crazy (or w00t! for girls) who told us about their live chat implementation in the wild:

We wanted this to be really fun for our shoppers, and chicks like to chat. Then came the idea, “what if we have a chat system right on our home page?”. The pre-requisites were: it has to be super easy to use, not require any sign-up, no plugins, and it has to support thousands of users at once. Solution = jQuery Ajax.

Our server crashed on day 2 from the memory used by PHP to refresh hundreds of ajax clients at once. Our solution was to cache a single JavaScript file that is loaded via ajax by each client every 15 seconds. This file contains all the necessary data to update a page with a bunch of chat bubbles and slide in new comments as if it were some sort of crazy java plugin. PHP runs via cron-job to update this cached JS/jQuery powered file every 2 seconds on our server, which turns out to be a lot less memory intensive than at every ajax request.

Posted by Dion Almaer at 5:16 am
8 Comments

+++--
3.3 rating from 23 votes

Thursday, January 29th, 2009

Rotate images with Canvas jQuery plugin

Category: Canvas, jQuery

Pawel Witkowski released an interesting jQuery plugin called Wilq32.RotateImage that lets you rotate images simply:

JAVASCRIPT:
  1.  
  2. // just do it 5 degrees
  3. $('#image2').rotate({angle:5})
  4.  
  5. // animate the rotation
  6. var rot=$('#image3').rotate({maxAngle:25,minAngle:-55,
  7.   bind: [
  8.     {"mouseover":function(){rot.rotateAnimation(85);}},
  9.     {"mouseout":function(){rot.rotateAnimation(-35);}}
  10.   ]
  11. });
  12.  

You can also do this type of thing on new browsers via CSS transforms so it would be cool to merge the two (if one is supported great, else try the other).

Posted by Dion Almaer at 4:20 am
3 Comments

+++--
3.9 rating from 74 votes

Tuesday, January 20th, 2009

Sexy Page Curls

Category: Component, jQuery

I thought that sexy curls were not related to technology, but Elliott Kember packaged a nice and easy page curl plugin using jQuery.

All you need to do is:

HTML:
  1.  
  2. <script type="text/javascript" src="turn/turn.js"></script>
  3. <link rel="stylesheet" type="text/css" href="turn/turn.css">
  4.  
  5. $(document).ready(function(){
  6.     $( '#target' ).fold();
  7. });
  8. </script>
  9.  

Posted by Dion Almaer at 7:08 am
6 Comments

+++--
3.7 rating from 45 votes

Friday, January 16th, 2009

Filament Group Goodness Using jQuery UI

Category: jQuery

We've featured the work of the Filament Group in the past and here they are again leveraging jQuery UI RC5 to really enhance some of their controls.

Date Range Picker

The Date Range Picker goes beyond the normal date picker control by

  • Allowing presets such 'Specific Date', 'All Dates Before', 'All Dates After', 'Date Range'
  • Integration with the Date.js date library
  • Multiple inputs for the start and end dates
  • Enhanced formatting options

Slider Control

They've also updated their slider control to be compatible with the upcoming jQuery UI 1.6 release and new options have been added for choosing the label and tooltip text source, better integration with native UI Slider options, and dynamic width adjustments based on the parent container.

The purpose of this plugin is to allow for the jQuery UI Slider plugin to be generated using progressive enhancement. The plugin scrapes the data from a select element and generates a jQuery UI Slider in its place, acting as a proxy to the select element (regardless of whether it is still visible, or hidden from the user). This means you can use the jQuery Slider plugin alongside other input elements in a form and submit or serialize the form as if the slider is not even there. This also allows the slider to work with our without javascript since the select element can be used if the slider is unavailable.

ThemeRoller-ready

The interesting part of these two controls is that they're now taking advantage of the new jQuery UI CSS Framework which makes them immediately ThemeRoller-ready. This allows for easy skinning of both controls via the ThemeRoller application.

Posted by Rey Bango at 12:39 pm
29 Comments

+++--
3.7 rating from 68 votes

Wednesday, January 14th, 2009

Happy Birthday jQuery! v1.3 is Released

Category: jQuery

Disclosure: I'm a member of the jQuery Project team

Back on January 14, 2006, a brash, young and talented developer named John Resig put out a personal project to the OSS world and hoped it could benefit *someone*. Little did he know that 3 years later, his side project would become one of the most influential frameworks for developing JavaScript-based applications. Today, the jQuery project turns 3 years old which, considering the churn rate for open source projects, is a monumental achievement. So it makes sense that on the project's 3rd birthday, the team has announced the release of jQuery v1.3, the latest and greatest release of jQuery which includes the new Sizzle selector engine.

Along with the inclusion of Sizzle, jQuery v1.3 includes a bevvy of new features:

  • Live Events: Event delegation with a jQuery twist
  • jQuery Event Overhaul: Completely rewired to simplify event handling.
  • HTML Injection Rewrite: Lightning-fast HTML appending.
  • Offset Rewrite: Super-quick position calculation.
  • No More Browser Sniffing: Using feature detection to help jQuery last for many more years to come.

The details of the release can be found via the release notes.

In addition to that, Remy Sharp donated a new dynamic API browser to the jQuery project which makes searching the jQuery API extremely easy:

The API browser includes:

  • All the latest jQuery and jQuery UI documentation.
  • The ability to mark pages as favorites for those pages you keep wanting to return to.
  • Syntax highlighting in the code examples
  • Live running of examples within the browser
  • Links to edit and experiment with the code examples

In addition, Tane Piper & Remy worked together to provide an AIR app version of the browser so you can view the API locally.

The biggest update though is that the jQuery projects (i.e. jQuery & jQuery UI) will be part of the Software Freedom Conservancy thus making the projects true non-profit endeavor and providing a number of benefits to both the project and the jQuery community including:

  1. It allows the current project members to continue to manage the projects and maintain ultimate responsibility for the direction of current and future efforts.
  2. It allows the projects to be considered a true non-profit efforts allowing us to be able to accept donations and contributions without incurring tremendous personal financial liability.
  3. The copyright of the code will be assigned to the conservancy thus ensuring that no single person will own contributions or assets of the project.
  4. It may allow corporations to write off time when an employee contributes to a project.
  5. Most importantly, it ensures that the jQuery projects will always be open and free software

With so many new individuals & corporations contributing to the project, doing this became a big priority to protect the investments made by the jQuery community.

This is a lot of great news for jQuery developers and here's wishing jQuery a happy 3rd birthday.

Posted by Rey Bango at 10:19 am
20 Comments

++++-
4.4 rating from 98 votes

Friday, January 9th, 2009

Beautiful Code Documentation

Category: Library, jQuery

Atul Varma (who I have the absolute pleasure to work with now) has created code documentation that actually looks beautiful. Typography matters.

You can check it out via his Ubiquity documentation example that shows you side by side documentation with the actual source code itself. This context is terrific. He does this all dynamically, and uses border padding to align the documentation with the code itself.

Here is what he has to say about how it is done:

The raw source code for the file being documented above just has chunks of comments that are marked-up in WikiCreole; when the parser runs into such a chunk, it renders it alongside the code it annotates using Ivan Fomichev and Chris Purcell’s JavaScript Creole 1.0 Parser.

The idea of using the documentation to annotate the code—or the code to annotate the documentation, depending on how you look at it—was inspired in part by some of the typography presented in Ellen Lupton’s excellent Thinking with Type, which I recommend to anyone interested in the field.

It’s nice not having a separate documentation build step: aside from making the process of writing and editing documentation quicker, it also lowers the barrier for entry to contributors since they don’t need to setup a toolchain. It also means that we get versioned documentation in every commit for free.

Right now there isn’t much else to the system; the only other feature I added is the auto-generation of quasimodal popup menus that link the names of XPCOM interfaces to their entries on XUL Planet and MDC. It’d be nice to have more features like this; other niceties would be an automatically-generated table of contents, JavaScript Doctests, search functionality, cross references to other code, and even the ability to fix code formatting errors in-page. For now, though, I need to focus on actually using this tool to document more code.

As soon as Ben and I saw this our minds started to race. What if you could navigate the code via hyperlinks too? Or have groups comment inline? Many exciting ideas.

It is fun to see the 80 character column limit in place (and seeing where that is ignored). 80 character limits with wide screen displays? I never get that :)

Posted by Dion Almaer at 9:11 am
8 Comments

+++--
3.5 rating from 51 votes

Thursday, January 8th, 2009

jQuery pageSlide: throwing content around

Category: Component, Examples, jQuery

Scott Robbin (Songza co-founder) has created a very cool jQuery plugin for pageSlide, an interaction based off of Aza's prototypes for Firefox Mobile and Ubiquity mouse gestures. The plugin wraps body content into a container and shifts it off of the page whenever a click event is fired, revealing a secondary interaction pane.

This plugin allows any developer to recreate a similar interaction on their own website using a few simple lines of Javascript. By attaching the method to an anchor tag, pageSlide wraps the original body content into a wrapper and creates an additional block for the secondary content load. The slide is animated whenever the click event is invoked.

HTML:
  1.  
  2. <script type="text/javascript">
  3.     $(document).ready(function() {
  4.         $('a.pageslide').pageSlide({
  5.             width: "300px"
  6.         });
  7.     });
  8. </script>
  9.  

For some reason I enjoy thinking of my desktop as a virtual area that I can shift around.... so this can suite me well.

Posted by Dion Almaer at 9:10 am
6 Comments

+++--
3.7 rating from 61 votes

Monday, December 22nd, 2008

jQuery 1.3 beta: Sizzling and feature testing

Category: jQuery

jQuery 1.3 beta 1 has been released with John and the team asking for testing help.

This is a big release as a lot has been changed:

  • Sizzle has been integrated
  • No more browser testing: For example, no more if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { which is replaced with if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
  • Live event delegration: Reglib's claim to fame was how event delegation was "live" meaning that if you added elements later on, they would also fall into the same delegations. With $("#foo > div").live("click", someFn); you get the same in jQuery
  • $(this).closest("div");: Returns this or closest ancestor that matches selector
  • .offset() rewrite - significantly faster, uses no browser sniffing.
  • .hide()/.show() rewrite - 50% - 200% faster.
  • .append/prepend/before/after rewrite - 10-15x faster.

Posted by Dion Almaer at 1:39 pm
27 Comments

+++--
3.9 rating from 59 votes

jQuery Gestures

Category: JavaScript, Library, jQuery

Adrien Friggeri has taken the music player ui and spent some time to create a really nice gestures library that allows you to add mouse gestures to a web page, supports complex (i.e. sequences of) gestures and provides visual feedback through the use of a canvas element.

Example code looks like this:

JAVASCRIPT:
  1.  
  2. // initialize the engine, inactive by default and set the trace color to red
  3. $.gestures.init({active:false,color:'#ff0000'});
  4.  
  5. // adds a new gesture : Down
  6. $.gestures.register('D', function() {
  7.   alert('down !');
  8.   });
  9.  
  10. // a more complex gesture : Down, Left, Up, Right
  11. $.gestures.register('DLUR', function() {
  12.   alert('this is a rectangle, no ?');
  13.   });
  14.  
  15. // you can log unknown gestures :
  16. $.gestures.error(function(gesture) {
  17.   alert("oops, I don't understand what \""+gesture+"\" means");
  18. });
  19.  
  20. // useful keyboard tricks :
  21. $(window).keydown(function(e) {
  22.   if ($.gestures.active() && e.which==27) {
  23.     // disable capture when user presses ESC
  24.     $.gestures.disable();
  25.   } else if (!$.gestures.active() && e.which==17) {
  26.     // enable capture when CTRL is pressed
  27.     $.gestures.enable();
  28.   }
  29. });
  30. $(window).keyup(function(e) {
  31.   // disable capture when CTRL is not pressed
  32.   if ($.gestures.active() && e.which==17) {
  33.   $.gestures.disable();
  34.   }
  35. });
  36.  

Posted by Dion Almaer at 8:28 am
10 Comments

++++-
4.1 rating from 33 votes

Wednesday, December 17th, 2008

Music Player UI

Category: Showcase, UI, jQuery

Yensdesign has a nice little example of a music player UI that uses mouse gestures and key handling to give a clean experience.

Songza did a great job here, and I still use it to find songs for the kids.

Posted by Dion Almaer at 6:31 am
3 Comments

+++--
3.4 rating from 25 votes

Monday, December 15th, 2008

The Cloud Player: Web-based iTunes using jQuery

Category: Examples, Sound, jQuery

Eric Wahlforss, the founder of SoundCloud, wrote in to tell us about "The Cloud Player", a iTunes / Songbird clone written entirely in Ajax:

we just released an open-source itunes-clone built in jquery (and app engine, soundmanager 2, soundcloud api), complete with smart playlists, drag'n'drop, keyboard shortcuts, load-as-you-scroll playlists, playlist sharing, waveform display of tracks, etc. we've extended jquery ui a bit for this to happen.

It's using soundcloud.com as the primary music source, and the SoundCloud JSONP API to access the track metadata, available at http://soundcloud.com/api.

I like how it shows the waveform of the entire track at the bottom of the screen. Unfortunately, it's limited to the rather tiny music selection on soundcloud's service, but since it's open-source, the future is interesting indeed.

Eric sent along a playlist with some of his electronic playlists: http://www.thecloudplayer.com/share/3e718.

Nice work!

Posted by Ben Galbraith at 1:11 pm
10 Comments

+++--
3.5 rating from 35 votes

Extending jQuery selectors with JavaScript

Category: jQuery

JAVASCRIPT:
  1.  
  2. // Flag images upon load:
  3. $('img').load(function(){
  4.     $(this).data('loaded',true);
  5. });
  6.  
  7. // Extend expr:
  8. $.extend($.expr[':'],{
  9.     loaded: function(a) {
  10.         return $(a).data('loaded');
  11.     }
  12. });
  13.  
  14. // Example of usage:
  15. alert( 'Images loaded so far: ' + $('img:loaded').size() );
  16.  

This code is one example of how you can extend the selector experience in jQuery with simple JavaScript code.

James Padolsey takes us through this in a lot of detail, showing other examples including a simple "if the element is inline" selector, as well as well as tying into jQuery's "data" functionality.

Posted by Dion Almaer at 6:15 am
2 Comments

+++--
3.9 rating from 44 votes

Friday, December 5th, 2008

JSOS: jQuery based desktop

Category: Showcase, jQuery

There have been plenty of JavaScript desktop in the browsers of the years (ah WebOS!).

James Luterek has posted about the latest jQuery based desktop environment.

I started creating an operating system like user interface in JavaScript. I had intended to use it for the admin sections of my content management system(that runs this website), but through developing it I started to question it's usability and decided to discontinue development.

Features in it's current state:

  • Start Button
  • Task Bar - view open windows and set focus/minimize
  • Windows (Create, move, maximize, minimize, resize, etc.)
  • Show Desktop on right click
  • Properties (Theme Color, Text Color, Background Color, Background Image)
  • Properties saved in cookies for next visit

Still don't know how to create a new window other than a Google one, and I am never quite sure when people will use these (even fully baked). I am sure it will happen, but not until the browser platform has gotten to a point where it actually can. Calling this an "OS" is funny too ;)

Happy Friday!

Posted by Dion Almaer at 2:16 pm
15 Comments

++---
2.2 rating from 84 votes

Wednesday, December 3rd, 2008

A great example of sharing; Sizzle Engine in Dojo Foundation

Category: CSS, Dojo, JavaScript, Library, Prototype, jQuery

Voting has started in Dojo land to take in John Resig's Sizzle next-gem CSS selector engine.

This is incredibly exciting, as it shows how Ajax libraries are working together more and more. Instead of reinventing the wheel in different ways for each project, is it possible to find some core pieces that can be nicely shared? Of course, if our world was nicer and we could share code by linking in a nice way maybe this would happen more.

As I mentioned in my thanksgiving note, the work that the Ajax library developers do is hugely important and impactful, and having them work together can only be great news.

Take a look at this public email to the Dojo Foundation on the vote:

Overview

The Sizzle project is a JavaScript library for performing selections
across a DOM tree using CSS selectors. The library is designed to be
standalone (have no external dependencies), lightweight, fast, and
extensible. This culminates in a library that is perfectly suited for
integration into other libraries. While it's feasible that a developer
may use Sizzle directly the target audience for it is other library
authors.

The code for Sizzle can be found in the following Git repository:
http://github.com/jeresig/sizzle/tree/master

All of the code for the project has been written by John Resig and is
released under an MIT license. There are some patches pending from
some other contributors (namely Prototype).

Right now the following libraries are adopting or are looking to adopt
Sizzle as their primary CSS selector engine:

It's likely that Sizzle will become the unified engine behind a
majority of the JavaScript libraries on the market (if not in numbers
then certainly in market share).

The project is owned by John Resig who will serve as BDFL/Project lead
if the project is accepted. There is no formal voting process, as of
yet, but it's likely that one will come about, considering the number of
projects using the codebase.

If the project is accepted to the foundation then all contributors to
the project will be required to have a CLA and follow the policies of
the Dojo foundation.

It's very likely that Sizzle will eventually expand into other areas
of JavaScript libraries (such as DOM manipulation and event binding).

That last line excites me too! It is interesting to see this happen in the Dojo Foundation. Remember, Dojo was founded out of toolkits coming together to aggregate forces. Kudos to everyone involved, and good luck!

Posted by Dion Almaer at 12:58 am
12 Comments

++++-
4.3 rating from 57 votes

Friday, November 28th, 2008

s3slider: fading gracefully

Category: jQuery

s3slider is a simple jQuery plugin that smoothly lets you fade through a set of images.

You include the script and then:

HTML:
  1.  
  2. // setup the images
  3. <div id="s3slider">
  4.    <ul id="s3sliderContent">
  5.       <li class="s3sliderImage">
  6.           <img src="#" />
  7.           <span>Your text comes here</span>
  8.       </li>
  9.       <li class="s3sliderImage">
  10.           <img src="#" />
  11.           <span>Your text comes here</span>
  12.       </li>
  13.       <div class="clear s3sliderImage"></div>
  14.    </ul>
  15. </div>
  16.  

Setup the CSS, and finally the JS

JAVASCRIPT:
  1.  
  2. $(document).ready(function() {
  3.    $('#s3slider').s3Slider({
  4.       timeOut: 4000
  5.    });
  6. });
  7.  

Posted by Dion Almaer at 4:15 am
4 Comments

+++--
3.4 rating from 21 votes

« Previous PageNext Page »