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 | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 4 | angular.module('app.common.directives').directive('confirm', [ |
| 5 | '$timeout', |
| 6 | function($timeout) { |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 7 | return { |
| 8 | 'restrict': 'E', |
| 9 | 'template': require('./confirm.html'), |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 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 | ], |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 25 | link: function(scope, e) { |
| 26 | scope.$watch('confirm', function() { |
| 27 | if (scope.confirm) { |
| 28 | $timeout(function() { |
| 29 | angular.element(e[0].parentNode).css({ |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 30 | 'min-height': |
| 31 | e[0].querySelector('.inline__confirm').offsetHeight + 'px' |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 32 | }); |
| 33 | }, 0); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 34 | } else { |
| 35 | angular.element(e[0].parentNode).css({'min-height': 0 + 'px'}); |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 36 | } |
| 37 | }); |
| 38 | } |
| 39 | }; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 40 | } |
| 41 | ]); |
Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 42 | })(window.angular); |