blob: a542783c5aa524cb12614587da12768668f80512 [file] [log] [blame]
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07001window.angular && (function(angular) {
2 'use strict';
Iftekharul Islam99d199f2017-03-24 15:28:25 -05003
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07004 angular
5 .module('app.common.directives')
6 .directive('confirm', ['$timeout', function($timeout) {
7 return {
8 'restrict': 'E',
9 'template': require('./confirm.html'),
10 '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({
31 'min-height': e[0].querySelector('.inline__confirm').offsetHeight + 'px'
32 });
33 }, 0);
34 }
35 else {
36 angular.element(e[0].parentNode).css({
37 'min-height': 0 + 'px'
38 });
39 }
40 });
41 }
42 };
43 }]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -050044})(window.angular);