PluginProbe
Welcart e-Commerce / 2.12.4
Welcart e-Commerce v2.12.4
2.12.4 2.12.3 2.11.35 2.12.2 2.12.1 2.11.34 2.11.33 2.11.32 2.11.31 2.11.30 1.3.16 1.3.17 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 All 292 releases
usc-e-shop / js / usces_initial.js

usces_initial.js in Welcart e-Commerce 2.12.4, at js/usces_initial.js

196 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function($) {
2
3 codSend = {
4 settings: {
5 url: uscesL10n.requestFile,
6 type: 'POST',
7 cache: false
8 },
9
10 send : function() {
11 $("#cod-response").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading-publish.gif" />');
12 var query = 'action=setup_cod_ajax&wc_nonce=' + $("#wc_nonce").val();
13 var cod_type = $("input[name='cod_type']:checked").val();
14
15 if( 'fix' == cod_type ){
16 var cod_fee = $("input[name='cod_fee']").val();
17 var cod_limit_amount = $("#cod_limit_amount_fix").val();
18 query += '&cod_type=' + cod_type + '&cod_fee=' + cod_fee + '&cod_limit_amount=' + cod_limit_amount;
19 }else{
20 var cod_first_amount = $("input[name='cod_first_amount']").val();
21 var cod_limit_amount = $("#cod_limit_amount_change").val();
22 var cod_first_fee = $("input[name='cod_first_fee']").val();
23 var cod_end_fee = $("input[name='cod_end_fee']").val();
24 query += '&cod_type=' + cod_type + '&cod_first_amount=' + cod_first_amount + '&cod_limit_amount=' + cod_limit_amount + '&cod_first_fee=' + cod_first_fee + '&cod_end_fee=' + cod_end_fee;
25 var amounts = $("input[name^='cod_amounts']");
26 for(var i=0; i<amounts.length; i++){
27 query += '&cod_amounts[]=' + $("input[name='cod_amounts\[" + i + "\]']").val() + '&cod_fees[]=' + $("input[name='cod_fees\[" + i + "\]']").val();
28 }
29 }
30
31 var s = codSend.settings;
32 s.data = query;
33 $.ajax( s ).done(function( data ){
34 var str = 'success' == data ? usces_ini.cod_updated : data;
35 $("#cod-response").html( str );
36 if( 'fix' == $("input[name='cod_type']:checked").val() ){
37 $('#cod_type_field').html(usces_ini.cod_type_fix);
38 }else if( 'change' == $("input[name='cod_type']:checked").val() ){
39 $('#cod_type_field').html(usces_ini.cod_type_change);
40 }
41 }).fail(function( msg ){
42 $("#cod-response").html(usces_ini.cod_failure);
43 });
44 return false;
45 }
46 };
47
48 $("#cod_dialog").dialog({
49 autoOpen: false,
50 height: 500,
51 width: 450,
52 modal: true,
53 buttons: [
54 {
55 text: usces_ini.cod_label_close,
56 click: function() {
57 $(this).dialog('close');
58 }
59 },
60 {
61 text: usces_ini.cod_label_update,
62 click: function() {
63 codSend.send();
64 }
65 }
66 ],
67 close: function() {
68 if( 'fix' == $("input[name='cod_type']:checked").val() ){
69 $('#cod_type_field').html(usces_ini.cod_type_fix);
70 }else if( 'change' == $("input[name='cod_type']:checked").val() ){
71 $('#cod_type_field').html(usces_ini.cod_type_change);
72 }
73 }
74 });
75
76 $('#detailed_setting')
77 .click(function() {
78 $('#cod_dialog').dialog('open');
79 });
80
81 $('#cod_type_fix')
82 .click(function() {
83 $('#cod_fix_table').css("display","");
84 $('#cod_change_table').css("display","none");
85 });
86
87 $('#cod_type_change')
88 .click(function() {
89 $('#cod_fix_table').css("display","none");
90 $('#cod_change_table').css("display","");
91 });
92
93 $("input[name='cod_first_amount']")
94 .change(function() {
95 var trs = $("input[name^='cod_amounts']");
96 var first_amount = $("input[name='cod_first_amount']");
97 if( 0 == trs.length && $(first_amount).val() != '' ){
98 $("#end_amount").html(parseInt($(first_amount).val())+1);
99 }else if( 0 < trs.length && $(first_amount).val() != '' ){
100 $('#amount_0').html(parseInt($(first_amount).val())+1);
101 }
102 });
103
104 $("#cod_limit_amount_change")
105 .change(function() {
106 if( 'change' == $("input[name='cod_type']:checked").val() ){
107 var pre = parseInt($("#end_amount").html());
108 var limit = parseInt($("#cod_limit_amount_change").val());
109 if( pre >= limit ){
110 alert(usces_ini.cod_limit + pre + ':' + limit);
111 }
112 }
113 });
114
115 $("input[name^='cod_amounts']")
116 .change(function() {
117 var trs = $("input[name^='cod_amounts']");
118 var cnt = $(trs).length;
119 var id = $(trs).index(this);
120 if( id >= cnt-1 ){
121 $(end_amount).html( parseInt($(trs).eq(id).val()) + 1 );
122 }else if( id < cnt-1 ){
123 $('#amount_'+(id+1)).html( parseInt($(trs).eq(id).val()) + 1 );
124 }
125 });
126
127 $('#add_row')
128 .click(function() {
129 var trs = $("input[name^='cod_amounts']");
130 $(trs).unbind("change");
131 var first_amount = $("input[name='cod_first_amount']");
132 var first_fee = $("input[name='cod_first_fee']");
133 var end_amount = $("#end_amount");
134 var enf_fee = $("input[name='cod_enf_fee']");
135 //alert(parseInt(first_amount)+':'+first_fee+':'+end_amount+':'+enf_fee+':'+trs.length);
136 if( 0 == trs.length){
137 prep = ( $(first_amount).val() == '' ) ? '' : parseInt( $(first_amount).val() )+1;
138 }else if( 0 < trs.length){
139 prep = ( $(trs).eq(trs.length-1).val() == '' ) ? '' : parseInt( $(trs).eq(trs.length-1).val() )+1;
140 }
141 html = '<tr id="tr_'+trs.length+'"><td class="cod_f"><span id="amount_'+trs.length+'">' + prep + '</span></td><td class="cod_m">'+uscesL10n.message[20]+'</td><td class="cod_e"><input name="cod_amounts['+trs.length+']" type="text" class="short_str num" /></td><td class="cod_cod"><input name="cod_fees['+trs.length+']" type="text" class="short_str num" /></td></tr>';
142 $('#cod_change_field').append(html);
143 trs = $("input[name^='cod_amounts']");
144 $(trs).bind("change", function(){
145 var cnt = $(trs).length;
146 var id = $(trs).index(this);
147 if( id >= cnt-1 ){
148 $(end_amount).html( parseInt($(trs).eq(id).val()) + 1 );
149 }else if( id < cnt-1 ){
150 $('#amount_'+(id+1)).html( parseInt($(trs).eq(id).val()) + 1 );
151 }
152 return false;
153 });
154 });
155
156 $('#del_row')
157 .click(function() {
158 var trs = $("input[name^='cod_amounts']");
159 $(trs).unbind("change");
160 var first_amount = $("input[name='cod_first_amount']");
161 var end_amount = $("#end_amount");
162 //alert(parseInt(first_amount)+':'+first_fee+':'+end_amount+':'+enf_fee+':'+trs.length);
163 var del_id = trs.length - 1;
164 //alert(trs.length);
165 if( 0 < trs.length){
166 $('#tr_'+del_id).remove();
167 }
168 trs = $("input[name^='cod_amounts']");
169 if( 0 == trs.length && $(first_amount).val() != '' ){
170 $(end_amount).html( parseInt($(first_amount).val())+1 );
171 }else if( 0 < trs.length && $(trs).eq(trs.length-1).val() != '' ){
172 $(end_amount).html( parseInt($(trs).eq(trs.length-1).val()) + 1 );
173 }
174 $(trs).bind("change", function(){
175 var cnt = $(trs).length;
176 var id = $(trs).index(this);
177
178 if( id >= cnt-1 && $(trs).eq(id).val() != '' ){
179 $(end_amount).html( parseInt($(trs).eq(id).val()) + 1 );
180 }else if( id < cnt-1 && $(trs).eq(id).val() != '' ){
181 $('#amount_'+(id+1)).html( parseInt($(trs).eq(id).val()) + 1 );
182 }
183 });
184 });
185
186 if( 'fix' == usces_ini.cod_type ){
187 $('#cod_type_field').html(usces_ini.cod_type_fix);
188 $('#cod_fix_table').css("display","");
189 $('#cod_change_table').css("display","none");
190 }else{
191 $('#cod_type_field').html(usces_ini.cod_type_change);
192 $('#cod_fix_table').css("display","none");
193 $('#cod_change_table').css("display","");
194 }
195 });
196