Class Index | File Index

Classes


Namespace jQuery


Defined in: jquery.enable.js.

Namespace Summary
Constructor Attributes Constructor Name and Description
 
jQuery.enable v0.6.0

jQuery.enable.js is a small library of jQuery plugins designed to extend evented behaviors to JavaScript objects and classes.

Method Summary
Method Attributes Method Name and Description
<static>  
jQuery.bindable(obj, types)

Augments a static object or Class prototype with custom event functionality.

<static>  
jQuery.cacheable(obj, defaultTtl)

Augments a static object or Class prototype with timed caching functionality.

<static>  
jQuery.eventProxy(fn, context)

Takes a function and returns a new one that will always have a particular context, omitting the event argument for improved compatibility with external APIs.

<static>  
jQuery.loadable(obj, defaultCfg)

Augments a static object or Class prototype with evented Ajax functionality.

<static>  
jQuery.observable(obj)
jQuery.observable
<static>  
jQuery.pollable(obj)
jQuery.pollable
<static>  
jQuery.renderable(obj, tpl, elem)
jQuery.renderable
<static>  
jQuery.unwhite(str)

Trims and splits a whitespace-delimited string.

Namespace Detail
jQuery
jQuery.enable v0.6.0

jQuery.enable.js is a small library of jQuery plugins designed to extend evented behaviors to JavaScript objects and classes. These behaviors include: custom events, Ajax, templating, caching, polling, and more.

The cornerstone of the library is jQuery.bindable behavior. All of the other behaviors "inherit" custom event functionality from bindable.


Author: Dave Furfero.
Method Detail
<static> {Object} jQuery.bindable(obj, types)

Augments a static object or Class prototype with custom event functionality.

// Usage with a static object
var dave = {
  name: 'dave',
  saySomething: function (text) {
    alert(this.name + ' says: ' + text);
    this.trigger('onSaySomething', [text]);
  }
};

// Add bindable behavior
$.bindable(dave);

// Add event listener using bind method
dave.bind('onSaySomething', function (evt, data) {
  console.log(this.name + ' said: ' + data);
});

dave.saySomething('hello, world!');
// alerts "furf says: hello, world!"
// logs "furf said: hello, world!"
// Usage with a class
function Person (name) {
  this.name = name
}

// Add bindable behavior with custom event method
$.bindable(Person, 'onSaySomething');

Person.prototype.saySomething = function (text) {
  alert(this.name + ' says: ' + text);
  this.trigger('onSaySomething', [text]);
};

// Create instance
var furf = new Person('furf');

// Add event listener using custom event method
furf.onSaySomething(function (evt, data) {
  console.log(this.name + ' said: ' + data);
});

furf.saySomething('hello, world!');
// alerts "furf says: hello, world!"
// logs "furf said: hello, world!"
Parameters:
{Object|Function} obj
(optional) Object to be augmented with bindable behavior. If none is supplied, a new Object will be created and augmented. If a function is supplied, its prototype will be augmented, allowing each instance of the function access to the bindable methods.
{String} types
(optional) Whitespace-delimited list of custom events which will be exposed as convenience bind methods on the augmented object
Returns:
{Object} Augmented object

<static> {object} jQuery.cacheable(obj, defaultTtl)

Augments a static object or Class prototype with timed caching functionality.

Parameters:
{Object|Function} obj
(optional) Object to be augmented with cacheable behavior
{Number} defaultTtl
(optional) Default time-to-live for cached items
Returns:
{object} Augmented object

<static> jQuery.eventProxy(fn, context)

Takes a function and returns a new one that will always have a particular context, omitting the event argument for improved compatibility with external APIs.

// Bind a proxied function to an evented object
loadableObject.bind('onLoadSuccess', jQuery.eventProxy(function (data) {
  alert(data.message);
}));

// Trigger the event
loadableObject.trigger('onLoadSuccess', [{ message: 'hello, world!' }]);

// The event object normally passed as the first argument to callbacks
// is ignored and our callback alerts "hello, world!"
Parameters:
{Function} fn
{Object} context
(optional)
See:
The documentation for jQuery.proxy.

<static> {Object} jQuery.loadable(obj, defaultCfg)

Augments a static object or Class prototype with evented Ajax functionality.

Parameters:
{Object|Function} obj
(optional) Object to be augmented with loadable behavior
{Object|String} defaultCfg
Default Ajax settings
Returns:
{Object} Augmented object

<static> {Object} jQuery.observable(obj)
jQuery.observable
Parameters:
{Object|Function} obj
Object to be augmented with observable behavior
Returns:
{Object} Augmented object

<static> {object} jQuery.pollable(obj)
jQuery.pollable
Parameters:
{Object|Function} obj
(optional) Object to be augmented with pollable behavior
Returns:
{object} Augmented object

<static> {Object} jQuery.renderable(obj, tpl, elem)
jQuery.renderable
Parameters:
{Object|Function} obj
(optional) Object to be augmented with renderable behavior
{String} tpl
Template or URL to template file
{String|jQuery} elem
(optional) Target DOM element
Returns:
{Object} Augmented object

<static> {Array} jQuery.unwhite(str)

Trims and splits a whitespace-delimited string. A shortcut for splitting "jQuery-style" lists.

jQuery.unwhite('onDoSomething onDoSomethingElse');
// returns ['onDoSomething', 'onDoSomethingElse']
Parameters:
{String} str
Whitespace-delimited list
Returns:
{Array} Array of list times

Documentation generated by JsDoc Toolkit 2.4.0 on Thu May 31 2012 13:51:38 GMT-0400 (EDT)