Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // +---------------------------------------------------------------------------+
- // | This file is part of the MrJeep Agavi Extension package. |
- // | Copyright (c) 2006, 2007 Jean-Philippe Dery |
- // | |
- // | For the full copyright and license information, please view the LICENSE |
- // | file that was distributed with this source code. |
- // +---------------------------------------------------------------------------+
- /**
- * Mjax.Selector is a mootools implementation of the original event selector.
- * This been ported to mootools by rossco.
- *
- * @package mjax
- * @subpackage behavior
- *
- * @author Ross Lawley
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @copyright Ross Lawley
- * @since 1.0.0
- * @version 1.0.0
- */
- Mjax.Selector = new Class(
- {
- // +-----------------------------------------------------------------------+
- // | METHODS |
- // +-----------------------------------------------------------------------+
- /**
- * Constructor. Register the behaviors rules. Those rules are stored into
- * an object and they are used to separate the javascript from the html
- * in a nice clean way.
- *
- * @param object The rules.
- *
- * @return void
- *
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @since 1.0.0
- */
- start: function(rules)
- {
- window.onDomReady(function(){this.assign(rules);}.bind(this));
- },
- // ------------------------------------------------------------------------
- /**
- * Assign the behaviors rules. Those rules are stored into an object and
- * they are used to separate the javascript from the html in a nice clean
- * way.
- *
- * @param object The rules.
- *
- * @return void
- *
- * @author Jean-Philippe Dery (jeanphilippe_dery@hotmail.com)
- * @since 1.0.0
- */
- assign : function(rules)
- {
- for(var key in rules)
- {
- var rule = rules[key];
- // Loop through all the selectors which are
- // separated by a ,
- key.clean().split(',').each(function(selector)
- {
- var pair = selector.split(':');
- $$(pair[0]).each(function(elem)
- {
- // Let see if there is no events binded to the selector. In
- // this case we just fire the rule
- if (pair.length == 1)
- {
- return rule(elem);
- }
- // At this point we have an event attached
- // to the selector so we simply add the event
- elem.addEvent(pair[1], rule.pass(elem));
- });
- });
- }
- },
- });
Add Comment
Please, Sign In to add comment