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