1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/app/assets/javascripts/directives/confirmation_needed.coffee

21 lines
631 B
CoffeeScript
Raw Normal View History

2016-03-23 18:39:41 +01:00
Application.Directives.directive 'confirmationNeeded', [->
return {
priority: 1
terminal: true
link: (scope, element, attrs)->
msg = attrs.confirmationNeeded || "Are you sure?"
clickAction = attrs.ngClick
element.bind 'click', ->
if attrs.confirmationNeededIf?
confirmNeededIf = scope.$eval(attrs.confirmationNeededIf)
if confirmNeededIf == true
if ( window.confirm(msg) )
scope.$eval(clickAction)
else
scope.$eval(clickAction)
else
if ( window.confirm(msg) )
scope.$eval(clickAction)
}
]