Sunday, June 14, 2009

jQuery.SerialScroll 1.2.2 released

Enhancements

  • Removed the check that avoids re-scrolling to the same index, this might be desirable sometimes.
  • The settings object is exposed in the onBefore as the this.

Links

Downloads

Saturday, June 6, 2009

Moving my plugins to Google Code

Google Code

I decided to move my plugins from my private svn to Google Code. This means the code being developed is now public and can be viewed and reviewed by anyone.

I'm also trying to automate the building process with a makefile in order to make deploys less tedious (thus more frequent :)).

Everyone's invited to check the code, review it, comment and report bugs. The repository has a few plugins that I actually never released. It doesn't contain non-jQuery scripts yet. I haven't moved them yet and won't do yet.


Links

Saturday, May 30, 2009

2 Ajax plugins for jQuery +1.3

Introduction

I never actually posted about 2 tiny plugins I made, once jQuery 1.3 was nearing.

Both are somehow related, they are related to Ajax (jQuery.ajax) and they provide sort of a manager to allow multiple implementations of the same feature.

Needless to say, both plugins only work under jQuery 1.3 or higher. The packages(zips) include jQuery 1.2.7pre because that's the version I used to test them when I made them. You obviously don't need to use that version.


XHR

Since jQuery 1.3. The default XHR "factory" function can be overriden by passing an 'xhr' setting to jQuery.ajax with a new function

This tiny plugin provides a simple registry for different xhr implementations to co-exist.

To provide a new implementation, you need to do something like this:

jQuery.xhr.register( 'my_xhr', function( settings ){
  return new MyXhrImplementation( settings );
});

The argument settings is the object passed to jQuery.ajax.

To use it, you do:

jQuery.ajax({
    url:'...',
    transport:'my_xhr',
    // ...
});

The built-in implementation is used by default (unless it's overriden with jQuery.ajaxSetup) and it's called 'xhr'.

Links & Downloads

AjaxFilter

This plugin lets you store multiple functions to sanitize ajax responses.

If you want to provide a new implementation, you need to do something like this:

jQuery.ajaxFilter.register('js_in_href','html',
 function( data ){
  return data.replace(/href="javascript:[^"]+"/g, '');
});

or

jQuery.ajaxFilter.register('eval','script html json',
 function( data ){
   return data.replace(/eval\(.+?\);?/g, '');
});

Arguments for jQuery.ajaxFilter.register() are:

  1. Name for the filter, used as 'filter' when calling jQuery.ajax.
  2. One or more dataTypes to handle. Can be any combination of ajax, html, json and xml separated by spaces.
  3. The filter function. Will receive 2 arguments: the data and the type. The 'this' will reference the settings object.

To use it, you do:

jQuery.ajax({
    url:'foo.html',
    filter:'js_in_href',
    // ...
});

The filter can also parse the response.
That means it can (for example) provide an alternative way of eval'ing json. This is specially useful for Adobe AIR apps. If the filter returns something else than a string, it's assumed to be the final response.

Links & Downloads

Monday, May 25, 2009

jQuery.ScrollTo 1.4.2 released

Notice

I've pretty much stopped updating this blog, but the plugin development is still on-going. You can find the link to the Github project page at the bottom of the article.

Fixes

  • Fixing max calculations for regular DOM elements.

Features

  • The plugin support percentages as target ('50%' or {top:'50%', left:'45%'}).
  • Exposed the max() calculation as $.scrollTo.max.

Enhancements

  • Renamed $.fn.scrollable to $.fn._scrollable to avoid conflicts with other plugins.

Links

Wednesday, March 11, 2009

jQuery.LocalScroll 1.2.7 released

Notice

I've pretty much stopped updating this blog, but the plugin development is still on-going. You can find the link to the Github project page at the bottom of the article.

In this release I cleaned up the code a little and added some features. Also removed a few old (aka deprecated) stuff that were still hanging around.

Enhancements

  • Added some misc enhancements and cleanup the code.
  • Updated the plugin to take advantage of recent scrollTo additions.

Changes

  • The element that triggered the scroll cannot be accessed anymore from within the onBefore, you can bind your own click (or w/e) to them in order to add a class or things like that.
  • settings.persistent is no longer supported (was deprecated).

Features

  • The set of settings can be accessed from within the onBefore as the 'this'.
  • The hash (#foo) is set to the URL before scrolling, so the back button works accurately (when scrolling the window).
  • The option 'hash' doesn't make the window jump when scrolling overflown elements
  • $.localScroll.hash now resets the element scroll to (0,0) by default. You can set the setting 'reset' to false to avoid this.
Enjoy!

Links