4 angular.module('foundation.offcanvas', ['foundation.core'])
5 .directive('zfOffcanvas', zfOffcanvas)
6 .service('FoundationOffcanvas', FoundationOffcanvas)
9 FoundationOffcanvas.$inject = ['FoundationApi'];
11 function FoundationOffcanvas(foundationApi) {
14 service.activate = activate;
15 service.deactivate = deactivate;
19 //target should be element ID
20 function activate(target) {
21 foundationApi.publish(target, 'show');
24 //target should be element ID
25 function deactivate(target) {
26 foundationApi.publish(target, 'hide');
29 function toggle(target) {
30 foundationApi.publish(target, 'toggle');
34 zfOffcanvas.$inject = ['FoundationApi'];
36 function zfOffcanvas(foundationApi) {
39 templateUrl: 'components/offcanvas/offcanvas.html',
50 function compile(tElement, tAttrs, transclude) {
51 var type = 'offcanvas';
58 function preLink(scope, iElement, iAttrs, controller) {
59 iAttrs.$set('zf-closable', type);
60 document.body.classList.add('has-off-canvas');
63 function postLink(scope, element, attrs) {
64 scope.position = scope.position || 'left';
68 foundationApi.subscribe(attrs.id, function(msg) {
69 if(msg === 'show' || msg === 'open') {
71 } else if (msg === 'close' || msg === 'hide') {
73 } else if (msg === 'toggle') {
77 if (!scope.$root.$$phase) {
84 scope.hide = function() {
89 scope.show = function() {
94 scope.toggle = function() {
95 scope.active = !scope.active;