summaryrefslogtreecommitdiffstats
path: root/afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js
diff options
context:
space:
mode:
Diffstat (limited to 'afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js')
-rw-r--r--afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js b/afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js
new file mode 100644
index 0000000..b1d6cff
--- /dev/null
+++ b/afb-client/bower_components/foundation-apps/js/angular/components/offcanvas/offcanvas.js
@@ -0,0 +1,102 @@
+(function() {
+ 'use strict';
+
+ angular.module('foundation.offcanvas', ['foundation.core'])
+ .directive('zfOffcanvas', zfOffcanvas)
+ .service('FoundationOffcanvas', FoundationOffcanvas)
+ ;
+
+ FoundationOffcanvas.$inject = ['FoundationApi'];
+
+ function FoundationOffcanvas(foundationApi) {
+ var service = {};
+
+ service.activate = activate;
+ service.deactivate = deactivate;
+
+ return service;
+
+ //target should be element ID
+ function activate(target) {
+ foundationApi.publish(target, 'show');
+ }
+
+ //target should be element ID
+ function deactivate(target) {
+ foundationApi.publish(target, 'hide');
+ }
+
+ function toggle(target) {
+ foundationApi.publish(target, 'toggle');
+ }
+ }
+
+ zfOffcanvas.$inject = ['FoundationApi'];
+
+ function zfOffcanvas(foundationApi) {
+ var directive = {
+ restrict: 'EA',
+ templateUrl: 'components/offcanvas/offcanvas.html',
+ transclude: true,
+ scope: {
+ position: '@'
+ },
+ replace: true,
+ compile: compile
+ };
+
+ return directive;
+
+ function compile(tElement, tAttrs, transclude) {
+ var type = 'offcanvas';
+
+ return {
+ pre: preLink,
+ post: postLink
+ }
+
+ function preLink(scope, iElement, iAttrs, controller) {
+ iAttrs.$set('zf-closable', type);
+ document.body.classList.add('has-off-canvas');
+ }
+
+ function postLink(scope, element, attrs) {
+ scope.position = scope.position || 'left';
+
+ scope.active = false;
+ //setup
+ foundationApi.subscribe(attrs.id, function(msg) {
+ if(msg === 'show' || msg === 'open') {
+ scope.show();
+ } else if (msg === 'close' || msg === 'hide') {
+ scope.hide();
+ } else if (msg === 'toggle') {
+ scope.toggle();
+ }
+
+ if (!scope.$root.$$phase) {
+ scope.$apply();
+ }
+
+ return;
+ });
+
+ scope.hide = function() {
+ scope.active = false;
+ return;
+ };
+
+ scope.show = function() {
+ scope.active = true;
+ return;
+ };
+
+ scope.toggle = function() {
+ scope.active = !scope.active;
+ return;
+ };
+ }
+ }
+ }
+
+})();