Skip to content
Browse files

gallery-2011.01.26-20-33 lsmith gallery-patch-330-toggleview

  • Loading branch information...
1 parent 95075b7 commit c467cb85536e130387fd7ac795ad34377b792726 YUI Builder committed Jan 26, 2011
View
4 src/gallery-patch-330-toggleview/build.properties
@@ -0,0 +1,4 @@
+builddir=../../../builder/componentbuild
+component=gallery-patch-330-toggleview
+component.jsfiles=patch.js
+component.requires=transition-native
View
6 src/gallery-patch-330-toggleview/build.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="YUI" default="local">
+ <property file="build.properties" />
+ <import file="${builddir}/3.x/bootstrap.xml"
+ description="Default Build Properties and Targets" />
+</project>
View
32 src/gallery-patch-330-toggleview/js/patch.js
@@ -0,0 +1,32 @@
+function _wrapCallBack(anim, fn, callback) {
+ return function() {
+ if (fn) {
+ fn.call(anim);
+ }
+ if (callback) {
+ callback.apply(anim._node, arguments);
+ }
+ };
+}
+
+Y.Node.prototype.toggleView = function (name, on) {
+ var callback;
+ this._toggles = this._toggles || [];
+ if (typeof name == 'boolean') { // no transition, just toggle
+ on = name;
+ }
+ if (typeof on === 'undefined' && name in this._toggles) {
+ on = ! this._toggles[name];
+ }
+
+ on = (on) ? 1 : 0;
+
+ if (on) {
+ this._show();
+ } else {
+ callback = _wrapCallBack(this, this._hide);
+ }
+
+ this._toggles[name] = on;
+ this.transition(Y.Transition.toggles[name][on], callback);
+};

0 comments on commit c467cb8

Please sign in to comment.
Something went wrong with that request. Please try again.