blob: 5bb699aa0fac82c770a01b0d9dade27b9452aba0 [file] [log] [blame]
Iftekharul Islam99d199f2017-03-24 15:28:25 -05001window.angular && (function (angular) {
2 'use strict';
3
4 angular
5 .module('app.common.directives')
6 .directive('confirm', ['$timeout', function($timeout){
7 return {
8 'restrict': 'E',
Ed Tanousbbcf6702017-10-06 13:53:06 -07009 'template': require('./confirm.html'),
Iftekharul Islam99d199f2017-03-24 15:28:25 -050010 'scope': {
11 'title': '@',
12 'message': '@',
13 'confirm': '=',
14 'callback': '='
15 },
16 'controller': ['$scope',function($scope){
17 $scope.cancel = function(){
18 $scope.confirm = false;
19 $scope.$parent.confirm = false;
20 };
21 $scope.accept = function(){
22 $scope.callback();
23 $scope.cancel();
24 }
25 }],
26 link: function(scope, e) {
27 scope.$watch('confirm', function(){
28 if(scope.confirm){
29 $timeout(function(){
30 angular.element(e[0].parentNode).css({'min-height': e[0].querySelector('.inline__confirm').offsetHeight + 'px'});
31 }, 0);
32 }else{
33 angular.element(e[0].parentNode).css({'min-height': 0+ 'px'});
34 }
35 });
36 }
37 };
38 }]);
39})(window.angular);