It would seem $.attr(element, 'tabindex') would be element.get('tabindex') in Moo. I can't believe how counter-self- explanatory jQ syntax is– "parents" (all of them?), "closest" (closest parent or sibling? single or a set of elements) wtf...

Once you decipher how the functions work extend Pseudo.selectors by doing:

$extend(Selectors.Pseudo, {
        tabable: function() {
                // this = element
        }
});

On 26 Jun 2009, at 21:10, Rolf -nl wrote:


I could use the :tabbable and :focusable selector functions from
jQuery I spotted in jQuery UI,however I have 0 experience in their
language syntax. How would someone start porting stuff like this too a
MooTools extension?

The majority of code is self explaining, but I for instance what
$.attr does .... i dunno...

//Additional selectors
$.extend($.expr[':'], {
 data: function(elem, i, match) {
   return !!$.data(elem, match[3]);
 },

 focusable: function(element) {
   var nodeName = element.nodeName.toLowerCase(),
     tabIndex = $.attr(element, 'tabindex');
   return (/input|select|textarea|button|object/.test(nodeName)
     ? !element.disabled
     : 'a' == nodeName || 'area' == nodeName
       ? element.href || !isNaN(tabIndex)
       : !isNaN(tabIndex))
     // the element and all of its ancestors must be visible
     // the browser may report that the area is hidden
     && !$(element)['area' == nodeName ? 'parents' : 'closest']
(':hidden').length;
 },

 tabbable: function(element) {
   var tabIndex = $.attr(element, 'tabindex');
   return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is
(':focusable');
 }
});

Reply via email to