|
1
|
|
|
/** |
|
2
|
|
|
* |
|
3
|
|
|
* NOTICE OF LICENSE |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the GNU General Public License (GPL 3) |
|
6
|
|
|
* that is bundled with this package in the file LICENSE.txt |
|
7
|
|
|
* |
|
8
|
|
|
* DISCLAIMER |
|
9
|
|
|
* |
|
10
|
|
|
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer |
|
11
|
|
|
* versions in the future. If you wish to customize Payone_Core for your |
|
12
|
|
|
* needs please refer to http://www.payone.de for more information. |
|
13
|
|
|
* |
|
14
|
|
|
* @category Payone |
|
15
|
|
|
* @package js |
|
16
|
|
|
* @subpackage payone |
|
17
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
|
18
|
|
|
* @author Matthias Walter <[email protected]> |
|
19
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
|
20
|
|
|
* @link http://www.noovias.com |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @param element |
|
25
|
|
|
*/ |
|
26
|
|
|
function payoneSwitchSafeInvoice(element) |
|
27
|
|
|
{ |
|
28
|
|
|
if (element == undefined) { |
|
29
|
|
|
return; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
var ElementValue = element.value; |
|
33
|
|
|
var ElementValueSplit = ElementValue.split('_'); |
|
34
|
|
|
var typeId = ElementValueSplit[0]; |
|
35
|
|
|
var typeCode = ElementValueSplit[1]; |
|
36
|
|
|
$("payone_safe_invoice_sin_type").setValue(typeCode); |
|
37
|
|
|
$("payone_safe_invoice_config_id").setValue(typeId); |
|
38
|
|
|
|
|
39
|
|
|
var divOne = $('payone_klarna_invoice_terms_div'); |
|
40
|
|
|
var divTwo = $('payone_klarna_additional_fields'); |
|
41
|
|
|
|
|
42
|
|
|
if (divOne == undefined || divTwo == undefined) { |
|
43
|
|
|
return; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
if (typeCode == 'KLV'){ |
|
47
|
|
|
divOne.show(); |
|
48
|
|
|
divTwo.show(); |
|
49
|
|
|
} else { |
|
50
|
|
|
divOne.hide(); |
|
51
|
|
|
divTwo.hide(); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
Event.observe( |
|
|
|
|
|
|
56
|
|
|
document, "dom:loaded", function () { |
|
57
|
|
|
payoneSwitchSafeInvoice($('payone_safe_invoice_sin_type_select')); |
|
58
|
|
|
} |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
Event.observe( |
|
|
|
|
|
|
62
|
|
|
document, "dom:ready", function () { |
|
63
|
|
|
payoneSwitchSafeInvoice($('payone_safe_invoice_sin_type_select')); |
|
64
|
|
|
} |
|
65
|
|
|
); |
|
66
|
|
|
|
|
67
|
|
|
Ajax.Responders.register( |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
onComplete: function (transport, element) { |
|
70
|
|
|
var typeSelect = $('payone_safe_invoice_sin_type_select'); |
|
71
|
|
|
if (typeSelect == undefined) { |
|
72
|
|
|
return; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
var url = element.request.url; |
|
76
|
|
|
if (url.indexOf('checkout/onepage/saveShippingMethod') !== -1 || url.indexOf('checkout/onepage/progress') !== 1) { |
|
77
|
|
|
payoneSwitchSafeInvoice(typeSelect); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
); |
|
82
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.