diff options
Diffstat (limited to 'app/common/directives/confirm.js')
-rw-r--r-- | app/common/directives/confirm.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/app/common/directives/confirm.js b/app/common/directives/confirm.js new file mode 100644 index 0000000..ed8c9dc --- /dev/null +++ b/app/common/directives/confirm.js @@ -0,0 +1,39 @@ +window.angular && (function (angular) { + 'use strict'; + + angular + .module('app.common.directives') + .directive('confirm', ['$timeout', function($timeout){ + return { + 'restrict': 'E', + 'templateUrl': 'common/directives/confirm.html', + 'scope': { + 'title': '@', + 'message': '@', + 'confirm': '=', + 'callback': '=' + }, + 'controller': ['$scope',function($scope){ + $scope.cancel = function(){ + $scope.confirm = false; + $scope.$parent.confirm = false; + }; + $scope.accept = function(){ + $scope.callback(); + $scope.cancel(); + } + }], + link: function(scope, e) { + scope.$watch('confirm', function(){ + if(scope.confirm){ + $timeout(function(){ + angular.element(e[0].parentNode).css({'min-height': e[0].querySelector('.inline__confirm').offsetHeight + 'px'}); + }, 0); + }else{ + angular.element(e[0].parentNode).css({'min-height': 0+ 'px'}); + } + }); + } + }; + }]); +})(window.angular); |