@@ -150,31 +150,20 @@ require(["prototype"], function(){
150
150
$(this.checkingUpsXmlId[a]).removeClassName('required-entry');
151
151
}
152
152
for (a = 0; a < this.checkingUpsId.length; a++) {
153
- $(this.checkingUpsXmlId[a]).addClassName('required-entry');
153
+ $(this.checkingUpsId[a]).addClassName('required-entry');
154
+ this.changeFieldsDisabledState(this.checkingUpsId, a);
154
155
}
155
156
Event.stopObserving($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
156
157
showRowArrayElements(this.onlyUpsElements);
157
158
hideRowArrayElements(this.onlyUpsXmlElements);
158
159
this.changeOriginShipment(null, 'default');
159
160
} else {
160
161
for (a = 0; a < this.checkingUpsXmlId.length; a++) {
161
- if ($F(this.carriersUpsActiveId) === '1') {
162
- if ($(this.checkingUpsXmlId[a] + '_inherit') !== null
163
- && $F(this.checkingUpsXmlId[a] + '_inherit') === '1'
164
- ) {
165
- continue;
166
- }
167
- $(this.checkingUpsXmlId[a]).addClassName('required-entry').disabled = false;
168
- } else {
169
- $(this.checkingUpsXmlId[a]).removeClassName('required-entry').disabled = true;
170
- if ($(this.checkingUpsXmlId[a]).next() !== undefined) {
171
- $(this.checkingUpsXmlId[a]).removeClassName('mage-error').next().remove();
172
- $(this.checkingUpsXmlId[a]).removeAttribute('style');
173
- }
174
- }
162
+ $(this.checkingUpsXmlId[a]).addClassName('required-entry');
163
+ this.changeFieldsDisabledState(this.checkingUpsXmlId, a);
175
164
}
176
165
for (a = 0; a < this.checkingUpsId.length; a++) {
177
- $(this.checkingUpsXmlId [a]).removeClassName('required-entry');
166
+ $(this.checkingUpsId [a]).removeClassName('required-entry');
178
167
}
179
168
Event.observe($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
180
169
showRowArrayElements(this.onlyUpsXmlElements);
@@ -186,6 +175,16 @@ require(["prototype"], function(){
186
175
{
187
176
this.originShipmentTitle = key ? key : $F('carriers_ups_origin_shipment');
188
177
this.updateAllowedMethods(this.originShipmentTitle);
178
+ },
179
+ changeFieldsDisabledState: function (fields, key) {
180
+ $(fields[key]).disabled = $F(this.carriersUpsActiveId) !== '1'
181
+ || $(fields[key] + '_inherit') !== null
182
+ && $F(fields[key] + '_inherit') === '1';
183
+
184
+ if ($(fields[key]).next() !== undefined) {
185
+ $(fields[key]).removeClassName('mage-error').next().remove();
186
+ $(fields[key]).removeAttribute('style');
187
+ }
189
188
}
190
189
};
191
190
xml = new upsXml();
0 commit comments