Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #331 from zurb/closeable-actionsheet
Browse files Browse the repository at this point in the history
Enable closable actionsheet
  • Loading branch information
AntJanus committed Dec 17, 2014
2 parents fd0741e + 059405f commit 0f2233f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
4 changes: 3 additions & 1 deletion js/angular/components/actionsheet/actionsheet.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<div class="action-sheet-container" ng-transclude>
<div class="action-sheet-container"
ng-class="{'is-active': active}"
ng-transclude>
</div>
31 changes: 30 additions & 1 deletion js/angular/components/actionsheet/actionsheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@
function zfActionSheetController($scope, foundationApi) {
var controller = this;
var content = controller.content = $scope.content;
var container = controller.container = $scope.container;

controller.registerContent = function(scope) {
content = scope;
content.active = false;
};

controller.registerContainer = function(scope) {
container = scope;
container.active = false;
};

controller.toggle = function() {
content.toggle();
container.toggle();

content.$apply();
container.$apply();
};

controller.hide = function() {
content.hide();
container.hide();

content.$apply();
container.$apply();
};
}

Expand Down Expand Up @@ -56,7 +68,12 @@
}

function postLink(scope, element, attrs, controller) {
foundationApi.subscribe(attrs.id, function(msg) {
var id = attrs.id || foundationApi.generateUuid();
attrs.$set('id', id);

scope.active = false;

foundationApi.subscribe(id, function(msg) {
if (msg === 'toggle') {
controller.toggle();
}
Expand All @@ -66,6 +83,18 @@
}

});

controller.registerContainer(scope);

scope.toggle = function() {
scope.active = !scope.active;
return;
};

scope.hide = function() {
scope.active = false;
return;
};
}
}
}
Expand Down

0 comments on commit 0f2233f

Please sign in to comment.