Version Notes
Release History :
v2.4.1
* add support for Magestore OneStepCheckout
* bug fix - if county field is hidden, don't populate it
v2.4.0
* major rework. Keeping compatible with the growing list of one-page-checkout extensions was a pain.
* now using the Magento prototype JS framework to do most of the heavy lifiting. Less tweaks to .phtml files means we can better maintain compativility with all possible checkout layouts.
v2.3.3
* no changes - repackaged to keep Magento Connect happy
v 2.3.2
* update to GoMage integration
v 2.3.1
* workaround for Firefox 4 bug
v 2.3.0
* updated to support Magento v 1.5
v 2.2.0
* added support for Gomage Light Checkout
v 2.1.0
* added support for One Step Checkout
v 2.0.2
* fix layout problem on in IE8 on onepage checkout
v 2.0.1
* fix minor typo in default config
v 2.0
* big re-design for compatibility with Magento 1.4
* added ability to search by house name/number + postcode (previous versions can search by postcode only)
* pressing enter key in the postcode input field does a search
v 1.6.2
* fix for Internet Explorer in admin panel - new customer page; the add address button didn't always work
* use default country in admin pannel - Magento doesn't do this by default
* in one page checkout unhide billing address fields on 'continue' - this esures any error messages are placed correctly if parts of the address are missing
v 1.6.1
* fix for admin panel - sales pages; Added a 1s delay before CraftyClicks stuff is added to a form.
In some rare cases the timing was such that the form may not yet exist in DOM when we tried to add
address finder button etc.
v 1.6.0
* added address lookup to the admin panel, to change order of address fields please see the
documentation tab - http://www.magentocommerce.com/boards/viewchild/17082/
v 1.5.1
* small modification following tests with the blank theme (changed order of initialisation in JavaScript)
v 1.5.0
* add config option for 1st result line.
* avoid using JavaScript DOM for modifying address forms - it was conflicting with Magento JavaScript.
We now edit the template .phtml files directly.
* fix problems with re-displaying state select box when country is changed from UK to USA.
* fix problem with postcode error message affecting button position if form was submitted with a blank postcode.
v 1.4.0
* make error message class configurable - it can now be styled to match other Magento errors
* make error message text configurable
* fix issue with error message not being shown if hiding of address fields was enabled
v 1.3.0
* populate the company field if company name is available
* unhide all address lines on lookup error to allow customer to enter the address manually
* update to latest CraftyClicks JavaScript (v3.5):
- added the on_error event
- fixed selection of result using keyboard (got broken in latest Firefox v3.5)
v 1.2.0
* can now hide the region/province (county) field
* update to latest CraftyClicks JavaScript (v3.4)
v 1.1.2 (bug fix release)
* fix typo in JS code
v 1.1.1 (bug fix release)
* fix rearranging address fields order; was causing problems on one page checkout
* fix hiding of result box on result select
* hide result box on country change
v 1.1.0
* added Admin Panel options to configure look and feel of the module
* add address lookup to multiship checkout pages
v 1.0.0 - Initial Release
Release Info
Developer | Magento Core Team |
Extension | UK_Postcode_Address_Finder |
Version | 2.4.1 |
Comparing to | |
See all releases |
Code changes from version 2.4.0 to 2.4.1
- app/code/local/CraftyClicks/etc/config.xml +1 -1
- app/etc/modules/CraftyClicks.xml +1 -1
- js/craftyclicks/crafty_mage_onepage.js~ +0 -237
- js/craftyclicks/craftyclicks_gomage_lightcheckout.js +5 -1
- js/craftyclicks/craftyclicks_magento.js +5 -1
- js/craftyclicks/craftyclicks_magento.js~ +0 -370
- js/craftyclicks/craftyclicks_magento_multiship.js~ +0 -323
- js/craftyclicks/craftyclicks_onepagecheckout.js +25 -6
- package.xml +8 -4
@@ -12,7 +12,7 @@
|
|
12 |
<config>
|
13 |
<modules>
|
14 |
<CraftyClicks>
|
15 |
-
<version>2.4.
|
16 |
</CraftyClicks>
|
17 |
</modules>
|
18 |
|
12 |
<config>
|
13 |
<modules>
|
14 |
<CraftyClicks>
|
15 |
+
<version>2.4.1</version>
|
16 |
</CraftyClicks>
|
17 |
</modules>
|
18 |
|
@@ -4,7 +4,7 @@
|
|
4 |
<CraftyClicks>
|
5 |
<active>true</active>
|
6 |
<codePool>local</codePool>
|
7 |
-
<version>2.4.
|
8 |
</CraftyClicks>
|
9 |
</modules>
|
10 |
</config>
|
4 |
<CraftyClicks>
|
5 |
<active>true</active>
|
6 |
<codePool>local</codePool>
|
7 |
+
<version>2.4.1</version>
|
8 |
</CraftyClicks>
|
9 |
</modules>
|
10 |
</config>
|
@@ -1,237 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
// This is a collection of JavaScript code to allow easy integration of
|
3 |
-
// postcode / address finder functionality into magento
|
4 |
-
//
|
5 |
-
// Provided by www.CraftyClicks.co.uk
|
6 |
-
//
|
7 |
-
// Based on CraftyClicks JS Version - 4.9.1 (23/03/2011)
|
8 |
-
//
|
9 |
-
// If you copy/use/modify this code - please keep this
|
10 |
-
// comment header in place
|
11 |
-
//
|
12 |
-
// This code relies on prototype js, you must have a reasonably recent version loaded
|
13 |
-
// in your template. Magento should include it as standard.
|
14 |
-
//
|
15 |
-
// If you need any help, contact support@craftyclicks.co.uk - we will help!
|
16 |
-
//
|
17 |
-
**********************************************************************************/
|
18 |
-
|
19 |
-
var _cp_li_class = '';
|
20 |
-
var _cp_div_class = '';
|
21 |
-
|
22 |
-
var _cp_checkout_type = 'OnePageCheckout';
|
23 |
-
|
24 |
-
var _cp_setup =
|
25 |
-
[{
|
26 |
-
"prefix" : "billing",
|
27 |
-
"fields" : { "postcode_id" : "billing:postcode",
|
28 |
-
"company_id" : "billing:company",
|
29 |
-
"street1_id" : "billing:street1",
|
30 |
-
"street2_id" : "billing:street2",
|
31 |
-
"street3_id" : "billing:street3",
|
32 |
-
"town_id" : "billing:city",
|
33 |
-
"county_id" : "billing:region",
|
34 |
-
"country_id" : "billing:country_id" },
|
35 |
-
"lookup_ready" : 0,
|
36 |
-
"old_postcode_width" : 0,
|
37 |
-
"cp_obj" : 0,
|
38 |
-
"orig_postcode_li" : 0,
|
39 |
-
"div_depth" : 0
|
40 |
-
},
|
41 |
-
{
|
42 |
-
"prefix" : "shipping",
|
43 |
-
"fields" : { "postcode_id" : "shipping:postcode",
|
44 |
-
"company_id" : "shipping:company",
|
45 |
-
"street1_id" : "shipping:street1",
|
46 |
-
"street2_id" : "shipping:street2",
|
47 |
-
"street3_id" : "shipping:street3",
|
48 |
-
"town_id" : "shipping:city",
|
49 |
-
"county_id" : "shipping:region",
|
50 |
-
"country_id" : "shipping:country_id" },
|
51 |
-
"lookup_ready" : 0,
|
52 |
-
"old_postcode_width" : 0,
|
53 |
-
"cp_obj" : 0,
|
54 |
-
"orig_postcode_li" : 0,
|
55 |
-
"div_depth" : 0
|
56 |
-
}];
|
57 |
-
|
58 |
-
function _cp_elem_move(e1, e2) {
|
59 |
-
e1.insert({after : e2});
|
60 |
-
}
|
61 |
-
|
62 |
-
function _cp_rearrange_fields(setup) {
|
63 |
-
var fields = setup.fields;
|
64 |
-
// test element id format, some templates don't follow the magento default naming...
|
65 |
-
if (!$(setup.fields.postcode_id)) {
|
66 |
-
// try an underscore
|
67 |
-
if ($(setup.fields.postcode_id.replace(":", "_"))) {
|
68 |
-
alert("underscores!");
|
69 |
-
for (ii in setup.fields) {
|
70 |
-
setup.fields[ii] = setup.fields[ii].replace(":", "_");
|
71 |
-
}
|
72 |
-
}
|
73 |
-
}
|
74 |
-
|
75 |
-
|
76 |
-
// test div depth - some magento temlates wrap fields in two layers of div in a li
|
77 |
-
var div_depth = 0;
|
78 |
-
if ($(setup.fields.postcode_id).up('div', 1).descendantOf($(fields.postcode_id).up('li'))) div_depth = 1;
|
79 |
-
setup.div_depth = div_depth;
|
80 |
-
//alert("_cp_rearrange_fields div_depth ="+div_depth);
|
81 |
-
|
82 |
-
setup.orig_postcode_li = $(fields.postcode_id).up('li'); // remember the default place for postcode, we migth have to move it about
|
83 |
-
|
84 |
-
// order: country, postcode, company (if we have it), street1, street2, street3 (if we have it), town
|
85 |
-
var li_list = [ $(fields.country_id).up('li') ];
|
86 |
-
var idx = 1;
|
87 |
-
|
88 |
-
// is postcode bundled with country?
|
89 |
-
if ($(fields.country_id).up('li') == $(fields.postcode_id).up('li')) {
|
90 |
-
// yes, so make sure postcode comes after country
|
91 |
-
_cp_elem_move($(setup.fields.country_id).up('div', div_depth), $(setup.fields.postcode_id).up('div', div_depth));
|
92 |
-
} else {
|
93 |
-
// postcode on a separate li, add it to the list
|
94 |
-
li_list[idx] = $(fields.postcode_id).up('li'); idx++;
|
95 |
-
}
|
96 |
-
|
97 |
-
var ne = $(fields.company_id);
|
98 |
-
if (ne) {
|
99 |
-
li_list[idx] = ne.up('li'); idx++;
|
100 |
-
}
|
101 |
-
li_list[idx] = $(fields.street1_id).up('li'); idx++;
|
102 |
-
ne = $(fields.street2_id);
|
103 |
-
if (ne) {
|
104 |
-
li_list[idx] = ne.up('li'); idx++;
|
105 |
-
}
|
106 |
-
ne = $(fields.street3_id);
|
107 |
-
if (ne) {
|
108 |
-
li_list[idx] = ne.up('li'); idx++;
|
109 |
-
}
|
110 |
-
li_list[idx] = $(fields.town_id).up('li'); idx++;
|
111 |
-
|
112 |
-
// is the State/Province (county) field bundled with postcode field?
|
113 |
-
if ($(fields.postcode_id).up('li') == $(fields.county_id).up('li')) {
|
114 |
-
// yes, so move the county together with the town
|
115 |
-
_cp_elem_move($(setup.fields.town_id).up('div', div_depth), $(setup.fields.county_id).up('div', div_depth));
|
116 |
-
// if the postocde div has got 'input-postcode' class, remove it - it isn't needed once postcode is on its own line and breaks button position!
|
117 |
-
if ($(setup.fields.postcode_id).up('div', div_depth).hasClassName('input-postcode')) $(setup.fields.postcode_id).up('div', div_depth).removeClassName('input-postcode');
|
118 |
-
}
|
119 |
-
|
120 |
-
for (var ii = 0; ii < idx; ii++) {
|
121 |
-
_cp_elem_move(li_list[ii], li_list[ii+1]);
|
122 |
-
}
|
123 |
-
// add result box (hidden initialy)
|
124 |
-
var tmp_html = '<li '+_cp_li_class+' style="display: none"><label> </label><div class="input-box" id="'+setup.prefix+'_cp_result_display"> </div></li>';
|
125 |
-
$(setup.fields.postcode_id).up('li').insert( {after: tmp_html} );
|
126 |
-
// create button (hidden initially)
|
127 |
-
tmp_html = ' <button type="button" style="display: none" id="'+setup.prefix+'_cp_button_id" class="'+_cp_button_class+'" onclick="_cp_instances['+_cp_instance_idx+'].doLookup()"><span><span>'+_cp_button_text+'</span></span></button>';
|
128 |
-
$(setup.fields.postcode_id).insert( {after : tmp_html} );
|
129 |
-
// add placeholder for postcode (hidden initially)
|
130 |
-
$(setup.fields.town_id).up('li').insert( {after: '<li '+_cp_li_class+' style="display: none" id="'+setup.prefix+'_cp_postcode_placeholder_id"></li>'} );
|
131 |
-
}
|
132 |
-
|
133 |
-
function _cp_add_lookup_fields(setup) {
|
134 |
-
// check if we need to do anything
|
135 |
-
if (!setup.lookup_ready) {
|
136 |
-
// do the magic for UK
|
137 |
-
// move postcode to the top
|
138 |
-
$(setup.orig_postcode_li).insert( $(setup.fields.postcode_id).up('div', setup.div_depth) );
|
139 |
-
// shrink postcode field if needed
|
140 |
-
if ('' != _cp_postcode_field_width) {
|
141 |
-
setup.old_postcode_width = $(setup.fields.postcode_id).getStyle("width");
|
142 |
-
$(setup.fields.postcode_id).setStyle({width: _cp_postcode_field_width});
|
143 |
-
}
|
144 |
-
// hide the placeholder li
|
145 |
-
if ($(setup.prefix+"_cp_postcode_placeholder_id")) $(setup.prefix+"_cp_postcode_placeholder_id").hide();
|
146 |
-
// show result box
|
147 |
-
$(setup.prefix+"_cp_result_display").up('li').show();
|
148 |
-
// show button
|
149 |
-
$(setup.prefix+"_cp_button_id").show();
|
150 |
-
// set state
|
151 |
-
setup.lookup_ready = 1;
|
152 |
-
}
|
153 |
-
}
|
154 |
-
|
155 |
-
function _cp_remove_lookup_fields(setup) {
|
156 |
-
// check if we need to do anything
|
157 |
-
if (setup.lookup_ready) {
|
158 |
-
// hide result box
|
159 |
-
setup.cp_obj.update_res(null);
|
160 |
-
$(setup.prefix+"_cp_result_display").up('li').hide();
|
161 |
-
// hide button
|
162 |
-
$(setup.prefix+"_cp_button_id").hide();
|
163 |
-
// show the placeholder li and move the postcode field there
|
164 |
-
$(setup.prefix+"_cp_postcode_placeholder_id").show();
|
165 |
-
$(setup.prefix+"_cp_postcode_placeholder_id").insert( $(setup.fields.postcode_id).up('div', setup.div_depth) );
|
166 |
-
// restore postcode field width if needed
|
167 |
-
if (setup.old_postcode_width) {
|
168 |
-
$(setup.fields.postcode_id).setStyle({width: setup.old_postcode_width});
|
169 |
-
}
|
170 |
-
// set state
|
171 |
-
setup.lookup_ready = 0;
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
function _cp_add_lookup(setup) {
|
176 |
-
cp_obj = CraftyPostcodeCreate();
|
177 |
-
setup.cp_obj = cp_obj;
|
178 |
-
// config
|
179 |
-
cp_obj.set("access_token", _cp_token_fe);
|
180 |
-
cp_obj.set("res_autoselect", "0");
|
181 |
-
cp_obj.set("result_elem_id", setup.prefix+"_cp_result_display");
|
182 |
-
cp_obj.set("form", "");
|
183 |
-
cp_obj.set("elem_company" , setup.fields.company_id); // optional
|
184 |
-
cp_obj.set("elem_street1" , setup.fields.street1_id);
|
185 |
-
cp_obj.set("elem_street2" , setup.fields.street2_id);
|
186 |
-
cp_obj.set("elem_street3" , setup.fields.street3_id);
|
187 |
-
cp_obj.set("elem_town" , setup.fields.town_id);
|
188 |
-
cp_obj.set("elem_county" , setup.fields.county_id); // optional
|
189 |
-
cp_obj.set("elem_postcode" , setup.fields.postcode_id);
|
190 |
-
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
191 |
-
cp_obj.set("max_width" , _cp_result_box_width);
|
192 |
-
if (1 < _cp_result_box_height) {
|
193 |
-
cp_obj.set("first_res_line", "");
|
194 |
-
cp_obj.set("max_lines" , _cp_result_box_height);
|
195 |
-
} else {
|
196 |
-
cp_obj.set("first_res_line", "----- please select your address ----");
|
197 |
-
cp_obj.set("max_lines" , 1);
|
198 |
-
}
|
199 |
-
cp_obj.set("busy_img_url" , _cp_busy_img_url);
|
200 |
-
cp_obj.set("hide_result" , _cp_hide_result);
|
201 |
-
cp_obj.set("traditional_county" , 1);
|
202 |
-
|
203 |
-
|
204 |
-
// initial page setup
|
205 |
-
_cp_rearrange_fields(setup);
|
206 |
-
|
207 |
-
if (_cp_enable_for_uk_only) {
|
208 |
-
_cp_country_process(setup);
|
209 |
-
$(setup.fields.country_id).observe('change', _cp_country_changed.bindAsEventListener(setup));
|
210 |
-
} else {
|
211 |
-
_cp_add_lookup_fields(setup);
|
212 |
-
}
|
213 |
-
}
|
214 |
-
|
215 |
-
function _cp_country_changed(e) {
|
216 |
-
// set the right context for the handler
|
217 |
-
_cp_country_process(this);
|
218 |
-
}
|
219 |
-
|
220 |
-
function _cp_country_process(setup) {
|
221 |
-
// show postcode lookup for:
|
222 |
-
// "GB" UK
|
223 |
-
// "JE" Jersey
|
224 |
-
// "GG" Guernsey
|
225 |
-
// "IM" Isle of Man
|
226 |
-
var curr_country = $(setup.fields.country_id).getValue();
|
227 |
-
if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
|
228 |
-
_cp_add_lookup_fields(setup);
|
229 |
-
} else {
|
230 |
-
_cp_remove_lookup_fields(setup);
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
document.observe("dom:loaded", function() {
|
235 |
-
_cp_add_lookup(_cp_setup[0]);
|
236 |
-
_cp_add_lookup(_cp_setup[1]);
|
237 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -210,7 +210,11 @@ function CraftyClicksMagentoClass () {
|
|
210 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
211 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
212 |
cp_obj.set("elem_town" , this.fields.town_id);
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
215 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
216 |
cp_obj.set("max_width" , _cp_result_box_width);
|
210 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
211 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
212 |
cp_obj.set("elem_town" , this.fields.town_id);
|
213 |
+
if (_cp_hide_county) {
|
214 |
+
cp_obj.set("elem_county" , ""); // optional
|
215 |
+
} else {
|
216 |
+
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
217 |
+
}
|
218 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
219 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
220 |
cp_obj.set("max_width" , _cp_result_box_width);
|
@@ -239,7 +239,11 @@ function CraftyClicksMagentoClass () {
|
|
239 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
240 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
241 |
cp_obj.set("elem_town" , this.fields.town_id);
|
242 |
-
|
|
|
|
|
|
|
|
|
243 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
244 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
245 |
cp_obj.set("max_width" , _cp_result_box_width);
|
239 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
240 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
241 |
cp_obj.set("elem_town" , this.fields.town_id);
|
242 |
+
if (_cp_hide_county) {
|
243 |
+
cp_obj.set("elem_county" , ""); // optional
|
244 |
+
} else {
|
245 |
+
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
246 |
+
}
|
247 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
248 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
249 |
cp_obj.set("max_width" , _cp_result_box_width);
|
@@ -1,370 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
// This is a collection of JavaScript code to allow easy integration of
|
3 |
-
// the Crafty Clicks postcode / address finder functionality into Magento
|
4 |
-
//
|
5 |
-
// Provided by www.CraftyClicks.co.uk
|
6 |
-
//
|
7 |
-
// Requires standard CraftyClicks JS - tested with v4.9.1
|
8 |
-
//
|
9 |
-
// If you copy/use/modify this code - please keep this
|
10 |
-
// comment header in place
|
11 |
-
//
|
12 |
-
// Copyright (c) 2009-2012 Crafty Clicks (http://www.craftyclicks.com)
|
13 |
-
//
|
14 |
-
// This code relies on prototype js, you must have a reasonably recent version loaded
|
15 |
-
// in your template. Magento should include it as standard.
|
16 |
-
//
|
17 |
-
// If you need any help, contact support@craftyclicks.co.uk - we will help!
|
18 |
-
//
|
19 |
-
**********************************************************************************/
|
20 |
-
function CraftyClicksMagentoClass () {
|
21 |
-
this.prefix = "";
|
22 |
-
this.fields = { "postcode_id" : "", // required
|
23 |
-
"company_id" : "", // optional
|
24 |
-
"street1_id" : "", // required
|
25 |
-
"street2_id" : "", // optional
|
26 |
-
"street3_id" : "", // optional
|
27 |
-
"street4_id" : "", // optional
|
28 |
-
"town_id" : "", // required
|
29 |
-
"county_id" : "", // optional
|
30 |
-
"country_id" : "", // required
|
31 |
-
"email_id" : "" // required
|
32 |
-
};
|
33 |
-
|
34 |
-
this.current_setup = 'initial'; // can be 'uk' or 'non_uk'
|
35 |
-
this.uk_postcode_width = ''
|
36 |
-
this.old_postcode_width = '';
|
37 |
-
this.cp_obj = 0;
|
38 |
-
this.div_depth = 0;
|
39 |
-
this.li_class = "fields";
|
40 |
-
|
41 |
-
this.elem_move = function(e1, e2) {
|
42 |
-
e1.insert({after : e2});
|
43 |
-
}
|
44 |
-
|
45 |
-
// test div depth - some magento temlates wrap fields in two layers of div in a li
|
46 |
-
this.set_div_depth = function() {
|
47 |
-
if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('li'))) {
|
48 |
-
this.div_depth = 1;
|
49 |
-
}
|
50 |
-
}
|
51 |
-
|
52 |
-
this.rearrange_fields = function() {
|
53 |
-
var fields = this.fields;
|
54 |
-
// postcode should be bundled with country in the same li on the standard magento address templates
|
55 |
-
// if this isn't the case, the rest of this code unlikely to work!
|
56 |
-
if ($(fields.country_id).up('li') == $(fields.postcode_id).up('li')) {
|
57 |
-
|
58 |
-
if ('' != $(fields.town_id).getValue()) {
|
59 |
-
_cp_hide_fields = false;
|
60 |
-
}
|
61 |
-
|
62 |
-
// order for non-UK: country, company (if we have it), street1, street2, street3 (if we have it), town, county (if we have it), postcode
|
63 |
-
var li_list = [ $(fields.country_id).up('li') ];
|
64 |
-
var idx = 1;
|
65 |
-
|
66 |
-
var ne = $(fields.company_id);
|
67 |
-
if (ne) {
|
68 |
-
// check if the email address is bundled with the company - on some templates it is and we then should separate it out.
|
69 |
-
if ($(fields.email_id) && ne.up('li') == $(fields.email_id).up('li')) {
|
70 |
-
// create a new li to hold the company on its own
|
71 |
-
$(fields.street1_id).up('li').insert( {before: '<li '+this.li_class+' id="'+this.prefix+'_company_placeholder_id"></li>'} );
|
72 |
-
$(this.prefix+"_company_placeholder_id").insert( $(fields.company_id).up('div', this.div_depth) );
|
73 |
-
ne = $(fields.company_id);
|
74 |
-
}
|
75 |
-
li_list[idx] = ne.up('li'); idx++;
|
76 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
77 |
-
}
|
78 |
-
|
79 |
-
li_list[idx] = $(fields.street1_id).up('li'); idx++;
|
80 |
-
$(fields.street1_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
81 |
-
ne = $(fields.street2_id);
|
82 |
-
if (ne) {
|
83 |
-
li_list[idx] = ne.up('li'); idx++;
|
84 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
85 |
-
}
|
86 |
-
ne = $(fields.street3_id);
|
87 |
-
if (ne) {
|
88 |
-
li_list[idx] = ne.up('li'); idx++;
|
89 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
90 |
-
}
|
91 |
-
ne = $(fields.street4_id);
|
92 |
-
if (ne) {
|
93 |
-
li_list[idx] = ne.up('li'); idx++;
|
94 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
95 |
-
}
|
96 |
-
li_list[idx] = $(fields.town_id).up('li'); idx++; // town and county are on the same li, so will move together
|
97 |
-
$(fields.town_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
98 |
-
|
99 |
-
for (var ii = 0; ii < idx; ii++) {
|
100 |
-
this.elem_move(li_list[ii], li_list[ii+1]);
|
101 |
-
}
|
102 |
-
|
103 |
-
// create a new li to hold the postcode on its own
|
104 |
-
$(fields.town_id).up('li').insert( {after: '<li '+this.li_class+' id="'+this.prefix+'_cp_postcode_placeholder_id"></li>'} );
|
105 |
-
$(this.prefix+"_cp_postcode_placeholder_id").insert( $(this.fields.postcode_id).up('div', this.div_depth) );
|
106 |
-
|
107 |
-
// check postcode field width, longer than 350px means we are on a magento enterprise template and we need to shrink things a bit
|
108 |
-
// so the lookup button fits on the form next to the postcode field
|
109 |
-
var pcWidth = parseInt($(this.fields.postcode_id).getStyle("width"));
|
110 |
-
if (350 < pcWidth) {
|
111 |
-
this.uk_postcode_width = '100px';
|
112 |
-
}
|
113 |
-
|
114 |
-
// move the telephone above the address - we move it only if we hide other address fields
|
115 |
-
ne = $(fields.telephone_id);
|
116 |
-
if (_cp_hide_fields && ne) {
|
117 |
-
// telephone may be bundled with company, if so separate it out
|
118 |
-
if ($(fields.company_id) && ne.up('li') == $(fields.company_id).up('li')) {
|
119 |
-
// create a new li to hold the telephone on its own at the top of the address
|
120 |
-
$(fields.country_id).up('li').insert( {before: '<li '+this.li_class+' id="'+this.prefix+'_telephone_placeholder_id"></li>'} );
|
121 |
-
$(this.prefix+"_telephone_placeholder_id").insert( ne.up('div', this.div_depth) );
|
122 |
-
} else {
|
123 |
-
// telephone is probably on its own, or with fax
|
124 |
-
$(fields.country_id).up('li').insert({before : ne.up('li')});
|
125 |
-
}
|
126 |
-
}
|
127 |
-
return (true);
|
128 |
-
} else {
|
129 |
-
return (false);
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
this.setup_for_uk = function() {
|
134 |
-
// check if we need to do anything
|
135 |
-
if ('uk' != this.current_setup) {
|
136 |
-
// do the magic for UK
|
137 |
-
// move postcode to the uk position after the country li
|
138 |
-
$(this.fields.country_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
139 |
-
// add result box
|
140 |
-
if (!$(this.prefix+'_cp_result_display')) {
|
141 |
-
var tmp_html = '<li '+this.li_class+' style="display: none"><label> </label><div class="input-box" id="'+this.prefix+'_cp_result_display"> </div></li>';
|
142 |
-
$(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
|
143 |
-
}
|
144 |
-
// show result box
|
145 |
-
$(this.prefix+"_cp_result_display").up('li').show();
|
146 |
-
// add button
|
147 |
-
if (!$(this.prefix+'_cp_button_div_id')) {
|
148 |
-
var tmp_html = '';
|
149 |
-
if (0 == this.div_depth) {
|
150 |
-
tmp_html = '<div class="field" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id"> </label><div class="input-box">';
|
151 |
-
} else {
|
152 |
-
tmp_html = '<div class="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id"> </label>';
|
153 |
-
}
|
154 |
-
if ('' != _cp_button_image) {
|
155 |
-
tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
|
156 |
-
} else {
|
157 |
-
tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
|
158 |
-
}
|
159 |
-
if (0 == this.div_depth) {
|
160 |
-
tmp_html += '</div>';
|
161 |
-
} else {
|
162 |
-
tmp_html += '</div></div>';
|
163 |
-
}
|
164 |
-
$(this.fields.postcode_id).up('div', this.div_depth).insert( {after : tmp_html} );
|
165 |
-
$(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
|
166 |
-
}
|
167 |
-
// show button
|
168 |
-
$(this.prefix+"_cp_button_div_id").show();
|
169 |
-
|
170 |
-
// shrink postcode field if needed
|
171 |
-
if ('' != this.uk_postcode_width) {
|
172 |
-
this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
|
173 |
-
$(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
|
174 |
-
}
|
175 |
-
|
176 |
-
// hide county if requested (and if it exists in the html at all)
|
177 |
-
if (_cp_hide_county) {
|
178 |
-
ne = $(this.fields.county_id);
|
179 |
-
if (ne) {
|
180 |
-
ne.up('div', this.div_depth).hide();
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
|
185 |
-
if ('initial' == this.current_setup && _cp_hide_fields) {
|
186 |
-
// first time and default to UK, hide address fields
|
187 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('hide');
|
188 |
-
}
|
189 |
-
|
190 |
-
// set state
|
191 |
-
this.current_setup = 'uk';
|
192 |
-
}
|
193 |
-
|
194 |
-
this.setup_for_non_uk = function() {
|
195 |
-
// check if we need to do anything
|
196 |
-
if ('non_uk' != this.current_setup) {
|
197 |
-
// hide result box (if it exist already)
|
198 |
-
if ($(this.prefix+"_cp_result_display")) {
|
199 |
-
this.cp_obj.update_res(null);
|
200 |
-
$(this.prefix+"_cp_result_display").up('li').hide();
|
201 |
-
}
|
202 |
-
// hide button (if it exist already)
|
203 |
-
if ($(this.prefix+"_cp_button_div_id")) {
|
204 |
-
$(this.prefix+"_cp_button_div_id").hide();
|
205 |
-
}
|
206 |
-
// move postcode to the non-uk position after the town/county li
|
207 |
-
$(this.fields.town_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
208 |
-
// restore postcode field width if needed
|
209 |
-
if ('' != this.old_postcode_width) {
|
210 |
-
$(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
|
211 |
-
}
|
212 |
-
// show county if it was hidden (and exists in the html at all)
|
213 |
-
if (_cp_hide_county) {
|
214 |
-
ne = $(this.fields.county_id);
|
215 |
-
if (ne) {
|
216 |
-
ne.up('div', this.div_depth).show();
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
// show all other addres lines
|
221 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
222 |
-
// set state
|
223 |
-
this.current_setup = 'non_uk';
|
224 |
-
}
|
225 |
-
}
|
226 |
-
|
227 |
-
this.add_lookup = function(setup) {
|
228 |
-
cp_obj = CraftyPostcodeCreate();
|
229 |
-
this.cp_obj = cp_obj;
|
230 |
-
// config
|
231 |
-
this.prefix = setup.prefix;
|
232 |
-
this.fields = setup.fields;
|
233 |
-
cp_obj.set("access_token", _cp_token_fe);
|
234 |
-
cp_obj.set("res_autoselect", "0");
|
235 |
-
cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
|
236 |
-
cp_obj.set("form", "");
|
237 |
-
cp_obj.set("elem_company" , this.fields.company_id); // optional
|
238 |
-
cp_obj.set("elem_street1" , this.fields.street1_id);
|
239 |
-
cp_obj.set("elem_street2" , this.fields.street2_id);
|
240 |
-
cp_obj.set("elem_street3" , this.fields.street3_id);
|
241 |
-
cp_obj.set("elem_town" , this.fields.town_id);
|
242 |
-
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
243 |
-
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
244 |
-
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
245 |
-
cp_obj.set("max_width" , _cp_result_box_width);
|
246 |
-
if (1 < _cp_result_box_height) {
|
247 |
-
cp_obj.set("first_res_line", "");
|
248 |
-
cp_obj.set("max_lines" , _cp_result_box_height);
|
249 |
-
} else {
|
250 |
-
cp_obj.set("first_res_line", "----- please select your address ----");
|
251 |
-
cp_obj.set("max_lines" , 1);
|
252 |
-
}
|
253 |
-
cp_obj.set("busy_img_url" , _cp_busy_img_url);
|
254 |
-
cp_obj.set("hide_result" , _cp_clear_result);
|
255 |
-
cp_obj.set("traditional_county" , 1);
|
256 |
-
cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
|
257 |
-
cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
|
258 |
-
cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
|
259 |
-
cp_obj.set("first_res_line", _cp_1st_res_line);
|
260 |
-
cp_obj.set("err_msg1", _cp_err_msg1);
|
261 |
-
cp_obj.set("err_msg2", _cp_err_msg2);
|
262 |
-
cp_obj.set("err_msg3", _cp_err_msg3);
|
263 |
-
cp_obj.set("err_msg4", _cp_err_msg4);
|
264 |
-
// initial page setup
|
265 |
-
this.set_div_depth();
|
266 |
-
if (this.rearrange_fields()) {
|
267 |
-
if (_cp_enable_for_uk_only) {
|
268 |
-
this.country_changed();
|
269 |
-
$(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
|
270 |
-
} else {
|
271 |
-
this.setup_for_uk();
|
272 |
-
}
|
273 |
-
} else {
|
274 |
-
// alert ('Postcode Lookup could not be added!');
|
275 |
-
}
|
276 |
-
}
|
277 |
-
|
278 |
-
this.country_changed = function(e) {
|
279 |
-
// show postcode lookup for:
|
280 |
-
// "GB" UK
|
281 |
-
// "JE" Jersey
|
282 |
-
// "GG" Guernsey
|
283 |
-
// "IM" Isle of Man
|
284 |
-
var curr_country = $(this.fields.country_id).getValue();
|
285 |
-
if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
|
286 |
-
this.setup_for_uk();
|
287 |
-
} else {
|
288 |
-
this.setup_for_non_uk();
|
289 |
-
}
|
290 |
-
}
|
291 |
-
|
292 |
-
this.button_clicked = function(e) {
|
293 |
-
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
|
294 |
-
this.cp_obj.doLookup();
|
295 |
-
}
|
296 |
-
|
297 |
-
this.result_ready = function() {
|
298 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
299 |
-
}
|
300 |
-
|
301 |
-
this.result_selected = function() {
|
302 |
-
if (_cp_clear_result) this.cp_obj.update_res(null);
|
303 |
-
}
|
304 |
-
|
305 |
-
this.result_error = function() {
|
306 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
307 |
-
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
document.observe("dom:loaded", function() {
|
312 |
-
|
313 |
-
if (!_cp_integrate) return;
|
314 |
-
|
315 |
-
if ($("billing:postcode")) {
|
316 |
-
var cc1 = new CraftyClicksMagentoClass();
|
317 |
-
cc1.add_lookup({
|
318 |
-
"prefix" : "billing",
|
319 |
-
"fields" : { "postcode_id" : "billing:postcode",
|
320 |
-
"company_id" : "billing:company",
|
321 |
-
"street1_id" : "billing:street1",
|
322 |
-
"street2_id" : "billing:street2",
|
323 |
-
"street3_id" : "billing:street3",
|
324 |
-
"street4_id" : "billing:street4",
|
325 |
-
"town_id" : "billing:city",
|
326 |
-
"county_id" : "billing:region",
|
327 |
-
"country_id" : "billing:country_id",
|
328 |
-
"email_id" : "billing:email",
|
329 |
-
"telephone_id": "billing:telephone" }
|
330 |
-
});
|
331 |
-
}
|
332 |
-
|
333 |
-
if ($("shipping:postcode")) {
|
334 |
-
var cc2 = new CraftyClicksMagentoClass();
|
335 |
-
cc2.add_lookup({
|
336 |
-
"prefix" : "shipping",
|
337 |
-
"fields" : { "postcode_id" : "shipping:postcode",
|
338 |
-
"company_id" : "shipping:company",
|
339 |
-
"street1_id" : "shipping:street1",
|
340 |
-
"street2_id" : "shipping:street2",
|
341 |
-
"street3_id" : "shipping:street3",
|
342 |
-
"street4_id" : "shipping:street4",
|
343 |
-
"town_id" : "shipping:city",
|
344 |
-
"county_id" : "shipping:region",
|
345 |
-
"country_id" : "shipping:country_id",
|
346 |
-
"email_id" : "shipping:email",
|
347 |
-
"telephone_id": "shipping:telephone" }
|
348 |
-
});
|
349 |
-
}
|
350 |
-
|
351 |
-
if ($("zip")) {
|
352 |
-
var cc3 = new CraftyClicksMagentoClass();
|
353 |
-
cc3.add_lookup({
|
354 |
-
"prefix" : "",
|
355 |
-
"fields" : { "postcode_id" : "zip",
|
356 |
-
"company_id" : "company",
|
357 |
-
"street1_id" : "street_1",
|
358 |
-
"street2_id" : "street_2",
|
359 |
-
"street3_id" : "street_3",
|
360 |
-
"street4_id" : "street_4",
|
361 |
-
"town_id" : "city",
|
362 |
-
"county_id" : "region",
|
363 |
-
"country_id" : "country",
|
364 |
-
"email_id" : "email_address",
|
365 |
-
"telephone_id": "telephone" }
|
366 |
-
});
|
367 |
-
}
|
368 |
-
|
369 |
-
});
|
370 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,323 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
// This is a collection of JavaScript code to allow easy integration of
|
3 |
-
// the Crafty Clicks postcode / address finder functionality into Magento
|
4 |
-
//
|
5 |
-
// Provided by www.CraftyClicks.co.uk
|
6 |
-
//
|
7 |
-
// Requires standard CraftyClicks JS - tested with v4.9.1
|
8 |
-
//
|
9 |
-
// If you copy/use/modify this code - please keep this
|
10 |
-
// comment header in place
|
11 |
-
//
|
12 |
-
// This code relies on prototype js, you must have a reasonably recent version loaded
|
13 |
-
// in your template. Magento should include it as standard.
|
14 |
-
//
|
15 |
-
// If you need any help, contact support@craftyclicks.co.uk - we will help!
|
16 |
-
//
|
17 |
-
**********************************************************************************/
|
18 |
-
function CraftyClicksMagentoClass () {
|
19 |
-
this.prefix = "";
|
20 |
-
this.fields = { "postcode_id" : "", // required
|
21 |
-
"company_id" : "", // optional
|
22 |
-
"street1_id" : "", // required
|
23 |
-
"street2_id" : "", // optional
|
24 |
-
"street3_id" : "", // optional
|
25 |
-
"street4_id" : "", // optional
|
26 |
-
"town_id" : "", // required
|
27 |
-
"county_id" : "", // optional
|
28 |
-
"country_id" : "", // required
|
29 |
-
"email_id" : "" // required
|
30 |
-
};
|
31 |
-
|
32 |
-
this.current_setup = 'initial'; // can be 'uk' or 'non_uk'
|
33 |
-
this.uk_postcode_width = ''
|
34 |
-
this.old_postcode_width = '';
|
35 |
-
this.cp_obj = 0;
|
36 |
-
this.uk_postcode_marker = 0;
|
37 |
-
this.div_depth = 0;
|
38 |
-
this.li_class = "fields";
|
39 |
-
|
40 |
-
this.elem_move = function(e1, e2) {
|
41 |
-
e1.insert({after : e2});
|
42 |
-
}
|
43 |
-
|
44 |
-
// test div depth - some magento temlates wrap fields in two layers of div in a li
|
45 |
-
this.set_div_depth = function() {
|
46 |
-
if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('li'))) {
|
47 |
-
this.div_depth = 1;
|
48 |
-
}
|
49 |
-
}
|
50 |
-
|
51 |
-
this.rearrange_fields = function() {
|
52 |
-
var fields = this.fields;
|
53 |
-
// postcode should be bundled with country in the same li on the standard magento address templates
|
54 |
-
// if this isn't the case, the rest of this code unlikely to work!
|
55 |
-
if ($(fields.country_id).up('li') == $(fields.postcode_id).up('li')) {
|
56 |
-
// order for non-UK: country, company (if we have it), street1, street2, street3 (if we have it), town, county (if we have it), postcode
|
57 |
-
var li_list = [ $(fields.country_id).up('li') ];
|
58 |
-
var idx = 1;
|
59 |
-
|
60 |
-
var ne = $(fields.company_id);
|
61 |
-
if (ne) {
|
62 |
-
// check if the email address is bundled with the company - on some templates it is and we then should separate it out.
|
63 |
-
if ($(fields.email_id) && ne.up('li') == $(fields.email_id).up('li')) {
|
64 |
-
// create a new li to hold the company on its own
|
65 |
-
$(fields.street1_id).up('li').insert( {before: '<li '+this.li_class+' id="'+this.prefix+'_company_placeholder_id"></li>'} );
|
66 |
-
$(this.prefix+"_company_placeholder_id").insert( $(fields.company_id).up('div', this.div_depth) );
|
67 |
-
ne = $(fields.company_id);
|
68 |
-
}
|
69 |
-
li_list[idx] = ne.up('li'); idx++;
|
70 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
71 |
-
}
|
72 |
-
|
73 |
-
li_list[idx] = $(fields.street1_id).up('li'); idx++;
|
74 |
-
$(fields.street1_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
75 |
-
ne = $(fields.street2_id);
|
76 |
-
if (ne) {
|
77 |
-
li_list[idx] = ne.up('li'); idx++;
|
78 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
79 |
-
}
|
80 |
-
ne = $(fields.street3_id);
|
81 |
-
if (ne) {
|
82 |
-
li_list[idx] = ne.up('li'); idx++;
|
83 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
84 |
-
}
|
85 |
-
ne = $(fields.street4_id);
|
86 |
-
if (ne) {
|
87 |
-
li_list[idx] = ne.up('li'); idx++;
|
88 |
-
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
89 |
-
}
|
90 |
-
li_list[idx] = $(fields.town_id).up('li'); idx++; // town and county are on the same li, so will move together
|
91 |
-
$(fields.town_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
92 |
-
|
93 |
-
for (var ii = 0; ii < idx; ii++) {
|
94 |
-
this.elem_move(li_list[ii], li_list[ii+1]);
|
95 |
-
}
|
96 |
-
|
97 |
-
// create a new li to hold the postcode on its own
|
98 |
-
$(fields.town_id).up('li').insert( {after: '<li '+this.li_class+' id="'+this.prefix+'_cp_postcode_placeholder_id"></li>'} );
|
99 |
-
$(this.prefix+"_cp_postcode_placeholder_id").insert( $(this.fields.postcode_id).up('div', this.div_depth) );
|
100 |
-
|
101 |
-
// check postcode field width, longer than 350px means we are on a magento enterprise template and we need to shrink things a bit
|
102 |
-
// so the lookup button fits on the form next to the postcode field
|
103 |
-
var pcWidth = parseInt($(this.fields.postcode_id).getStyle("width"));
|
104 |
-
if (350 < pcWidth) {
|
105 |
-
this.uk_postcode_width = '100px';
|
106 |
-
}
|
107 |
-
|
108 |
-
// check if the telephone field is bundled with the company - on some templates it is and we then should separate it out.
|
109 |
-
ne = $(fields.telephone_id);
|
110 |
-
var ne1 = $(fields.company_id);
|
111 |
-
if (ne && ne1 && ne.up('li') == ne1.up('li')) {
|
112 |
-
// create a new li to hold the company on its own
|
113 |
-
$(fields.street1_id).up('li').insert( {before: '<li '+this.li_class+' id="'+this.prefix+'_company_placeholder_id"></li>'} );
|
114 |
-
$(this.prefix+"_company_placeholder_id").insert( $(fields.company_id).up('div', this.div_depth) );
|
115 |
-
ne = $(fields.company_id);
|
116 |
-
}
|
117 |
-
// move the telephone above the address
|
118 |
-
if (ne) {
|
119 |
-
if ($(fields.country_id).up('li') == ne.up('li')) {
|
120 |
-
// create a new li to hold the postcode on its own
|
121 |
-
$(fields.town_id).up('li').insert( {after: '<li '+this.li_class+' id="'+this.prefix+'_cp_postcode_placeholder_id"></li>'} );
|
122 |
-
$(this.prefix+"_cp_postcode_placeholder_id").insert( $(this.fields.postcode_id).up('div', this.div_depth) );
|
123 |
-
}
|
124 |
-
|
125 |
-
.insert({before : ne.up('li')});
|
126 |
-
}
|
127 |
-
return (true);
|
128 |
-
} else {
|
129 |
-
return (false);
|
130 |
-
}
|
131 |
-
}
|
132 |
-
|
133 |
-
this.setup_for_uk = function() {
|
134 |
-
// check if we need to do anything
|
135 |
-
if ('uk' != this.current_setup) {
|
136 |
-
// do the magic for UK
|
137 |
-
// move postcode to the uk position after the country li
|
138 |
-
$(this.fields.country_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
139 |
-
// add result box
|
140 |
-
if (!$(this.prefix+'_cp_result_display')) {
|
141 |
-
var tmp_html = '<li '+this.li_class+' style="display: none"><label> </label><div class="input-box" id="'+this.prefix+'_cp_result_display"> </div></li>';
|
142 |
-
$(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
|
143 |
-
}
|
144 |
-
// show result box
|
145 |
-
$(this.prefix+"_cp_result_display").up('li').show();
|
146 |
-
// add button
|
147 |
-
if (!$(this.prefix+'_cp_button_div_id')) {
|
148 |
-
// var tmp_html = '<div id="'+this.prefix+'_cp_button_div_id"> <button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+ '"><span><span>'+_cp_button_text+'</span></span></button></div>';
|
149 |
-
var tmp_html = '<div class="field" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id"> </label><div class="input-box">';
|
150 |
-
if ('' != _cp_button_image) {
|
151 |
-
tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
|
152 |
-
} else {
|
153 |
-
tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
|
154 |
-
}
|
155 |
-
tmp_html += '</div></div>';
|
156 |
-
$(this.fields.postcode_id).up('div', 1).insert( {after : tmp_html} );
|
157 |
-
$(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
|
158 |
-
}
|
159 |
-
// show button
|
160 |
-
$(this.prefix+"_cp_button_div_id").show();
|
161 |
-
|
162 |
-
// shrink postcode field if needed
|
163 |
-
if ('' != this.uk_postcode_width) {
|
164 |
-
this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
|
165 |
-
$(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
|
166 |
-
}
|
167 |
-
|
168 |
-
// hide county if requested (and if it exists in the html at all)
|
169 |
-
if (_cp_hide_county) {
|
170 |
-
ne = $(this.fields.county_id);
|
171 |
-
if (ne) {
|
172 |
-
ne.up('div', this.div_depth).hide();
|
173 |
-
}
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
if ('initial' == this.current_setup && _cp_hide_fields) {
|
178 |
-
// first time and default to UK, hide address fields
|
179 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('hide');
|
180 |
-
}
|
181 |
-
|
182 |
-
// set state
|
183 |
-
this.current_setup = 'uk';
|
184 |
-
}
|
185 |
-
|
186 |
-
this.setup_for_non_uk = function() {
|
187 |
-
// check if we need to do anything
|
188 |
-
if ('non_uk' != this.current_setup) {
|
189 |
-
// hide result box (if it exist already)
|
190 |
-
if ($(this.prefix+"_cp_result_display")) {
|
191 |
-
this.cp_obj.update_res(null);
|
192 |
-
$(this.prefix+"_cp_result_display").up('li').hide();
|
193 |
-
}
|
194 |
-
// hide button (if it exist already)
|
195 |
-
if ($(this.prefix+"_cp_button_div_id")) {
|
196 |
-
$(this.prefix+"_cp_button_div_id").hide();
|
197 |
-
}
|
198 |
-
// move postcode to the non-uk position after the town/county li
|
199 |
-
$(this.fields.town_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
200 |
-
// restore postcode field width if needed
|
201 |
-
if ('' != this.old_postcode_width) {
|
202 |
-
$(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
|
203 |
-
}
|
204 |
-
// show county if it was hidden (and exists in the html at all)
|
205 |
-
if (_cp_hide_county) {
|
206 |
-
ne = $(this.fields.county_id);
|
207 |
-
if (ne) {
|
208 |
-
ne.up('div', this.div_depth).show();
|
209 |
-
}
|
210 |
-
}
|
211 |
-
|
212 |
-
// show all other addres lines
|
213 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
214 |
-
// set state
|
215 |
-
this.current_setup = 'non_uk';
|
216 |
-
}
|
217 |
-
}
|
218 |
-
|
219 |
-
this.add_lookup = function(setup) {
|
220 |
-
cp_obj = CraftyPostcodeCreate();
|
221 |
-
this.cp_obj = cp_obj;
|
222 |
-
// config
|
223 |
-
this.prefix = setup.prefix;
|
224 |
-
this.fields = setup.fields;
|
225 |
-
cp_obj.set("access_token", _cp_token_fe);
|
226 |
-
cp_obj.set("res_autoselect", "0");
|
227 |
-
cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
|
228 |
-
cp_obj.set("form", "");
|
229 |
-
cp_obj.set("elem_company" , this.fields.company_id); // optional
|
230 |
-
cp_obj.set("elem_street1" , this.fields.street1_id);
|
231 |
-
cp_obj.set("elem_street2" , this.fields.street2_id);
|
232 |
-
cp_obj.set("elem_street3" , this.fields.street3_id);
|
233 |
-
cp_obj.set("elem_town" , this.fields.town_id);
|
234 |
-
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
235 |
-
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
236 |
-
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
237 |
-
cp_obj.set("max_width" , _cp_result_box_width);
|
238 |
-
if (1 < _cp_result_box_height) {
|
239 |
-
cp_obj.set("first_res_line", "");
|
240 |
-
cp_obj.set("max_lines" , _cp_result_box_height);
|
241 |
-
} else {
|
242 |
-
cp_obj.set("first_res_line", "----- please select your address ----");
|
243 |
-
cp_obj.set("max_lines" , 1);
|
244 |
-
}
|
245 |
-
cp_obj.set("busy_img_url" , _cp_busy_img_url);
|
246 |
-
cp_obj.set("hide_result" , _cp_clear_result);
|
247 |
-
cp_obj.set("traditional_county" , 1);
|
248 |
-
cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
|
249 |
-
cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
|
250 |
-
cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
|
251 |
-
cp_obj.set("first_res_line", _cp_1st_res_line);
|
252 |
-
cp_obj.set("err_msg1", _cp_err_msg1);
|
253 |
-
cp_obj.set("err_msg2", _cp_err_msg2);
|
254 |
-
cp_obj.set("err_msg3", _cp_err_msg3);
|
255 |
-
cp_obj.set("err_msg4", _cp_err_msg4);
|
256 |
-
// initial page setup
|
257 |
-
this.set_div_depth();
|
258 |
-
if (this.rearrange_fields()) {
|
259 |
-
if (_cp_enable_for_uk_only) {
|
260 |
-
this.country_changed();
|
261 |
-
$(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
|
262 |
-
} else {
|
263 |
-
this.setup_for_uk();
|
264 |
-
}
|
265 |
-
} else {
|
266 |
-
alert ('could not do it!!!');
|
267 |
-
}
|
268 |
-
}
|
269 |
-
|
270 |
-
this.country_changed = function(e) {
|
271 |
-
// show postcode lookup for:
|
272 |
-
// "GB" UK
|
273 |
-
// "JE" Jersey
|
274 |
-
// "GG" Guernsey
|
275 |
-
// "IM" Isle of Man
|
276 |
-
var curr_country = $(this.fields.country_id).getValue();
|
277 |
-
if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
|
278 |
-
this.setup_for_uk();
|
279 |
-
} else {
|
280 |
-
this.setup_for_non_uk();
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
this.button_clicked = function(e) {
|
285 |
-
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
|
286 |
-
this.cp_obj.doLookup();
|
287 |
-
}
|
288 |
-
|
289 |
-
this.result_ready = function() {
|
290 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
291 |
-
}
|
292 |
-
|
293 |
-
this.result_selected = function() {
|
294 |
-
if (_cp_clear_result) this.cp_obj.update_res(null);
|
295 |
-
}
|
296 |
-
|
297 |
-
this.result_error = function() {
|
298 |
-
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
299 |
-
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
|
300 |
-
}
|
301 |
-
}
|
302 |
-
|
303 |
-
document.observe("dom:loaded", function() {
|
304 |
-
if ($("zip")) {
|
305 |
-
var cc3 = new CraftyClicksMagentoClass();
|
306 |
-
cc3.add_lookup({
|
307 |
-
"prefix" : "",
|
308 |
-
"fields" : { "postcode_id" : "zip",
|
309 |
-
"company_id" : "company",
|
310 |
-
"street1_id" : "street_1",
|
311 |
-
"street2_id" : "street_2",
|
312 |
-
"street3_id" : "street_3",
|
313 |
-
"street4_id" : "street_4",
|
314 |
-
"town_id" : "city",
|
315 |
-
"county_id" : "region",
|
316 |
-
"country_id" : "country",
|
317 |
-
"email_id" : "email_address",
|
318 |
-
"telephone_id": "telephone" }
|
319 |
-
});
|
320 |
-
}
|
321 |
-
|
322 |
-
});
|
323 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,10 +1,14 @@
|
|
1 |
/*
|
2 |
// This is a collection of JavaScript code to allow easy integration of
|
3 |
-
// the Crafty Clicks postcode / address finder functionality into
|
4 |
-
//
|
5 |
//
|
|
|
6 |
// http://www.magentocommerce.com/magento-connect/one-step-checkout-version-3.html
|
7 |
//
|
|
|
|
|
|
|
8 |
// Provided by www.CraftyClicks.co.uk
|
9 |
//
|
10 |
// Requires standard CraftyClicks JS - tested with v4.9.1
|
@@ -28,8 +32,8 @@ function CraftyClicksMagentoClass () {
|
|
28 |
"street2_id" : "", // optional
|
29 |
"street3_id" : "", // optional
|
30 |
"street4_id" : "", // optional
|
31 |
-
"town_id"
|
32 |
-
"county_id"
|
33 |
"country_id" : "" // required
|
34 |
};
|
35 |
|
@@ -60,13 +64,24 @@ function CraftyClicksMagentoClass () {
|
|
60 |
_cp_hide_fields = false;
|
61 |
}
|
62 |
|
63 |
-
// postcode could be bundled with county/state in the same li on the OSC templates
|
64 |
if ($(fields.county_id) && $(fields.county_id).up('li') == $(fields.postcode_id).up('li')) {
|
65 |
// create a new li to hold the county on its own and put it after the town
|
66 |
if ($(fields.town_id)) {
|
67 |
$(fields.town_id).up('li').insert( {after: '<li class="'+this.li_class+'" id="'+this.prefix+'_county_placeholder_id"></li>'} );
|
68 |
$(this.prefix+"_county_placeholder_id").insert( $(fields.county_id).up('div', this.div_depth) );
|
69 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
|
72 |
if ($(fields.company_id)) {
|
@@ -210,7 +225,11 @@ function CraftyClicksMagentoClass () {
|
|
210 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
211 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
212 |
cp_obj.set("elem_town" , this.fields.town_id);
|
213 |
-
|
|
|
|
|
|
|
|
|
214 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
215 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
216 |
cp_obj.set("max_width" , _cp_result_box_width);
|
1 |
/*
|
2 |
// This is a collection of JavaScript code to allow easy integration of
|
3 |
+
// the Crafty Clicks postcode / address finder functionality into these
|
4 |
+
// checkout extensions :
|
5 |
//
|
6 |
+
// OneStepCheckout extension for Magento (www.onestepcheckout.com)
|
7 |
// http://www.magentocommerce.com/magento-connect/one-step-checkout-version-3.html
|
8 |
//
|
9 |
+
// Magestore OneStepCheckout (www.magestore.com)
|
10 |
+
// http://www.magentocommerce.com/magento-connect/one-step-checkout-4908.html
|
11 |
+
//
|
12 |
// Provided by www.CraftyClicks.co.uk
|
13 |
//
|
14 |
// Requires standard CraftyClicks JS - tested with v4.9.1
|
32 |
"street2_id" : "", // optional
|
33 |
"street3_id" : "", // optional
|
34 |
"street4_id" : "", // optional
|
35 |
+
"town_id" : "", // required
|
36 |
+
"county_id" : "", // optional
|
37 |
"country_id" : "" // required
|
38 |
};
|
39 |
|
64 |
_cp_hide_fields = false;
|
65 |
}
|
66 |
|
67 |
+
// postcode could be bundled with county/state or with town in the same li on the OSC templates
|
68 |
if ($(fields.county_id) && $(fields.county_id).up('li') == $(fields.postcode_id).up('li')) {
|
69 |
// create a new li to hold the county on its own and put it after the town
|
70 |
if ($(fields.town_id)) {
|
71 |
$(fields.town_id).up('li').insert( {after: '<li class="'+this.li_class+'" id="'+this.prefix+'_county_placeholder_id"></li>'} );
|
72 |
$(this.prefix+"_county_placeholder_id").insert( $(fields.county_id).up('div', this.div_depth) );
|
73 |
}
|
74 |
+
} else if ($(fields.town_id) && $(fields.town_id).up('li') == $(fields.postcode_id).up('li')) {
|
75 |
+
// create a new li to hold the town on its own and put it after the postcode for now
|
76 |
+
$(fields.postcode_id).up('li').insert( {after: '<li class="'+this.li_class+'" id="'+this.prefix+'_county_placeholder_id"></li>'} );
|
77 |
+
$(this.prefix+"_county_placeholder_id").insert( $(fields.town_id).up('div', this.div_depth) );
|
78 |
+
// we probably have the state/county field sitting with the country - separate
|
79 |
+
if ($(fields.county_id) && $(fields.county_id).up('li') == $(fields.country_id).up('li')) {
|
80 |
+
// put county with the town
|
81 |
+
$(fields.town_id).up('div', this.div_depth).insert( {after: $(fields.county_id).up('div', this.div_depth)} );
|
82 |
+
}
|
83 |
+
// and now move country to the top
|
84 |
+
$(fields.street1_id).up('li').insert( {before: $(fields.country_id).up('li')} );
|
85 |
}
|
86 |
|
87 |
if ($(fields.company_id)) {
|
225 |
cp_obj.set("elem_street2" , this.fields.street2_id);
|
226 |
cp_obj.set("elem_street3" , this.fields.street3_id);
|
227 |
cp_obj.set("elem_town" , this.fields.town_id);
|
228 |
+
if (_cp_hide_county) {
|
229 |
+
cp_obj.set("elem_county" , ""); // optional
|
230 |
+
} else {
|
231 |
+
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
232 |
+
}
|
233 |
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
234 |
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
235 |
cp_obj.set("max_width" , _cp_result_box_width);
|
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>UK_Postcode_Address_Finder</name>
|
4 |
-
<version>2.4.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -15,6 +15,10 @@ UK address entry is greatly speeded up thus improving the user experience. The b
|
|
15 |

|
16 |
The extension is free to try and install, but to go live a paid up account with Crafty Clicks will be required. For current prices please go to http://www.craftyclicks.co.uk/paf-database-pricing</description>
|
17 |
<notes>Release History :
|
|
|
|
|
|
|
|
|
18 |
v2.4.0
|
19 |
* major rework. Keeping compatible with the growing list of one-page-checkout extensions was a pain. 
|
20 |
* now using the Magento prototype JS framework to do most of the heavy lifiting. Less tweaks to .phtml files means we can better maintain compativility with all possible checkout layouts.
|
@@ -102,9 +106,9 @@ v 1.1.0 
|
|
102 |

|
103 |
v 1.0.0 - Initial Release</notes>
|
104 |
<authors><author><name>Crafty Clicks</name><user>auto-converted</user><email>support@craftyclicks.co.uk</email></author></authors>
|
105 |
-
<date>2012-
|
106 |
-
<time>
|
107 |
-
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="CraftyClicks"><dir name="Helper"><file name="Data.php" hash="e5f75947ad629aabb2e3cbcde412e2cc"/></dir><dir name="etc"><file name="config.xml" hash="
|
108 |
<compatible/>
|
109 |
<dependencies/>
|
110 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>UK_Postcode_Address_Finder</name>
|
4 |
+
<version>2.4.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
15 |

|
16 |
The extension is free to try and install, but to go live a paid up account with Crafty Clicks will be required. For current prices please go to http://www.craftyclicks.co.uk/paf-database-pricing</description>
|
17 |
<notes>Release History :
|
18 |
+
v2.4.1
|
19 |
+
* add support for Magestore OneStepCheckout
|
20 |
+
* bug fix - if county field is hidden, don't populate it
|
21 |
+

|
22 |
v2.4.0
|
23 |
* major rework. Keeping compatible with the growing list of one-page-checkout extensions was a pain. 
|
24 |
* now using the Magento prototype JS framework to do most of the heavy lifiting. Less tweaks to .phtml files means we can better maintain compativility with all possible checkout layouts.
|
106 |

|
107 |
v 1.0.0 - Initial Release</notes>
|
108 |
<authors><author><name>Crafty Clicks</name><user>auto-converted</user><email>support@craftyclicks.co.uk</email></author></authors>
|
109 |
+
<date>2012-05-11</date>
|
110 |
+
<time>22:06:44</time>
|
111 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="local"><dir name="CraftyClicks"><dir name="Helper"><file name="Data.php" hash="e5f75947ad629aabb2e3cbcde412e2cc"/></dir><dir name="etc"><file name="config.xml" hash="e04bf5b7922fbcf92020270656d459d7"/><file name="config.xml~" hash="899a2ba8e56a4040aa16f164e34afc48"/><file name="system.xml" hash="4d59155995bbeef1f8056a4b5f24cab1"/><file name="system.xml~" hash="dcde0b35d40eac36790d7180675de55d"/></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="CraftyClicks.xml" hash="4dca0534c1a1ce23cb0af9d137033b06"/></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="craftyclicks"><file name="common_config.phtml" hash="23cdf88769ff3a4013f3be4d3d0be6c2"/><file name="common_config.phtml~" hash="11c42a7f0366225407a2a6a883cf2e1a"/></dir></dir><dir name="layout"><file name="craftyclicks.xml" hash="a6d94d42619512c35c1e8bd05bab8e55"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="craftyclicks.xml" hash="dad3bdf940efdc974b86784da78fe822"/></dir><dir name="template"><dir name="craftyclicks"><file name="common_config.phtml" hash="e1bb4493d4c35f46a1d3cfe60d503d97"/></dir></dir></dir></dir></dir></dir></dir><dir name="js"><dir name="craftyclicks"><file name="crafty_postcode.class.js" hash="44593e9ea50fbfb6a6a35760b878331f"/><file name="craftyclicks_gomage_lightcheckout.js" hash="cd1f53eb75cc60e0e14512d2a6424394"/><file name="craftyclicks_magento.js" hash="59f1b127f08a3b605fcbd9f7c308bf2a"/><file name="craftyclicks_magento_admin.js" hash="7c64061e12c7946133205656392baa2d"/><file name="craftyclicks_onepagecheckout.js" hash="5196fac5876d6684f3b58063c9c2cd90"/></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="craftyclicks"><file name="button_find_address.gif" hash="0fdef9bf7ad0f7ec3f6530b7ff40bf59"/><file name="crafty_postcode_busy.gif" hash="618a14f4dca4f51100cd2400e7f9049c"/></dir></dir></dir></dir></dir></dir></target></contents>
|
112 |
<compatible/>
|
113 |
<dependencies/>
|
114 |
</package>
|