Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 1 | window.angular && (function(angular) { |
| 2 | 'use strict'; |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 3 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame^] | 4 | 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 Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 44 | })(window.angular); |