|
1
|
|
|
(function($) { |
|
2
|
|
|
$.entwine('ecommerceUpdatePricing', function($) { |
|
3
|
|
|
$('#Root_Pricing').entwine({ |
|
4
|
|
|
onmatch : function() { |
|
5
|
|
|
UpdatePrices.init(); |
|
|
|
|
|
|
6
|
|
|
} |
|
7
|
|
|
}); |
|
8
|
|
|
|
|
9
|
|
|
}); |
|
10
|
|
|
|
|
11
|
|
|
}(jQuery)); |
|
12
|
|
|
|
|
13
|
|
|
UpdatePrices = { |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
parentElement: null, |
|
16
|
|
|
|
|
17
|
|
|
init: function() { |
|
18
|
|
|
this.parentElement = jQuery('#Root_Pricing') |
|
19
|
|
|
var countryCurrencies = jQuery.parseJSON(jQuery(UpdatePrices.parentElement).find('[name=CountryCurrencies]').val()); |
|
|
|
|
|
|
20
|
|
|
var fromField = jQuery(UpdatePrices.parentElement).find('#From select'); |
|
21
|
|
|
var toField = jQuery(UpdatePrices.parentElement).find('#To'); |
|
22
|
|
|
|
|
23
|
|
|
jQuery(fromField).change( |
|
24
|
|
|
function() { |
|
25
|
|
|
var code = jQuery(this).val(); |
|
26
|
|
|
var countries = new Array(); |
|
|
|
|
|
|
27
|
|
|
if(code in countryCurrencies) { |
|
28
|
|
|
var currency = countryCurrencies[code]; |
|
29
|
|
|
jQuery.each(countryCurrencies, function(countryCode, countryCurrency) { |
|
30
|
|
|
if(countryCurrency == currency && countryCode != code) { |
|
31
|
|
|
countries.push(countryCode); |
|
32
|
|
|
} |
|
33
|
|
|
}); |
|
34
|
|
|
} |
|
35
|
|
|
jQuery(toField).find('li').hide(); |
|
36
|
|
|
jQuery(toField).find(':checkbox').attr('checked', false); |
|
37
|
|
|
for(i = 0; i < countries.length; i++) { |
|
|
|
|
|
|
38
|
|
|
jQuery(toField).find('li.val' + countries[i]).show(); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
); |
|
42
|
|
|
jQuery(fromField).change(); |
|
43
|
|
|
|
|
44
|
|
|
jQuery(this.parentElement).find('#UpdatePriceLink a').click( |
|
45
|
|
|
function(event) { |
|
46
|
|
|
var fromCountry = jQuery(fromField).val(); |
|
47
|
|
|
var toCountries = jQuery(toField).find(':checkbox:checked'); |
|
48
|
|
|
if(fromCountry && jQuery(toCountries).length > 0) { |
|
49
|
|
|
var confirmation = confirm('Are you sure that you want to copy those prices over ?'); |
|
50
|
|
|
if(confirmation) { |
|
51
|
|
|
toCountries = jQuery.map(toCountries, function(element) { |
|
52
|
|
|
return jQuery(element).attr('value'); |
|
53
|
|
|
}); |
|
54
|
|
|
toCountries.join(','); |
|
55
|
|
|
var link = jQuery(this).attr('href'); |
|
56
|
|
|
link += '&' + jQuery(fromField).attr('name') + '=' + jQuery(fromField).val(); |
|
57
|
|
|
link += '&' + jQuery(toField).attr('id') + '=' + toCountries; |
|
58
|
|
|
alert(link); |
|
59
|
|
|
jQuery(this).attr('href', link); |
|
60
|
|
|
return true; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
event.preventDefault(); |
|
64
|
|
|
return false; |
|
65
|
|
|
} |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
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.