SuperSelectors
SuperSelectors is an extra collection of MooTools psuedo selectors that provide shortcuts to selecting elements.
Download in Package Debut Article
Plugin Code (Version 2.0)
/* grab random elements */
/* credit: http://blog.kassens.net/custom-pseudo-selectors */
Selectors.Pseudo.random = function(probability, local) {
return Math.random() < (probability || .5).toFloat();
};
/* grab elements with no value */
Selectors.Pseudo.noValue = function() {
return '' == this.value;
}
/* grab elements with a specific empty attribute */
Selectors.Pseudo.emptyAttribute = function(att) {
return '' == this.get(att);
}
/* grab disabled elements */
Selectors.Pseudo.disabled = function() {
return this.disabled;
}
/* grab enabled elements */
Selectors.Pseudo.enabled = function() {
return !this.disabled;
}
/* grab each type of input */
['text','password','radio','checkbox','submit','image','reset','button','file','hidden'].each(function(type) {
Selectors.Pseudo.(type) = function() {
return type == this.get('type');
}
});
/* form element ? */
Selectors.Pseudo.input = function() {
return ['textarea','select','input','button'].contains(this.get('tag'));
}
Options & Events
None.
Code Revisions & Bug Fixes
None.
