Created
January 9, 2010 05:34
-
-
Save jingoro/272739 to your computer and use it in GitHub Desktop.
YUI3 node-visibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI().add('node-visibility', function(Y) { | |
Y.mix(Y.DOM, { | |
visible: function(node) { | |
return Y.DOM.getStyle(node, 'display') != 'none'; | |
}, | |
toggle: function(node) { | |
Y.DOM.visible(node) ? Y.DOM.hide(node) : Y.DOM.show(node); | |
}, | |
hide: function(node) { | |
Y.DOM.setStyle(node, 'display', 'none'); | |
}, | |
show: function(node) { | |
Y.DOM.setStyle(node, 'display', ''); | |
} | |
}); | |
var methods = ['visible', 'toggle', 'hide', 'show']; | |
Y.Node.importMethod(Y.DOM, methods); | |
Y.NodeList.importMethod(Y.Node.prototype, methods); | |
}, "0.1", { requires: ["dom", "node"] }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment