PluginProbe
Welcart e-Commerce / 1.3.8
Welcart e-Commerce v1.3.8
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 1.3.8, at js/usces_initial.js

198 lines 6.7 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 success: function(data, dataType){
9 var str = 'success' == data ? usces_ini.cod_updated : data;
10 $("#cod-response").html( str );
11 if( 'fix' == $("input[name='cod_type']:checked").val() ){
12 $('#cod_type_field').html(usces_ini.cod_type_fix);
13 }else if( 'change' == $("input[name='cod_type']:checked").val() ){
14 $('#cod_type_field').html(usces_ini.cod_type_change);
15 }
16 },
17 error: function(msg){
18 $("#cod-response").html(usces_ini.cod_failure);
19 }
20 },
21
22 send : function() {
23 $("#cod-response").html('<img src="' + uscesL10n.USCES_PLUGIN_URL + '/images/loading-publish.gif" />');
24 var query = 'action=setup_cod_ajax';
25 var cod_type = $("input[name='cod_type']:checked").val();
26
27 if( 'fix' == cod_type ){
28 var cod_fee = $("input[name='cod_fee']").val();
29 var cod_limit_amount = $("#cod_limit_amount_fix").val();
30 query += '&cod_type=' + cod_type + '&cod_fee=' + cod_fee + '&cod_limit_amount=' + cod_limit_amount;
31 }else{
32 var cod_first_amount = $("input[name='cod_first_amount']").val();
33 var cod_limit_amount = $("#cod_limit_amount_change").val();
34 var cod_first_fee = $("input[name='cod_first_fee']").val();
35 var cod_end_fee = $("input[name='cod_end_fee']").val();
36 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;
37 var amounts = $("input[name^='cod_amounts']");
38 for(var i=0; i<amounts.length; i++){
39 query += '&cod_amounts[]=' + $("input[name='cod_amounts\[" + i + "\]']").val() + '&cod_fees[]=' + $("input[name='cod_fees\[" + i + "\]']").val();
40 }
41 }
42
43
44 var s = codSend.settings;
45 s.data = query;
46 $.ajax( s );
47 return false;
48 }
49 };
50
51 $("#cod_dialog").dialog({
52 autoOpen: false,
53 height: 500,
54 width: 450,
55 modal: true,
56 buttons: {
57 'Cancel' : function() {
58 $(this).dialog('close');
59 },
60 'Update' : function() {
61 codSend.send();
62 }
63 },
64 close: function() {
65 if( 'fix' == $("input[name='cod_type']:checked").val() ){
66 $('#cod_type_field').html(usces_ini.cod_type_fix);
67 }else if( 'change' == $("input[name='cod_type']:checked").val() ){
68 $('#cod_type_field').html(usces_ini.cod_type_change);
69 }
70 }
71 });
72
73 $('#detailed_setting')
74 .click(function() {
75 $('#cod_dialog').dialog('open');
76 });
77
78 $('#cod_type_fix')
79 .click(function() {
80 $('#cod_fix_table').css("display","");
81 $('#cod_change_table').css("display","none");
82 });
83
84 $('#cod_type_change')
85 .click(function() {
86 $('#cod_fix_table').css("display","none");
87 $('#cod_change_table').css("display","");
88 });
89
90 $("input[name='cod_first_amount']")
91 .change(function() {
92 var trs = $("input[name^='cod_amounts']");
93 var first_amount = $("input[name='cod_first_amount']");
94 if( 0 == trs.length && $(first_amount).val() != '' ){
95 $("#end_amount").html(parseInt($(first_amount).val())+1);
96 }else if( 0 < trs.length && $(first_amount).val() != '' ){
97 $('#amount_0').html(parseInt($(first_amount).val())+1);
98 }
99
100 });
101
102 $("#cod_limit_amount_change")
103 .change(function() {
104 if( 'change' == $("input[name='cod_type']:checked").val() ){
105 var pre = parseInt($("#end_amount").html());
106 var limit = parseInt($("#cod_limit_amount_change").val());
107 if( pre >= limit ){
108 alert(usces_ini.cod_limit + pre + ':' + limit);
109 }
110 }
111 });
112
113 $("input[name^='cod_amounts']")
114 .change(function() {
115 var trs = $("input[name^='cod_amounts']");
116 var cnt = $(trs).length;
117 var id = $(trs).index(this);
118
119 if( id >= cnt-1 ){
120 $(end_amount).html( parseInt($(trs).eq(id).val()) + 1 );
121 }else if( id < cnt-1 ){
122 $('#amount_'+(id+1)).html( parseInt($(trs).eq(id).val()) + 1 );
123 }
124 });
125
126 $('#add_row')
127 .click(function() {
128 var trs = $("input[name^='cod_amounts']");
129 $(trs).unbind("change");
130 var first_amount = $("input[name='cod_first_amount']");
131 var first_fee = $("input[name='cod_first_fee']");
132 var end_amount = $("#end_amount");
133 var enf_fee = $("input[name='cod_enf_fee']");
134 //alert(parseInt(first_amount)+':'+first_fee+':'+end_amount+':'+enf_fee+':'+trs.length);
135 if( 0 == trs.length){
136 prep = ( $(first_amount).val() == '' ) ? '' : parseInt( $(first_amount).val() )+1;
137 }else if( 0 < trs.length){
138 prep = ( $(trs).eq(trs.length-1).val() == '' ) ? '' : parseInt( $(trs).eq(trs.length-1).val() )+1;
139 }
140 html = '<tr id="tr_'+trs.length+'"><td class="cod_f"><span id="amount_'+trs.length+'">' + prep + '</span></td><td class="cod_m">~</td><td class="cod_e"><input name="cod_amounts['+trs.length+']" type="text" class="short_str ui-widget-content ui-corner-all num" /></td><td class="cod_cod"><input name="cod_fees['+trs.length+']" type="text" class="short_str num" /></td></tr>';
141 $('#cod_change_field').append(html);
142 trs = $("input[name^='cod_amounts']");
143 $(trs).bind("change", function(){
144 var cnt = $(trs).length;
145 var id = $(trs).index(this);
146
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
197 });
198