Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax fix #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 38 additions & 26 deletions html/js/mondido.payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(!jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict
console.log(str);
}
};
window.do_log = do_log;

if (mondidoSettings.config.development == true) { do_log("Development mode is on"); }

Expand Down Expand Up @@ -67,14 +68,14 @@ if(!jQuery)throw new Error("Bootstrap requires jQuery");+function(a){"use strict
$('#country_code').val(str);
}

switch (mondidoSettings.metadataCountry) {
case 'Sweden':
switch (mondidoSettings.metadataCountry.toLowerCase()) {
case 'sweden':
setCountryCode('swe');
break;
case 'Norway':
case 'norway':
setCountryCode('nor');
break;
case 'Finland':
case 'finland':
setCountryCode('fin');
break;
default:
Expand Down Expand Up @@ -243,8 +244,6 @@ jQuery(function($) {
}

function ssn_lookup(ssn_value) {


var ssn = ssn_value;
var is_test = 'true';
var country_code = mondidoSettings.country_code.toLowerCase();
Expand All @@ -257,9 +256,9 @@ jQuery(function($) {
ssn = ssn.slice(2);
}

console.log("country_code ->" + country_code.toLowerCase());
console.log("ssn length ->" +ssn.length);
console.log( $_mondido_ssn_load_value);
do_log("country_code ->" + country_code.toLowerCase());
do_log("ssn length ->" +ssn.length);
do_log( $_mondido_ssn_load_value);

if (ssn_value == $_mondido_ssn_load_value) {
return false;
Expand All @@ -268,7 +267,7 @@ jQuery(function($) {
if (country_code.toLowerCase() == "swe" && ssn.length < 10) {
$('#row-customer-details').addClass('hidden');
$('#row-ssn-details-loading').addClass('hidden');
console.log("lock ssn" + country_code.toLowerCase());
do_log("lock ssn" + country_code.toLowerCase());
return false;
}

Expand Down Expand Up @@ -333,6 +332,9 @@ jQuery(function($) {
} else {

$('#ssn').addClass('hidden');
var loading_ssn = $("#row-ssn-details-loading");

loading_ssn.removeClass('hidden');
var jqxhr = $.get(ssn_url, function() {}).done(function(address) {
$_mondido_ssn_load_value = ssn;

Expand Down Expand Up @@ -379,6 +381,7 @@ jQuery(function($) {
});

}
loading_ssn.addClass('hidden');
});
}
}
Expand Down Expand Up @@ -544,15 +547,6 @@ jQuery(function($) {
$('#swish_number').val(sn);
});

$('#invoiceform').submit(function(e) {
if ($('#accept')[0].checked == false) {
alert('Du behöver godkänna villkoren.');
return false;
}
return true;
});


$('#mondidopayform').submit(function(e) {
var errString = $("#validation-error").text() + "\n";

Expand Down Expand Up @@ -673,13 +667,7 @@ jQuery(function($) {
ssn_lookup($('#ssn').val(), ssn_lookup);
}

$(document).ajaxStart(function() {
loading_ssn.removeClass('hidden');
});

$(document).ajaxStop(function() {
loading_ssn.addClass('hidden');
});
});

function validate_email(email) {
Expand Down Expand Up @@ -713,7 +701,14 @@ function validate_phone(phone_number) {
if (phone_number == null) {
return false
}

phone_number = phone_number.replace(/\s/g,'');
if (phone_number.charAt(0) === "+") {
phone_number = phone_number.slice(1);
}
if (phone_number.charAt(0) === "0") {
phone_number = phone_number.slice(1);
}
$('#phone').val(phone_number);
valid = ((phone_number.length >= 8) && (phone_number.length <= 11));
if (valid) {
$('#phone').addClass('valid');
Expand Down Expand Up @@ -937,6 +932,23 @@ String.prototype.removeEnd = function(s) {

(function() {

$('#swishform').on('submit', function() {
$('#paybtn-swish').hide();
});

$('#paypalform').on('submit', function() {
$('#paybtn-paypal').hide();
});
$('#invoiceform').submit(function(e) {
if ($('#accept')[0].checked == false) {
alert('Du behöver godkänna villkoren.');
return false;
}

$('#paybtn').hide();
return true;
});

$('#mondidopayform').on('submit', function() {
var checks = true;
var errString = $('#validation-error').text().replace(/\s+/, "");
Expand Down