/***************************************************************************** * $.plugin - jQuery Plugin for on-demand loading of scripts and styles * * Documentation : http://nicolas.rudas.info/jQuery/getPlugin/ * Downloads : http://code.google.com/p/lazyloader/downloads/ * Issues : http://plugins.jquery.com/project/getPlugin/ * * Version: 081002 - 02 Oct 2008 * * ==================================================== ** USAGE: * ==================================================== * $.plugin(name,settings) Create a new plugin with specified name and settings * $.plugin(name) Access to plugin object * $.plugin(name).get() Load specified plugin and call default callback when ready * $.plugin(name,function) Load specified plugin and call function when ready (overide default callback) * $.plugin() Load all necessary plugins * * ==================================================== ** OPTIONS: * ==================================================== * @param name {String} What you want to name your plugin * * @param settings {Object} The settings for this plugin * - files {Array,String} List of files you want to load * - selectors {Array,String} If elements match these selector, the plugin will be loaded * - callback {Function} Function to be called after a plugin has loaded * - cache {Boolean} Cache files in browser's memory * - ajax {Object} Ajax options (same as in jQuery.ajax) * - context {Object, jQuery} The document where you want files to be inserted * - target {Object, jQuery} The element where you want files to be inserted * - init {Function} Function to be called when setting-up plugin * - preLoad {Function} Function to be called before loading each file * - postLoad {Function} Function to be called after loading each file * * @param callback {Function} A Function to call after plugin has loaded. Overrides default callback * * ==================================================== ** API: * ==================================================== * $.plugin(name) * .get([callback]) Load specified plugin and call callback when ready * If no callback specified, default callback is called * * .getFile(url) Load specified file and call default callback when ready * * .isNeeded() Check if plugin is needed (according to selectors provided) * Returns TRUE if it is needed, otherwise returns plugin object * * ==================================================== ** EXAMPLES: * ==================================================== * Create a Tabs Plugin: * $.plugin('tabs',{ * files: ['../styles/tabs.css', * '../scripts/tabs.js'], * selectors: ['.tabs'], * callback : function(){ $('.tabs').tabs(); } * }); * * $.plugin('tabs').get(); * * Create a Loader Plugin: * $.plugin('loader',{ * files: ['../styles/mystyles.css', * '../scripts/myscript.js', * '../scripts/myscript2.js', * '../scripts/myscript3.js'] * selectors: ['body'], * init : function(url){ $('body').append('