Version Notes
Release History
v2.5.3
* Fixed extra js include for wp & ecommerceteam checkouts
* Added support for Unicode Systems' Express Checkout
v2.5.2
* Fixed special character escaping issue with error messages
* Added support for Lotus Breath one step checkout
* New feature: detect & change country after address selected. (Guernsey, Jersey, Isle of Man or UK)
v2.5.1
* Fixed issue in Admin Panel
* Fixed issue with Amasty Checkout
* Fine tuned a county hiding for Firecheckout
v2.5.0
* Major Code Rework.
v2.4.9
* Added support for Awesome Checkout
v2.4.8
* Added support for the new Responsive Magento Template. New option in settings: Button Absolute Position.
* If the company field is hidden, push the company data into the address field.
v2.4.7
*Added support for AITOC Checkout.
v2.4.6
* Added support for Amesty One Step Checkout. Updated IWD Checkout support for a newer version. (backwards compatible to older IWD versions)
v2.4.5
* fix packaging issue with v2.4.4, no changes.
v2.4.4
* update support for Templates Master Firecheckout
* test and mark as Magento 1.8 compatible
v2.4.3
* add support of AheadWorks OneStepCheckout
v2.4.2
* add support for further one-page-checkout extensions, supported now are: AHT, EcommerceTeam, GoMage, IWD, Magestore, Mage World, OneStepCheckout, Tempates Master, Vinagento, Web Experiment
* small changes to config settings
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 | Crafty Clicks |
Extension | UK_Postcode_Address_Finder |
Version | 2.5.3 |
Comparing to | |
See all releases |
Code changes from version 2.5.2 to 2.5.3
@@ -12,7 +12,7 @@
|
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Craftyclicks_Clicktoaddress>
|
15 |
-
<version>2.5.
|
16 |
</Craftyclicks_Clicktoaddress>
|
17 |
</modules>
|
18 |
|
12 |
<config>
|
13 |
<modules>
|
14 |
<Craftyclicks_Clicktoaddress>
|
15 |
+
<version>2.5.3</version>
|
16 |
</Craftyclicks_Clicktoaddress>
|
17 |
</modules>
|
18 |
|
@@ -81,14 +81,14 @@
|
|
81 |
|
82 |
<ecommerceteam_echeckout_onepage_index>
|
83 |
<reference name="head">
|
84 |
-
<action method="removeItem"><type>js</type><name>craftyclicks/craftyclicks_magento.js</name></action>
|
85 |
<action method="addJs"><script>craftyclicks/clicktoaddress/craftyclicks_ecomm_easycheckout.js</script></action>
|
86 |
</reference>
|
87 |
</ecommerceteam_echeckout_onepage_index>
|
88 |
|
89 |
<wp_onepagecheckout_default>
|
90 |
<reference name="head">
|
91 |
-
<action method="removeItem"><type>js</type><name>craftyclicks/craftyclicks_magento.js</name></action>
|
92 |
<action method="addJs"><script>craftyclicks/clicktoaddress/craftyclicks_webandpeople_onepagecheckout.js</script></action>
|
93 |
</reference>
|
94 |
</wp_onepagecheckout_default>
|
@@ -161,4 +161,12 @@
|
|
161 |
<block type="page/html" name="craftyclicks_config2" template="craftyclicks/clicktoaddress/common_config.phtml"/>
|
162 |
</reference>
|
163 |
</lotusbreath_onestepcheckout_index_index>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
</layout>
|
81 |
|
82 |
<ecommerceteam_echeckout_onepage_index>
|
83 |
<reference name="head">
|
84 |
+
<action method="removeItem"><type>js</type><name>craftyclicks/clickaddress/craftyclicks_magento.js</name></action>
|
85 |
<action method="addJs"><script>craftyclicks/clicktoaddress/craftyclicks_ecomm_easycheckout.js</script></action>
|
86 |
</reference>
|
87 |
</ecommerceteam_echeckout_onepage_index>
|
88 |
|
89 |
<wp_onepagecheckout_default>
|
90 |
<reference name="head">
|
91 |
+
<action method="removeItem"><type>js</type><name>craftyclicks/clickaddress/craftyclicks_magento.js</name></action>
|
92 |
<action method="addJs"><script>craftyclicks/clicktoaddress/craftyclicks_webandpeople_onepagecheckout.js</script></action>
|
93 |
</reference>
|
94 |
</wp_onepagecheckout_default>
|
161 |
<block type="page/html" name="craftyclicks_config2" template="craftyclicks/clicktoaddress/common_config.phtml"/>
|
162 |
</reference>
|
163 |
</lotusbreath_onestepcheckout_index_index>
|
164 |
+
|
165 |
+
<!-- Unicode Systems, Express Checkout | One Step Checkout - http://www.magentocommerce.com/magento-connect/express-checkout-one-step-checkout.html -->
|
166 |
+
<checkout_onepage_index>
|
167 |
+
<reference name="head">
|
168 |
+
<action ifconfig="opcheckout/general/enabled" method="removeItem"><type>js</type><name>craftyclicks/clicktoaddress/craftyclicks_magento.js</name></action>
|
169 |
+
<action ifconfig="opcheckout/general/enabled" method="addJs"><script>craftyclicks/clicktoaddress/craftyclicks_opcheckout.js</script></action>
|
170 |
+
</reference>
|
171 |
+
</checkout_onepage_index>
|
172 |
</layout>
|
@@ -0,0 +1,438 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// This file works for the standard magento checkout (both community and enterprise)
|
6 |
+
//
|
7 |
+
// It also covers, these aftermarket extensions:
|
8 |
+
//
|
9 |
+
// OneStepCheckout Pro by Mage World
|
10 |
+
// http://www.mage-world.com/one-step-checkout-pro-magento-extension.html
|
11 |
+
//
|
12 |
+
// Provided by www.CraftyClicks.co.uk
|
13 |
+
//
|
14 |
+
// Requires standard CraftyClicks JS - tested with v4.9.1
|
15 |
+
//
|
16 |
+
// If you copy/use/modify this code - please keep this
|
17 |
+
// comment header in place
|
18 |
+
//
|
19 |
+
// Copyright (c) 2009-2014 Crafty Clicks (http://www.craftyclicks.com)
|
20 |
+
//
|
21 |
+
// This code relies on prototype js, you must have a reasonably recent version loaded
|
22 |
+
// in your template. Magento should include it as standard.
|
23 |
+
//
|
24 |
+
// If you need any help, contact support@craftyclicks.co.uk - we will help!
|
25 |
+
//
|
26 |
+
**********************************************************************************/
|
27 |
+
function CraftyClicksMagentoClass () {
|
28 |
+
this.prefix = "";
|
29 |
+
this.fields = { "postcode_id" : "", // required
|
30 |
+
"company_id" : "", // optional
|
31 |
+
"street1_id" : "", // required
|
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 |
+
"email_id" : "" // required
|
39 |
+
};
|
40 |
+
|
41 |
+
this.current_setup = 'initial'; // can be 'uk' or 'non_uk'
|
42 |
+
this.uk_postcode_width = ''
|
43 |
+
this.old_postcode_width = '';
|
44 |
+
this.cp_obj = 0;
|
45 |
+
this.div_depth = 0;
|
46 |
+
this.li_class = '';
|
47 |
+
this.mw_opc = false;
|
48 |
+
|
49 |
+
this.elem_move = function(e1, e2) {
|
50 |
+
e1.insert({after : e2});
|
51 |
+
}
|
52 |
+
|
53 |
+
// test div depth - some magento temlates wrap fields in two layers of div in a li
|
54 |
+
this.set_div_depth = function() {
|
55 |
+
if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('li'))) {
|
56 |
+
this.div_depth = 1;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
this.rearrange_fields = function() {
|
61 |
+
var fields = this.fields;
|
62 |
+
|
63 |
+
this.mw_opc = (typeof $MW_Onestepcheckout !== "undefined" ? true : false);
|
64 |
+
this.crafty_melissa = false;
|
65 |
+
if(typeof crafty_melissa_cfg !== "undefined"){
|
66 |
+
this.crafty_melissa = (parseInt(crafty_melissa_cfg.usaauto.active) || parseInt(crafty_melissa_cfg.globalauto.active)) ? true : false;
|
67 |
+
}
|
68 |
+
|
69 |
+
if (this.mw_opc) {
|
70 |
+
this.li_class = 'fields';
|
71 |
+
}
|
72 |
+
|
73 |
+
// postcode should be bundled with country in the same li on the standard magento address templates
|
74 |
+
// if this isn't the case, the rest of this code unlikely to work!
|
75 |
+
if ($(fields.country_id).up('li') == $(fields.postcode_id).up('li') || this.mw_opc || this.crafty_melissa) {
|
76 |
+
|
77 |
+
if ('' != $(fields.town_id).getValue()) {
|
78 |
+
_cp_hide_fields = false;
|
79 |
+
}
|
80 |
+
|
81 |
+
// order for non-UK: country, company (if we have it), street1, street2, street3 (if we have it), town, county (if we have it), postcode
|
82 |
+
var li_list = [ $(fields.country_id).up('li') ];
|
83 |
+
var idx = 1;
|
84 |
+
|
85 |
+
var ne = $(fields.company_id);
|
86 |
+
if (ne) {
|
87 |
+
// check if the email address is bundled with the company - on some templates it is and we then should separate it out.
|
88 |
+
if ($(fields.email_id) && ne.up('li') == $(fields.email_id).up('li') && !this.mw_opc) {
|
89 |
+
// create a new li to hold the company on its own
|
90 |
+
$(fields.street1_id).up('li').insert( {before: '<li class="'+this.li_class+'" id="'+this.prefix+'_company_placeholder_id"></li>'} );
|
91 |
+
$(this.prefix+"_company_placeholder_id").insert( $(fields.company_id).up('div', this.div_depth) );
|
92 |
+
ne = $(fields.company_id);
|
93 |
+
}
|
94 |
+
li_list[idx] = ne.up('li'); idx++;
|
95 |
+
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
96 |
+
}
|
97 |
+
|
98 |
+
li_list[idx] = $(fields.street1_id).up('li'); idx++;
|
99 |
+
$(fields.street1_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
100 |
+
ne = $(fields.street2_id);
|
101 |
+
if (ne) {
|
102 |
+
li_list[idx] = ne.up('li'); idx++;
|
103 |
+
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
104 |
+
}
|
105 |
+
ne = $(fields.street3_id);
|
106 |
+
if (ne) {
|
107 |
+
li_list[idx] = ne.up('li'); idx++;
|
108 |
+
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
109 |
+
}
|
110 |
+
ne = $(fields.street4_id);
|
111 |
+
if (ne) {
|
112 |
+
li_list[idx] = ne.up('li'); idx++;
|
113 |
+
ne.up('li').addClassName(this.prefix+'_cp_address_class');
|
114 |
+
}
|
115 |
+
li_list[idx] = $(fields.town_id).up('li'); idx++; // town and county are on the same li, so will move together
|
116 |
+
$(fields.town_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
117 |
+
|
118 |
+
if (this.mw_opc) {
|
119 |
+
$(fields.county_id).up('li').addClassName(this.prefix+'_cp_address_class');
|
120 |
+
this.uk_postcode_width = '100px';
|
121 |
+
} else {
|
122 |
+
for (var ii = 0; ii < idx; ii++) {
|
123 |
+
this.elem_move(li_list[ii], li_list[ii+1]);
|
124 |
+
}
|
125 |
+
// create a new li to hold the postcode on its own
|
126 |
+
$(fields.town_id).up('li').insert( {after: '<li class="'+this.li_class+'" id="'+this.prefix+'_cp_postcode_placeholder_id"></li>'} );
|
127 |
+
$(this.prefix+"_cp_postcode_placeholder_id").insert( $(this.fields.postcode_id).up('div', this.div_depth) );
|
128 |
+
|
129 |
+
// check postcode field width, longer than 350px means we are on a magento enterprise template and we need to shrink things a bit
|
130 |
+
// so the lookup button fits on the form next to the postcode field
|
131 |
+
var pcWidth = parseInt($(this.fields.postcode_id).getStyle("width"));
|
132 |
+
if (350 < pcWidth || _cp_button_fixposition) {
|
133 |
+
this.uk_postcode_width = '100px';
|
134 |
+
}
|
135 |
+
|
136 |
+
// move the telephone above the address - we move it only if we hide other address fields
|
137 |
+
ne = $(fields.telephone_id);
|
138 |
+
if (_cp_hide_fields && ne) {
|
139 |
+
// telephone may be bundled with company, if so separate it out
|
140 |
+
if ($(fields.company_id) && ne.up('li') == $(fields.company_id).up('li')) {
|
141 |
+
// create a new li to hold the telephone on its own at the top of the address
|
142 |
+
$(fields.country_id).up('li').insert( {before: '<li class="'+this.li_class+'" id="'+this.prefix+'_telephone_placeholder_id"></li>'} );
|
143 |
+
$(this.prefix+"_telephone_placeholder_id").insert( ne.up('div', this.div_depth) );
|
144 |
+
} else {
|
145 |
+
// telephone is probably on its own, or with fax
|
146 |
+
$(fields.country_id).up('li').insert({before : ne.up('li')});
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
150 |
+
return (true);
|
151 |
+
} else {
|
152 |
+
return (false);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
this.setup_for_uk = function() {
|
157 |
+
// check if we need to do anything
|
158 |
+
if ('uk' != this.current_setup) {
|
159 |
+
// do the magic for UK
|
160 |
+
if (this.mw_opc) {
|
161 |
+
// add result box
|
162 |
+
if (!$(this.prefix+'_cp_result_display')) {
|
163 |
+
var tmp_html = '<li class="'+this.li_class+'" style="display: none"><div class="widthfull"><div class="field"><label> </label><div class="input-box" id="'+this.prefix+'_cp_result_display"> </div></div></div></li>';
|
164 |
+
$(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
|
165 |
+
}
|
166 |
+
} else {
|
167 |
+
// move postcode to the uk position after the country li
|
168 |
+
$(this.fields.country_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
169 |
+
// add result box
|
170 |
+
if (!$(this.prefix+'_cp_result_display')) {
|
171 |
+
var tmp_html = '<li class="'+this.li_class+'" style="display: none"><label> </label><div class="input-box" id="'+this.prefix+'_cp_result_display"> </div></li>';
|
172 |
+
$(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
|
173 |
+
}
|
174 |
+
}
|
175 |
+
// show result box
|
176 |
+
$(this.prefix+"_cp_result_display").up('li').show();
|
177 |
+
// add button
|
178 |
+
if (!$(this.prefix+'_cp_button_div_id')) {
|
179 |
+
var tmp_html = '';
|
180 |
+
if (0 == this.div_depth) {
|
181 |
+
tmp_html = '<div class="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id"> </label>';
|
182 |
+
} else {
|
183 |
+
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">';
|
184 |
+
}
|
185 |
+
if ('' != _cp_button_image) {
|
186 |
+
tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
|
187 |
+
} else {
|
188 |
+
tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
|
189 |
+
}
|
190 |
+
if (0 == this.div_depth) {
|
191 |
+
tmp_html += '</div>';
|
192 |
+
} else {
|
193 |
+
tmp_html += '</div></div>';
|
194 |
+
}
|
195 |
+
$(this.fields.postcode_id).up('div', this.div_depth).insert( {after : tmp_html} );
|
196 |
+
$(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
|
197 |
+
}
|
198 |
+
|
199 |
+
// shrink postcode field if needed
|
200 |
+
if ('' != this.uk_postcode_width) {
|
201 |
+
this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
|
202 |
+
$(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
|
203 |
+
}
|
204 |
+
|
205 |
+
// black magic against new magento template
|
206 |
+
|
207 |
+
if(_cp_button_fixposition){
|
208 |
+
// button is below the input box. Set the bounding LI element relative
|
209 |
+
$(this.prefix+'_cp_button_div_id').up('li').setStyle({position:'relative'});
|
210 |
+
// set the button's div to absolute. (0,0 is the li's 0,0)
|
211 |
+
// set the button's div to be on same distance on Y axis as the input box & input box width + 10 px extra on the X axis.
|
212 |
+
$(this.prefix+'_cp_button_div_id').setStyle({position:'absolute', top: "0px", left: parseInt($(this.fields.postcode_id).getStyle('width')) + 10 + "px"});
|
213 |
+
}
|
214 |
+
// show button
|
215 |
+
$(this.prefix+"_cp_button_div_id").show();
|
216 |
+
|
217 |
+
// hide county if requested (and if it exists in the html at all)
|
218 |
+
if (_cp_hide_county) {
|
219 |
+
ne = $(this.fields.county_id);
|
220 |
+
if (ne) {
|
221 |
+
ne.up('div', this.div_depth).hide();
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
if ('initial' == this.current_setup && _cp_hide_fields) {
|
227 |
+
// first time and default to UK, hide address fields
|
228 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('hide');
|
229 |
+
}
|
230 |
+
|
231 |
+
// set state
|
232 |
+
this.current_setup = 'uk';
|
233 |
+
}
|
234 |
+
|
235 |
+
this.setup_for_non_uk = function() {
|
236 |
+
// check if we need to do anything
|
237 |
+
if ('non_uk' != this.current_setup) {
|
238 |
+
// hide result box (if it exist already)
|
239 |
+
if ($(this.prefix+"_cp_result_display")) {
|
240 |
+
this.cp_obj.update_res(null);
|
241 |
+
$(this.prefix+"_cp_result_display").up('li').hide();
|
242 |
+
}
|
243 |
+
// hide button (if it exist already)
|
244 |
+
if ($(this.prefix+"_cp_button_div_id")) {
|
245 |
+
$(this.prefix+"_cp_button_div_id").hide();
|
246 |
+
}
|
247 |
+
if (!this.mw_opc) {
|
248 |
+
// move postcode to the non-uk position after the town/county li
|
249 |
+
$(this.fields.town_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
|
250 |
+
}
|
251 |
+
// restore postcode field width if needed
|
252 |
+
if ('' != this.old_postcode_width) {
|
253 |
+
$(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
|
254 |
+
}
|
255 |
+
// show county if it was hidden (and exists in the html at all)
|
256 |
+
if (_cp_hide_county) {
|
257 |
+
ne = $(this.fields.county_id);
|
258 |
+
if (ne) {
|
259 |
+
ne.up('div', this.div_depth).show();
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
// show all other addres lines
|
264 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
265 |
+
// set state
|
266 |
+
this.current_setup = 'non_uk';
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
this.add_lookup = function(setup) {
|
271 |
+
cp_obj = CraftyPostcodeCreate();
|
272 |
+
this.cp_obj = cp_obj;
|
273 |
+
// config
|
274 |
+
this.prefix = setup.prefix;
|
275 |
+
this.fields = setup.fields;
|
276 |
+
cp_obj.set("access_token", _cp_token_fe);
|
277 |
+
cp_obj.set("res_autoselect", "0");
|
278 |
+
cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
|
279 |
+
cp_obj.set("form", "");
|
280 |
+
if ($(this.fields.company_id)) cp_obj.set("elem_company" , this.fields.company_id); // company field exists, use it
|
281 |
+
else cp_obj.set("elem_company" , this.fields.street1_id); // no company field, put company names on 1st line of address
|
282 |
+
cp_obj.set("elem_street1" , this.fields.street1_id);
|
283 |
+
cp_obj.set("elem_street2" , this.fields.street2_id);
|
284 |
+
cp_obj.set("elem_street3" , this.fields.street3_id);
|
285 |
+
cp_obj.set("elem_town" , this.fields.town_id);
|
286 |
+
if (_cp_hide_county) {
|
287 |
+
cp_obj.set("elem_county" , ""); // optional
|
288 |
+
} else {
|
289 |
+
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
290 |
+
}
|
291 |
+
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
292 |
+
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
293 |
+
cp_obj.set("max_width" , _cp_result_box_width);
|
294 |
+
if (1 < _cp_result_box_height) {
|
295 |
+
cp_obj.set("first_res_line", "");
|
296 |
+
cp_obj.set("max_lines" , _cp_result_box_height);
|
297 |
+
} else {
|
298 |
+
cp_obj.set("first_res_line", "----- please select your address ----");
|
299 |
+
cp_obj.set("max_lines" , 1);
|
300 |
+
}
|
301 |
+
cp_obj.set("busy_img_url" , _cp_busy_img_url);
|
302 |
+
cp_obj.set("hide_result" , _cp_clear_result);
|
303 |
+
cp_obj.set("traditional_county" , 1);
|
304 |
+
cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
|
305 |
+
cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
|
306 |
+
cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
|
307 |
+
cp_obj.set("first_res_line", _cp_1st_res_line);
|
308 |
+
cp_obj.set("err_msg1", _cp_err_msg1);
|
309 |
+
cp_obj.set("err_msg2", _cp_err_msg2);
|
310 |
+
cp_obj.set("err_msg3", _cp_err_msg3);
|
311 |
+
cp_obj.set("err_msg4", _cp_err_msg4);
|
312 |
+
// initial page setup
|
313 |
+
this.set_div_depth();
|
314 |
+
if (this.rearrange_fields()) {
|
315 |
+
if (_cp_enable_for_uk_only) {
|
316 |
+
this.country_changed();
|
317 |
+
$(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
|
318 |
+
} else {
|
319 |
+
this.setup_for_uk();
|
320 |
+
}
|
321 |
+
} else {
|
322 |
+
// alert ('Postcode Lookup could not be added!');
|
323 |
+
}
|
324 |
+
}
|
325 |
+
|
326 |
+
this.country_changed = function(e) {
|
327 |
+
// show postcode lookup for:
|
328 |
+
// "GB" UK
|
329 |
+
// "JE" Jersey
|
330 |
+
// "GG" Guernsey
|
331 |
+
// "IM" Isle of Man
|
332 |
+
var curr_country = $(this.fields.country_id).getValue();
|
333 |
+
if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
|
334 |
+
this.setup_for_uk();
|
335 |
+
} else {
|
336 |
+
this.setup_for_non_uk();
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
this.button_clicked = function(e) {
|
341 |
+
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
|
342 |
+
this.cp_obj.doLookup();
|
343 |
+
}
|
344 |
+
|
345 |
+
this.result_ready = function() {
|
346 |
+
}
|
347 |
+
|
348 |
+
this.result_selected = function() {
|
349 |
+
if (_cp_clear_result) this.cp_obj.update_res(null);
|
350 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
351 |
+
|
352 |
+
switch($(this.fields.postcode_id).getValue().substring(0,2)){
|
353 |
+
case "GY":
|
354 |
+
$(this.fields.country_id).setValue("GG");
|
355 |
+
break;
|
356 |
+
case "JE":
|
357 |
+
$(this.fields.country_id).setValue("JE");
|
358 |
+
break;
|
359 |
+
case "IM":
|
360 |
+
$(this.fields.country_id).setValue("IM");
|
361 |
+
break;
|
362 |
+
case default:
|
363 |
+
$(this.fields.country_id).setValue("GB");
|
364 |
+
break;
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
this.result_error = function() {
|
369 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
370 |
+
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
document.observe("dom:loaded", function() {
|
375 |
+
|
376 |
+
if (!_cp_integrate) return;
|
377 |
+
|
378 |
+
if ($("billing:postcode")) {
|
379 |
+
var cc1 = new CraftyClicksMagentoClass();
|
380 |
+
cc1.add_lookup({
|
381 |
+
"prefix" : "billing",
|
382 |
+
"fields" : { "postcode_id" : "billing:postcode",
|
383 |
+
"company_id" : "billing:company",
|
384 |
+
"street1_id" : "billing:street1",
|
385 |
+
"street2_id" : "billing:street2",
|
386 |
+
"street3_id" : "billing:street3",
|
387 |
+
"street4_id" : "billing:street4",
|
388 |
+
"town_id" : "billing:city",
|
389 |
+
"county_id" : "billing:region",
|
390 |
+
"country_id" : "billing:country_id",
|
391 |
+
"email_id" : "billing:email",
|
392 |
+
"telephone_id": "billing:telephone" }
|
393 |
+
});
|
394 |
+
}
|
395 |
+
|
396 |
+
if ($("shipping:postcode")) {
|
397 |
+
var cc2 = new CraftyClicksMagentoClass();
|
398 |
+
cc2.add_lookup({
|
399 |
+
"prefix" : "shipping",
|
400 |
+
"fields" : { "postcode_id" : "shipping:postcode",
|
401 |
+
"company_id" : "shipping:company",
|
402 |
+
"street1_id" : "shipping:street1",
|
403 |
+
"street2_id" : "shipping:street2",
|
404 |
+
"street3_id" : "shipping:street3",
|
405 |
+
"street4_id" : "shipping:street4",
|
406 |
+
"town_id" : "shipping:city",
|
407 |
+
"county_id" : "shipping:region",
|
408 |
+
"country_id" : "shipping:country_id",
|
409 |
+
"email_id" : "shipping:email",
|
410 |
+
"telephone_id": "shipping:telephone" }
|
411 |
+
});
|
412 |
+
}
|
413 |
+
|
414 |
+
if ($("zip")) {
|
415 |
+
var cc3 = new CraftyClicksMagentoClass();
|
416 |
+
cc3.add_lookup({
|
417 |
+
"prefix" : "",
|
418 |
+
"fields" : { "postcode_id" : "zip",
|
419 |
+
"company_id" : "company",
|
420 |
+
"street1_id" : "street_1",
|
421 |
+
"street2_id" : "street_2",
|
422 |
+
"street3_id" : "street_3",
|
423 |
+
"street4_id" : "street_4",
|
424 |
+
"town_id" : "city",
|
425 |
+
"county_id" : "region",
|
426 |
+
"country_id" : "country",
|
427 |
+
"email_id" : "email_address",
|
428 |
+
"telephone_id": "telephone" }
|
429 |
+
});
|
430 |
+
}
|
431 |
+
|
432 |
+
// preload the busy img
|
433 |
+
if ('' != _cp_busy_img_url) {
|
434 |
+
var image = new Image();
|
435 |
+
image.src = _cp_busy_img_url;
|
436 |
+
}
|
437 |
+
});
|
438 |
+
|
@@ -0,0 +1,388 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// This file works for the standard magento checkout (both community and enterprise)
|
6 |
+
//
|
7 |
+
// Provided by www.CraftyClicks.co.uk
|
8 |
+
//
|
9 |
+
// Requires standard CraftyClicks JS - tested with v4.9.1
|
10 |
+
//
|
11 |
+
// If you copy/use/modify this code - please keep this
|
12 |
+
// comment header in place
|
13 |
+
//
|
14 |
+
// Copyright (c) 2009-2014 Crafty Clicks (http://www.craftyclicks.com)
|
15 |
+
//
|
16 |
+
// This code relies on prototype js, you must have a reasonably recent version loaded
|
17 |
+
// in your template. Magento should include it as standard.
|
18 |
+
//
|
19 |
+
// If you need any help, contact support@craftyclicks.co.uk - we will help!
|
20 |
+
//
|
21 |
+
**********************************************************************************/
|
22 |
+
function CraftyClicksMagentoClass () {
|
23 |
+
this.prefix = "";
|
24 |
+
this.fields = { "postcode_id" : "", // required
|
25 |
+
"company_id" : "", // optional
|
26 |
+
"street1_id" : "", // required
|
27 |
+
"street2_id" : "", // optional
|
28 |
+
"street3_id" : "", // optional
|
29 |
+
"street4_id" : "", // optional
|
30 |
+
"town_id" : "", // required
|
31 |
+
"county_id" : "", // optional
|
32 |
+
"country_id" : "", // required
|
33 |
+
"email_id" : "" // required
|
34 |
+
};
|
35 |
+
|
36 |
+
this.current_setup = 'initial'; // can be 'uk' or 'non_uk'
|
37 |
+
this.uk_postcode_width = ''
|
38 |
+
this.old_postcode_width = '';
|
39 |
+
this.cp_obj = 0;
|
40 |
+
this.div_depth = 0;
|
41 |
+
this.li_class = '';
|
42 |
+
this.mw_opc = false;
|
43 |
+
|
44 |
+
this.elem_move = function(e1, e2) {
|
45 |
+
e1.insert({after : e2});
|
46 |
+
}
|
47 |
+
|
48 |
+
// test div depth - some magento temlates wrap fields in two layers of div in a li
|
49 |
+
this.set_div_depth = function() {
|
50 |
+
if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('td'))) {
|
51 |
+
this.div_depth = 1;
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
this.rearrange_fields = function() {
|
56 |
+
var fields = this.fields;
|
57 |
+
|
58 |
+
this.crafty_melissa = false;
|
59 |
+
if(typeof crafty_melissa_cfg !== "undefined"){
|
60 |
+
this.crafty_melissa = (parseInt(crafty_melissa_cfg.usaauto.active) || parseInt(crafty_melissa_cfg.globalauto.active)) ? true : false;
|
61 |
+
}
|
62 |
+
|
63 |
+
// postcode should be bundled with country in the same li on the standard magento address templates
|
64 |
+
// if this isn't the case, the rest of this code unlikely to work!
|
65 |
+
|
66 |
+
if ('' != $(fields.town_id).getValue()) {
|
67 |
+
_cp_hide_fields = false;
|
68 |
+
}
|
69 |
+
|
70 |
+
// order for non-UK: country, company (if we have it), street1, street2, street3 (if we have it), town, county (if we have it), postcode
|
71 |
+
var li_list = [ $(fields.country_id).up('td') ];
|
72 |
+
var idx = 1;
|
73 |
+
|
74 |
+
var ne = $(fields.company_id);
|
75 |
+
if (ne) {
|
76 |
+
// check if the email address is bundled with the company - on some templates it is and we then should separate it out.
|
77 |
+
if ($(fields.email_id) && ne.up('td') == $(fields.email_id).up('td')) {
|
78 |
+
// create a new li to hold the company on its own
|
79 |
+
$(fields.street1_id).up('td').insert( {before: '<li class="'+this.li_class+'" id="'+this.prefix+'_company_placeholder_id"></li>'} );
|
80 |
+
$(this.prefix+"_company_placeholder_id").insert( $(fields.company_id).up('div') );
|
81 |
+
ne = $(fields.company_id);
|
82 |
+
}
|
83 |
+
li_list[idx] = ne.up('td'); idx++;
|
84 |
+
ne.up('td').addClassName(this.prefix+'_cp_address_class');
|
85 |
+
}
|
86 |
+
|
87 |
+
li_list[idx] = $(fields.street1_id).up('td'); idx++;
|
88 |
+
$(fields.street1_id).up('td').addClassName(this.prefix+'_cp_address_class');
|
89 |
+
ne = $(fields.street2_id);
|
90 |
+
if (ne) {
|
91 |
+
li_list[idx] = ne.up('td'); idx++;
|
92 |
+
ne.up('td').addClassName(this.prefix+'_cp_address_class');
|
93 |
+
}
|
94 |
+
ne = $(fields.street3_id);
|
95 |
+
if (ne) {
|
96 |
+
li_list[idx] = ne.up('td'); idx++;
|
97 |
+
ne.up('td').addClassName(this.prefix+'_cp_address_class');
|
98 |
+
}
|
99 |
+
ne = $(fields.street4_id);
|
100 |
+
if (ne) {
|
101 |
+
li_list[idx] = ne.up('td'); idx++;
|
102 |
+
ne.up('td').addClassName(this.prefix+'_cp_address_class');
|
103 |
+
}
|
104 |
+
li_list[idx] = $(fields.town_id).up('td'); idx++; // town and county are on the same li, so will move together
|
105 |
+
$(fields.town_id).up('td').addClassName(this.prefix+'_cp_address_class');
|
106 |
+
|
107 |
+
$(fields.street1_id).up('td').insert({after: $(this.fields.postcode_id).up('td')});
|
108 |
+
$$('label[for="'+fields.street1_id+'"]')[0].up('td').insert({after: $$('label[for="'+this.fields.postcode_id+'"]')[0].up('td')});
|
109 |
+
|
110 |
+
$(fields.town_id).up('tr').insert({after: $(this.fields.street1_id).up('td')});
|
111 |
+
$(fields.town_id).up('tr').insert({after: $$('label[for="'+this.fields.street1_id+'"]')[0].up('td')});
|
112 |
+
|
113 |
+
$(this.fields.street1_id).up('td').wrap(new Element('tr'));
|
114 |
+
$$('label[for="'+this.fields.street1_id+'"]')[0].up('td').wrap(new Element('tr'));
|
115 |
+
|
116 |
+
// check postcode field width, longer than 350px means we are on a magento enterprise template and we need to shrink things a bit
|
117 |
+
// so the lookup button fits on the form next to the postcode field
|
118 |
+
var pcWidth = parseInt($(this.fields.postcode_id).getStyle("width"));
|
119 |
+
if (350 < pcWidth || _cp_button_fixposition) {
|
120 |
+
this.uk_postcode_width = '100px';
|
121 |
+
}
|
122 |
+
return (true);
|
123 |
+
}
|
124 |
+
|
125 |
+
this.setup_for_uk = function() {
|
126 |
+
// check if we need to do anything
|
127 |
+
if ('uk' != this.current_setup) {
|
128 |
+
// do the magic for UK
|
129 |
+
|
130 |
+
$(this.fields.country_id).up('tr').insert( {after: $$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr')} );
|
131 |
+
$$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr').insert( {after: $(this.fields.postcode_id).up('tr')} );
|
132 |
+
// move postcode to the uk position after the country li
|
133 |
+
//$(this.fields.country_id).up('td').insert( {after: $(this.fields.postcode_id).up('td')} );
|
134 |
+
// add result box
|
135 |
+
if (!$(this.prefix+'_cp_result_display')) {
|
136 |
+
var tmp_html = '<tr id="'+this.prefix+'_cp_result_display_tr"><td colspan="2"><div class="input-box" id="'+this.prefix+'_cp_result_display"> </div></td></tr>';
|
137 |
+
$(this.fields.postcode_id).up('tr').insert( {after: tmp_html} );
|
138 |
+
} else {
|
139 |
+
$(this.fields.postcode_id).up('tr').insert( {after: $(this.prefix+'_cp_result_display_tr')} );
|
140 |
+
}
|
141 |
+
// show result box
|
142 |
+
$(this.prefix+"_cp_result_display").up('td').show();
|
143 |
+
// add button
|
144 |
+
if (!$(this.prefix+'_cp_button_div_id')) {
|
145 |
+
var tmp_html = '';
|
146 |
+
tmp_html = '<td><div class="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id"> </label>';
|
147 |
+
|
148 |
+
if ('' != _cp_button_image) {
|
149 |
+
tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
|
150 |
+
} else {
|
151 |
+
tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
|
152 |
+
}
|
153 |
+
tmp_html += '</div></td>';
|
154 |
+
$(this.fields.postcode_id).up('td').insert( {after : tmp_html} );
|
155 |
+
$(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
|
156 |
+
}
|
157 |
+
// show button
|
158 |
+
$(this.prefix+"_cp_button_div_id").show();
|
159 |
+
// hide county if requested (and if it exists in the html at all)
|
160 |
+
if (_cp_hide_county) {
|
161 |
+
ne = $(this.fields.county_id);
|
162 |
+
if (ne) {
|
163 |
+
$$('label[for="'+this.fields.county_id+'"]')[0].up('tr').hide();
|
164 |
+
ne.up('tr').hide();
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
if ('initial' == this.current_setup && _cp_hide_fields) {
|
170 |
+
// first time and default to UK, hide address fields
|
171 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('hide');
|
172 |
+
}
|
173 |
+
|
174 |
+
// set state
|
175 |
+
this.current_setup = 'uk';
|
176 |
+
}
|
177 |
+
|
178 |
+
this.setup_for_non_uk = function() {
|
179 |
+
// check if we need to do anything
|
180 |
+
if ('non_uk' != this.current_setup) {
|
181 |
+
|
182 |
+
|
183 |
+
$$('label[for="'+this.fields.town_id+'"]')[0].up('tr').insert( {after: $$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr')} );
|
184 |
+
$$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr').insert( {after: $(this.fields.postcode_id).up('tr')} );
|
185 |
+
|
186 |
+
// hide result box (if it exist already)
|
187 |
+
if ($(this.prefix+"_cp_result_display")) {
|
188 |
+
this.cp_obj.update_res(null);
|
189 |
+
$(this.prefix+"_cp_result_display").up('td').hide();
|
190 |
+
}
|
191 |
+
// hide button (if it exist already)
|
192 |
+
if ($(this.prefix+"_cp_button_div_id")) {
|
193 |
+
$(this.prefix+"_cp_button_div_id").hide();
|
194 |
+
}
|
195 |
+
// move postcode to the non-uk position after the town/county li
|
196 |
+
$(this.fields.town_id).up('tr').insert( {after: $$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr')} );
|
197 |
+
$$('label[for="'+this.fields.postcode_id+'"]')[0].up('tr').insert( {after: $(this.fields.postcode_id).up('tr')} );
|
198 |
+
// restore postcode field width if needed
|
199 |
+
if ('' != this.old_postcode_width) {
|
200 |
+
$(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
|
201 |
+
}
|
202 |
+
// show county if it was hidden (and exists in the html at all)
|
203 |
+
if (_cp_hide_county) {
|
204 |
+
ne = $(this.fields.county_id);
|
205 |
+
if (ne) {
|
206 |
+
$$('label[for="'+this.fields.county_id+'"]')[0].up('tr').show();
|
207 |
+
ne.up('tr').show();
|
208 |
+
}
|
209 |
+
}
|
210 |
+
|
211 |
+
// show all other addres lines
|
212 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
213 |
+
// set state
|
214 |
+
this.current_setup = 'non_uk';
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
this.add_lookup = function(setup) {
|
219 |
+
cp_obj = CraftyPostcodeCreate();
|
220 |
+
this.cp_obj = cp_obj;
|
221 |
+
// config
|
222 |
+
this.prefix = setup.prefix;
|
223 |
+
this.fields = setup.fields;
|
224 |
+
cp_obj.set("access_token", _cp_token_fe);
|
225 |
+
cp_obj.set("res_autoselect", "0");
|
226 |
+
cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
|
227 |
+
cp_obj.set("form", "");
|
228 |
+
if ($(this.fields.company_id)) cp_obj.set("elem_company" , this.fields.company_id); // company field exists, use it
|
229 |
+
else cp_obj.set("elem_company" , this.fields.street1_id); // no company field, put company names on 1st line of address
|
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 |
+
if (_cp_hide_county) {
|
235 |
+
cp_obj.set("elem_county" , ""); // optional
|
236 |
+
} else {
|
237 |
+
cp_obj.set("elem_county" , this.fields.county_id); // optional
|
238 |
+
}
|
239 |
+
cp_obj.set("elem_postcode" , this.fields.postcode_id);
|
240 |
+
cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
|
241 |
+
cp_obj.set("max_width" , _cp_result_box_width);
|
242 |
+
if (1 < _cp_result_box_height) {
|
243 |
+
cp_obj.set("first_res_line", "");
|
244 |
+
cp_obj.set("max_lines" , _cp_result_box_height);
|
245 |
+
} else {
|
246 |
+
cp_obj.set("first_res_line", "----- please select your address ----");
|
247 |
+
cp_obj.set("max_lines" , 1);
|
248 |
+
}
|
249 |
+
cp_obj.set("busy_img_url" , _cp_busy_img_url);
|
250 |
+
cp_obj.set("hide_result" , _cp_clear_result);
|
251 |
+
cp_obj.set("traditional_county" , 1);
|
252 |
+
cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
|
253 |
+
cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
|
254 |
+
cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
|
255 |
+
cp_obj.set("first_res_line", _cp_1st_res_line);
|
256 |
+
cp_obj.set("err_msg1", _cp_err_msg1);
|
257 |
+
cp_obj.set("err_msg2", _cp_err_msg2);
|
258 |
+
cp_obj.set("err_msg3", _cp_err_msg3);
|
259 |
+
cp_obj.set("err_msg4", _cp_err_msg4);
|
260 |
+
// initial page setup
|
261 |
+
this.set_div_depth();
|
262 |
+
if (this.rearrange_fields()) {
|
263 |
+
if (_cp_enable_for_uk_only) {
|
264 |
+
this.country_changed();
|
265 |
+
$(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
|
266 |
+
} else {
|
267 |
+
this.setup_for_uk();
|
268 |
+
}
|
269 |
+
} else {
|
270 |
+
// alert ('Postcode Lookup could not be added!');
|
271 |
+
}
|
272 |
+
}
|
273 |
+
|
274 |
+
this.country_changed = function(e) {
|
275 |
+
// show postcode lookup for:
|
276 |
+
// "GB" UK
|
277 |
+
// "JE" Jersey
|
278 |
+
// "GG" Guernsey
|
279 |
+
// "IM" Isle of Man
|
280 |
+
var curr_country = $(this.fields.country_id).getValue();
|
281 |
+
if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
|
282 |
+
this.setup_for_uk();
|
283 |
+
} else {
|
284 |
+
this.setup_for_non_uk();
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
this.button_clicked = function(e) {
|
289 |
+
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
|
290 |
+
this.cp_obj.doLookup();
|
291 |
+
}
|
292 |
+
|
293 |
+
this.result_ready = function() {
|
294 |
+
$(this.prefix+'_cp_result_display').down('select').setStyle({ width: '236px'});
|
295 |
+
}
|
296 |
+
|
297 |
+
this.result_selected = function() {
|
298 |
+
if (_cp_clear_result) this.cp_obj.update_res(null);
|
299 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
300 |
+
|
301 |
+
switch($(this.fields.postcode_id).getValue().substring(0,2)){
|
302 |
+
case "GY":
|
303 |
+
$(this.fields.country_id).setValue("GG");
|
304 |
+
break;
|
305 |
+
case "JE":
|
306 |
+
$(this.fields.country_id).setValue("JE");
|
307 |
+
break;
|
308 |
+
case "IM":
|
309 |
+
$(this.fields.country_id).setValue("IM");
|
310 |
+
break;
|
311 |
+
default:
|
312 |
+
$(this.fields.country_id).setValue("GB");
|
313 |
+
break;
|
314 |
+
}
|
315 |
+
}
|
316 |
+
|
317 |
+
this.result_error = function() {
|
318 |
+
$$('.'+this.prefix+'_cp_address_class').invoke('show');
|
319 |
+
if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
|
320 |
+
}
|
321 |
+
}
|
322 |
+
|
323 |
+
document.observe("dom:loaded", function() {
|
324 |
+
console.log('activated');
|
325 |
+
|
326 |
+
if (!_cp_integrate) return;
|
327 |
+
|
328 |
+
if ($("billing:postcode")) {
|
329 |
+
var cc1 = new CraftyClicksMagentoClass();
|
330 |
+
cc1.add_lookup({
|
331 |
+
"prefix" : "billing",
|
332 |
+
"fields" : { "postcode_id" : "billing:postcode",
|
333 |
+
"company_id" : "billing:company",
|
334 |
+
"street1_id" : "billing:street1",
|
335 |
+
"street2_id" : "billing:street2",
|
336 |
+
"street3_id" : "billing:street3",
|
337 |
+
"street4_id" : "billing:street4",
|
338 |
+
"town_id" : "billing:city",
|
339 |
+
"county_id" : "billing:region",
|
340 |
+
"country_id" : "billing:country_id",
|
341 |
+
"email_id" : "billing:email",
|
342 |
+
"telephone_id": "billing:telephone" }
|
343 |
+
});
|
344 |
+
}
|
345 |
+
|
346 |
+
if ($("shipping:postcode")) {
|
347 |
+
var cc2 = new CraftyClicksMagentoClass();
|
348 |
+
cc2.add_lookup({
|
349 |
+
"prefix" : "shipping",
|
350 |
+
"fields" : { "postcode_id" : "shipping:postcode",
|
351 |
+
"company_id" : "shipping:company",
|
352 |
+
"street1_id" : "shipping:street1",
|
353 |
+
"street2_id" : "shipping:street2",
|
354 |
+
"street3_id" : "shipping:street3",
|
355 |
+
"street4_id" : "shipping:street4",
|
356 |
+
"town_id" : "shipping:city",
|
357 |
+
"county_id" : "shipping:region",
|
358 |
+
"country_id" : "shipping:country_id",
|
359 |
+
"email_id" : "shipping:email",
|
360 |
+
"telephone_id": "shipping:telephone" }
|
361 |
+
});
|
362 |
+
}
|
363 |
+
|
364 |
+
if ($("zip")) {
|
365 |
+
var cc3 = new CraftyClicksMagentoClass();
|
366 |
+
cc3.add_lookup({
|
367 |
+
"prefix" : "",
|
368 |
+
"fields" : { "postcode_id" : "zip",
|
369 |
+
"company_id" : "company",
|
370 |
+
"street1_id" : "street_1",
|
371 |
+
"street2_id" : "street_2",
|
372 |
+
"street3_id" : "street_3",
|
373 |
+
"street4_id" : "street_4",
|
374 |
+
"town_id" : "city",
|
375 |
+
"county_id" : "region",
|
376 |
+
"country_id" : "country",
|
377 |
+
"email_id" : "email_address",
|
378 |
+
"telephone_id": "telephone" }
|
379 |
+
});
|
380 |
+
}
|
381 |
+
|
382 |
+
// preload the busy img
|
383 |
+
if ('' != _cp_busy_img_url) {
|
384 |
+
var image = new Image();
|
385 |
+
image.src = _cp_busy_img_url;
|
386 |
+
}
|
387 |
+
});
|
388 |
+
|
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>UK_Postcode_Address_Finder</name>
|
4 |
-
<version>2.5.
|
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.5.2
|
19 |
* Fixed special character escaping issue with error messages
|
20 |
* Added support for Lotus Breath one step checkout
|
@@ -146,9 +150,9 @@ v 1.1.0 
|
|
146 |

|
147 |
v 1.0.0 - Initial Release</notes>
|
148 |
<authors><author><name>Crafty Clicks</name><user>styloa</user><email>support@craftyclicks.co.uk</email></author></authors>
|
149 |
-
<date>2015-
|
150 |
-
<time>
|
151 |
-
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Craftyclicks"><dir name="Clicktoaddress"><dir name="Helper"><file name="Data.php" hash="a561b9307d3a038e91d32c232820f54d"/></dir><dir name="data"><dir name="craftyclicks_clicktoaddress_setup"><file name="data-upgrade-2.4.9-2.5.0.php" hash="580589f5aff53b041773886008b23743"/></dir></dir><dir name="etc"><file name="config.xml" hash="
|
152 |
<compatible/>
|
153 |
<dependencies><required><php><min>4.0.0</min><max>6.0.0</max></php></required></dependencies>
|
154 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>UK_Postcode_Address_Finder</name>
|
4 |
+
<version>2.5.3</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.5.3
|
19 |
+
* Fixed extra js include for wp & ecommerceteam checkouts
|
20 |
+
* Added support for Unicode Systems' Express Checkout
|
21 |
+

|
22 |
v2.5.2
|
23 |
* Fixed special character escaping issue with error messages
|
24 |
* Added support for Lotus Breath one step checkout
|
150 |

|
151 |
v 1.0.0 - Initial Release</notes>
|
152 |
<authors><author><name>Crafty Clicks</name><user>styloa</user><email>support@craftyclicks.co.uk</email></author></authors>
|
153 |
+
<date>2015-03-09</date>
|
154 |
+
<time>15:05:31</time>
|
155 |
+
<contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Craftyclicks"><dir name="Clicktoaddress"><dir name="Helper"><file name="Data.php" hash="a561b9307d3a038e91d32c232820f54d"/></dir><dir name="data"><dir name="craftyclicks_clicktoaddress_setup"><file name="data-upgrade-2.4.9-2.5.0.php" hash="580589f5aff53b041773886008b23743"/></dir></dir><dir name="etc"><file name="config.xml" hash="533805cf5695f45aab8d4a178ebbf89d"/><file name="system.xml" hash="9ab78f3e038966c6c147932367a3586b"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Craftyclicks_Clicktoaddress.xml" hash="66e9933c58e73eaebf95266ea67b11bc"/><file name="CraftyClicks.xml" hash="34ceb62bbcd46b57947d369bf58737a1"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="craftyclicks_clicktoaddress.xml" hash="76a352b24809cb433f0dfe0beadb4144"/></dir><dir name="template"><dir name="craftyclicks"><dir name="clicktoaddress"><file name="common_config.phtml" hash="105cfbd98b0da641df4c182b5a1930b1"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir><dir name="layout"><file name="craftyclicks_clicktoaddress.xml" hash="eb137a167c971b7e57f771d6fbbe05c8"/></dir></dir><dir name="template"><dir name="craftyclicks"><dir name="clicktoaddress"><file name="common_config.phtml" hash="f5790f5c764684d79d4a0a9fa1d23344"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="js"><dir name="craftyclicks"><dir name="clicktoaddress"><file name="crafty_postcode.class.js" hash="44593e9ea50fbfb6a6a35760b878331f"/><file name="craftyclicks_aheadworks_onestepcheckout.js" hash="8e771ddfcbd125a86298bec9627e0455"/><file name="craftyclicks_aitoc_checkout.js" hash="e4e1128e97c78545afe5a2b176c3865c"/><file name="craftyclicks_amesty_onepagecheckout.js" hash="9b1040089d3e4fbfcac15474c959b46a"/><file name="craftyclicks_ath_oscheckout.js" hash="5b1bf7b4b52750c3495ed028ababad2b"/><file name="craftyclicks_awesome_checkout.js" hash="3acb3da5f1fa843046076fb1c8f4b9cf"/><file name="craftyclicks_ecomm_easycheckout.js" hash="dfa623bd3ec54f5680c9da6a01825142"/><file name="craftyclicks_gomage_lightcheckout.js" hash="1c6f9d930a3d946508bda2bd54b8f93b"/><file name="craftyclicks_iwd_onestepcheckout.js" hash="4134989d3d606a052f62e8f2cf304c0c"/><file name="craftyclicks_iwd_onestepcheckout_v2_2.js" hash="a6ca0de328765b07d5b7447b7c54951e"/><file name="craftyclicks_magento.js" hash="e37d09979e449bc98bb99b2e99895a5d"/><file name="craftyclicks_magento.js~" hash="aa12f726bcb272d247e1af2e32768145"/><file name="craftyclicks_magento_admin.js" hash="84a831a251d80e5b4ba6513431a4c98d"/><file name="craftyclicks_onepagecheckout.js" hash="d0cfccf16beb7586b4eba73edeb0fd58"/><file name="craftyclicks_opcheckout.js" hash="e71388f11b95899e216ee469c559f0b3"/><file name="craftyclicks_tm_firecheckout.js" hash="f3173c46c6d131c2021172919adcba3b"/><file name="craftyclicks_vinagentocheckout.js" hash="1157f50866b78fdecaf948e3f07d23b0"/><file name="craftyclicks_webandpeople_onepagecheckout.js" hash="7c319da4b6889fbe75ba8c5abfb503ec"/></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="craftyclicks"><dir name="clicktoaddress"><file name="button_find_address.gif" hash="0fdef9bf7ad0f7ec3f6530b7ff40bf59"/><file name="crafty_postcode_busy.gif" hash="618a14f4dca4f51100cd2400e7f9049c"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
156 |
<compatible/>
|
157 |
<dependencies><required><php><min>4.0.0</min><max>6.0.0</max></php></required></dependencies>
|
158 |
</package>
|