Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit 04c3712

Browse files
author
James Kleeh
committed
Update angular-confirm.js
1 parent 35031f8 commit 04c3712

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

angular-confirm.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,22 @@ angular.module('angular-confirm', ['ui.bootstrap'])
4646
},
4747
link: function(scope, element, attrs) {
4848

49-
function bind(func) {
50-
element.unbind("click").bind("click", function() {
51-
func();
52-
});
53-
}
54-
55-
function bindConfirm() {
56-
bind($confirm({text: scope.confirm}, scope.ngClick));
57-
}
58-
59-
function bindDefault() {
60-
bind(function() {
61-
if (scope.$$phase || scope.$root.$$phase) {
62-
scope.ngClick();
63-
} else {
64-
scope.$apply(scope.ngClick);
65-
}
66-
});
67-
}
6849

69-
if ('confirmIf' in attrs) {
7050
scope.$watch('confirmIf', function(newVal) {
7151
if (newVal) {
72-
bindConfirm();
52+
element.unbind("click").bind("click", function() {
53+
$confirm({text: scope.confirm}, scope.ngClick);
54+
});
7355
} else {
74-
bindDefault();
56+
element.unbind("click").bind("click",function() {
57+
if (scope.$$phase || scope.$root.$$phase) {
58+
scope.ngClick();
59+
} else {
60+
scope.$apply(scope.ngClick);
61+
}
62+
});
7563
}
7664
});
77-
} else {
78-
bindConfirm();
79-
}
8065
}
8166
}
8267
});

0 commit comments

Comments
 (0)