Skip to content

Commit

Permalink
[smarcet] - #13220
Browse files Browse the repository at this point in the history
* fixed js issue on older browers
* refactoring
* added ios redirection
  • Loading branch information
smarcet committed Sep 1, 2017
1 parent ad9a0b5 commit 45e1b4d
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions summit/javascript/forms/rsvp.form.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ $(document).ready(function () {
});

function addRSVP(form, event_id, summit_id, security_id) {
var url = `api/v1/summits/${summit_id}/schedule/${event_id}/rsvp?SecurityID=${security_id}`;
var modal_id = `#rsvpModal_${event_id}`;
var url = 'api/v1/summits/'+summit_id+'/schedule/'+event_id+'/rsvp?SecurityID='+security_id;
var modal_id = '#rsvpModal_'+event_id;

$.ajax({
type: 'POST',
Expand All @@ -75,42 +75,43 @@ function addRSVP(form, event_id, summit_id, security_id) {
text:"Your rsvp to this event was sent successfully.",
type: "success"
}).then(function () {



var is_mobile = bowser.mobile || bowser.tablet;
var is_ios = bowser.ios;
var is_android = bowser.android;

if(is_android){
var form = $('.rsvp_form');
var event_id = $('input[name="event_id"]', form).val();
window.location = "org.openstack.android.summit://events/"+event_id;
return;
}
else {
var url = new URI(window.location);
if (url.hasQuery("BackURL")) {
window.location = url.query(true)['BackURL'];
}
if(is_ios){
window.location = "org.openstack.ios.openstack-summit://events/"+event_id;
return;
}
var url = new URI(window.location);
if (url.hasQuery("BackURL")) {
window.location = url.query(true)['BackURL'];
return;
}

});
return;
}
else{
// close modal
var modal = $('#rsvpModal');
if(modal.length > 0)
modal.modal('hide');
}
// close modal
var modal = $('#rsvpModal');
if(modal.length > 0)
modal.modal('hide');

},
error: function (jqXHR, textStatus, errorThrown) {
$(modal_id).modal('hide');
var responseCode = jqXHR.status;
if(responseCode == 412) {
var response = $.parseJSON(jqXHR.responseText);
swal('Validation error', response.messages[0].message, 'warning');
} else {
swal('Error', 'There was a problem sending the rsvp, please contact admin.', 'warning');
return;
}

swal('Error', 'There was a problem sending the rsvp, please contact admin.', 'warning');
}
});
}

0 comments on commit 45e1b4d

Please sign in to comment.