blob: b537905bfa6a04fd06c06a14d75a32e52dfce1d3 [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 Geisslerd27bb132018-05-24 11:07:27 -07004 angular.module('app.common.directives').directive('confirm', [
5 '$timeout',
6 function($timeout) {
Andrew Geisslerba5e3f32018-05-24 10:58:00 -07007 return {
8 'restrict': 'E',
9 'template': require('./confirm.html'),
Andrew Geisslerd27bb132018-05-24 11:07:27 -070010 '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 ],
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070025 link: function(scope, e) {
26 scope.$watch('confirm', function() {
27 if (scope.confirm) {
28 $timeout(function() {
29 angular.element(e[0].parentNode).css({
Andrew Geisslerd27bb132018-05-24 11:07:27 -070030 'min-height':
31 e[0].querySelector('.inline__confirm').offsetHeight + 'px'
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070032 });
33 }, 0);
Andrew Geisslerd27bb132018-05-24 11:07:27 -070034 } else {
35 angular.element(e[0].parentNode).css({'min-height': 0 + 'px'});
Andrew Geisslerba5e3f32018-05-24 10:58:00 -070036 }
37 });
38 }
39 };
Andrew Geisslerd27bb132018-05-24 11:07:27 -070040 }
41 ]);
Iftekharul Islam99d199f2017-03-24 15:28:25 -050042})(window.angular);