var mobirise_swift = angular.module('Mobirise');
// Controller
mobirise_swift.controller('OwnersCtrl', function($scope,$http,$attrs,$window,$rootScope) {
$scope.init = function()
{
console.info('Hello from OwnersCtrl');
$scope.httpconfig = {
headers:{
'Authorization': 'Bearer ' + gJWT
}
};
$scope.notificationsended = false;
$scope.sending = false;
$scope.btniconclass = 'fa-envelope';
$scope.btnclass = 'btn-primary';
$scope.btnmessage = 'Envoyer votre demande';
}
$scope.contact = {
type:'owner'
};
$scope.recaptcha = {
key: '6Ldt9zgUAAAAAGCDq_e98Ltxx_gk4Y-SwNs-34di',
response:''
};
$scope.send = function($event) {
console.log($scope.contact);
var config = {
headers:{
'Authorization': 'Bearer ' + gJWT
}
};
$scope.sending = true;
$scope.btniconclass = 'fa-spinner fa-pulse';
// Send contact
$http.post('https://www.lorge.be/api/v1/notification',
{
type:'contact',
captcha:$scope.recaptcha.response,
contact:$scope.contact
},config).then(function (success){
if (typeof(success.data.success) == 'undefined' || success.data.success == false)
{
$scope.sending = false;
$scope.btnclass = 'btn-danger';
$scope.btniconclass = 'fa-times';
$scope.btnmessage = "Erreur lors de l'envoi";
return;
}
$scope.notificationsended = true;
$scope.sending = false;
$scope.btnclass = 'btn-success';
$scope.btniconclass = 'fa-check';
$scope.btnmessage = $sce.trustAsHtml('Demande envoyée');
});
$event.preventDefault();
};
});