Permalink
Browse files

Update ipad installer

  • Loading branch information...
1 parent d069a18 commit 0cb35a999d31533f61f8f8ba42071ecee906d9a0 @ConradIrwin ConradIrwin committed Jun 20, 2012
Showing with 28 additions and 1 deletion.
  1. +28 −1 js/lib/showable.js
View
@@ -1,4 +1,4 @@
-lib.showable = function (_public, _protected) {
+lib.showable = function (_public, _protected, manager) {
lib.model(_public, _protected, 'visible');
lib.destroyable(_public, _protected);
@@ -24,3 +24,30 @@ lib.showable = function (_public, _protected) {
return _public;
};
+
+// If you have a collection of mutually exclusive showables, this function will
+// ensure that the correct ones are hidden when the correct others are shown.
+// (aka. lib.thereShouldOnlyBeOne)
+lib.showable.manager = function () {
+
+ var _public = {}, visible = null;
+
+ _public.manage = function (showable) {
+ showable.wheneverEqual('visible', true, function () {
+ if (visible && visible !== showable) {
+ visible.hide();
+ }
+ visible = showable;
+ });
+
+ showable.wheneverEqual('visible', false, function () {
+ if (showable === visible) {
+ visible = null;
+ }
+ });
+ };
+
+ _(arguments).chain().flatten().each(_public.manage);
+
+ return _public;
+};

0 comments on commit 0cb35a9

Please sign in to comment.