Inline Code
Sample Text Variable esc
var Toolkit = {
createPlugin: function(plugin, callback, collection) {
var name = plugin;
// Prefix with toolkit to avoid collisions
if ($.fn[name]) {
name = 'toolkit' + name.charAt(0).toUpperCase() + name.slice(1);
}
$.fn[name] = collection ?
// Apply the instance to a collection of elements
function() {
var instance = Toolkit.cache[plugin + ':' + this.selector] = callback.apply(this, arguments);
return this.each(function() {
$(this).cache('toolkit.' + plugin, instance);
});
} :
// Apply the instance per element
function() {
var args = arguments;
return this.each(function() {
$(this).cache('toolkit.' + plugin, callback.apply(this, args));
});
};
}
};