Skip to content

Instantly share code, notes, and snippets.

@jingoro
Created January 9, 2010 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jingoro/272739 to your computer and use it in GitHub Desktop.
Save jingoro/272739 to your computer and use it in GitHub Desktop.
YUI3 node-visibility
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