forked from darylrowland/inline-confirm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinline-confirm.js
46 lines (42 loc) · 1.56 KB
/
inline-confirm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var scripts = document.getElementsByTagName("script")
var currentScriptPath = scripts[scripts.length-1].src;
var templatePath = currentScriptPath.replace('inline-confirm.js', 'inline-confirm.tpl.html')
angular.module('inlineConfirm', [] ).directive('inlineConfirm', function ($parse) {
return {
restrict: 'EA',
scope: {
"text": "@text",
"yesText": "@yestext",
"noText": "@notext",
"type": "@type",
"confirmFunction": "&confirmfunction",
"mainClass": "@mainclass",
"actionClass": "@actionclass",
"confirmClass": "@confirmclass",
"hideOnConfirm": "@hideonconfirm",
},
templateUrl: templatePath, // load the template file
compile: function(element, attrs) {
// Set default values
if (!attrs.hideonconfirm) { attrs.hideonconfirm = false; }
if (!attrs.yestext) { attrs.yestext = 'Yes'; }
if (!attrs.notext) { attrs.notext = 'No'; }
},
controller: function ( $scope ) {
$scope.show = true;
$scope.showConfirmOptions = function() {
$scope.showConfirm = true;
}
$scope.noClick = function(e) {
$scope.showConfirm = false;
e.preventDefault();
e.stopPropagation();
}
$scope.yesClick = function(e) {
$scope.showConfirm = false;
$scope.confirmFunction();
$scope.show = false;
}
}
};
});