1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-03 14:24:23 +01:00
fab-manager/app/assets/javascripts/directives/stripe-angular.js

24 lines
716 B
JavaScript
Raw Normal View History

2018-11-21 11:08:53 +01:00
'use strict';
2016-03-23 18:39:41 +01:00
// https://github.com/gtramontina/stripe-angular
Application.Directives.directive('stripeForm', ['$window',
2018-11-21 10:59:07 +01:00
function ($window) {
2018-11-21 11:08:53 +01:00
var directive = { restrict: 'A' };
2018-11-21 10:59:07 +01:00
directive.link = function (scope, element, attributes) {
2018-11-21 11:08:53 +01:00
var form = angular.element(element);
2018-11-21 10:59:07 +01:00
form.bind('submit', function () {
2018-11-21 11:08:53 +01:00
var button = form.find('button');
button.prop('disabled', true);
2018-11-21 10:59:07 +01:00
$window.Stripe.createToken(form[0], function () {
2018-11-21 11:08:53 +01:00
var args = arguments;
2018-11-21 10:59:07 +01:00
scope.$apply(function () {
2018-11-21 11:08:53 +01:00
scope[attributes.stripeForm].apply(scope, args);
});
2018-11-21 10:59:07 +01:00
// button.prop('disabled', false);
2018-11-21 11:08:53 +01:00
});
});
};
return directive;
}]);