| Iftekharul Islam | 99d199f | 2017-03-24 15:28:25 -0500 | [diff] [blame] | 1 | window.angular && (function (angular) { | 
 | 2 |     'use strict'; | 
 | 3 |  | 
 | 4 |     angular | 
 | 5 |         .module('app.common.directives') | 
 | 6 |         .directive('confirm', ['$timeout', function($timeout){ | 
 | 7 |             return { | 
 | 8 |                 'restrict': 'E', | 
 | 9 |                 'templateUrl': 'common/directives/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({'min-height': e[0].querySelector('.inline__confirm').offsetHeight + 'px'}); | 
 | 31 |                             }, 0); | 
 | 32 |                         }else{ | 
 | 33 |                             angular.element(e[0].parentNode).css({'min-height': 0+ 'px'}); | 
 | 34 |                         } | 
 | 35 |                     }); | 
 | 36 |                 } | 
 | 37 |             }; | 
 | 38 |         }]); | 
 | 39 | })(window.angular); |