Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Update ipad installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Jun 20, 2012
1 parent d069a18 commit 0cb35a9
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion js/lib/showable.js
@@ -1,4 +1,4 @@
lib.showable = function (_public, _protected) { lib.showable = function (_public, _protected, manager) {


lib.model(_public, _protected, 'visible'); lib.model(_public, _protected, 'visible');
lib.destroyable(_public, _protected); lib.destroyable(_public, _protected);
Expand All @@ -24,3 +24,30 @@ lib.showable = function (_public, _protected) {


return _public; 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.