Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.29 diff -u -r1.29 drupal.js --- misc/drupal.js 14 Oct 2006 02:39:48 -0000 1.29 +++ misc/drupal.js 6 Mar 2007 05:45:40 -0000 @@ -200,6 +200,34 @@ return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523'); }; +/** + * Add behaviors to the jQuery object. + */ +jQuery.extend({ + behaviors: [], + registerBehavior: function(attachFunction, ready) { + // Default to true. + var ready = (ready == null) ? true : ready; + jQuery.behaviors.push(attachFunction); + if (ready) { + jQuery.readyList.push(attachFunction); + } + } +}); + +/** + * Attach registered behaviors. + */ +jQuery.fn.attachBehaviors = function() { + var elt = this; + if (jQuery.behaviors) { + // Execute all of them. + jQuery.each(jQuery.behaviors, function(){ + this.apply(elt); + }); + } +}; + // Global Killswitch on the element if (Drupal.jsEnabled) { document.documentElement.className = 'js';