UK_Postcode_Address_Finder - Version 2.4.0

Version Notes

Release History :
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

Download this release

Release Info

Developer Magento Core Team
Extension UK_Postcode_Address_Finder
Version 2.4.0
Comparing to
See all releases


Code changes from version 2.3.3 to 2.4.0

Files changed (32) hide show
  1. app/code/local/CraftyClicks/etc/config.xml +17 -4
  2. app/code/local/CraftyClicks/etc/config.xml~ +57 -0
  3. app/code/local/CraftyClicks/etc/system.xml +33 -13
  4. app/code/local/CraftyClicks/etc/system.xml~ +170 -0
  5. app/code/local/GoMage/Checkout/Block/Onepage/Abstract.php +0 -278
  6. app/design/adminhtml/default/default/layout/craftyclicks.xml +48 -0
  7. app/design/adminhtml/default/default/template/craftyclicks/common_config.phtml +64 -0
  8. app/design/frontend/base/default/layout/craftyclicks.xml +55 -27
  9. app/design/frontend/base/default/template/craftyclicks/address_form.phtml +0 -5
  10. app/design/frontend/base/default/template/craftyclicks/checkout/onepage/billing.phtml +0 -255
  11. app/design/frontend/base/default/template/craftyclicks/checkout/onepage/shipping.phtml +0 -206
  12. app/design/frontend/base/default/template/craftyclicks/checkout_onepage.phtml +0 -6
  13. app/design/frontend/base/default/template/craftyclicks/common_config.phtml +65 -0
  14. app/design/frontend/base/default/template/craftyclicks/common_config.phtml~ +63 -0
  15. app/design/frontend/base/default/template/craftyclicks/crafty_template_helper.php +0 -216
  16. app/design/frontend/base/default/template/craftyclicks/customer/address/edit.phtml +0 -205
  17. app/design/frontend/base/default/template/craftyclicks/gomage_lightcheckout.phtml +0 -6
  18. app/design/frontend/base/default/template/craftyclicks/single_page_checkout.phtml +0 -6
  19. app/design/frontend/base/default/template/onestepcheckout/__orig_files_cc/billing_fields.phtml +0 -203
  20. app/design/frontend/base/default/template/onestepcheckout/__orig_files_cc/shipping_fields.phtml +0 -119
  21. app/design/frontend/base/default/template/onestepcheckout/billing_fields.phtml +0 -227
  22. app/design/frontend/base/default/template/onestepcheckout/shipping_fields.phtml +0 -142
  23. app/etc/modules/CraftyClicks.xml +1 -1
  24. js/craftyclicks/crafty_mage_onepage.js~ +237 -0
  25. js/craftyclicks/crafty_postcode.class.js +2 -2
  26. js/craftyclicks/craftyclicks_gomage_lightcheckout.js +318 -0
  27. js/craftyclicks/craftyclicks_magento.js +370 -0
  28. js/craftyclicks/craftyclicks_magento.js~ +370 -0
  29. js/craftyclicks/craftyclicks_magento_admin.js +365 -0
  30. js/craftyclicks/craftyclicks_magento_multiship.js~ +323 -0
  31. js/craftyclicks/craftyclicks_onepagecheckout.js +319 -0
  32. package.xml +17 -15
app/code/local/CraftyClicks/etc/config.xml CHANGED
@@ -12,7 +12,7 @@
12
  <config>
13
  <modules>
14
  <CraftyClicks>
15
- <version>2.3.3</version>
16
  </CraftyClicks>
17
  </modules>
18
 
@@ -24,7 +24,18 @@
24
  </craftyclicks>
25
  </updates>
26
  </layout>
27
- </frontend>
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  <global>
30
  <helpers>
@@ -38,15 +49,17 @@
38
  <general>
39
  <craftyclicks>
40
  <active>0</active>
 
41
  <model>craftyclicks</model>
42
  <access_token>xxxxx-xxxxx-xxxxx-xxxxx</access_token>
 
43
  <button_image></button_image>
44
  <button_class>button</button_class>
45
  <hide_fields>0</hide_fields>
46
  <hide_county>1</hide_county>
47
  <clear_result>0</clear_result>
48
- <house_search>0</house_search>
49
  <error_class>error</error_class>
 
50
  <first_res_line>----- please select your address ----</first_res_line>
51
  <error_msg_1>This postcode could not be found, please try again or enter your address manually</error_msg_1>
52
  <error_msg_2>This postcode is not valid, please try again or enter your address manually</error_msg_2>
@@ -55,4 +68,4 @@
55
  </craftyclicks>
56
  </general>
57
  </default>
58
- </config>
12
  <config>
13
  <modules>
14
  <CraftyClicks>
15
+ <version>2.4.0</version>
16
  </CraftyClicks>
17
  </modules>
18
 
24
  </craftyclicks>
25
  </updates>
26
  </layout>
27
+ </frontend>
28
+
29
+ <adminhtml>
30
+ <layout>
31
+ <updates>
32
+ <craftyclicks>
33
+ <file>craftyclicks.xml</file>
34
+ </craftyclicks>
35
+ </updates>
36
+ </layout>
37
+ </adminhtml>
38
+
39
 
40
  <global>
41
  <helpers>
49
  <general>
50
  <craftyclicks>
51
  <active>0</active>
52
+ <active_admin_panel>0</active_admin_panel>
53
  <model>craftyclicks</model>
54
  <access_token>xxxxx-xxxxx-xxxxx-xxxxx</access_token>
55
+ <access_token_admin_panel>xxxxx-xxxxx-xxxxx-xxxxx</access_token_admin_panel>
56
  <button_image></button_image>
57
  <button_class>button</button_class>
58
  <hide_fields>0</hide_fields>
59
  <hide_county>1</hide_county>
60
  <clear_result>0</clear_result>
 
61
  <error_class>error</error_class>
62
+ <max_res_lines>5</max_res_lines>
63
  <first_res_line>----- please select your address ----</first_res_line>
64
  <error_msg_1>This postcode could not be found, please try again or enter your address manually</error_msg_1>
65
  <error_msg_2>This postcode is not valid, please try again or enter your address manually</error_msg_2>
68
  </craftyclicks>
69
  </general>
70
  </default>
71
+ </config>
app/code/local/CraftyClicks/etc/config.xml~ ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Crafty Clicks - Address Finder
5
+ *
6
+ * @category CraftyClicks
7
+ * @package CraftyClicks
8
+ * @copyright CraftyClicks.co.uk
9
+ */
10
+ -->
11
+
12
+ <config>
13
+ <modules>
14
+ <CraftyClicks>
15
+ <version>2.3.3</version>
16
+ </CraftyClicks>
17
+ </modules>
18
+
19
+ <frontend>
20
+ <layout>
21
+ <updates>
22
+ <craftyclicks>
23
+ <file>craftyclicks.xml</file>
24
+ </craftyclicks>
25
+ </updates>
26
+ </layout>
27
+ </frontend>
28
+
29
+ <global>
30
+ <helpers>
31
+ <craftyclicks>
32
+ <class>CraftyClicks_Helper</class>
33
+ </craftyclicks>
34
+ </helpers>
35
+ </global>
36
+
37
+ <default>
38
+ <general>
39
+ <craftyclicks>
40
+ <active>0</active>
41
+ <model>craftyclicks</model>
42
+ <access_token>xxxxx-xxxxx-xxxxx-xxxxx</access_token>
43
+ <button_image></button_image>
44
+ <button_class>button</button_class>
45
+ <hide_fields>0</hide_fields>
46
+ <hide_county>1</hide_county>
47
+ <clear_result>0</clear_result>
48
+ <error_class>error</error_class>
49
+ <first_res_line>----- please select your address ----</first_res_line>
50
+ <error_msg_1>This postcode could not be found, please try again or enter your address manually</error_msg_1>
51
+ <error_msg_2>This postcode is not valid, please try again or enter your address manually</error_msg_2>
52
+ <error_msg_3>Unable to connect to address lookup server, please enter your address manually</error_msg_3>
53
+ <error_msg_4>An unexpected error occured, please enter your address manually</error_msg_4>
54
+ </craftyclicks>
55
+ </general>
56
+ </default>
57
+ </config>
app/code/local/CraftyClicks/etc/system.xml CHANGED
@@ -30,15 +30,36 @@
30
  <show_in_store>0</show_in_store>
31
  </active>
32
 
 
 
 
 
 
 
 
 
 
 
33
  <access_token translate="label">
34
- <label>Access Token</label>
35
  <frontend_type>text</frontend_type>
36
  <sort_order>5</sort_order>
37
  <show_in_default>1</show_in_default>
38
  <show_in_website>1</show_in_website>
39
  <show_in_store>0</show_in_store>
 
40
  </access_token>
41
 
 
 
 
 
 
 
 
 
 
 
42
  <button_image translate="label">
43
  <label>Button Image</label>
44
  <frontend_type>text</frontend_type>
@@ -92,17 +113,6 @@
92
  <comment>Select to hide the result box once an address is selected.</comment>
93
  </clear_result>
94
 
95
- <house_search translate="label">
96
- <label>Search by house name/number</label>
97
- <frontend_type>select</frontend_type>
98
- <source_model>adminhtml/system_config_source_yesno</source_model>
99
- <sort_order>27</sort_order>
100
- <show_in_default>1</show_in_default>
101
- <show_in_website>1</show_in_website>
102
- <show_in_store>0</show_in_store>
103
- <comment>If 'yes' customers can provide a house name/number to speed up searching.</comment>
104
- </house_search>
105
-
106
  <error_class translate="label">
107
  <label>Error Msg Class</label>
108
  <frontend_type>text</frontend_type>
@@ -113,6 +123,16 @@
113
  <comment>Set the css class to use for the error messages. Try 'error-msg', 'error' or even leave it blank.</comment>
114
  </error_class>
115
 
 
 
 
 
 
 
 
 
 
 
116
  <first_res_line translate="label">
117
  <label>First Result Line</label>
118
  <frontend_type>text</frontend_type>
@@ -178,4 +198,4 @@
178
  </groups>
179
  </general>
180
  </sections>
181
- </config>
30
  <show_in_store>0</show_in_store>
31
  </active>
32
 
33
+ <active_admin_panel translate="label">
34
+ <label>Enabled - Admin Panel</label>
35
+ <frontend_type>select</frontend_type>
36
+ <source_model>adminhtml/system_config_source_yesno</source_model>
37
+ <sort_order>2</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>0</show_in_store>
41
+ </active_admin_panel>
42
+
43
  <access_token translate="label">
44
+ <label>Access Token - Frontend</label>
45
  <frontend_type>text</frontend_type>
46
  <sort_order>5</sort_order>
47
  <show_in_default>1</show_in_default>
48
  <show_in_website>1</show_in_website>
49
  <show_in_store>0</show_in_store>
50
+ <comment>Your access token for use on the public facing website. This should be set to "web/external" use in your Crafty Clicks MyAccount.</comment>
51
  </access_token>
52
 
53
+ <access_token_admin_panel translate="label">
54
+ <label>Access Token - Admin Panel</label>
55
+ <frontend_type>text</frontend_type>
56
+ <sort_order>6</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>0</show_in_store>
60
+ <comment>Your access token for use on the internal admin panel. This should be set to "internal" use in your Crafty Clicks MyAccount. Contact us if you need more info on licensing.</comment>
61
+ </access_token_admin_panel>
62
+
63
  <button_image translate="label">
64
  <label>Button Image</label>
65
  <frontend_type>text</frontend_type>
113
  <comment>Select to hide the result box once an address is selected.</comment>
114
  </clear_result>
115
 
 
 
 
 
 
 
 
 
 
 
 
116
  <error_class translate="label">
117
  <label>Error Msg Class</label>
118
  <frontend_type>text</frontend_type>
123
  <comment>Set the css class to use for the error messages. Try 'error-msg', 'error' or even leave it blank.</comment>
124
  </error_class>
125
 
126
+ <max_res_lines translate="label">
127
+ <label>Result Box Lines</label>
128
+ <frontend_type>text</frontend_type>
129
+ <sort_order>32</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>0</show_in_store>
133
+ <comment>Maximum number of lines to show in the result drop-down box.</comment>
134
+ </max_res_lines>
135
+
136
  <first_res_line translate="label">
137
  <label>First Result Line</label>
138
  <frontend_type>text</frontend_type>
198
  </groups>
199
  </general>
200
  </sections>
201
+ </config>
app/code/local/CraftyClicks/etc/system.xml~ ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Crafty Clicks
5
+ *
6
+ * @category CraftyClicks
7
+ * @package CraftyClicks_AddressFinder
8
+ * @copyright CraftyClicks.co.uk
9
+ */
10
+ -->
11
+
12
+ <config>
13
+ <sections>
14
+ <general>
15
+ <groups>
16
+ <craftyclicks translate="label" module="craftyclicks">
17
+ <label>Crafty Clicks - Address Finder</label>
18
+ <sort_order>124</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ <fields>
23
+ <active translate="label">
24
+ <label>Enabled - Frontend</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ </active>
32
+
33
+ <access_token translate="label">
34
+ <label>Access Token</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>5</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ </access_token>
41
+
42
+ <button_image translate="label">
43
+ <label>Button Image</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>12</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>0</show_in_store>
49
+ <comment>Here you can enter an image file name to use as the 'Find Address' button. Leave blank for a default Magento button. Images should be placed under images/craftclicks in you skin folder.</comment>
50
+ </button_image>
51
+
52
+ <button_class translate="label">
53
+ <label>Button Class</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>13</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ <comment>Here you can set the css class to use for the 'Find Address' button. Leave blank for a browser default button. Try 'button'.</comment>
60
+ </button_class>
61
+
62
+ <hide_fields translate="label">
63
+ <label>Hide Address Fields for New Address Entry</label>
64
+ <frontend_type>select</frontend_type>
65
+ <source_model>adminhtml/system_config_source_yesno</source_model>
66
+ <sort_order>20</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>0</show_in_store>
70
+ <comment>Select to hide address fields until a postcode is looked up and an address is selected. Address fields are only hidden if they are blank (i.e. new address entry, not edit).</comment>
71
+ </hide_fields>
72
+
73
+ <hide_county translate="label">
74
+ <label>Hide County Field for UK</label>
75
+ <frontend_type>select</frontend_type>
76
+ <source_model>adminhtml/system_config_source_yesno</source_model>
77
+ <sort_order>22</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ <comment>Select to hide the state/province (county) field if country selected is UK. County is not required to address mail in the UK, so no need to force customers to fill out this field.</comment>
82
+ </hide_county>
83
+
84
+ <clear_result translate="label">
85
+ <label>Clear Result Once Selected</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>adminhtml/system_config_source_yesno</source_model>
88
+ <sort_order>25</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>0</show_in_store>
92
+ <comment>Select to hide the result box once an address is selected.</comment>
93
+ </clear_result>
94
+
95
+ <error_class translate="label">
96
+ <label>Error Msg Class</label>
97
+ <frontend_type>text</frontend_type>
98
+ <sort_order>30</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>0</show_in_store>
102
+ <comment>Set the css class to use for the error messages. Try 'error-msg', 'error' or even leave it blank.</comment>
103
+ </error_class>
104
+
105
+ <first_res_line translate="label">
106
+ <label>First Result Line</label>
107
+ <frontend_type>text</frontend_type>
108
+ <sort_order>33</sort_order>
109
+ <show_in_default>1</show_in_default>
110
+ <show_in_website>1</show_in_website>
111
+ <show_in_store>0</show_in_store>
112
+ <comment>Text to place as first line in the result drop-down box.</comment>
113
+ </first_res_line>
114
+
115
+ <error_msg_1 translate="label">
116
+ <label>Error Msg #1</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>35</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ <comment>This message is shown if the postcode is in valid format, but not found int the database.</comment>
123
+ </error_msg_1>
124
+
125
+ <error_msg_2 translate="label">
126
+ <label>Error Msg #2</label>
127
+ <frontend_type>text</frontend_type>
128
+ <sort_order>37</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>0</show_in_store>
132
+ <comment>This message is shown if the postcode format is not valid.</comment>
133
+ </error_msg_2>
134
+
135
+ <error_msg_3 translate="label">
136
+ <label>Error Msg #3</label>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>39</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ <comment>This message is shown if the connection to lookup server times out.</comment>
143
+ </error_msg_3>
144
+
145
+ <error_msg_4 translate="label">
146
+ <label>Error Msg #4</label>
147
+ <frontend_type>text</frontend_type>
148
+ <sort_order>41</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>0</show_in_store>
152
+ <comment>This message is shown if any other error occurs.</comment>
153
+ </error_msg_4>
154
+
155
+ <help_label translate="label">
156
+ <label>Problems?</label>
157
+ <frontend_type>label</frontend_type>
158
+ <sort_order>50</sort_order>
159
+ <show_in_default>1</show_in_default>
160
+ <show_in_website>1</show_in_website>
161
+ <show_in_store>0</show_in_store>
162
+ <comment>Look on the module magento connect page, or email support@craftyclicks.co.uk.</comment>
163
+ </help_label>
164
+ </fields>
165
+ <comment><![CDATA[<a href="http://www.craftyclicks.co.uk" target="_blank">Signup for your free CraftyClicks evaluation account</a>]]></comment>
166
+ </craftyclicks>
167
+ </groups>
168
+ </general>
169
+ </sections>
170
+ </config>
app/code/local/GoMage/Checkout/Block/Onepage/Abstract.php DELETED
@@ -1,278 +0,0 @@
1
- <?php
2
- /**
3
- * GoMage LightCheckout Extension
4
- *
5
- * @category Extension
6
- * @copyright Copyright (c) 2010-2011 GoMage (http://www.gomage.com)
7
- * @author GoMage
8
- * @license http://www.gomage.com/license-agreement/ Single domain license
9
- * @terms of use http://www.gomage.com/terms-of-use
10
- * @version Release: 2.0
11
- * @since Class available since Release 1.0
12
- */
13
-
14
- class GoMage_Checkout_Block_Onepage_Abstract extends Mage_Checkout_Block_Onepage_Abstract{
15
-
16
- protected $mode;
17
- protected $helper;
18
- protected $default_address_template = 'gomage/checkout/html/address/field/default.phtml';
19
- protected $field_code_to_label = array('company'=>'Company', 'street'=>'Street', 'city'=>'City', 'telephone'=>'Telephone', 'fax'=>'Fax', 'postcode'=>'Zip/Postal', 'country_id'=>'Country', 'region'=>'State/Province');
20
-
21
- public function __construct(){
22
- $this->helper = Mage::helper('gomage_checkout');
23
- }
24
-
25
- public function getCustomerComment(){
26
- return $this->getQuote()->getGomageCheckoutCustomerComment();
27
- }
28
-
29
- public function getCheckoutMode(){
30
-
31
- if(is_null($this->mode)){
32
- $this->mode = intval($this->helper->getCheckoutMode());
33
- }
34
-
35
- return $this->mode;
36
-
37
- }
38
-
39
- public function getConfigData($node){
40
- return $this->helper->getConfigData($node);
41
- }
42
-
43
- public function isEnabled($node){
44
- return (bool) $this->getConfigData('address_fields/'.$node);
45
- }
46
- public function getDefaultCountryId(){
47
- return $this->helper->getDefaultCountryId();
48
- }
49
- public function getDefaultShippingMethod(){
50
- return $this->helper->getDefaultShippingMethod();
51
- }
52
- public function getDefaultPaymentMethod(){
53
- return $this->helper->getDefaultPaymentMethod();
54
- }
55
-
56
- public function getSortedFields(){
57
-
58
- $address_fields = array('company','street','city','telephone','fax','postcode','country_id','region');
59
- $rows = array();
60
-
61
- foreach(Mage::getStoreConfig('gomage_checkout/address_fields') as $field_name=>$status){
62
-
63
- if($status != false){
64
- if(in_array($field_name, $address_fields)){
65
- $order = intval(Mage::getStoreConfig('gomage_checkout/address_sort/'.$field_name.'_order'));
66
- if(!isset($rows[$order]) || count($rows[$order]) < 2){
67
-
68
- if($field_name == 'postcode' && isset($rows[$order][0]) && $rows[$order][0] == 'region'){
69
-
70
- array_unshift($rows[$order], $field_name);
71
-
72
- }else{
73
-
74
- $rows[$order][] = $field_name;
75
-
76
- }
77
-
78
-
79
-
80
- }else{
81
- $rows[] = array($field_name);
82
- }
83
- }
84
-
85
- }
86
-
87
-
88
- }
89
-
90
- ksort($rows);
91
-
92
- echo $this->_renderFields($rows);
93
-
94
-
95
- }
96
-
97
- protected function _renderCraftyClicksButton() {
98
- $_html = '';
99
- $doLookupFn = 'onclick="_cp_do_lookup()"';
100
- $divId = 'id="findAddrBtnDiv"';
101
- if ('shipping' == $this->prefix) {
102
- $doLookupFn = 'onclick="_cp_do_lookup2()"';
103
- $divId = 'id="findAddrBtnDiv2"';
104
- }
105
- $_html .= '<div class="field field-last" '.$divId.'><br/><div>&nbsp;';
106
- if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')){
107
- $_html .= '<img style="cursor: pointer;" src="'.$this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')).'" '.$doLookupFn.' title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"/>';
108
- } else {
109
- $_html .= '<button type="button" '.$doLookupFn.' title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"><span><span>Find Address</span></span></button>';
110
- }
111
- $_html .= '</div></div>';
112
-
113
-
114
- return ($_html);
115
- }
116
-
117
- protected function _renderFields($fields){
118
-
119
- $html = '';
120
-
121
- foreach($fields as $_fields){
122
- if(is_array($_fields)){
123
-
124
- $_cc_add_result_box = false;
125
-
126
- if(count($_fields) > 1){
127
-
128
- $data = array();
129
-
130
- $_html = '';
131
-
132
- $i = 0;
133
-
134
- $row_class = array();
135
-
136
- foreach($_fields as $field_code){
137
-
138
-
139
- $data = array(
140
-
141
- 'prefix'=>$this->prefix,
142
- 'value'=>$this->getAddress()->getData($field_code),
143
- 'label'=>@$this->field_code_to_label[$field_code],
144
- 'input_name'=>$this->prefix.'['.$field_code.']',
145
- 'input_id'=>$this->prefix.'_'.$field_code,
146
-
147
- );
148
-
149
- if($this->getConfigData('address_fields/'.$field_code) == 'req'){
150
-
151
- $data['is_required'] = true;
152
-
153
- }
154
-
155
- if(!($template = $this->getData($field_code.'_template'))){
156
- $template = $this->default_address_template;
157
- }
158
-
159
- $_html .= '<div class="field field-'.$field_code.' '.($i%2 == 0 ? ' field-first ' : ' field-last ').'" ';
160
- if ('company' == $field_code || 'city' == $field_code) {
161
- $_html .= 'id="hideOnNewAddress_'.$this->prefix.'_'.$field_code.'" ';
162
- } else if ('street' == $field_code) {
163
- $_html .= 'id="hideOnNewAddress_'.$this->prefix.'_street1" ';
164
- } else if ('region' == $field_code) {
165
- $_html .= 'id="countyDiv'.($this->prefix=='billing'?'':'2').'" ';
166
- }
167
- $_html .= '>'.$this->getLayout()->createBlock('gomage_checkout/onepage_'.$this->prefix)->setTemplate($template)->addData($data)->toHtml().'</div>';
168
-
169
- if ('postcode' == $field_code) {
170
- // add the button
171
- $_html .= $this->_renderCraftyClicksButton();
172
- $_cc_add_result_box = true;
173
- }
174
-
175
- $row_class[] = $field_code;
176
-
177
- if(++$i == 2){
178
- break;
179
- }
180
- }
181
-
182
- $html .= '<li class="fields '.implode('-', $row_class).'">'.$_html.'</li>';
183
-
184
- }else{
185
-
186
- $field_code = array_shift($_fields);
187
-
188
- $data = array(
189
- 'prefix'=>$this->prefix,
190
- 'address_prefix'=>$this->prefix,
191
- 'value'=>$this->getAddress()->getData($field_code),
192
- 'label'=>@$this->field_code_to_label[$field_code],
193
- 'input_name'=>$this->prefix.'['.$field_code.']',
194
- 'input_id'=>$this->prefix.'_'.$field_code,
195
- );
196
-
197
- if($this->getConfigData('address_fields/'.$field_code) == 'req'){
198
-
199
- $data['is_required'] = true;
200
-
201
- }
202
-
203
- if(!($template = $this->getData($field_code.'_template'))){
204
- $template = $this->default_address_template;
205
- }
206
-
207
- $_pre_html = '<div ';
208
- if ('company' == $field_code || 'city' == $field_code) {
209
- $_pre_html .= 'id="hideOnNewAddress_'.$this->prefix.'_'.$field_code.'" ';
210
- } else if ('street' == $field_code) {
211
- $_pre_html .= 'id="hideOnNewAddress_'.$this->prefix.'_street1" ';
212
- } else if ('region' == $field_code) {
213
- $_pre_html .= 'id="countyDiv'.($this->prefix=='billing'?'':'2').'" ';
214
- }
215
- $_html = $this->getLayout()->createBlock('gomage_checkout/onepage_'.$this->prefix)->setTemplate($template)->addData($data)->toHtml();
216
- if ('postcode' == $field_code) {
217
- // add the button
218
- $html .= '<li class="fields '.$field_code.'">';
219
- $html .= $_pre_html.'class="field field-'.$field_code.' field-first">'.$_html.'</div>';
220
- $html .= $this->_renderCraftyClicksButton();
221
- $html .= '</li>';
222
- $_cc_add_result_box = true;
223
- } else {
224
- $html .= '<li>'.$_pre_html.'>'.$_html.'</li>';
225
- }
226
- }
227
-
228
- if ($_cc_add_result_box) {
229
- $html .= '
230
- <li><span style="display:none;" id="crafty_postcode_result_display'.($this->prefix=='billing'?'':'2').'">&nbsp;</span></li>';
231
- }
232
- }
233
- }
234
-
235
- return $html;
236
-
237
-
238
- }
239
-
240
- public function getAddressesHtmlSelect($type)
241
- {
242
- if ($this->isCustomerLoggedIn()) {
243
- $options = array();
244
- foreach ($this->getCustomer()->getAddresses() as $address) {
245
- $options[] = array(
246
- 'value'=>$address->getId(),
247
- 'label'=>$address->format('oneline')
248
- );
249
- }
250
-
251
- $addressId = $this->getAddress()->getCustomerAddressId();
252
- if (empty($addressId)) {
253
- if ($type=='billing') {
254
- $address = $this->getCustomer()->getPrimaryBillingAddress();
255
- } else {
256
- $address = $this->getCustomer()->getPrimaryShippingAddress();
257
- }
258
- if ($address) {
259
- $addressId = $address->getId();
260
- }
261
- }
262
-
263
- $select = $this->getLayout()->createBlock('core/html_select')
264
- ->setName($type.'_address_id')
265
- ->setId($type.'-address-select')
266
- ->setClass('address-select')
267
- ->setExtraParams('onchange="checkout.loadAddress(\''.$type.'\', this.value, \''.$this->getUrl('gomage_checkout/onepage/ajax', array('action'=>'load_address')).'\')"')
268
- ->setValue($addressId)
269
- ->setOptions($options);
270
-
271
- $select->addOption('', Mage::helper('checkout')->__('New Address'));
272
-
273
- return $select->getHtml();
274
- }
275
- return '';
276
- }
277
-
278
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/craftyclicks.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Crafty Clicks Postcode Lookup
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2009-2012 Crafty Clicks (http://www.craftyclicks.com)
8
+ * @author Crafty Clicks
9
+ */
10
+ -->
11
+
12
+ <layout>
13
+ <adminhtml_sales_order_create_index>
14
+ <reference name="head">
15
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
16
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento_admin.js</script></action>
17
+ </reference>
18
+ <reference name="js">
19
+ <block type="adminhtml/template" name="craftyclicks_config" template="craftyclicks/common_config.phtml" />
20
+ </reference>
21
+ </adminhtml_sales_order_create_index>
22
+
23
+ <adminhtml_sales_order_create_load_block_data>
24
+ <reference name="content">
25
+ <block type="adminhtml/template" name="craftyclicks_config" template="craftyclicks/common_config.phtml" />
26
+ </reference>
27
+ </adminhtml_sales_order_create_load_block_data>
28
+
29
+ <adminhtml_customer_edit>
30
+ <reference name="head">
31
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
32
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento_admin.js</script></action>
33
+ </reference>
34
+ <reference name="js">
35
+ <block type="adminhtml/template" name="craftyclicks_config" template="craftyclicks/common_config.phtml" />
36
+ </reference>
37
+ </adminhtml_customer_edit>
38
+
39
+ <adminhtml_customer_new>
40
+ <reference name="head">
41
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
42
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento_admin.js</script></action>
43
+ </reference>
44
+ <reference name="js">
45
+ <block type="adminhtml/template" name="craftyclicks_config" template="craftyclicks/common_config.phtml" />
46
+ </reference>
47
+ </adminhtml_customer_new>
48
+ </layout>
app/design/adminhtml/default/default/template/craftyclicks/common_config.phtml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $conf = Mage::getStoreConfig('general');
4
+ $js_config = "";
5
+
6
+ if (1 == $conf['craftyclicks']['active_admin_panel']) {
7
+ $js_config = " var _cp_integrate = true;";
8
+ $js_config.= " var _cp_enable_for_uk_only = true;"; // if true, the button will show up only for UK
9
+ if (array_key_exists('button_image',$conf['craftyclicks']) && '' != $conf['craftyclicks']['button_image']) {
10
+ $js_config.= " var _cp_button_image = '".$this->getSkinUrl('images/craftyclicks/'.$conf['craftyclicks']['button_image'])."';";
11
+ } else {
12
+ $js_config.= " var _cp_button_image = '';";
13
+ }
14
+ $js_config.= " var _cp_button_text = 'Find Address';";
15
+ $js_config.= " var _cp_button_class = '".$conf['craftyclicks']['button_class']."';";
16
+ $js_config.= " var _cp_result_box_height = '".$conf['craftyclicks']['max_res_lines']."';"; // number of lines to show in result box, must be 1 or more
17
+ $js_config.= " var _cp_result_box_width = '';"; // width of the result box
18
+ $js_config.= " var _cp_busy_img_url = '';"; // the url of the image to show while waiting for lookup results, e.g. a spinning wheel etc.
19
+
20
+ if (array_key_exists('clear_result',$conf['craftyclicks']) && $conf['craftyclicks']['clear_result']) {
21
+ $js_config.= " var _cp_clear_result = true;";
22
+ } else {
23
+ $js_config.= " var _cp_clear_result = false;";
24
+ }
25
+
26
+ $js_config.= " var _cp_hide_result = true;"; // once users make the selection, hide the result box - true/false
27
+ $js_config.= " var _cp_1st_res_line = '".$conf['craftyclicks']['first_res_line']."';";
28
+ $js_config.= " var _cp_err_msg1 = '".$conf['craftyclicks']['error_msg_1']."';";
29
+ $js_config.= " var _cp_err_msg2 = '".$conf['craftyclicks']['error_msg_2']."';";
30
+ $js_config.= " var _cp_err_msg3 = '".$conf['craftyclicks']['error_msg_3']."';";
31
+ $js_config.= " var _cp_err_msg4 = '".$conf['craftyclicks']['error_msg_4']."';";
32
+ $js_config.= " var _cp_token_adm = '".$conf['craftyclicks']['access_token_admin_panel']."';";
33
+
34
+ if (array_key_exists('hide_fields',$conf['craftyclicks']) && $conf['craftyclicks']['hide_fields']) {
35
+ $js_config.= " var _cp_hide_fields = true;";
36
+ } else {
37
+ $js_config.= " var _cp_hide_fields = false;";
38
+ }
39
+
40
+ if (array_key_exists('hide_county',$conf['craftyclicks']) && $conf['craftyclicks']['hide_county']) {
41
+ $js_config.= " var _cp_hide_county = true;";
42
+ } else {
43
+ $js_config.= " var _cp_hide_county = false;";
44
+ }
45
+
46
+ if (array_key_exists('error_class',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_class']) {
47
+ $js_config.= " var _cp_error_class = '".$conf['craftyclicks']['error_class']."';";
48
+ } else {
49
+ $js_config.= " var _cp_error_class = '';";
50
+ }
51
+
52
+ } else { //if (1 == $conf['craftyclicks']['active_admin_panel']) {
53
+ $js_config = " var _cp_integrate = false; ";
54
+ }
55
+ ?>
56
+
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+
60
+ <?php echo $js_config; ?>
61
+
62
+ //]]>
63
+ </script>
64
+
app/design/frontend/base/default/layout/craftyclicks.xml CHANGED
@@ -1,46 +1,74 @@
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
 
2
 
3
  <layout>
4
 
 
 
5
  <checkout_onepage_index>
6
- <reference name="checkout.onepage.billing">
7
- <action method="setTemplate"><template>craftyclicks/checkout/onepage/billing.phtml</template></action>
8
- </reference>
9
- <reference name="checkout.onepage.shipping">
10
- <action method="setTemplate"><template>craftyclicks/checkout/onepage/shipping.phtml</template></action>
11
- </reference>
12
- <reference name="before_body_end">
13
- <block type="checkout/onepage_billing" name="checkout.onepage.billing" as="billing" template="craftyclicks/checkout_onepage.phtml"/>
14
- </reference>
15
  </checkout_onepage_index>
16
 
17
  <checkout_multishipping_customer_address>
18
- <reference name="customer_address_edit">
19
- <action method="setTemplate"><template>craftyclicks/customer/address/edit.phtml</template></action>
20
- </reference>
21
- <reference name="before_body_end">
22
- <block type="customer/address_edit" name="customer.address.edit" as="shipping" template="craftyclicks/address_form.phtml"/>
23
- </reference>
24
  </checkout_multishipping_customer_address>
25
-
 
 
 
 
 
 
 
 
26
  <customer_address_form>
27
- <reference name="customer_address_edit">
28
- <action method="setTemplate"><template>craftyclicks/customer/address/edit.phtml</template></action>
29
- </reference>
30
- <reference name="before_body_end">
31
- <block type="customer/address_edit" name="customer.address.edit" template="craftyclicks/address_form.phtml"/>
32
- </reference>
33
  </customer_address_form>
 
 
 
 
 
 
 
 
 
 
34
 
35
  <onestepcheckout_index_index>
36
- <reference name="before_body_end">
37
- <block type="onestepcheckout/checkout" name="onestepcheckout.craftyclicks" as="craftyclicks" template="craftyclicks/single_page_checkout.phtml"/>
 
 
38
  </reference>
39
  </onestepcheckout_index_index>
40
-
41
  <gomage_checkout_onepage_index>
42
- <reference name="before_body_end">
43
- <block type="gomage_checkout/onepage" name="gomage_checkout.craftyclicks" as="craftyclicks" template="craftyclicks/gomage_lightcheckout.phtml"/>
 
 
44
  </reference>
45
  </gomage_checkout_onepage_index>
 
46
  </layout>
1
  <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Crafty Clicks Postcode Lookup
5
+ *
6
+ * @category Extension
7
+ * @copyright Copyright (c) 2009-2012 Crafty Clicks (http://www.craftyclicks.com)
8
+ * @author Crafty Clicks
9
+ */
10
+ -->
11
 
12
  <layout>
13
 
14
+ <!-- standard magento pages -->
15
+
16
  <checkout_onepage_index>
17
+ <reference name="head">
18
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
19
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento.js</script></action>
20
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
21
+ </reference>
 
 
 
 
22
  </checkout_onepage_index>
23
 
24
  <checkout_multishipping_customer_address>
25
+ <reference name="head">
26
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
27
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento.js</script></action>
28
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
29
+ </reference>
 
30
  </checkout_multishipping_customer_address>
31
+
32
+ <checkout_multishipping_register>
33
+ <reference name="head">
34
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
35
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento.js</script></action>
36
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
37
+ </reference>
38
+ </checkout_multishipping_register>
39
+
40
  <customer_address_form>
41
+ <reference name="head">
42
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
43
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento.js</script></action>
44
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
45
+ </reference>
 
46
  </customer_address_form>
47
+
48
+ <customer_account_create>
49
+ <reference name="head">
50
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
51
+ <action method="addJs"><script>craftyclicks/craftyclicks_magento.js</script></action>
52
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
53
+ </reference>
54
+ </customer_account_create>
55
+
56
+ <!-- after-market single page checkout extensions -->
57
 
58
  <onestepcheckout_index_index>
59
+ <reference name="head">
60
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
61
+ <action method="addJs"><script>craftyclicks/craftyclicks_onepagecheckout.js</script></action>
62
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
63
  </reference>
64
  </onestepcheckout_index_index>
65
+
66
  <gomage_checkout_onepage_index>
67
+ <reference name="head">
68
+ <action method="addJs"><script>craftyclicks/crafty_postcode.class.js</script></action>
69
+ <action method="addJs"><script>craftyclicks/craftyclicks_gomage_lightcheckout.js</script></action>
70
+ <block type="page/html" name="craftyclicks_config" template="craftyclicks/common_config.phtml"/>
71
  </reference>
72
  </gomage_checkout_onepage_index>
73
+
74
  </layout>
app/design/frontend/base/default/template/craftyclicks/address_form.phtml DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
- require ('crafty_template_helper.php');
3
-
4
- crafty_add_address_finder($this, '', 'company', 'street_', 'city', 'region', 'zip', 'country', '530px');
5
- ?>
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/checkout/onepage/billing.phtml DELETED
@@ -1,255 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- *
26
- *
27
- * NOTE - this file is modified to include the CraftyClicks Address Finder Extension
28
- */
29
- ?>
30
- <form id="co-billing-form" action="">
31
- <fieldset>
32
- <ul class="form-list">
33
- <?php if ($this->customerHasAddresses()): ?>
34
- <li class="wide">
35
- <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
36
- <div class="input-box">
37
- <?php echo $this->getAddressesHtmlSelect('billing') ?>
38
- </div>
39
- </li>
40
- <?php endif; ?>
41
- <li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
42
- <fieldset>
43
- <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
44
- <ul>
45
- <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
46
- <li class="fields">
47
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
48
- <div class="field">
49
- <label for="billing:company"><?php echo $this->__('Company') ?></label>
50
- <div class="input-box">
51
- <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
52
- </div>
53
- </div>
54
- <?php endif ?>
55
- <?php if(!$this->isCustomerLoggedIn()): ?>
56
- <div class="field">
57
- <label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
58
- <div class="input-box">
59
- <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
60
- </div>
61
- </div>
62
- <?php endif ?>
63
- </li>
64
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
65
- <li class="fields">
66
- <div class="field">
67
- <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
68
- <div class="input-box">
69
- <?php echo $this->getCountryHtmlSelect('billing') ?>
70
- </div>
71
- </div>
72
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/house_search')) : ?>
73
- </li>
74
- <li class="fields">
75
- <div class="field" id="houseSearchDiv">
76
- <label for="crafty_in_search_string"><?php echo $this->__('House Name or Number') ?></label>
77
- <div class="input-box">
78
- <input type="text" title="<?php echo $this->__('House Name or Number') ?>" name="crafty_in_search_string" id="crafty_in_search_string" class="input-text" />
79
- </div>
80
- </div>
81
- <?php endif ?>
82
- <div class="field" id="zipDiv">
83
- <label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
84
- <div class="input-box">
85
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international required-entry"/>
86
- </div>
87
- </div>
88
- <div class="field" id="findAddrBtnDiv" style="display:none;"><br />
89
- &nbsp;
90
- <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
91
- <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
92
- <?php else : ?>
93
- <button type="button" onclick="_cp_do_lookup()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"><span><span>Find Address</span></span></button>
94
- <?php endif ?>
95
- </div>
96
- </li>
97
- <li class="fields">
98
- <span style="display:none;" id="crafty_postcode_result_display">&nbsp;</span>
99
- </li>
100
- <li class="fields" id="hideOnNewAddress_billing:company">
101
- <div class="field">
102
- <label for="billing:company"><?php echo $this->__('Company') ?></label>
103
- <div class="input-box">
104
- <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" />
105
- </div>
106
- </div>
107
- </li>
108
- <?php endif ?>
109
- <li class="wide" id="hideOnNewAddress_billing:street1">
110
- <label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
111
- <div class="input-box">
112
- <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" class="input-text required-entry" />
113
- </div>
114
- </li>
115
- <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
116
- <li class="wide" id="hideOnNewAddress_billing:street<?php echo $_i?>">
117
- <div class="input-box">
118
- <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="billing[street][]" id="billing:street<?php echo $_i?>" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet($_i)) ?>" class="input-text" />
119
- </div>
120
- </li>
121
- <?php endfor ?>
122
- <li class="fields" id="hideOnNewAddress_billing:city">
123
- <div class="field">
124
- <label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
125
- <div class="input-box">
126
- <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->htmlEscape($this->getAddress()->getCity()) ?>" class="input-text required-entry" id="billing:city" />
127
- </div>
128
- </div>
129
- <div class="field" id="countyDiv">
130
- <label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
131
- <div class="input-box">
132
- <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
133
- <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
134
- </select>
135
- <script type="text/javascript">
136
- //<![CDATA[
137
- $('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
138
- //]]>
139
- </script>
140
- <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
141
- </div>
142
- </div>
143
- </li>
144
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
145
- <li class="fields">
146
- <div class="field">
147
- <label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
148
- <div class="input-box">
149
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international required-entry" />
150
- </div>
151
- </div>
152
- <div class="field">
153
- <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
154
- <div class="input-box">
155
- <?php echo $this->getCountryHtmlSelect('billing') ?>
156
- </div>
157
- </div>
158
- </li>
159
- <?php endif ?>
160
- <li lang="fields">
161
- <div class="field">
162
- <label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
163
- <div class="input-box">
164
- <input type="text" name="billing[telephone]" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" id="billing:telephone" />
165
- </div>
166
- </div>
167
- <div class="field">
168
- <label for="billing:fax"><?php echo $this->__('Fax') ?></label>
169
- <div class="input-box">
170
- <input type="text" name="billing[fax]" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text" id="billing:fax" />
171
- </div>
172
- </div>
173
- </li>
174
- <?php if(!$this->isCustomerLoggedIn()): ?>
175
-
176
- <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
177
- <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
178
- <?php if ($_dob->isEnabled() || $_gender->isEnabled()): ?>
179
- <li class="fields">
180
- <?php if ($_dob->isEnabled()): ?>
181
- <div class="field">
182
- <?php echo $_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
183
- </div>
184
- <?php endif; ?>
185
- <?php if ($_gender->isEnabled()): ?>
186
- <div class="field">
187
- <?php echo $_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
188
- </div>
189
- <?php endif ?>
190
- </li>
191
- <?php endif ?>
192
-
193
- <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
194
- <?php if ($_taxvat->isEnabled()): ?>
195
- <li>
196
- <?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
197
- </li>
198
- <?php endif ?>
199
-
200
- <li class="fields" id="register-customer-password">
201
- <div class="field">
202
- <label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
203
- <div class="input-box">
204
- <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
205
- </div>
206
- </div>
207
- <div class="field">
208
- <label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
209
- <div class="input-box">
210
- <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="input-text required-entry validate-cpassword" />
211
- </div>
212
- </div>
213
- </li>
214
- <?php endif; ?>
215
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
216
- <li class="control">
217
- <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="billing:save_in_address_book"><?php echo $this->__('Save in address book') ?></label>
218
- </li>
219
- <?php else:?>
220
- <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>
221
- <?php endif; ?>
222
- </ul>
223
- </fieldset>
224
- </li>
225
- <?php if ($this->canShip()): ?>
226
- <li class="control">
227
- <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo $this->__('Ship to this address') ?></label></li>
228
- <li class="control">
229
- <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
230
- </li>
231
- <?php endif; ?>
232
- </ul>
233
- <?php if (!$this->canShip()): ?>
234
- <input type="hidden" name="billing[use_for_shipping]" value="1" />
235
- <?php endif; ?>
236
- <div class="buttons-set" id="billing-buttons-container">
237
- <p class="required"><?php echo $this->__('* Required Fields') ?></p>
238
- <button type="button" title="<?php echo $this->__('Continue') ?>" class="button" onclick="billing.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
239
- <span class="please-wait" id="billing-please-wait" style="display:none;">
240
- <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
241
- </span>
242
- </div>
243
- </fieldset>
244
- </form>
245
- <script type="text/javascript">
246
- //<![CDATA[
247
- var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
248
- var billingForm = new VarienForm('co-billing-form');
249
-
250
- //billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
251
- $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
252
-
253
- var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', countryRegions, undefined, 'billing:postcode');
254
- //]]>
255
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/checkout/onepage/shipping.phtml DELETED
@@ -1,206 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- *
26
- *
27
- * NOTE - this file is modified to include the CraftyClicks Address Finder Extension
28
- */
29
- ?>
30
- <form action="" id="co-shipping-form">
31
- <ul class="form-list">
32
- <?php if ($this->customerHasAddresses()): ?>
33
- <li class="wide">
34
- <label for="shipping-address-select"><?php echo $this->__('Select a shipping address from your address book or enter a new address.') ?></label>
35
- <div class="input-box">
36
- <?php echo $this->getAddressesHtmlSelect('shipping') ?>
37
- </div>
38
- </li>
39
- <?php endif ?>
40
- <li id="shipping-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif ?>>
41
- <fieldset>
42
- <input type="hidden" name="shipping[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="shipping:address_id" />
43
- <ul>
44
- <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress())->setFieldIdFormat('shipping:%s')->setFieldNameFormat('shipping[%s]')->setFieldParams('onchange="shipping.setSameAsBilling(false)"')->toHtml() ?></li>
45
- <li class="fields">
46
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
47
- <div class="fields">
48
- <label for="shipping:company"><?php echo $this->__('Company') ?></label>
49
- <div class="input-box">
50
- <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" />
51
- </div>
52
- </div>
53
- <?php endif ?>
54
- <?php if(false): ?>
55
- <div class="fields">
56
- <label for="shipping:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
57
- <div class="input-box">
58
- <input type="text" name="shipping[email]" id="shipping:email" value="<?php echo $this->htmlEscape($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
59
- </div>
60
- </div>
61
- <?php endif ?>
62
- </li>
63
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
64
- <li class="fields">
65
- <div class="field">
66
- <label for="shipping:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
67
- <div class="input-box">
68
- <?php echo $this->getCountryHtmlSelect('shipping') ?>
69
- </div>
70
- </div>
71
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/house_search')) : ?>
72
- </li>
73
- <li class="fields">
74
- <div class="field" id="houseSearchDiv2">
75
- <label for="crafty_in_search_string2"><?php echo $this->__('House Name or Number') ?></label>
76
- <div class="input-box">
77
- <input type="text" title="<?php echo $this->__('House Name or Number') ?>" name="crafty_in_search_string2" id="crafty_in_search_string2" class="input-text" />
78
- </div>
79
- </div>
80
- <?php endif ?>
81
- <div class="field" id="zipDiv2">
82
- <label for="shipping:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
83
- <div class="input-box">
84
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international required-entry" onchange="shipping.setSameAsBilling(false);" />
85
- </div>
86
- </div>
87
- <div class="field" id="findAddrBtnDiv2" style="display:none;"><br />
88
- &nbsp;
89
- <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
90
- <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup2()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
91
- <?php else : ?>
92
- <button type="button" onclick="_cp_do_lookup2()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"><span><span>Find Address</span></span></button>
93
- <?php endif ?>
94
- </div>
95
- </li>
96
- <li class="fields">
97
- <span style="display:none;" id="crafty_postcode_result_display2">&nbsp;</span>
98
- </li>
99
- <li class="fields" id="hideOnNewAddress_shipping:company">
100
- <div class="fields">
101
- <label for="shipping:company"><?php echo $this->__('Company') ?></label>
102
- <div class="input-box">
103
- <input type="text" id="shipping:company" name="shipping[company]" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" />
104
- </div>
105
- </div>
106
- </li>
107
- <?php endif ?>
108
- <li class="wide" id="hideOnNewAddress_shipping:street1">
109
- <label for="shipping:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
110
- <div class="input-box">
111
- <input type="text" title="<?php echo $this->__('Street Address') ?>" name="shipping[street][]" id="shipping:street1" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" class="input-text required-entry" onchange="shipping.setSameAsBilling(false);" />
112
- </div>
113
- </li>
114
- <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
115
- <li class="wide" id="hideOnNewAddress_shipping:street<?php echo $_i?>">
116
- <div class="input-box">
117
- <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="shipping[street][]" id="shipping:street<?php echo $_i?>" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet($_i)) ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" />
118
- </div>
119
- </li>
120
- <?php endfor ?>
121
- <li class="fields" id="hideOnNewAddress_shipping:city">
122
- <div class="field">
123
- <label for="shipping:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
124
- <div class="input-box">
125
- <input type="text" title="<?php echo $this->__('City') ?>" name="shipping[city]" value="<?php echo $this->htmlEscape($this->getAddress()->getCity()) ?>" class="input-text required-entry" id="shipping:city" onchange="shipping.setSameAsBilling(false);" />
126
- </div>
127
- </div>
128
- <div class="field" id="countyDiv2">
129
- <label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
130
- <div class="input-box">
131
- <select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
132
- <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
133
- </select>
134
- <script type="text/javascript">
135
- //<![CDATA[
136
- $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
137
- //]]>
138
- </script>
139
- <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
140
- </div>
141
- </div>
142
- </li>
143
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
144
- <li class="fields">
145
- <div class="field">
146
- <label for="shipping:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
147
- <div class="input-box">
148
- <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="shipping[postcode]" id="shipping:postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international required-entry" onchange="shipping.setSameAsBilling(false);" />
149
- </div>
150
- </div>
151
- <div class="field">
152
- <label for="shipping:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
153
- <div class="input-box">
154
- <?php echo $this->getCountryHtmlSelect('shipping') ?>
155
- </div>
156
- </div>
157
- </li>
158
- <?php endif ?>
159
- <li class="fields">
160
- <div class="field">
161
- <label for="shipping:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
162
- <div class="input-box">
163
- <input type="text" name="shipping[telephone]" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" id="shipping:telephone" onchange="shipping.setSameAsBilling(false);" />
164
- </div>
165
- </div>
166
- <div class="field">
167
- <label for="shipping:fax"><?php echo $this->__('Fax') ?></label>
168
- <div class="input-box">
169
- <input type="text" name="shipping[fax]" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text" id="shipping:fax" onchange="shipping.setSameAsBilling(false);" />
170
- </div>
171
- </div>
172
- </li>
173
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
174
- <li class="control">
175
- <input type="checkbox" name="shipping[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="shipping:save_in_address_book" onchange="shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="shipping:save_in_address_book"><?php echo $this->__('Save in address book') ?></label></li>
176
- <?php else:?>
177
- <li class="no-display"><input type="hidden" name="shipping[save_in_address_book]" value="1" /></li>
178
- <?php endif;?>
179
- </ul>
180
- </fieldset>
181
- </li>
182
- <li class="control">
183
- <input type="checkbox" name="shipping[same_as_billing]" id="shipping:same_as_billing" value="1"<?php if($this->getAddress()->getSameAsBilling()): ?> checked="checked"<?php endif; ?> title="<?php echo $this->__('Use Billing Address') ?>" onclick="shipping.setSameAsBilling(this.checked)" class="checkbox" /><label for="shipping:same_as_billing"><?php echo $this->__('Use Billing Address') ?></label>
184
- </li>
185
- </ul>
186
- <div class="buttons-set" id="shipping-buttons-container">
187
- <p class="required"><?php echo $this->__('* Required Fields') ?></p>
188
- <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
189
- <button type="button" class="button" title="<?php echo $this->__('Continue') ?>" onclick="shipping.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
190
- <span id="shipping-please-wait" class="please-wait" style="display:none;">
191
- <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
192
- </span>
193
- </div>
194
- </form>
195
- <script type="text/javascript">
196
- //<![CDATA[
197
- var shipping = new Shipping('co-shipping-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveShipping') ?>',
198
- '<?php echo $this->getUrl('checkout/onepage/shippingMethod') ?>');
199
- var shippingForm = new VarienForm('co-shipping-form');
200
- shippingForm.extraChildParams = ' onchange="shipping.setSameAsBilling(false);"';
201
- //shippingForm.setElementsRelation('shipping:country_id', 'shipping:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
202
- $('shipping-address-select') && shipping.newAddress(!$('shipping-address-select').value);
203
-
204
- var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', countryRegions, undefined, 'shipping:postcode');
205
- //]]>
206
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/checkout_onepage.phtml DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
- require ('crafty_template_helper.php');
3
-
4
- crafty_add_address_finder($this, '', 'billing:company', 'billing:street', 'billing:city', 'billing:region', 'billing:postcode', 'billing:country_id', '530px');
5
- crafty_add_address_finder($this, '2', 'shipping:company', 'shipping:street', 'shipping:city', 'shipping:region', 'shipping:postcode', 'shipping:country_id', '530px');
6
- ?>
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/common_config.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $conf = Mage::getStoreConfig('general');
4
+ $js_config = "";
5
+
6
+ if (1 == $conf['craftyclicks']['active']) {
7
+ $js_config = " var _cp_integrate = true;";
8
+ $js_config.= " var _cp_enable_for_uk_only = true;"; // if true, the button will show up only for UK
9
+ if (array_key_exists('button_image',$conf['craftyclicks']) && '' != $conf['craftyclicks']['button_image']) {
10
+ $js_config.= " var _cp_button_image = '".$this->getSkinUrl('images/craftyclicks/'.$conf['craftyclicks']['button_image'])."';";
11
+ } else {
12
+ $js_config.= " var _cp_button_image = '';";
13
+ }
14
+ $js_config.= " var _cp_button_text = 'Find Address';";
15
+ $js_config.= " var _cp_button_class = '".$conf['craftyclicks']['button_class']."';";
16
+ $js_config.= " var _cp_result_box_height = '".$conf['craftyclicks']['max_res_lines']."';"; // number of lines to show in result box, must be 1 or more
17
+ $js_config.= " var _cp_result_box_width = '';"; // width of the result box
18
+ $js_config.= " var _cp_busy_img_url = '';"; // the url of the image to show while waiting for lookup results, e.g. a spinning wheel etc.
19
+
20
+ if (array_key_exists('clear_result',$conf['craftyclicks']) && $conf['craftyclicks']['clear_result']) {
21
+ $js_config.= " var _cp_clear_result = true;";
22
+ } else {
23
+ $js_config.= " var _cp_clear_result = false;";
24
+ }
25
+
26
+ $js_config.= " var _cp_hide_result = true;"; // once users make the selection, hide the result box - true/false
27
+ $js_config.= " var _cp_1st_res_line = '".$conf['craftyclicks']['first_res_line']."';";
28
+ $js_config.= " var _cp_err_msg1 = '".$conf['craftyclicks']['error_msg_1']."';";
29
+ $js_config.= " var _cp_err_msg2 = '".$conf['craftyclicks']['error_msg_2']."';";
30
+ $js_config.= " var _cp_err_msg3 = '".$conf['craftyclicks']['error_msg_3']."';";
31
+ $js_config.= " var _cp_err_msg4 = '".$conf['craftyclicks']['error_msg_4']."';";
32
+ $js_config.= " var _cp_token_fe = '".$conf['craftyclicks']['access_token']."';";
33
+
34
+ if (array_key_exists('hide_fields',$conf['craftyclicks']) && $conf['craftyclicks']['hide_fields']) {
35
+ $js_config.= " var _cp_hide_fields = true;";
36
+ } else {
37
+ $js_config.= " var _cp_hide_fields = false;";
38
+ }
39
+
40
+ if (array_key_exists('hide_county',$conf['craftyclicks']) && $conf['craftyclicks']['hide_county']) {
41
+ $js_config.= " var _cp_hide_county = true;";
42
+ } else {
43
+ $js_config.= " var _cp_hide_county = false;";
44
+ }
45
+
46
+ if (array_key_exists('error_class',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_class']) {
47
+ $js_config.= " var _cp_error_class = '".$conf['craftyclicks']['error_class']."';";
48
+ } else {
49
+ $js_config.= " var _cp_error_class = '';";
50
+ }
51
+
52
+ } else { //if (1 == $conf['craftyclicks']['active']) {
53
+ $js_config = " var _cp_integrate = false; ";
54
+ }
55
+ ?>
56
+
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+
60
+ <?php echo $js_config; ?>
61
+
62
+ //]]>
63
+ </script>
64
+
65
+
app/design/frontend/base/default/template/craftyclicks/common_config.phtml~ ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $conf = Mage::getStoreConfig('general');
4
+
5
+ if (1 == $conf['craftyclicks']['active']) {
6
+ $js_config = " var _cp_enable_for_uk_only = true;"; // if true, the button will show up only for UK
7
+ if (array_key_exists('button_image',$conf['craftyclicks']) && '' != $conf['craftyclicks']['button_image']) {
8
+ $js_config.= " var _cp_button_image = '".$this->getSkinUrl('images/craftyclicks/'.$conf['craftyclicks']['button_image'])."';";
9
+ } else {
10
+ $js_config.= " var _cp_button_image = '';";
11
+ }
12
+ $js_config.= " var _cp_button_text = 'Find Address';";
13
+ $js_config.= " var _cp_button_class = '".$conf['craftyclicks']['button_class']."';";
14
+ $js_config.= " var _cp_result_box_height = 5;"; // number of lines to show in result box, must be 1 or more
15
+ $js_config.= " var _cp_result_box_width = '';"; // width of the result box
16
+ $js_config.= " var _cp_busy_img_url = '';"; // the url of the image to show while waiting for lookup results, e.g. a spinning wheel etc.
17
+
18
+ if (array_key_exists('clear_result',$conf['craftyclicks']) && $conf['craftyclicks']['clear_result']) {
19
+ $js_config.= " var _cp_clear_result = true;";
20
+ } else {
21
+ $js_config.= " var _cp_clear_result = false;";
22
+ }
23
+
24
+ $js_config.= " var _cp_hide_result = true;"; // once users make the selection, hide the result box - true/false
25
+ $js_config.= " var _cp_max_res_lines = '".$conf['craftyclicks']['max_res_lines']."';";
26
+ $js_config.= " var _cp_1st_res_line = '".$conf['craftyclicks']['first_res_line']."';";
27
+ $js_config.= " var _cp_err_msg1 = '".$conf['craftyclicks']['error_msg_1']."';";
28
+ $js_config.= " var _cp_err_msg2 = '".$conf['craftyclicks']['error_msg_2']."';";
29
+ $js_config.= " var _cp_err_msg3 = '".$conf['craftyclicks']['error_msg_3']."';";
30
+ $js_config.= " var _cp_err_msg4 = '".$conf['craftyclicks']['error_msg_4']."';";
31
+ $js_config.= " var _cp_token_fe = '".$conf['craftyclicks']['access_token']."';";
32
+
33
+ if (array_key_exists('hide_fields',$conf['craftyclicks']) && $conf['craftyclicks']['hide_fields']) {
34
+ $js_config.= " var _cp_hide_fields = true;";
35
+ } else {
36
+ $js_config.= " var _cp_hide_fields = false;";
37
+ }
38
+
39
+ if (array_key_exists('hide_county',$conf['craftyclicks']) && $conf['craftyclicks']['hide_county']) {
40
+ $js_config.= " var _cp_hide_county = true;";
41
+ } else {
42
+ $js_config.= " var _cp_hide_county = false;";
43
+ }
44
+
45
+ if (array_key_exists('error_class',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_class']) {
46
+ $js_config.= " var _cp_error_class = '".$conf['craftyclicks']['error_class']."';";
47
+ } else {
48
+ $js_config.= " var _cp_error_class = '';";
49
+ }
50
+ ?>
51
+
52
+ <script type="text/javascript">
53
+ //<![CDATA[
54
+
55
+ <?php echo $js_config; ?>
56
+
57
+ //]]>
58
+ </script>
59
+
60
+ <?php
61
+ } //if (1 == $conf['craftyclicks']['active']) {
62
+ ?>
63
+
app/design/frontend/base/default/template/craftyclicks/crafty_template_helper.php DELETED
@@ -1,216 +0,0 @@
1
- <?php
2
- $crafty_script_added = false;
3
- function crafty_add_address_finder($obj, $suffix = '', $company_id = 'company', $street_id = 'street_', $town_id='city', $county_id='region', $postcode_id = 'zip', $country_id = '_cp_country', $res_width='') {
4
- global $crafty_script_added;
5
- $conf = Mage::getStoreConfig('general');
6
-
7
- if (1 == $conf['craftyclicks']['active']) {
8
-
9
- if (false == $crafty_script_added) {
10
- echo "<script type=\"text/javascript\" charset=\"ISO-8859-1\" src=\"".$obj->getJsUrl('craftyclicks/crafty_postcode.class.js')."\"></script>\n";
11
- $crafty_script_added = true;
12
- }
13
-
14
- echo "<script type=\"text/javascript\">
15
-
16
- var cp_obj".$suffix." = CraftyPostcodeCreate();
17
- cp_obj".$suffix.".set('max_width', '".$res_width."');
18
- cp_obj".$suffix.".set('access_token', '".$conf['craftyclicks']['access_token']."');
19
- cp_obj".$suffix.".set('result_elem_id', 'crafty_postcode_result_display".$suffix."');
20
- cp_obj".$suffix.".set('form', '');";
21
-
22
- $element_ids = $company_id.',';
23
- for ($streetNum = 1; $streetNum<=3; $streetNum++) {
24
- if ($streetNum<=$obj->helper('customer/address')->getStreetLines()) {
25
- $element_ids.= $street_id.$streetNum.',';
26
- } else {
27
- $element_ids.= ',';
28
- }
29
- }
30
- $element_ids.=$town_id.','.$county_id.','.$postcode_id;
31
- if (1 == $conf['craftyclicks']['house_search']) {
32
- $element_ids.=',,crafty_in_search_string'.$suffix;
33
- }
34
-
35
- echo "
36
- cp_obj".$suffix.".set('elements', '".$element_ids."');
37
- cp_obj".$suffix.".set('res_autoselect', '0');
38
- cp_obj".$suffix.".set('busy_img_url', '".$obj->getSkinUrl('craftyclicks/crafty_postcode_busy.gif')."');
39
- cp_obj".$suffix.".set('on_result_ready', _cp_result_ready".$suffix.");
40
- cp_obj".$suffix.".set('on_result_selected', _cp_result_selected".$suffix.");
41
- cp_obj".$suffix.".set('on_error', _cp_result_error".$suffix.");
42
- ";
43
- if (array_key_exists('first_res_line',$conf['craftyclicks']) && '' != $conf['craftyclicks']['first_res_line']) {
44
- echo " cp_obj".$suffix.".set('first_res_line', '".$conf['craftyclicks']['first_res_line']."');";
45
- }
46
- if (array_key_exists('error_msg_1',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_1']) {
47
- echo " cp_obj".$suffix.".set('err_msg1', '".$conf['craftyclicks']['error_msg_1']."');";
48
- }
49
- if (array_key_exists('error_msg_2',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_2']) {
50
- echo " cp_obj".$suffix.".set('err_msg2', '".$conf['craftyclicks']['error_msg_2']."');";
51
- }
52
- if (array_key_exists('error_msg_3',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_3']) {
53
- echo " cp_obj".$suffix.".set('err_msg3', '".$conf['craftyclicks']['error_msg_3']."');";
54
- }
55
- if (array_key_exists('error_msg_4',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_msg_4']) {
56
- echo " cp_obj".$suffix.".set('err_msg4', '".$conf['craftyclicks']['error_msg_4']."');";
57
- }
58
- echo "
59
- function _cp_set_elem_disp(elemId, new_display) {
60
- var elem = document.getElementById(elemId);
61
- if (elem) {
62
- elem.style.display = new_display;
63
- }
64
- }
65
- ";
66
-
67
- if (1 == $conf['craftyclicks']['hide_fields']) { // && '' == $obj->getAddress()->getPostcode()) {
68
- // hide address fields if they are blank, only show them once an address is selected
69
- echo "
70
- function _cp_set_addr_fields_display".$suffix."(new_display) {
71
- _cp_set_elem_disp('hideOnNewAddress_".$town_id."', new_display);
72
- _cp_set_elem_disp('hideOnNewAddress_".$company_id."', new_display);
73
- ";
74
- // do all street lines
75
- for ($street_num = 1; $street_num<=$obj->helper('customer/address')->getStreetLines(); $street_num++) {
76
- echo "
77
- _cp_set_elem_disp('hideOnNewAddress_".$street_id.$street_num."', new_display);";
78
- }
79
-
80
- echo "
81
- }
82
- // hide all address lines
83
- if ('' == document.getElementById('".$postcode_id."').value) {
84
- _cp_set_addr_fields_display".$suffix."('none');
85
- }
86
-
87
- function _cp_addr_fields_show".$suffix."() {
88
- _cp_set_addr_fields_display".$suffix."('block');
89
- }
90
- ";
91
- } else {
92
- echo "
93
- function _cp_addr_fields_show".$suffix."() {
94
- // stub
95
- }
96
- ";
97
- }
98
- if (1 == $conf['craftyclicks']['clear_result']) {
99
- echo "
100
- function _cp_addr_result_hide".$suffix."() {
101
- cp_obj".$suffix.".update_res(null);
102
- _cp_set_elem_disp('crafty_postcode_result_display".$suffix."', 'none');
103
- }
104
- ";
105
- } else {
106
- echo "
107
- function _cp_addr_result_hide".$suffix."() {
108
- //STUB
109
- }
110
- ";
111
- }
112
-
113
- if (1 == $conf['craftyclicks']['hide_county']) {
114
- echo "
115
- function _cp_county_display".$suffix."(new_display) {
116
- _cp_set_elem_disp('countyDiv".$suffix."', new_display);
117
- }
118
- ";
119
- } else {
120
- echo "
121
- function _cp_county_display".$suffix."(dummy) {
122
- //STUB
123
- }
124
- ";
125
- }
126
-
127
- echo "
128
- function _cp_result_ready".$suffix."() {
129
- _cp_addr_fields_show".$suffix."();
130
- }
131
-
132
- function _cp_result_selected".$suffix."() {
133
- _cp_addr_result_hide".$suffix."();
134
- }
135
- function _cp_result_error".$suffix."() {
136
- _cp_addr_fields_show".$suffix."();";
137
-
138
- if (array_key_exists('error_class',$conf['craftyclicks']) && '' != $conf['craftyclicks']['error_class']) {
139
- echo " document.getElementById('crafty_postcode_result_display".$suffix."').className = '".$conf['craftyclicks']['error_class']."';";
140
- }
141
- echo " }
142
- function _cp_country_handler".$suffix."() {
143
- if ('GB' != document.getElementById('".$country_id."').value) {
144
- if (document.getElementById('zipDiv')) {
145
- document.getElementById('".$postcode_id."').style.width = _cp_oldZipWidth".$suffix.";
146
- document.getElementById('zipDiv').style.width = _cp_oldZipDivWidth".$suffix.";
147
- }
148
- _cp_set_elem_disp('findAddrBtnDiv".$suffix."', 'none');
149
- _cp_set_elem_disp('crafty_postcode_result_display".$suffix."', 'none');";
150
- if (1 == $conf['craftyclicks']['house_search']) {
151
- echo "
152
- _cp_set_elem_disp('houseSearchDiv".$suffix."', 'none');";
153
- }
154
- echo "
155
- _cp_addr_fields_show".$suffix."();
156
- cp_obj".$suffix.".update_res(null);
157
- _cp_county_display".$suffix."('inline');
158
- } else {
159
- if (document.getElementById('zipDiv')) {
160
- document.getElementById('".$postcode_id."').style.width = '135px';
161
- document.getElementById('zipDiv".$suffix."').style.width = '150px';
162
- document.getElementById('findAddrBtnDiv".$suffix."').style.width = '125px';
163
- }
164
- _cp_set_elem_disp('findAddrBtnDiv".$suffix."', 'inline');";
165
- if (1 == $conf['craftyclicks']['house_search']) {
166
- echo "
167
- _cp_set_elem_disp('houseSearchDiv".$suffix."', 'inline');";
168
- }
169
- echo "
170
- _cp_county_display".$suffix."('none');
171
- }
172
- }
173
- function _cp_do_lookup".$suffix."()
174
- {
175
- document.getElementById('crafty_postcode_result_display".$suffix."').className = '';
176
- document.getElementById('crafty_postcode_result_display".$suffix."').style.display = 'inline';";
177
- if (1 == $conf['craftyclicks']['house_search']) {
178
- echo "
179
- cp_obj".$suffix.".doHouseSearch();";
180
- } else {
181
- echo "
182
- cp_obj".$suffix.".doLookup();";
183
- }
184
- echo "
185
- }
186
-
187
- var _cp_oldZipWidth".$suffix.", _cp_oldZipDivWidth".$suffix.";
188
- if (document.getElementById('zipDiv')) {
189
- _cp_oldZipWidth".$suffix." = document.getElementById('". $postcode_id."').style.width;
190
- _cp_oldZipDivWidth".$suffix." = document.getElementById('zipDiv').style.width;
191
- }
192
- var _cp_countryElem".$suffix." = document.getElementById('".$country_id."');
193
-
194
- Event.observe(_cp_countryElem".$suffix.", 'change', _cp_country_handler".$suffix.");
195
- Event.observe(_cp_countryElem".$suffix.", 'click', _cp_country_handler".$suffix.");
196
- Event.observe(_cp_countryElem".$suffix.", 'keypress', _cp_country_handler".$suffix.");
197
-
198
- _cp_country_handler".$suffix."();
199
-
200
- // make the search button default on Enter key - optional!
201
- function _cp_key_pressed_on_postcode".$suffix."(e) {
202
- var cc = 0;
203
- if (!e) e = window.event;
204
- if(e.keyCode) {cc = e.keyCode;}
205
- else if(e.which) {cc = e.which;}
206
- if(cc == 13){
207
- _cp_do_lookup".$suffix."()
208
- return false;
209
- }
210
- }
211
- var _cp_postcodeElem".$suffix." = document.getElementById('".$postcode_id."');
212
- Event.observe(_cp_postcodeElem".$suffix.", 'keypress', _cp_key_pressed_on_postcode".$suffix.");
213
- </script>";
214
- }
215
- }
216
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/customer/address/edit.phtml DELETED
@@ -1,205 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category design
22
- * @package base_default
23
- * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- *
26
- *
27
- * NOTE - this file is modified to include the CraftyClicks Address Finder Extension
28
- */
29
- ?>
30
- <?php
31
- /**
32
- * Edit customer address template
33
- *
34
- * @see Mage_Customer_Block_Address_Edit
35
- */
36
- ?>
37
- <?php if($this->getTitle()): ?>
38
- <div class="page-title">
39
- <h1><?php echo $this->getTitle() ?></h1>
40
- </div>
41
- <?php endif; ?>
42
- <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
43
- <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="form-validate">
44
- <div class="fieldset">
45
- <?php echo $this->getBlockHtml('formkey')?>
46
- <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
47
- <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
48
- <h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
49
- <ul class="form-list">
50
- <li class="fields">
51
- <?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getCustomer())->toHtml() ?>
52
- </li>
53
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : ?>
54
- <li class="wide">
55
- <label for="company"><?php echo $this->__('Company') ?></label>
56
- <div class="input-box">
57
- <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
58
- </div>
59
- </li>
60
- <?php endif ?>
61
- <li class="fields">
62
- <div class="field">
63
- <label for="telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
64
- <div class="input-box">
65
- <input type="text" name="telephone" value="<?php echo $this->htmlEscape($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" id="telephone" />
66
- </div>
67
- </div>
68
- <div class="field">
69
- <label for="fax"><?php echo $this->__('Fax') ?></label>
70
- <div class="input-box">
71
- <input type="text" name="fax" id="fax" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" class="input-text" />
72
- </div>
73
- </div>
74
- </li>
75
- </ul>
76
- </div>
77
- <div class="fieldset">
78
- <h2 class="legend"><?php echo $this->__('Address') ?></h2>
79
- <ul class="form-list">
80
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
81
- <li class="fields">
82
- <div class="field">
83
- <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
84
- <div class="input-box">
85
- <?php echo $this->getCountryHtmlSelect() ?>
86
- </div>
87
- </div>
88
- <?php if (1 == Mage::getStoreConfig('general/craftyclicks/house_search')) : ?>
89
- </li>
90
- <li class="fields">
91
- <div class="field" id="houseSearchDiv">
92
- <label for="crafty_in_search_string"><?php echo $this->__('House Name or Number') ?></label>
93
- <div class="input-box">
94
- <input type="text" title="<?php echo $this->__('House Name or Number') ?>" name="crafty_in_search_string" id="crafty_in_search_string" class="input-text" />
95
- </div>
96
- </div>
97
- <?php endif ?>
98
- <div class="field" id="zipDiv">
99
- <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
100
- <div class="input-box">
101
- <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
102
- </div>
103
- </div>
104
- <div class="field" id="findAddrBtnDiv" style="display:none;"><br />
105
- &nbsp;
106
- <?php if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')) : ?>
107
- <img style="cursor: pointer;" src="<?php echo $this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')); ?>" onclick="_cp_do_lookup()" title="Find Address" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"/>
108
- <?php else : ?>
109
- <button type="button" title="Find Address" onclick="_cp_do_lookup()" class="<?php echo Mage::getStoreConfig('general/craftyclicks/button_class');?>"><span><span>Find Address</span></span></button>
110
- <?php endif ?>
111
- </div>
112
- </li>
113
- <li class="wide">
114
- <span style="display:none;" id="crafty_postcode_result_display">&nbsp;</span>
115
- </li>
116
- <li class="wide" id="hideOnNewAddress_company">
117
- <label for="company"><?php echo $this->__('Company') ?></label>
118
- <div class="input-box">
119
- <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getCompany()) ?>" class="input-text" />
120
- </div>
121
- </li>
122
- <?php endif ?>
123
- <li class="wide" id="hideOnNewAddress_street_1">
124
- <label for="street_1" class="required"><em>*</em><?php echo $this->__('Street Address') ?></label>
125
- <div class="input-box">
126
- <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet(1)) ?>" title="<?php echo $this->__('Street Address') ?>" id="street_1" class="input-text required-entry" />
127
- </div>
128
- </li>
129
- <?php for ($_i=2, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++): ?>
130
- <li class="wide" id="hideOnNewAddress_street_<?php echo $_i?>">
131
- <div class="input-box">
132
- <input type="text" name="street[]" value="<?php echo $this->htmlEscape($this->getAddress()->getStreet($_i)) ?>" title="<?php echo $this->__('Street Address '.$_i) ?>" id="street_<?php echo $_i?>" class="input-text" />
133
- </div>
134
- </li>
135
- <?php endfor ?>
136
- <li class="fields" id="hideOnNewAddress_city">
137
- <div class="field">
138
- <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
139
- <div class="input-box">
140
- <input type="text" name="city" value="<?php echo $this->htmlEscape($this->getAddress()->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text required-entry" id="city" />
141
- </div>
142
- </div>
143
- <div class="field" id="countyDiv">
144
- <label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
145
- <div class="input-box">
146
- <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
147
- <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
148
- </select>
149
- <script type="text/javascript">
150
- //<![CDATA[
151
- $('region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
152
- //]]>
153
- </script>
154
- <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
155
- </div>
156
- </div>
157
- </li>
158
- <?php if (1 != Mage::getStoreConfig('general/craftyclicks/active')) : // for CraftyClicks we put country & postcode above other address fields ?>
159
- <li class="fields">
160
- <div class="field">
161
- <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
162
- <div class="input-box">
163
- <input type="text" name="postcode" value="<?php echo $this->htmlEscape($this->getAddress()->getPostcode()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
164
- </div>
165
- </div>
166
- <div class="field">
167
- <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
168
- <div class="input-box">
169
- <?php echo $this->getCountryHtmlSelect() ?>
170
- </div>
171
- </div>
172
- </li>
173
- <?php endif ?>
174
- <li<?php if($this->canSetAsDefaultBilling()) echo ' class="control"' ?>>
175
- <?php if($this->isDefaultBilling()): ?>
176
- <strong><?php echo $this->__('Default Billing Address') ?></strong>
177
- <?php elseif($this->canSetAsDefaultBilling()): ?>
178
- <input type="checkbox" id="primary_billing" name="default_billing" value="1" title="<?php echo $this->__('Use as My Default Billing Address') ?>" class="checkbox" /><label for="primary_billing"><?php echo $this->__('Use as my default billing address') ?></label>
179
- <?php else: ?>
180
- <input type="hidden" name="default_billing" value="1" />
181
- <?php endif; ?>
182
- </li>
183
- <li<?php if($this->canSetAsDefaultShipping()) echo ' class="control"' ?>>
184
- <?php if($this->isDefaultShipping()): ?>
185
- <strong><?php echo $this->__('Default Shipping Address') ?></strong>
186
- <?php elseif($this->canSetAsDefaultShipping()): ?>
187
- <input type="checkbox" id="primary_shipping" name="default_shipping" value="1" title="<?php echo $this->__('Use as My Default Shipping Address') ?>" class="checkbox" /><label for="primary_shipping"><?php echo $this->__('Use as my default shipping address') ?></label>
188
- <?php else: ?>
189
- <input type="hidden" name="default_shipping" value="1" />
190
- <?php endif; ?>
191
- </li>
192
- </ul>
193
- </div>
194
- <div class="buttons-set">
195
- <p class="required"><?php echo $this->__('* Required Fields') ?></p>
196
- <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
197
- <button type="submit" title="<?php echo $this->__('Save Address') ?>" class="button"><span><span><?php echo $this->__('Save Address') ?></span></span></button>
198
- </div>
199
- </form>
200
- <script type="text/javascript">
201
- //<![CDATA[
202
- var dataForm = new VarienForm('form-validate', true);
203
- new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'zip');
204
- //]]>
205
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/gomage_lightcheckout.phtml DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
- require ('crafty_template_helper.php');
3
-
4
- crafty_add_address_finder($this, '', 'billing_company', 'billing_street', 'billing_city', 'billing_region', 'billing_postcode', 'billing_country_id', '');
5
- crafty_add_address_finder($this, '2', 'shipping_company', 'shipping_street', 'shipping_city', 'shipping_region', 'shipping_postcode', 'shipping_country_id', '');
6
- ?>
 
 
 
 
 
 
app/design/frontend/base/default/template/craftyclicks/single_page_checkout.phtml DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
- require ('crafty_template_helper.php');
3
-
4
- crafty_add_address_finder($this, '', 'billing:company', 'billing:street', 'billing:city', 'billing:region', 'billing:postcode', 'billing:country_id', '');
5
- crafty_add_address_finder($this, '2', 'shipping:company', 'shipping:street', 'shipping:city', 'shipping:region', 'shipping:postcode', 'shipping:country_id', '');
6
- ?>
 
 
 
 
 
 
app/design/frontend/base/default/template/onestepcheckout/__orig_files_cc/billing_fields.phtml DELETED
@@ -1,203 +0,0 @@
1
- <?php
2
- $helper = Mage::helper('onestepcheckout/checkout');
3
- $billingFields['firstname'] = '
4
- <div class="input-box input-firstname'.((in_array('firstname', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
5
- <label for="billing:firstname">'.$this->__('First Name').'<span class="required">*</span></label><br />
6
- <input class="required-entry input-text" type="text" name="billing[firstname]" id="billing:firstname" value="'.$this->getFirstname().'" />
7
- </div>';
8
- $billingFields['lastname'] = '
9
- <div class="input-box input-lastname'.((in_array('lastname', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
10
- <label for="billing:lastname">'.$this->__('Last Name').' <span class="required">*</span></label><br />
11
- <input class="required-entry input-text" type="text" name="billing[lastname]" id="billing:lastname" value="'.$this->getLastname().'" />
12
- </div>';
13
- ?>
14
- <?php if(!$this->isCustomerLoggedIn()): ?>
15
- <?php $billingFields['email'] = '
16
- <div class="input-box input-email'.((in_array('email', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
17
- <label for="billing:email">'.$this->__('Email Address').' <span class="required">*</span></label><br />
18
- <input type="text" name="billing[email]" id="billing:email" value="'.$this->htmlEscape($this->getAddress()->getEmail()).'" title="'.$this->__('Email Address') .'" class="validate-email required-entry input-text" />
19
- </div>';
20
- ?>
21
- <?php endif; ?>
22
- <?php if(!$this->isCustomerLoggedIn() || in_array('email_registered', $this->formErrors['billing_errors'])): ?>
23
- <?php $billingFields['email_error'] = '
24
- <div class="clearfix" id="onestepcheckout-email-error" '.((!in_array('email_registered', $this->formErrors['billing_errors'])) ? 'style="display: none"' : '').'>
25
- <div id="onestepcheckout-email-error-message" class="onestepcheckout-error">'.
26
- ((in_array('email_registered', $this->formErrors['billing_errors'])) ? $this->__('Email address already registered. Please <a href="#" onclick="login_popup.show(); return false;">login now</a> or use a different email address.') : $this->__('Invalid email address.'))
27
- .'</div>
28
- </div>';
29
- ?>
30
- <?php endif; ?>
31
-
32
- <?php if(!$this->settings['exclude_telephone']):?>
33
- <?php $billingFields['telephone'] = '
34
- <div class="input-box input-telephone'.((in_array('telephone', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
35
- <label for="billing:telephone">'.$this->__('Telephone').' <span class="required">*</span></label><br/>
36
- <input type="text" name="billing[telephone]" value="'.$this->htmlEscape($this->getTelephone()).'" title="'.$this->__('Telephone').'" class="required-entry input-text" id="billing:telephone" />
37
- </div>';
38
- ?>
39
- <?php endif; ?>
40
-
41
- <?php if(!$this->settings['exclude_address']):?>
42
- <?php
43
- $addressFields = '';
44
- for ($_i=1, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++){
45
-
46
- $addressFields .= '<input type="text" title="'.$this->__('Street Address '.$_i).'" name="billing[street][]" id="billing:street'.$_i.'" value="'.$this->htmlEscape($this->getStreet($_i)).'" class="'.(($_i == 1)? 'required-entry ' : '').'input-text onestepcheckout-address-line" />';
47
- $addressFields .= (($_i != $this->helper('customer/address')->getStreetLines()) ? '<br/>': '');
48
- }
49
- $billingFields['street'] = '
50
- <div class="input-box input-address'.((in_array('telephone', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
51
- <label for="billing:street1">'.$this->__('Address').'<span class="required">*</span></label><br />
52
- '.$addressFields.'
53
- </div>';
54
- ?>
55
- <?php endif; ?>
56
-
57
- <?php if(!$this->settings['exclude_country_id']):?>
58
- <?php
59
- $billingFields['country_id'] = '
60
- <div class="input-box input-country'.((in_array('country', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
61
- <label for="billing:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
62
- '.$this->getCountryHtmlSelect('billing').'
63
- </div>';
64
- ?>
65
- <?php else: ?>
66
- <?php $billingFields['country_id'] = '
67
- <input type="hidden" name="billing[country_id]" id="billing:country_id" value="'.$this->settings['default_country'].'" />';
68
- ?>
69
- <?php endif; ?>
70
- <?php if(!$this->settings['exclude_region']): ?>
71
- <?php $billingFields['region_id'] = '
72
- <div class="input-box input-region'.((in_array('region', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
73
- <label for="billing:region">'.$this->__('State/Province').' <span class="required">*</span></label><br/>
74
- <select id="billing:region_id" name="billing[region_id]" title="'.$this->__('State/Province').'" class="validate-select" style="display:none">
75
- <option value="">'.$this->__('Please select region, state or province').'</option>
76
- </select>
77
- <script type="text/javascript">
78
- $("billing:region_id").setAttribute("defaultValue", "'.$this->getRegionId().'");
79
- </script>
80
- <input type="text" id="billing:region" name="billing[region]" value="'.$this->htmlEscape($this->getRegion()).'" title="'.$this->__('State/Province').'" class="required-entry input-text" style="display:none" />
81
- </div>';
82
- ?>
83
- <?php endif; ?>
84
- <?php if(!$this->settings['exclude_city']):?>
85
- <?php $billingFields['city'] = '
86
- <div class="input-box input-city'.((in_array('city', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
87
- <label for="billing:city">'.$this->__('City').' <span class="required">*</span></label><br/>
88
- <input type="text" name="billing[city]" value="'.$this->htmlEscape($this->getCity()).'" title="'.$this->__('City').'" class="required-entry input-text" id="billing:city" />
89
- </div>';
90
- ?>
91
- <?php endif; ?>
92
-
93
- <?php if(!$this->settings['exclude_zip']): ?>
94
- <?php $billingFields['postcode'] = '
95
- <div class="input-box input-postcode'.((in_array('postcode', $this->formErrors['billing_errors'])) ? ' input-error' : '').'" >
96
- <label for="billing:postcode">'.$this->__('Zip/Postal Code').' <span class="required">*</span></label><br />
97
- <input type="text" title="'.$this->__('Zip/Postal Code').'" name="billing[postcode]" id="billing:postcode" value="'.$this->htmlEscape($this->getPostcode()).'" class="validate-zip-international required-entry input-text" />
98
- </div>';
99
- ?>
100
- <?php endif; ?>
101
-
102
- <?php if(!$this->settings['exclude_company']): ?>
103
- <?php $billingFields['company'] = '
104
- <div class="input-box input-company'.((in_array('company', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
105
- <label for="billing:company">'.$this->__('Company').'</label><br/>
106
- <input type="text" name="billing[company]" value="'.$this->htmlEscape($this->getCompany()).'" title="'.$this->__('Company').'" class="input-text" id="billing:company" />
107
- </div>';
108
- ?>
109
- <?php endif; ?>
110
-
111
- <?php if(!$this->settings['exclude_fax']): ?>
112
- <?php $billingFields['fax'] = '
113
- <div class="input-box input-fax'.((in_array('fax', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
114
- <label for="billing:fax">'.$this->__('Fax').'</label><br/>
115
- <input type="text" name="billing[fax]" value="'.$this->htmlEscape($this->getFax()).'" title="'.$this->__('Fax').'" class="input-text" id="billing:fax" />
116
- </div>';
117
- ?>
118
- <?php endif; ?>
119
-
120
- <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat'); ?>
121
- <?php if($_taxvat->isEnabled()): ?>
122
- <?php $billingFields['taxvat'] =
123
- $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())
124
- ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();
125
- ?>
126
- <?php endif; ?>
127
-
128
- <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
129
- <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
130
-
131
- <?php if ($_dob && $_dob->isEnabled()): ?>
132
- <?php $billingFields['dob'] = '
133
- <div class="field">
134
- '.$_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml().'
135
- </div>.';
136
- ?>
137
- <?php endif; ?>
138
- <?php if ($_gender && $_gender->isEnabled()): ?>
139
- <?php $billingFields['gender'] = '
140
- <div class="field">
141
- '.$_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml().'
142
- </div>';
143
- ?>
144
- <?php endif ?>
145
- <?php if(!$this->isCustomerLoggedIn() && $helper->showCreateAccount()): ?>
146
- <?php $billingFields['create_account'] = '
147
- <div class="input-box">
148
- <input id="id_create_account" type="checkbox" name="create_account" value="1" '.((isset($_POST['create_account']) && $_POST['create_account'] == '1') ? ' checked="checked"' : '').' />
149
- <label for="id_create_account">'.$this->__('Create an account for later use').'</label>
150
- </div>
151
-
152
- <script>
153
- document.observe("dom:loaded", function() {
154
- $("id_create_account").observe("click", function(e) {
155
- var element = e.element();
156
- if(element.checked) {
157
- $("onestepcheckout-li-password").show();
158
- }
159
- else {
160
- $("onestepcheckout-li-password").hide();
161
- }
162
- });
163
- });
164
- </script>';
165
- ?>
166
- <?php endif; ?>
167
- <?php if($helper->showPasswords() && !$this->isCustomerLoggedIn()): ?>
168
- <?php
169
- //id="onestepcheckout-li-password"
170
- $billingFields['password'] = '
171
- <li id="onestepcheckout-li-password" '.(($helper->hidePasswords()) ? 'style="display: none;"':'').'>
172
- <div class="input-box input-password'.((in_array('password', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
173
- <label for="billing:customer_password">'.$this->__('Password').'</label><br/>
174
- <input type="password" class="required-entry validate-password input-text" value="'.((isset($_POST['billing']['customer_password'])) ? $_POST['billing']['customer_password'] : '').'" title="Password" id="billing:customer_password" name="billing[customer_password]"/>
175
- </div>
176
- <div class="input-box input-password'.((in_array('confirm_password', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
177
- <label for="billing:confirm_password">'.$this->__('Confirm password').'</label><br/>
178
- <input type="password" class="required-entry validate-password input-text" value="'.((isset($_POST['billing']['confirm_password'])) ? $_POST['billing']['confirm_password'] : '').'" id="billing:confirm_password" title="Confirm Password" name="billing[confirm_password]"/>
179
- </div>
180
- </li>';
181
- ?>
182
- <?php endif; ?>
183
-
184
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
185
- <?php $billingFields['save_in_address_book'] = '
186
- <li class="control">
187
- <input type="checkbox" name="billing[save_in_address_book]" value="1" title="'.$this->__('Save in address book').'" id="billing:save_in_address_book" onchange="shipping.setSameAsBilling(false);"'.(($this->getAddress()->getSaveInAddressBook()) ? 'checked="checked"':'').' class="checkbox" /><label for="billing:save_in_address_book">'.$this->__('Save in address book').'</label>
188
- </li>';
189
- ?>
190
- <?php else:?>
191
- <?php $billingFields['save_in_address_book'] = '
192
- <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>';
193
- ?>
194
- <?php endif; ?>
195
-
196
- <?php $billingFields = $this->getBillingFieldsOrder($billingFields);?>
197
- <?php foreach($billingFields as $key => $value):?>
198
- <?php if(!empty($value['has_li'])):?>
199
- <?php echo implode('',$value['fields']);?>
200
- <?php else:?>
201
- <li class="clearfix"><?php echo implode('',$value['fields']);?></li>
202
- <?php endif;?>
203
- <?php endforeach;?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/onestepcheckout/__orig_files_cc/shipping_fields.phtml DELETED
@@ -1,119 +0,0 @@
1
- <?php
2
- $helper = Mage::helper('onestepcheckout/checkout');
3
- $shippingFields['firstname'] = '
4
- <div class="input-box input-firstname'.((in_array('firstname', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
5
- <label for="shipping:firstname">'.$this->__('First Name').'<span class="required">*</span></label><br />
6
- <input class="required-entry input-text" type="text" name="shipping[firstname]" id="shipping:firstname" value="'.$this->getFirstname().'" />
7
- </div>';
8
- $shippingFields['lastname'] = '
9
- <div class="input-box input-lastname'.((in_array('lastname', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
10
- <label for="shipping:lastname">'.$this->__('Last Name').' <span class="required">*</span></label><br />
11
- <input class="required-entry input-text" type="text" name="shipping[lastname]" id="shipping:lastname" value="'.$this->getLastname().'" />
12
- </div>';
13
- ?>
14
-
15
- <?php if(!$this->settings['exclude_address']):?>
16
- <?php
17
- $addressFields = '';
18
- for ($_i=1, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++){
19
-
20
- $addressFields .= '<input type="text" title="'.$this->__('Street Address '.$_i).'" name="shipping[street][]" id="shipping:street'.$_i.'" value="'.$this->htmlEscape($this->getStreet($_i)).'" class="'.(($_i == 1)? 'required-entry ' : '').'input-text onestepcheckout-address-line" />';
21
- $addressFields .= (($_i != $this->helper('customer/address')->getStreetLines()) ? '<br/>': '');
22
- }
23
- $shippingFields['street'] = '
24
- <div class="input-box input-address'.((in_array('telephone', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
25
- <label for="shipping:street1">'.$this->__('Address').'<span class="required">*</span></label><br />
26
- '.$addressFields.'
27
- </div>';
28
- ?>
29
- <?php endif; ?>
30
-
31
- <?php if(!$this->settings['exclude_country_id']):?>
32
- <?php
33
- $shippingFields['country_id'] = '
34
- <div class="input-box input-country'.((in_array('country', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
35
- <label for="shipping:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
36
- '.$this->getCountryHtmlSelect('shipping').'
37
- </div>';
38
- ?>
39
- <?php else: ?>
40
- <?php $shippingFields['country_id'] = '
41
- <input type="hidden" name="shipping[country_id]" id="shipping:country_id" value="'.$this->settings['default_country'].'" />';
42
- ?>
43
- <?php endif; ?>
44
- <?php if(!$this->settings['exclude_region'] || !$this->settings['exclude_country_id']): ?>
45
- <?php $shippingFields['region_id'] = '
46
- <div class="input-box input-region'.((in_array('region', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
47
- <label for="shipping:region">'.$this->__('State/Province').' <span class="required">*</span></label><br/>
48
- <select id="shipping:region_id" name="shipping[region_id]" title="'.$this->__('State/Province').'" class="validate-select" style="display:none">
49
- <option value="">'.$this->__('Please select region, state or province').'</option>
50
- </select>
51
- <script type="text/javascript">
52
- $("shipping:region_id").setAttribute("defaultValue", "'.$this->getRegionId().'");
53
- </script>
54
- <input type="text" id="shipping:region" name="shipping[region]" value="'.$this->htmlEscape($this->getRegion()).'" title="'.$this->__('State/Province').'" class="required-entry input-text" style="display:none" />
55
- </div>';
56
- ?>
57
- <?php endif; ?>
58
- <?php if(!$this->settings['exclude_city']):?>
59
- <?php $shippingFields['city'] = '
60
- <div class="input-box input-city'.((in_array('city', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
61
- <label for="shipping:city">'.$this->__('City').' <span class="required">*</span></label><br/>
62
- <input type="text" name="shipping[city]" value="'.$this->htmlEscape($this->getCity()).'" title="'.$this->__('City').'" class="required-entry input-text" id="shipping:city" />
63
- </div>';
64
- ?>
65
- <?php endif; ?>
66
- <?php if(!$this->settings['exclude_zip']): ?>
67
- <?php $shippingFields['postcode'] = '
68
- <div class="input-box input-postcode'.((in_array('postcode', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'" >
69
- <label for="shipping:postcode">'.$this->__('Zip/Postal Code').' <span class="required">*</span></label><br />
70
- <input type="text" title="'.$this->__('Zip/Postal Code').'" name="shipping[postcode]" id="shipping:postcode" value="'.$this->htmlEscape($this->getPostcode()).'" class="validate-zip-international required-entry input-text" />
71
- </div>';
72
- ?>
73
- <?php endif; ?>
74
- <?php if(!$this->settings['exclude_telephone']):?>
75
- <?php $shippingFields['telephone'] = '
76
- <div class="input-box input-telephone'.((in_array('telephone', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
77
- <label for="shipping:telephone">'.$this->__('Telephone').' <span class="required">*</span></label><br/>
78
- <input type="text" name="shipping[telephone]" value="'.$this->htmlEscape($this->getTelephone()).'" title="'.$this->__('Telephone').'" class="required-entry input-text" id="shipping:telephone" />
79
- </div>';
80
- ?>
81
- <?php endif; ?>
82
- <?php if(!$this->settings['exclude_company']): ?>
83
- <?php $shippingFields['company'] = '
84
- <div class="input-box input-company'.((in_array('company', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
85
- <label for="shipping:company">'.$this->__('Company').'</label><br/>
86
- <input type="text" name="shipping[company]" value="'.$this->htmlEscape($this->getCompany()).'" title="'.$this->__('Company').'" class="input-text" id="shipping:company" />
87
- </div>';
88
- ?>
89
- <?php endif; ?>
90
-
91
- <?php if(!$this->settings['exclude_fax']): ?>
92
- <?php $shippingFields['fax'] = '
93
- <div class="input-box input-fax'.((in_array('fax', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
94
- <label for="shipping:fax">'.$this->__('Fax').'</label><br/>
95
- <input type="text" name="shipping[fax]" value="'.$this->htmlEscape($this->getFax()).'" title="'.$this->__('Fax').'" class="input-text" id="shipping:fax" />
96
- </div>';
97
- ?>
98
- <?php endif; ?>
99
-
100
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
101
- <?php $shippingFields['save_in_address_book'] = '
102
- <li class="control">
103
- <input type="checkbox" name="shipping[save_in_address_book]" value="1" title="'.$this->__('Save in address book').'" id="shipping:save_in_address_book" '.(($this->getAddress()->getSaveInAddressBook()) ? 'checked="checked"':'').' class="checkbox" /><label for="shipping:save_in_address_book">'.$this->__('Save in address book').'</label>
104
- </li>';
105
- ?>
106
- <?php else:?>
107
- <?php $shippingFields['save_in_address_book'] = '
108
- <li class="no-display"><input type="hidden" name="shipping[save_in_address_book]" value="1" /></li>';
109
- ?>
110
- <?php endif; ?>
111
-
112
- <?php $shippingFields = $this->getshippingFieldsOrder($shippingFields);?>
113
- <?php foreach($shippingFields as $key => $value):?>
114
- <?php if(!empty($value['has_li'])):?>
115
- <?php echo implode('',$value['fields']);?>
116
- <?php else:?>
117
- <li class="clearfix"><?php echo implode('',$value['fields']);?></li>
118
- <?php endif;?>
119
- <?php endforeach;?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/onestepcheckout/billing_fields.phtml DELETED
@@ -1,227 +0,0 @@
1
- <?php
2
- $helper = Mage::helper('onestepcheckout/checkout');
3
- $billingFields['firstname'] = '
4
- <div class="input-box input-firstname'.((in_array('firstname', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
5
- <label for="billing:firstname">'.$this->__('First Name').'<span class="required">*</span></label><br />
6
- <input class="required-entry input-text" type="text" name="billing[firstname]" id="billing:firstname" value="'.$this->getFirstname().'" />
7
- </div>';
8
- $billingFields['lastname'] = '
9
- <div class="input-box input-lastname'.((in_array('lastname', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
10
- <label for="billing:lastname">'.$this->__('Last Name').' <span class="required">*</span></label><br />
11
- <input class="required-entry input-text" type="text" name="billing[lastname]" id="billing:lastname" value="'.$this->getLastname().'" />
12
- </div>';
13
- ?>
14
- <?php if(!$this->isCustomerLoggedIn()): ?>
15
- <?php $billingFields['email'] = '
16
- <div class="input-box input-email'.((in_array('email', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
17
- <label for="billing:email">'.$this->__('Email Address').' <span class="required">*</span></label><br />
18
- <input type="text" name="billing[email]" id="billing:email" value="'.$this->htmlEscape($this->getAddress()->getEmail()).'" title="'.$this->__('Email Address') .'" class="validate-email required-entry input-text" />
19
- </div>';
20
- ?>
21
- <?php endif; ?>
22
- <?php if(!$this->isCustomerLoggedIn() || in_array('email_registered', $this->formErrors['billing_errors'])): ?>
23
- <?php $billingFields['email_error'] = '
24
- <div class="clearfix" id="onestepcheckout-email-error" '.((!in_array('email_registered', $this->formErrors['billing_errors'])) ? 'style="display: none"' : '').'>
25
- <div id="onestepcheckout-email-error-message" class="onestepcheckout-error">'.
26
- ((in_array('email_registered', $this->formErrors['billing_errors'])) ? $this->__('Email address already registered. Please <a href="#" onclick="login_popup.show(); return false;">login now</a> or use a different email address.') : $this->__('Invalid email address.'))
27
- .'</div>
28
- </div>';
29
- ?>
30
- <?php endif; ?>
31
-
32
- <?php if(!$this->settings['exclude_telephone']):?>
33
- <?php $billingFields['telephone'] = '
34
- <div class="input-box input-telephone'.((in_array('telephone', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
35
- <label for="billing:telephone">'.$this->__('Telephone').' <span class="required">*</span></label><br/>
36
- <input type="text" name="billing[telephone]" value="'.$this->htmlEscape($this->getTelephone()).'" title="'.$this->__('Telephone').'" class="required-entry input-text" id="billing:telephone" />
37
- </div>';
38
- ?>
39
- <?php endif; ?>
40
-
41
- <?php if(!$this->settings['exclude_address']):?>
42
- <?php
43
- $addressFields = '';
44
- for ($_i=1, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++){
45
-
46
- $addressFields .= '<input type="text" title="'.$this->__('Street Address '.$_i).'" name="billing[street][]" id="billing:street'.$_i.'" value="'.$this->htmlEscape($this->getStreet($_i)).'" class="'.(($_i == 1)? 'required-entry ' : '').'input-text onestepcheckout-address-line" />';
47
- $addressFields .= (($_i != $this->helper('customer/address')->getStreetLines()) ? '<br/>': '');
48
- }
49
- $billingFields['street'] = '
50
- <div id="hideOnNewAddress_billing:street1" class="input-box input-address'.((in_array('telephone', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
51
- <label for="billing:street1">'.$this->__('Address').'<span class="required">*</span></label><br />
52
- '.$addressFields.'
53
- </div>';
54
- ?>
55
- <?php endif; ?>
56
-
57
- <?php if(!$this->settings['exclude_country_id']):?>
58
- <?php
59
- $billingFields['country_id'] = '
60
- <div class="input-box input-country'.((in_array('country', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
61
- <label for="billing:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
62
- '.$this->getCountryHtmlSelect('billing').'
63
- </div>';
64
- ?>
65
- <?php else: ?>
66
- <?php $billingFields['country_id'] = '
67
- <input type="hidden" name="billing[country_id]" id="billing:country_id" value="'.$this->settings['default_country'].'" />';
68
- ?>
69
- <?php endif; ?>
70
- <?php if(!$this->settings['exclude_region']): ?>
71
- <?php $billingFields['region_id'] = '
72
- <div id="countyDiv" class="input-box input-region'.((in_array('region', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
73
- <label for="billing:region">'.$this->__('State/Province').' <span class="required">*</span></label><br/>
74
- <select id="billing:region_id" name="billing[region_id]" title="'.$this->__('State/Province').'" class="validate-select" style="display:none">
75
- <option value="">'.$this->__('Please select region, state or province').'</option>
76
- </select>
77
- <script type="text/javascript">
78
- $("billing:region_id").setAttribute("defaultValue", "'.$this->getRegionId().'");
79
- </script>
80
- <input type="text" id="billing:region" name="billing[region]" value="'.$this->htmlEscape($this->getRegion()).'" title="'.$this->__('State/Province').'" class="required-entry input-text" style="display:none" />
81
- </div>';
82
- ?>
83
- <?php endif; ?>
84
- <?php if(!$this->settings['exclude_city']):?>
85
- <?php $billingFields['city'] = '
86
- <div id="hideOnNewAddress_billing:city" class="input-box input-city'.((in_array('city', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
87
- <label for="billing:city">'.$this->__('City').' <span class="required">*</span></label><br/>
88
- <input type="text" name="billing[city]" value="'.$this->htmlEscape($this->getCity()).'" title="'.$this->__('City').'" class="required-entry input-text" id="billing:city" />
89
- </div>';
90
- ?>
91
- <?php endif; ?>
92
-
93
- <?php if(!$this->settings['exclude_zip']): ?>
94
- <?php $billingFields['postcode'] = '
95
- <div class="input-box input-postcode'.((in_array('postcode', $this->formErrors['billing_errors'])) ? ' input-error' : '').'" >
96
- <label for="billing:postcode">'.$this->__('Zip/Postal Code').' <span class="required">*</span></label><br />
97
- <input type="text" title="'.$this->__('Zip/Postal Code').'" name="billing[postcode]" id="billing:postcode" value="'.$this->htmlEscape($this->getPostcode()).'" class="validate-zip-international required-entry input-text" />
98
- </div>';
99
- /* CraftyClicks - START */
100
- if (1 == Mage::getStoreConfig('general/craftyclicks/active')) {
101
- $billingFields['postcode'] .= '<div id="findAddrBtnDiv" style="display:none;"><br />&nbsp;';
102
- // $billingFields['postcode'] .= '<div id="findAddrBtnDiv"><br />&nbsp;';
103
- if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')){
104
- $billingFields['postcode'] .= '<img style="cursor: pointer;" src="'.$this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')).'" onclick="_cp_do_lookup()" title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"/>';
105
- } else {
106
- $billingFields['postcode'] .= '<button type="button" onclick="_cp_do_lookup()" title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"><span><span>Find Address</span></span></button>';
107
- }
108
- $billingFields['postcode'] .= '</div>';
109
- }
110
- /* CraftyClicks - END */
111
- ?>
112
- <?php endif; ?>
113
-
114
- <?php if(!$this->settings['exclude_company']): ?>
115
- <?php $billingFields['company'] = '
116
- <div id="hideOnNewAddress_billing:company" class="input-box input-company'.((in_array('company', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
117
- <label for="billing:company">'.$this->__('Company').'</label><br/>
118
- <input type="text" name="billing[company]" value="'.$this->htmlEscape($this->getCompany()).'" title="'.$this->__('Company').'" class="input-text" id="billing:company" />
119
- </div>';
120
- ?>
121
- <?php endif; ?>
122
-
123
- <?php if(!$this->settings['exclude_fax']): ?>
124
- <?php $billingFields['fax'] = '
125
- <div class="input-box input-fax'.((in_array('fax', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
126
- <label for="billing:fax">'.$this->__('Fax').'</label><br/>
127
- <input type="text" name="billing[fax]" value="'.$this->htmlEscape($this->getFax()).'" title="'.$this->__('Fax').'" class="input-text" id="billing:fax" />
128
- </div>';
129
- ?>
130
- <?php endif; ?>
131
-
132
- <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat'); ?>
133
- <?php if($_taxvat->isEnabled()): ?>
134
- <?php $billingFields['taxvat'] =
135
- $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())
136
- ->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml();
137
- ?>
138
- <?php endif; ?>
139
-
140
- <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
141
- <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
142
-
143
- <?php if ($_dob && $_dob->isEnabled()): ?>
144
- <?php $billingFields['dob'] = '
145
- <div class="field">
146
- '.$_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml().'
147
- </div>.';
148
- ?>
149
- <?php endif; ?>
150
- <?php if ($_gender && $_gender->isEnabled()): ?>
151
- <?php $billingFields['gender'] = '
152
- <div class="field">
153
- '.$_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml().'
154
- </div>';
155
- ?>
156
- <?php endif ?>
157
- <?php if(!$this->isCustomerLoggedIn() && $helper->showCreateAccount()): ?>
158
- <?php $billingFields['create_account'] = '
159
- <div class="input-box">
160
- <input id="id_create_account" type="checkbox" name="create_account" value="1" '.((isset($_POST['create_account']) && $_POST['create_account'] == '1') ? ' checked="checked"' : '').' />
161
- <label for="id_create_account">'.$this->__('Create an account for later use').'</label>
162
- </div>
163
-
164
- <script>
165
- document.observe("dom:loaded", function() {
166
- $("id_create_account").observe("click", function(e) {
167
- var element = e.element();
168
- if(element.checked) {
169
- $("onestepcheckout-li-password").show();
170
- }
171
- else {
172
- $("onestepcheckout-li-password").hide();
173
- }
174
- });
175
- });
176
- </script>';
177
- ?>
178
- <?php endif; ?>
179
- <?php if($helper->showPasswords() && !$this->isCustomerLoggedIn()): ?>
180
- <?php
181
- //id="onestepcheckout-li-password"
182
- $billingFields['password'] = '
183
- <li id="onestepcheckout-li-password" '.(($helper->hidePasswords()) ? 'style="display: none;"':'').'>
184
- <div class="input-box input-password'.((in_array('password', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
185
- <label for="billing:customer_password">'.$this->__('Password').'</label><br/>
186
- <input type="password" class="required-entry validate-password input-text" value="'.((isset($_POST['billing']['customer_password'])) ? $_POST['billing']['customer_password'] : '').'" title="Password" id="billing:customer_password" name="billing[customer_password]"/>
187
- </div>
188
- <div class="input-box input-password'.((in_array('confirm_password', $this->formErrors['billing_errors'])) ? ' input-error' : '').'">
189
- <label for="billing:confirm_password">'.$this->__('Confirm password').'</label><br/>
190
- <input type="password" class="required-entry validate-password input-text" value="'.((isset($_POST['billing']['confirm_password'])) ? $_POST['billing']['confirm_password'] : '').'" id="billing:confirm_password" title="Confirm Password" name="billing[confirm_password]"/>
191
- </div>
192
- </li>';
193
- ?>
194
- <?php endif; ?>
195
-
196
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
197
- <?php $billingFields['save_in_address_book'] = '
198
- <li class="control">
199
- <input type="checkbox" name="billing[save_in_address_book]" value="1" title="'.$this->__('Save in address book').'" id="billing:save_in_address_book" onchange="shipping.setSameAsBilling(false);"'.(($this->getAddress()->getSaveInAddressBook()) ? 'checked="checked"':'').' class="checkbox" /><label for="billing:save_in_address_book">'.$this->__('Save in address book').'</label>
200
- </li>';
201
- ?>
202
- <?php else:?>
203
- <?php $billingFields['save_in_address_book'] = '
204
- <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>';
205
- ?>
206
- <?php endif; ?>
207
-
208
- <?php $billingFields = $this->getBillingFieldsOrder($billingFields);?>
209
- <?php foreach($billingFields as $key => $value):?>
210
- <?php if(!empty($value['has_li'])):?>
211
- <?php echo implode('',$value['fields']);?>
212
- <?php else:?>
213
- <li class="clearfix"><?php echo implode('',$value['fields']);?></li>
214
- <?php endif;?>
215
- <?php /* CraftyClicks - START */
216
- if (1 == Mage::getStoreConfig('general/craftyclicks/active')) {
217
- // we look out for the postcode field, if found we add a result box under it
218
- foreach ($value['fields'] as $val_key => $one_val) {
219
- if(strpos($one_val, 'postcode') ) {
220
- echo '<li class="fields">
221
- <span style="display:none;" id="crafty_postcode_result_display">&nbsp;</span>
222
- </li>';
223
- }
224
- }
225
- }
226
- /* CraftyClicks - END */ ?>
227
- <?php endforeach;?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/onestepcheckout/shipping_fields.phtml DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
- $helper = Mage::helper('onestepcheckout/checkout');
3
- $shippingFields['firstname'] = '
4
- <div class="input-box input-firstname'.((in_array('firstname', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
5
- <label for="shipping:firstname">'.$this->__('First Name').'<span class="required">*</span></label><br />
6
- <input class="required-entry input-text" type="text" name="shipping[firstname]" id="shipping:firstname" value="'.$this->getFirstname().'" />
7
- </div>';
8
- $shippingFields['lastname'] = '
9
- <div class="input-box input-lastname'.((in_array('lastname', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
10
- <label for="shipping:lastname">'.$this->__('Last Name').' <span class="required">*</span></label><br />
11
- <input class="required-entry input-text" type="text" name="shipping[lastname]" id="shipping:lastname" value="'.$this->getLastname().'" />
12
- </div>';
13
- ?>
14
-
15
- <?php if(!$this->settings['exclude_address']):?>
16
- <?php
17
- $addressFields = '';
18
- for ($_i=1, $_n=$this->helper('customer/address')->getStreetLines(); $_i<=$_n; $_i++){
19
-
20
- $addressFields .= '<input type="text" title="'.$this->__('Street Address '.$_i).'" name="shipping[street][]" id="shipping:street'.$_i.'" value="'.$this->htmlEscape($this->getStreet($_i)).'" class="'.(($_i == 1)? 'required-entry ' : '').'input-text onestepcheckout-address-line" />';
21
- $addressFields .= (($_i != $this->helper('customer/address')->getStreetLines()) ? '<br/>': '');
22
- }
23
- $shippingFields['street'] = '
24
- <div id="hideOnNewAddress_shipping:street1" class="input-box input-address'.((in_array('telephone', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
25
- <label for="shipping:street1">'.$this->__('Address').'<span class="required">*</span></label><br />
26
- '.$addressFields.'
27
- </div>';
28
- ?>
29
- <?php endif; ?>
30
-
31
- <?php if(!$this->settings['exclude_country_id']):?>
32
- <?php
33
- $shippingFields['country_id'] = '
34
- <div class="input-box input-country'.((in_array('country', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
35
- <label for="shipping:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
36
- '.$this->getCountryHtmlSelect('shipping').'
37
- </div>';
38
- ?>
39
- <?php else: ?>
40
- <?php $shippingFields['country_id'] = '
41
- <input type="hidden" name="shipping[country_id]" id="shipping:country_id" value="'.$this->settings['default_country'].'" />';
42
- ?>
43
- <?php endif; ?>
44
- <?php if(!$this->settings['exclude_region'] || !$this->settings['exclude_country_id']): ?>
45
- <?php $shippingFields['region_id'] = '
46
- <div id="countyDiv2" class="input-box input-region'.((in_array('region', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
47
- <label for="shipping:region">'.$this->__('State/Province').' <span class="required">*</span></label><br/>
48
- <select id="shipping:region_id" name="shipping[region_id]" title="'.$this->__('State/Province').'" class="validate-select" style="display:none">
49
- <option value="">'.$this->__('Please select region, state or province').'</option>
50
- </select>
51
- <script type="text/javascript">
52
- $("shipping:region_id").setAttribute("defaultValue", "'.$this->getRegionId().'");
53
- </script>
54
- <input type="text" id="shipping:region" name="shipping[region]" value="'.$this->htmlEscape($this->getRegion()).'" title="'.$this->__('State/Province').'" class="required-entry input-text" style="display:none" />
55
- </div>';
56
- ?>
57
- <?php endif; ?>
58
- <?php if(!$this->settings['exclude_city']):?>
59
- <?php $shippingFields['city'] = '
60
- <div id="hideOnNewAddress_shipping:city" class="input-box input-city'.((in_array('city', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
61
- <label for="shipping:city">'.$this->__('City').' <span class="required">*</span></label><br/>
62
- <input type="text" name="shipping[city]" value="'.$this->htmlEscape($this->getCity()).'" title="'.$this->__('City').'" class="required-entry input-text" id="shipping:city" />
63
- </div>';
64
- ?>
65
- <?php endif; ?>
66
- <?php if(!$this->settings['exclude_zip']): ?>
67
- <?php $shippingFields['postcode'] = '
68
- <div class="input-box input-postcode'.((in_array('postcode', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'" >
69
- <label for="shipping:postcode">'.$this->__('Zip/Postal Code').' <span class="required">*</span></label><br />
70
- <input type="text" title="'.$this->__('Zip/Postal Code').'" name="shipping[postcode]" id="shipping:postcode" value="'.$this->htmlEscape($this->getPostcode()).'" class="validate-zip-international required-entry input-text" />
71
- </div>';
72
- /* CraftyClicks - START */
73
- if (1 == Mage::getStoreConfig('general/craftyclicks/active')) {
74
- $shippingFields['postcode'] .= '<div id="findAddrBtnDiv2" style="display:none;"><br />&nbsp;';
75
- // $shippingFields['postcode'] .= '<div id="findAddrBtnDiv2"><br />&nbsp;';
76
- if ('' != Mage::getStoreConfig('general/craftyclicks/button_image')){
77
- $shippingFields['postcode'] .= '<img style="cursor: pointer;" src="'.$this->getSkinUrl('images/craftyclicks/'.Mage::getStoreConfig('general/craftyclicks/button_image')).'" onclick="_cp_do_lookup2()" title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"/>';
78
- } else {
79
- $shippingFields['postcode'] .= '<button type="button" onclick="_cp_do_lookup2()" title="Find Address" class="'.Mage::getStoreConfig('general/craftyclicks/button_class').'"><span><span>Find Address</span></span></button>';
80
- }
81
- $shippingFields['postcode'] .= '</div>';
82
- }
83
- /* CraftyClicks - END */
84
- ?>
85
- <?php endif; ?>
86
- <?php if(!$this->settings['exclude_telephone']):?>
87
- <?php $shippingFields['telephone'] = '
88
- <div class="input-box input-telephone'.((in_array('telephone', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
89
- <label for="shipping:telephone">'.$this->__('Telephone').' <span class="required">*</span></label><br/>
90
- <input type="text" name="shipping[telephone]" value="'.$this->htmlEscape($this->getTelephone()).'" title="'.$this->__('Telephone').'" class="required-entry input-text" id="shipping:telephone" />
91
- </div>';
92
- ?>
93
- <?php endif; ?>
94
- <?php if(!$this->settings['exclude_company']): ?>
95
- <?php $shippingFields['company'] = '
96
- <div id="hideOnNewAddress_shipping:company" class="input-box input-company'.((in_array('company', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
97
- <label for="shipping:company">'.$this->__('Company').'</label><br/>
98
- <input type="text" name="shipping[company]" value="'.$this->htmlEscape($this->getCompany()).'" title="'.$this->__('Company').'" class="input-text" id="shipping:company" />
99
- </div>';
100
- ?>
101
- <?php endif; ?>
102
-
103
- <?php if(!$this->settings['exclude_fax']): ?>
104
- <?php $shippingFields['fax'] = '
105
- <div class="input-box input-fax'.((in_array('fax', $this->formErrors['shipping_errors'])) ? ' input-error' : '').'">
106
- <label for="shipping:fax">'.$this->__('Fax').'</label><br/>
107
- <input type="text" name="shipping[fax]" value="'.$this->htmlEscape($this->getFax()).'" title="'.$this->__('Fax').'" class="input-text" id="shipping:fax" />
108
- </div>';
109
- ?>
110
- <?php endif; ?>
111
-
112
- <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
113
- <?php $shippingFields['save_in_address_book'] = '
114
- <li class="control">
115
- <input type="checkbox" name="shipping[save_in_address_book]" value="1" title="'.$this->__('Save in address book').'" id="shipping:save_in_address_book" '.(($this->getAddress()->getSaveInAddressBook()) ? 'checked="checked"':'').' class="checkbox" /><label for="shipping:save_in_address_book">'.$this->__('Save in address book').'</label>
116
- </li>';
117
- ?>
118
- <?php else:?>
119
- <?php $shippingFields['save_in_address_book'] = '
120
- <li class="no-display"><input type="hidden" name="shipping[save_in_address_book]" value="1" /></li>';
121
- ?>
122
- <?php endif; ?>
123
-
124
- <?php $shippingFields = $this->getshippingFieldsOrder($shippingFields);?>
125
- <?php foreach($shippingFields as $key => $value):?>
126
- <?php if(!empty($value['has_li'])):?>
127
- <?php echo implode('',$value['fields']);?>
128
- <?php else:?>
129
- <li class="clearfix"><?php echo implode('',$value['fields']);?></li>
130
- <?php endif;?>
131
- <?php /* CraftyClicks - START */
132
- if (1 == Mage::getStoreConfig('general/craftyclicks/active')) {
133
- // we look out for the postcode field, if found we add a result box under it
134
- foreach ($value['fields'] as $val_key => $one_val) {
135
- if(strpos($one_val, 'postcode') ) {
136
- echo '<li class="fields">
137
- <span style="display:none;" id="crafty_postcode_result_display2">&nbsp;</span>
138
- </li>';
139
- }
140
- }
141
- }
142
- /* CraftyClicks - END */ ?><?php endforeach;?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/CraftyClicks.xml CHANGED
@@ -4,7 +4,7 @@
4
  <CraftyClicks>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
- <version>2.3.3</version>
8
  </CraftyClicks>
9
  </modules>
10
  </config>
4
  <CraftyClicks>
5
  <active>true</active>
6
  <codePool>local</codePool>
7
+ <version>2.4.0</version>
8
  </CraftyClicks>
9
  </modules>
10
  </config>
js/craftyclicks/crafty_mage_onepage.js~ ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>&nbsp;</label><div class="input-box" id="'+setup.prefix+'_cp_result_display">&nbsp;</div></li>';
125
+ $(setup.fields.postcode_id).up('li').insert( {after: tmp_html} );
126
+ // create button (hidden initially)
127
+ tmp_html = '&nbsp;&nbsp;<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
+ });
js/craftyclicks/crafty_postcode.class.js CHANGED
@@ -4,7 +4,7 @@
4
  //
5
  // Provided by www.CraftyClicks.co.uk
6
  //
7
- // Version - 4.9.1 (23/03/2011)
8
  //
9
  // Feel free to copy/use/modify this code any way you see fit. Please keep this
10
  // comment header in place when you do.
@@ -13,4 +13,4 @@
13
  // details of how to sign up for an account.
14
  //
15
  **********************************************************************************/
16
- var _cp_instances=[],_cp_instance_idx=0,_cp_pl=["FLAT","SHOP","UNIT","BLOCK","STALL","SUITE","APARTMENT","MAISONETTE","HOUSE NUMBER"];function CraftyPostcodeCreate(){_cp_instance_idx++;_cp_instances[_cp_instance_idx]=new CraftyPostcodeClass();_cp_instances[_cp_instance_idx].obj_idx=_cp_instance_idx;return _cp_instances[_cp_instance_idx]}function _cp_sp(b){var d="",c;for(c=0;c<_cp_pl.length;c++){d=_cp_pl[c];if(d==b.substr(0,d.length).toUpperCase()){return(b.substr(d.length))}}return("")}function _cp_eh(a){var b="";while(b=a.shift()){if(!isNaN(parseInt(b))){return(parseInt(b))}}return""}function _cp_kp(a){var b;if(!a){a=window.event}if(a.keyCode){b=a.keyCode}else{if(a.which){b=a.which}}if(b==13){this.onclick()}}function CraftyPostcodeClass(){this.config={lookup_url:"pcls1.craftyclicks.co.uk/js/",access_token:"",basic_address:0,traditional_county:0,busy_img_url:"crafty_postcode_busy.gif",hide_result:0,org_uppercase:1,town_uppercase:1,county_uppercase:0,addr_uppercase:0,delimiter:", ",msg1:"Please wait while we find the address",err_msg1:"This postcode could not be found, please try again or enter your address manually",err_msg2:"This postcode is not valid, please try again or enter your address manually",err_msg3:"Unable to connect to address lookup server, please enter your address manually.",err_msg4:"An unexpected error occured, please enter your address manually.",res_autoselect:1,res_select_on_change:1,debug_mode:0,lookup_timeout:10000,form:"",elements:"",max_width:"400px",max_lines:1,first_res_line:"---- please select your address ----",result_elem_id:"",on_result_ready:null,on_result_selected:null,on_error:null,pre_populate_common_address_parts:0,elem_company:"crafty_out_company",elem_house_num:"",elem_street1:"crafty_out_street1",elem_street2:"crafty_out_street2",elem_street3:"crafty_out_street3",elem_town:"crafty_out_town",elem_county:"crafty_out_county",elem_postcode:"crafty_in_out_postcode",elem_udprn:"crafty_out_udprn",single_res_autoselect:0,single_res_notice:"---- address found, see below ----",elem_search_house:"crafty_in_search_house",elem_search_street:"crafty_in_search_street",elem_search_town:"crafty_in_search_town",max_results:25,err_msg5:"The house name/number could not be found, please try again.",err_msg6:"No results found, please modify your search and try again.",err_msg7:"Too many results, please modify your search and try again.",err_msg9:"Please provide more data and try again.",err_msg8:"Trial account limit reached, please use AA11AA, AA11AB, AA11AD or AA11AE."};this.xmlhttp=null;this.res_arr=null;this.disp_arr=null;this.res_arr_idx=0;this.dummy_1st_line=0;this.cc=0;this.flexi_search=0;this.lookup_timeout=null;this.obj_name="";this.house_search=0;this.set=function(a,b){this.config[a]=b};this.res_clicked=function(a){this.cc++;if(this.res_selected(a)){if(0!=this.config.hide_result&&((2>=this.config.max_lines&&1<this.cc)||(2<this.config.max_lines))){this.update_res(null);this.cc=0}}};this.res_selected=function(a){if(1==this.dummy_1st_line){if(0==a){return 0}else{a--}}a=this.disp_arr[a]["index"];this.populate_form_fields(this.res_arr[a]);if(this.config.on_result_selected){this.config.on_result_selected(a)}return 1};this.populate_form_fields=function(j){var b=[];var o=this.config.delimiter;for(var e=0;e<8;e++){b[e]=this.get_elem(e)}b[11]=this.get_elem(11);if(b[11]){b[11].value=j.udprn}if(b[0]){if(b[0]==b[1]&&""!=j.org){b[1].value=j.org;b[1]=b[2];b[2]=b[3];b[3]=null}else{b[0].value=j.org}}var n=j.housename2;if(""!=n&&""!=j.housename1){n+=o}n+=j.housename1;var k=j.housenumber;if(b[7]){b[7].value=n;if(""!=n&&""!=k){b[7].value+=o}b[7].value+=k;n="";k=""}var d=j.street1;var c=j.street2;if(""!=k){if(""!=c){c=k+" "+c}else{if(""!=d){d=k+" "+d}else{d=k}}}var g=c+(c==""?"":(d==""?"":o))+d;var m=j.locality_dep;var h=j.locality;if(""!=g&&parseInt(g)==g){if(""!=m){m=parseInt(g)+" "+m}else{h=parseInt(g)+" "+h}g="";d=""}var f=m+(m==""||h==""?"":o)+h;var a=g+(g==""||f==""?"":o)+f;if(b[1]&&b[2]&&b[3]){if(""!=j.pobox||""!=n){if(""!=j.pobox){b[1].value=j.pobox}else{b[1].value=n}if(""==f){if(""==c){b[2].value=d;b[3].value=""}else{b[2].value=c;b[3].value=d}}else{if(""==g){if(""==m){b[2].value=h;b[3].value=""}else{b[2].value=m;b[3].value=h}}else{b[2].value=g;b[3].value=f}}}else{if(""==g){if(""==m){b[1].value=h;b[2].value="";b[3].value=""}else{b[1].value=m;b[2].value=h;b[3].value=""}}else{if(""==f){if(""==c){b[1].value=d;b[2].value="";b[3].value=""}else{b[1].value=c;b[2].value=d;b[3].value=""}}else{if(""==c){b[1].value=d;if(""==m){b[2].value=h;b[3].value=""}else{b[2].value=m;b[3].value=h}}else{if(""==m){b[1].value=c;b[2].value=d;b[3].value=h}else{if(g.length<f.length){b[1].value=g;b[2].value=m;b[3].value=h}else{b[1].value=c;b[2].value=d;b[3].value=f}}}}}}}else{if(b[1]&&b[2]){if(""!=j.pobox){b[1].value=j.pobox;b[2].value=a}else{if(""!=n&&""!=g&&""!=f){if((n.length+g.length)<(g.length+f.length)){b[1].value=n+(n==""?"":o)+g;b[2].value=f}else{b[1].value=n;b[2].value=g+(g==""?"":o)+f}}else{if(""!=n&&""!=g){b[1].value=n;b[2].value=g}else{if(""==n&&""!=g){if(""==f){if(""!=c){b[1].value=c;b[2].value=d}else{b[1].value=g;b[2].value=""}}else{b[1].value=g;b[2].value=f}}else{if(""==g&&""!=n){b[1].value=n;b[2].value=f}else{b[1].value=f;b[2].value=""}}}}}}else{var l;if(b[1]){l=b[1]}else{if(b[2]){l=b[2]}else{l=b[3]}}if(""!=j.pobox){l.value=j.pobox+o+f}else{l.value=n+(n==""||a==""?"":o)+a}}}if(b[4]){b[4].value=j.town}if(b[5]){b[5].value=j.county}if(b[6]){b[6].value=j.postcode}return 1};this.show_busy=function(){var b=document.createElement("img");var a=document.createAttribute("src");a.value=this.config.busy_img_url;b.setAttributeNode(a);a=document.createAttribute("title");a.value=this.config.msg1;b.setAttributeNode(a);this.update_res(b)};this.disp_err=function(d,b){var a=null;var e="";if(""!=d){switch(d){case"0001":e=this.config.err_msg1;break;case"0002":e=this.config.err_msg2;break;case"9001":e=this.config.err_msg3;break;case"0003":e=this.config.err_msg9;break;case"0004":e=this.config.err_msg6;break;case"0005":e=this.config.err_msg7;break;case"7001":e=this.config.err_msg8;break;default:e="("+d+") "+this.config.err_msg4;break}if(this.config.debug_mode){var c="";switch(d){case"8000":c=" :: No Access Token ";break;case"8001":c=" :: Invalid Token Format ";break;case"8002":c=" :: Invalid Token ";break;case"8003":c=" :: Out of Credits ";break;case"8004":c=" :: Restricted by rules ";break;case"8005":c=" :: Token suspended ";break}e+=c+" :: DBG :: "+b}a=document.createTextNode(e)}this.update_res(a);if(this.config.on_error){this.config.on_error(e)}};this.disp_err_msg=function(b){var a=null;if(""!=b){a=document.createTextNode(b)}this.update_res(a);if(this.config.on_error){this.config.on_error(b)}};this.display_res_line=function(d,c){var b=document.getElementById("crafty_postcode_lookup_result_option"+this.obj_idx);var e=document.createElement("option");e.appendChild(document.createTextNode(d));if(null!=b){b.appendChild(e)}else{var a=document.createElement("select");a.id="crafty_postcode_lookup_result_option"+this.obj_idx;a.onclick=Function("_cp_instances["+this.obj_idx+"].res_clicked(this.selectedIndex);");a.onkeypress=_cp_kp;if(0!=this.config.res_select_on_change){a.onchange=Function("_cp_instances["+this.obj_idx+"].res_selected(this.selectedIndex);")}if(this.config.max_width&&""!=this.config.max_width){a.style.width=this.config.max_width}var f=this.res_arr_idx;if(1==this.dummy_1st_line){f++}if((navigator.appName=="Microsoft Internet Explorer")&&(parseFloat(navigator.appVersion)<=4)){a.size=0}else{if(f>=this.config.max_lines){a.size=this.config.max_lines}else{a.size=f}}a.appendChild(e);this.update_res(a)}};this.update_res=function(a){if(this.lookup_timeout){clearTimeout(this.lookup_timeout)}try{if(document.getElementById){var b=document.getElementById(this.config.result_elem_id);if(b.hasChildNodes()){while(b.firstChild){b.removeChild(b.firstChild)}}if(null!=a){b.appendChild(a)}}}catch(c){}};this.str_trim=function(b){var a=0;var c=b.length-1;while(a<b.length&&b[a]==" "){a++}while(c>a&&b[c]==" "){c-=1}return b.substring(a,c+1)};this.cp_uc=function(e){if("PC"==e||"UK"==e||"EU"==e){return(e)}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var c="";var f=1;var b=0;for(var a=0;a<e.length;a++){if(-1!=d.indexOf(e.charAt(a))){if(f||b){c=c+e.charAt(a);f=0}else{c=c+e.charAt(a).toLowerCase()}}else{c=c+e.charAt(a);if(a+2>=e.length&&"'"==e.charAt(a)){f=0}else{if("("==e.charAt(a)){close_idx=e.indexOf(")",a+1);if(a+3<close_idx){b=0;f=1}else{b=1}}else{if(")"==e.charAt(a)){b=0;f=1}else{if("-"==e.charAt(a)){close_idx=e.indexOf("-",a+1);if((-1!=close_idx&&a+3>=close_idx)||a+3>=e.length){b=0;f=0}else{b=0;f=1}}else{if(a+2<e.length&&"0"<=e.charAt(a)&&"9">=e.charAt(a)){f=0}else{f=1}}}}}}}return(c)};this.leading_caps=function(a,b){if(0!=b||2>a.length){return(a)}var d="";var f=a.split(" ");for(var c=0;c<f.length;c++){var e=this.str_trim(f[c]);if(""!=e){if(""!=d){d=d+" "}d=d+this.cp_uc(e)}}return(d)};this.new_res_line=function(){var a=[];a.org="";a.housename1="";a.housename2="";a.pobox="";a.housenumber="";a.street1="";a.street2="";a.locality_dep="";a.locality="";a.town="";a.county="";a.postcode="";a.udprn="";return(a)};this.res_arr_compare=function(e,c){if(e.match_quality>c.match_quality){return(1)}if(e.match_quality<c.match_quality){return(-1)}if(e.street1>c.street1){return(1)}if(e.street1<c.street1){return(-1)}if(e.street2>c.street2){return(1)}if(e.street2<c.street2){return(-1)}var h;if(""==e.housenumber){h=_cp_eh(Array(e.housename1,e.housename2))}else{h=parseInt(e.housenumber)}var g;if(""==c.housenumber){g=_cp_eh(Array(c.housename1,c.housename2))}else{g=parseInt(c.housenumber)}if(""==h&&""!=g){return(1)}else{if(""!=h&&""==g){return(-1)}else{if(h>g){return(1)}if(h<g){return(-1)}}}var f=_cp_sp(e.housename1);if(!isNaN(parseInt(f))){f=parseInt(f)}var d=_cp_sp(c.housename1);if(!isNaN(parseInt(d))){d=parseInt(d)}if(f>d){return(1)}if(f<d){return(-1)}var f=_cp_sp(e.housename2);if(!isNaN(parseInt(f))){f=parseInt(f)}var d=_cp_sp(c.housename2);if(!isNaN(parseInt(d))){d=parseInt(d)}if(f>d){return(1)}if(f<d){return(-1)}f=e.housename2+e.housename1;d=c.housename2+c.housename1;if(f>d){return(1)}if(f<d){return(-1)}if(e.org>c.org){return(1)}if(e.org<c.org){return(-1)}return(1)};this.disp_res_arr=function(){this.res_arr=this.res_arr.sort(this.res_arr_compare);if(0!=this.config.res_autoselect){this.populate_form_fields(this.res_arr[0])}var a=this.config.delimiter;this.disp_arr=[];for(var c=0;c<this.res_arr_idx;c++){var e=this.res_arr[c];var b=e.org+(e.org!=""?a:"")+e.housename2+(e.housename2!=""?a:"")+e.housename1+(e.housename1!=""?a:"")+e.pobox+(e.pobox!=""?a:"")+e.housenumber+(e.housenumber!=""?" ":"")+e.street2+(e.street2!=""?a:"")+e.street1+(e.street1!=""?a:"")+e.locality_dep+(e.locality_dep!=""?a:"")+e.locality+(e.locality!=""?a:"")+e.town;if(this.flexi_search){b+=a+e.postcode}var d=[];d.index=c;d.str=b;this.disp_arr[c]=d}this.dummy_1st_line=0;if(""!=this.config.first_res_line){this.dummy_1st_line=1;this.display_res_line(this.config.first_res_line,-1)}for(var c=0;c<this.res_arr_idx;c++){this.display_res_line(this.disp_arr[c]["str"],c)}if(this.config.pre_populate_common_address_parts){var f=this.new_res_line();f.org=this.res_arr[0]["org"];f.housename1=this.res_arr[0]["housename1"];f.housename2=this.res_arr[0]["housename2"];f.pobox=this.res_arr[0]["pobox"];f.housenumber=this.res_arr[0]["housenumber"];f.street1=this.res_arr[0]["street1"];f.street2=this.res_arr[0]["street2"];f.locality_dep=this.res_arr[0]["locality_dep"];f.locality=this.res_arr[0]["locality"];f.town=this.res_arr[0]["town"];f.county=this.res_arr[0]["county"];f.postcode=this.res_arr[0]["postcode"];f.udprn=this.res_arr[0]["udprn"];for(var c=1;c<this.res_arr_idx;c++){if(this.res_arr[c]["org"]!=f.org){f.org=""}if(this.res_arr[c]["housename2"]!=f.housename2){f.housename2=""}if(this.res_arr[c]["housename1"]!=f.housename1){f.housename1=""}if(this.res_arr[c]["pobox"]!=f.pobox){f.pobox=""}if(this.res_arr[c]["housenumber"]!=f.housenumber){f.housenumber=""}if(this.res_arr[c]["street1"]!=f.street1){f.street1=""}if(this.res_arr[c]["street2"]!=f.street2){f.street2=""}if(this.res_arr[c]["locality_dep"]!=f.locality_dep){f.locality_dep=""}if(this.res_arr[c]["locality"]!=f.locality){f.locality=""}if(this.res_arr[c]["town"]!=f.town){f.town=""}if(this.res_arr[c]["county"]!=f.county){f.county=""}if(this.res_arr[c]["postcode"]!=f.postcode){f.postcode=""}if(this.res_arr[c]["udprn"]!=f.udprn){f.udprn=""}}this.populate_form_fields(f)}};this.get_elem=function(a){var d="";var c=null;if(""!=this.config.elements){var b=this.config.elements.split(",");d=b[a]}else{switch(a){case 0:d=this.config.elem_company;break;case 1:d=this.config.elem_street1;break;case 2:d=this.config.elem_street2;break;case 3:d=this.config.elem_street3;break;case 4:d=this.config.elem_town;break;case 5:d=this.config.elem_county;break;case 6:default:d=this.config.elem_postcode;break;case 7:d=this.config.elem_house_num;break;case 8:d=this.config.elem_search_house;break;case 9:d=this.config.elem_search_street;break;case 10:d=this.config.elem_search_town;break;case 11:d=this.config.elem_udprn;break}}if(""!=d){if(""!=this.config.form){c=document.forms[this.config.form].elements[d]}else{if(document.getElementById){c=document.getElementById(d)}}}return(c)};this.doHouseSearch=function(){var a=this.get_elem(8);if(a&&0<a.value.length){this.house_search=1}this.doLookup()};this.doLookup=function(){this.xmlhttp=null;var a=this.get_elem(6);var b=null;if(a){this.show_busy();this.lookup_timeout=setTimeout("_cp_instances["+this.obj_idx+"].lookup_timeout_err()",this.config.lookup_timeout);b=this.validate_pc(a.value)}if(null!=b){this.direct_xml_fetch(0,b)}else{this.disp_err("0002","invalid postcode format")}};this.flexiSearch=function(){this.xmlhttp=null;var a="";if(this.get_elem(8)&&""!=this.get_elem(8).value){a+="&search_house="+this.get_elem(8).value}if(this.get_elem(9)&&""!=this.get_elem(9).value){a+="&search_street="+this.get_elem(9).value}if(this.get_elem(10)&&""!=this.get_elem(10).value){a+="&search_town="+this.get_elem(10).value}if(""!=a){this.show_busy();this.lookup_timeout=setTimeout("_cp_instances["+this.obj_idx+"].lookup_timeout_err()",this.config.lookup_timeout);this.direct_xml_fetch(1,a)}else{this.disp_err("0003","search string too short")}};this.validate_pc=function(c){var b="";do{b=c;c=c.replace(/[^A-Za-z0-9]/,"")}while(b!=c);b=c.toUpperCase();if(7>=b.length&&5<=b.length){var d=b.substring(b.length-3,b.length);var a=b.substring(0,b.length-3);if(true==/[CIKMOV]/.test(d)){return null}if("0"<=d.charAt(0)&&"9">=d.charAt(0)&&"A"<=d.charAt(1)&&"Z">=d.charAt(1)&&"A"<=d.charAt(2)&&"Z">=d.charAt(2)){switch(a.length){case 2:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)&&"0"<=a.charAt(1)&&"9">=a.charAt(1)){return(b)}break;case 3:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)){if("0"<=a.charAt(1)&&"9">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){return(b)}else{if("A"<=a.charAt(1)&&"Z">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){return(b)}else{if("0"<=a.charAt(1)&&"9">=a.charAt(1)&&"A"<=a.charAt(2)&&"Z">=a.charAt(2)){return(b)}}}}break;case 4:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)&&"A"<=a.charAt(1)&&"Z">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){if("0"<=a.charAt(3)&&"9">=a.charAt(3)){return(b)}else{if("A"<=a.charAt(3)&&"Z">=a.charAt(3)){return(b)}}}break;default:break}}}return null};this.direct_xml_fetch=function(d,a){try{var e=document.getElementById(this.config.result_elem_id);var b="";if("https:"==document.location.protocol){b="https://"}else{b="http://"}if(0==d){b+=this.config.lookup_url;if(this.config.basic_address){b+="basicaddress"}else{b+="rapidaddress"}b+="?postcode="+a+"&callback=_cp_instances["+this.obj_idx+"].handle_js_response&callback_id=0"}else{if(this.config.basic_address){this.disp_err("1207","BasicAddress can't be used for Flexi Search!");return}else{b+=this.config.lookup_url+"flexiaddress?callback=_cp_instances["+this.obj_idx+"].handle_js_response&callback_id=1";b+="&max_results="+this.config.max_results;b+=a}}if(""!=this.config.access_token){b+="&key="+this.config.access_token}var c=document.createElement("script");c.src=encodeURI(b);c.type="text/javascript";e.appendChild(c)}catch(f){this.disp_err("1206",f)}};this.handle_js_response=function(c,d,e){if(!d){var f=e.error_code;var a=e.error_msg;this.disp_err(f,a)}else{this.res_arr=[];this.res_arr_idx=0;if(0==c){this.flexi_search=0;if(this.house_search){e=this.filter_data_by_house_name(e);if(null==e){this.disp_err_msg(this.config.err_msg5);return}}this.add_to_res_array(e)}else{this.flexi_search=1;this.res_arr.total_postcode_count=e.total_postcode_count;this.res_arr.total_thoroughfare_count=e.total_thoroughfare_count;this.res_arr.total_delivery_point_count=e.total_delivery_point_count;for(var i=1;i<=e.total_postcode_count;i++){this.add_to_res_array(e[i])}}if(this.res_arr_idx){var b=false;if(1==this.res_arr_idx&&this.config.single_res_autoselect){var g=null;if(""!=this.config.single_res_notice){g=document.createTextNode(this.config.single_res_notice)}this.update_res(g);this.populate_form_fields(this.res_arr[0]);b=true}else{this.disp_res_arr();document.getElementById("crafty_postcode_lookup_result_option"+this.obj_idx).focus()}if(0==c&&""!=e.postcode){var h=this.get_elem(6);h.value=e.postcode}if(this.config.on_result_ready){this.config.on_result_ready()}if(b&&this.config.on_result_selected){this.config.on_result_selected(0)}}else{this.disp_err("1205","no result to display")}}};this.add_to_res_array=function(f){for(var d=1;d<=f.thoroughfare_count;d++){var e=f[d]["thoroughfare_name"];if(""!=f[d]["thoroughfare_descriptor"]){e+=" "+f[d]["thoroughfare_descriptor"]}e=this.leading_caps(e,this.config.addr_uppercase);var c=f[d]["dependent_thoroughfare_name"];if(""!=f[d]["dependent_thoroughfare_descriptor"]){c+=" "+f[d]["dependent_thoroughfare_descriptor"]}c=this.leading_caps(c,this.config.addr_uppercase);if("delivery_point_count" in f[d]&&0<f[d]["delivery_point_count"]){for(var a=1;a<=f[d]["delivery_point_count"];a++){var g=this.new_res_line();g.street1=e;g.street2=c;var b=f[d][a];if("match_quality" in b){g.match_quality=b.match_quality}else{g.match_quality=1}g.housenumber=b.building_number;g.housename2=this.leading_caps(b.sub_building_name,this.config.addr_uppercase);g.housename1=this.leading_caps(b.building_name,this.config.addr_uppercase);g.org=b.department_name;if(""!=g.org&&""!=b.organisation_name){g.org+=this.config.delimiter}g.org=this.leading_caps(g.org+b.organisation_name,this.config.org_uppercase);g.pobox=this.leading_caps(b.po_box_number,this.config.addr_uppercase);g.postcode=f.postcode;g.town=this.leading_caps(f.town,this.config.town_uppercase);g.locality=this.leading_caps(f.dependent_locality,this.config.addr_uppercase);g.locality_dep=this.leading_caps(f.double_dependent_locality,this.config.addr_uppercase);if(this.config.traditional_county){g.county=this.leading_caps(f.traditional_county,this.config.county_uppercase)}else{g.county=this.leading_caps(f.postal_county,this.config.county_uppercase)}g.udprn=b.udprn;this.res_arr[this.res_arr_idx]=g;this.res_arr_idx++}}else{var g=this.new_res_line();g.street1=e;g.street2=c;g.postcode=f.postcode;g.town=this.leading_caps(f.town,this.config.town_uppercase);g.locality=this.leading_caps(f.dependent_locality,this.config.addr_uppercase);g.locality_dep=this.leading_caps(f.double_dependent_locality,this.config.addr_uppercase);if(this.config.traditional_county){g.county=this.leading_caps(f.traditional_county,this.config.county_uppercase)}else{g.county=this.leading_caps(f.postal_county,this.config.county_uppercase)}g.match_quality=2;this.res_arr[this.res_arr_idx]=g;this.res_arr_idx++}}};this.filter_data_by_house_name=function(f){var g=this.get_elem(8);if(!g||!g.value.length){return f}var j=g.value.toUpperCase();var k=-1;if(parseInt(j)==j){k=parseInt(j)}var l=" "+j;var e=[];var i=1;var b=0;for(var c=1;c<=f.thoroughfare_count;c++){e[i]=[];b=0;for(var d=1;d<=f[c]["delivery_point_count"];d++){var h=f[c][d];var a=" "+h.sub_building_name+" "+h.building_name+" ";if(-1!=a.indexOf(l)||k==parseInt(h.building_number)){b++;e[i][b]=[];e[i][b]["building_number"]=h.building_number;e[i][b]["sub_building_name"]=h.sub_building_name;e[i][b]["building_name"]=h.building_name;e[i][b]["department_name"]=h.department_name;e[i][b]["organisation_name"]=h.organisation_name;e[i][b]["po_box_number"]=h.po_box_number;e[i][b]["udprn"]=h.udprn}}if(b){e[i]["delivery_point_count"]=b;e[i]["thoroughfare_name"]=f[c]["thoroughfare_name"];e[i]["thoroughfare_descriptor"]=f[c]["thoroughfare_descriptor"];e[i]["dependent_thoroughfare_name"]=f[c]["dependent_thoroughfare_name"];e[i]["dependent_thoroughfare_descriptor"]=f[c]["dependent_thoroughfare_descriptor"];i++}}if(1<i){e.thoroughfare_count=i-1;e.town=f.town;e.dependent_locality=f.dependent_locality;e.double_dependent_locality=f.double_dependent_locality;e.traditional_county=f.traditional_county;e.postal_county=f.postal_county;e.postcode=f.postcode;return e}return null};this.lookup_timeout_err=function(){this.disp_err("9001","Internal Timeout after "+this.config.lookup_timeout+"ms")}};
4
  //
5
  // Provided by www.CraftyClicks.co.uk
6
  //
7
+ // Version - 4.9.2 (17/05/2011)
8
  //
9
  // Feel free to copy/use/modify this code any way you see fit. Please keep this
10
  // comment header in place when you do.
13
  // details of how to sign up for an account.
14
  //
15
  **********************************************************************************/
16
+ if(!_cp_js_included){var _cp_js_included=1;var _cp_instances=[],_cp_instance_idx=0,_cp_pl=["FLAT","SHOP","UNIT","BLOCK","STALL","SUITE","APARTMENT","MAISONETTE","HOUSE NUMBER"];function CraftyPostcodeCreate(){_cp_instance_idx++;_cp_instances[_cp_instance_idx]=new CraftyPostcodeClass();_cp_instances[_cp_instance_idx].obj_idx=_cp_instance_idx;return _cp_instances[_cp_instance_idx]}function _cp_sp(b){var d="",c;for(c=0;c<_cp_pl.length;c++){d=_cp_pl[c];if(d==b.substr(0,d.length).toUpperCase()){return(b.substr(d.length))}}return("")}function _cp_eh(a){var b="";while(b=a.shift()){if(!isNaN(parseInt(b))){return(parseInt(b))}}return""}function _cp_kp(a){var b;if(!a){a=window.event}if(a.keyCode){b=a.keyCode}else{if(a.which){b=a.which}}if(b==13){this.onclick()}}function CraftyPostcodeClass(){this.config={lookup_url:"pcls1.craftyclicks.co.uk/js/",access_token:"",basic_address:0,traditional_county:0,busy_img_url:"crafty_postcode_busy.gif",hide_result:0,org_uppercase:1,town_uppercase:1,county_uppercase:0,addr_uppercase:0,delimiter:", ",msg1:"Please wait while we find the address",err_msg1:"This postcode could not be found, please try again or enter your address manually",err_msg2:"This postcode is not valid, please try again or enter your address manually",err_msg3:"Unable to connect to address lookup server, please enter your address manually.",err_msg4:"An unexpected error occured, please enter your address manually.",res_autoselect:1,res_select_on_change:1,debug_mode:0,lookup_timeout:10000,form:"",elements:"",max_width:"400px",max_lines:1,first_res_line:"---- please select your address ----",result_elem_id:"",on_result_ready:null,on_result_selected:null,on_error:null,pre_populate_common_address_parts:0,elem_company:"crafty_out_company",elem_house_num:"",elem_street1:"crafty_out_street1",elem_street2:"crafty_out_street2",elem_street3:"crafty_out_street3",elem_town:"crafty_out_town",elem_county:"crafty_out_county",elem_postcode:"crafty_in_out_postcode",elem_udprn:"crafty_out_udprn",single_res_autoselect:0,single_res_notice:"---- address found, see below ----",elem_search_house:"crafty_in_search_house",elem_search_street:"crafty_in_search_street",elem_search_town:"crafty_in_search_town",max_results:25,err_msg5:"The house name/number could not be found, please try again.",err_msg6:"No results found, please modify your search and try again.",err_msg7:"Too many results, please modify your search and try again.",err_msg9:"Please provide more data and try again.",err_msg8:"Trial account limit reached, please use AA11AA, AA11AB, AA11AD or AA11AE."};this.xmlhttp=null;this.res_arr=null;this.disp_arr=null;this.res_arr_idx=0;this.dummy_1st_line=0;this.cc=0;this.flexi_search=0;this.lookup_timeout=null;this.obj_name="";this.house_search=0;this.set=function(a,b){this.config[a]=b};this.res_clicked=function(a){this.cc++;if(this.res_selected(a)){if(0!=this.config.hide_result&&((2>=this.config.max_lines&&1<this.cc)||(2<this.config.max_lines))){this.update_res(null);this.cc=0}}};this.res_selected=function(a){if(1==this.dummy_1st_line){if(0==a){return 0}else{a--}}a=this.disp_arr[a]["index"];this.populate_form_fields(this.res_arr[a]);if(this.config.on_result_selected){this.config.on_result_selected(a)}return 1};this.populate_form_fields=function(j){var b=[];var o=this.config.delimiter;for(var e=0;e<8;e++){b[e]=this.get_elem(e)}b[11]=this.get_elem(11);if(b[11]){b[11].value=j.udprn}if(b[0]){if(b[0]==b[1]&&""!=j.org){b[1].value=j.org;b[1]=b[2];b[2]=b[3];b[3]=null}else{b[0].value=j.org}}var n=j.housename2;if(""!=n&&""!=j.housename1){n+=o}n+=j.housename1;var k=j.housenumber;if(b[7]){b[7].value=n;if(""!=n&&""!=k){b[7].value+=o}b[7].value+=k;n="";k=""}var d=j.street1;var c=j.street2;if(""!=k){if(""!=c){c=k+" "+c}else{if(""!=d){d=k+" "+d}else{d=k}}}var g=c+(c==""?"":(d==""?"":o))+d;var m=j.locality_dep;var h=j.locality;if(""!=g&&parseInt(g)==g){if(""!=m){m=parseInt(g)+" "+m}else{h=parseInt(g)+" "+h}g="";d=""}var f=m+(m==""||h==""?"":o)+h;var a=g+(g==""||f==""?"":o)+f;if(b[1]&&b[2]&&b[3]){if(""!=j.pobox||""!=n){if(""!=j.pobox){b[1].value=j.pobox}else{b[1].value=n}if(""==f){if(""==c){b[2].value=d;b[3].value=""}else{b[2].value=c;b[3].value=d}}else{if(""==g){if(""==m){b[2].value=h;b[3].value=""}else{b[2].value=m;b[3].value=h}}else{b[2].value=g;b[3].value=f}}}else{if(""==g){if(""==m){b[1].value=h;b[2].value="";b[3].value=""}else{b[1].value=m;b[2].value=h;b[3].value=""}}else{if(""==f){if(""==c){b[1].value=d;b[2].value="";b[3].value=""}else{b[1].value=c;b[2].value=d;b[3].value=""}}else{if(""==c){b[1].value=d;if(""==m){b[2].value=h;b[3].value=""}else{b[2].value=m;b[3].value=h}}else{if(""==m){b[1].value=c;b[2].value=d;b[3].value=h}else{if(g.length<f.length){b[1].value=g;b[2].value=m;b[3].value=h}else{b[1].value=c;b[2].value=d;b[3].value=f}}}}}}}else{if(b[1]&&b[2]){if(""!=j.pobox){b[1].value=j.pobox;b[2].value=a}else{if(""!=n&&""!=g&&""!=f){if((n.length+g.length)<(g.length+f.length)){b[1].value=n+(n==""?"":o)+g;b[2].value=f}else{b[1].value=n;b[2].value=g+(g==""?"":o)+f}}else{if(""!=n&&""!=g){b[1].value=n;b[2].value=g}else{if(""==n&&""!=g){if(""==f){if(""!=c){b[1].value=c;b[2].value=d}else{b[1].value=g;b[2].value=""}}else{b[1].value=g;b[2].value=f}}else{if(""==g&&""!=n){b[1].value=n;b[2].value=f}else{b[1].value=f;b[2].value=""}}}}}}else{var l;if(b[1]){l=b[1]}else{if(b[2]){l=b[2]}else{l=b[3]}}if(""!=j.pobox){l.value=j.pobox+o+f}else{l.value=n+(n==""||a==""?"":o)+a}}}if(b[4]){b[4].value=j.town}if(b[5]){b[5].value=j.county}if(b[6]){b[6].value=j.postcode}return 1};this.show_busy=function(){var b=document.createElement("img");var a=document.createAttribute("src");a.value=this.config.busy_img_url;b.setAttributeNode(a);a=document.createAttribute("title");a.value=this.config.msg1;b.setAttributeNode(a);this.update_res(b)};this.disp_err=function(d,b){var a=null;var e="";if(""!=d){switch(d){case"0001":e=this.config.err_msg1;break;case"0002":e=this.config.err_msg2;break;case"9001":e=this.config.err_msg3;break;case"0003":e=this.config.err_msg9;break;case"0004":e=this.config.err_msg6;break;case"0005":e=this.config.err_msg7;break;case"7001":e=this.config.err_msg8;break;default:e="("+d+") "+this.config.err_msg4;break}if(this.config.debug_mode){var c="";switch(d){case"8000":c=" :: No Access Token ";break;case"8001":c=" :: Invalid Token Format ";break;case"8002":c=" :: Invalid Token ";break;case"8003":c=" :: Out of Credits ";break;case"8004":c=" :: Restricted by rules ";break;case"8005":c=" :: Token suspended ";break}e+=c+" :: DBG :: "+b}a=document.createTextNode(e)}this.update_res(a);if(this.config.on_error){this.config.on_error(e)}};this.disp_err_msg=function(b){var a=null;if(""!=b){a=document.createTextNode(b)}this.update_res(a);if(this.config.on_error){this.config.on_error(b)}};this.display_res_line=function(d,c){var b=document.getElementById("crafty_postcode_lookup_result_option"+this.obj_idx);var e=document.createElement("option");e.appendChild(document.createTextNode(d));if(null!=b){b.appendChild(e)}else{var a=document.createElement("select");a.id="crafty_postcode_lookup_result_option"+this.obj_idx;a.onclick=Function("_cp_instances["+this.obj_idx+"].res_clicked(this.selectedIndex);");a.onkeypress=_cp_kp;if(0!=this.config.res_select_on_change){a.onchange=Function("_cp_instances["+this.obj_idx+"].res_selected(this.selectedIndex);")}if(this.config.max_width&&""!=this.config.max_width){a.style.width=this.config.max_width}var f=this.res_arr_idx;if(1==this.dummy_1st_line){f++}if((navigator.appName=="Microsoft Internet Explorer")&&(parseFloat(navigator.appVersion)<=4)){a.size=0}else{if(f>=this.config.max_lines){a.size=this.config.max_lines}else{a.size=f}}a.appendChild(e);this.update_res(a)}};this.update_res=function(a){if(this.lookup_timeout){clearTimeout(this.lookup_timeout)}try{if(document.getElementById){var b=document.getElementById(this.config.result_elem_id);if(b.hasChildNodes()){while(b.firstChild){b.removeChild(b.firstChild)}}if(null!=a){b.appendChild(a)}}}catch(c){}};this.str_trim=function(b){var a=0;var c=b.length-1;while(a<b.length&&b[a]==" "){a++}while(c>a&&b[c]==" "){c-=1}return b.substring(a,c+1)};this.cp_uc=function(e){if("PC"==e||"UK"==e||"EU"==e){return(e)}var d="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var c="";var f=1;var b=0;for(var a=0;a<e.length;a++){if(-1!=d.indexOf(e.charAt(a))){if(f||b){c=c+e.charAt(a);f=0}else{c=c+e.charAt(a).toLowerCase()}}else{c=c+e.charAt(a);if(a+2>=e.length&&"'"==e.charAt(a)){f=0}else{if("("==e.charAt(a)){close_idx=e.indexOf(")",a+1);if(a+3<close_idx){b=0;f=1}else{b=1}}else{if(")"==e.charAt(a)){b=0;f=1}else{if("-"==e.charAt(a)){close_idx=e.indexOf("-",a+1);if((-1!=close_idx&&a+3>=close_idx)||a+3>=e.length){b=0;f=0}else{b=0;f=1}}else{if(a+2<e.length&&"0"<=e.charAt(a)&&"9">=e.charAt(a)){f=0}else{f=1}}}}}}}return(c)};this.leading_caps=function(a,b){if(0!=b||2>a.length){return(a)}var d="";var f=a.split(" ");for(var c=0;c<f.length;c++){var e=this.str_trim(f[c]);if(""!=e){if(""!=d){d=d+" "}d=d+this.cp_uc(e)}}return(d)};this.new_res_line=function(){var a=[];a.org="";a.housename1="";a.housename2="";a.pobox="";a.housenumber="";a.street1="";a.street2="";a.locality_dep="";a.locality="";a.town="";a.county="";a.postcode="";a.udprn="";return(a)};this.res_arr_compare=function(e,c){if(e.match_quality>c.match_quality){return(1)}if(e.match_quality<c.match_quality){return(-1)}if(e.street1>c.street1){return(1)}if(e.street1<c.street1){return(-1)}if(e.street2>c.street2){return(1)}if(e.street2<c.street2){return(-1)}var h;if(""==e.housenumber){h=_cp_eh(Array(e.housename1,e.housename2))}else{h=parseInt(e.housenumber)}var g;if(""==c.housenumber){g=_cp_eh(Array(c.housename1,c.housename2))}else{g=parseInt(c.housenumber)}if(""==h&&""!=g){return(1)}else{if(""!=h&&""==g){return(-1)}else{if(h>g){return(1)}if(h<g){return(-1)}}}var f=_cp_sp(e.housename1);if(!isNaN(parseInt(f))){f=parseInt(f)}var d=_cp_sp(c.housename1);if(!isNaN(parseInt(d))){d=parseInt(d)}if(f>d){return(1)}if(f<d){return(-1)}var f=_cp_sp(e.housename2);if(!isNaN(parseInt(f))){f=parseInt(f)}var d=_cp_sp(c.housename2);if(!isNaN(parseInt(d))){d=parseInt(d)}if(f>d){return(1)}if(f<d){return(-1)}f=e.housename2+e.housename1;d=c.housename2+c.housename1;if(f>d){return(1)}if(f<d){return(-1)}if(e.org>c.org){return(1)}if(e.org<c.org){return(-1)}return(1)};this.disp_res_arr=function(){this.res_arr=this.res_arr.sort(this.res_arr_compare);if(0!=this.config.res_autoselect){this.populate_form_fields(this.res_arr[0])}var a=this.config.delimiter;this.disp_arr=[];for(var c=0;c<this.res_arr_idx;c++){var e=this.res_arr[c];var b=e.org+(e.org!=""?a:"")+e.housename2+(e.housename2!=""?a:"")+e.housename1+(e.housename1!=""?a:"")+e.pobox+(e.pobox!=""?a:"")+e.housenumber+(e.housenumber!=""?" ":"")+e.street2+(e.street2!=""?a:"")+e.street1+(e.street1!=""?a:"")+e.locality_dep+(e.locality_dep!=""?a:"")+e.locality+(e.locality!=""?a:"")+e.town;if(this.flexi_search){b+=a+e.postcode}var d=[];d.index=c;d.str=b;this.disp_arr[c]=d}this.dummy_1st_line=0;if(""!=this.config.first_res_line){this.dummy_1st_line=1;this.display_res_line(this.config.first_res_line,-1)}for(var c=0;c<this.res_arr_idx;c++){this.display_res_line(this.disp_arr[c]["str"],c)}if(this.config.pre_populate_common_address_parts){var f=this.new_res_line();f.org=this.res_arr[0]["org"];f.housename1=this.res_arr[0]["housename1"];f.housename2=this.res_arr[0]["housename2"];f.pobox=this.res_arr[0]["pobox"];f.housenumber=this.res_arr[0]["housenumber"];f.street1=this.res_arr[0]["street1"];f.street2=this.res_arr[0]["street2"];f.locality_dep=this.res_arr[0]["locality_dep"];f.locality=this.res_arr[0]["locality"];f.town=this.res_arr[0]["town"];f.county=this.res_arr[0]["county"];f.postcode=this.res_arr[0]["postcode"];f.udprn=this.res_arr[0]["udprn"];for(var c=1;c<this.res_arr_idx;c++){if(this.res_arr[c]["org"]!=f.org){f.org=""}if(this.res_arr[c]["housename2"]!=f.housename2){f.housename2=""}if(this.res_arr[c]["housename1"]!=f.housename1){f.housename1=""}if(this.res_arr[c]["pobox"]!=f.pobox){f.pobox=""}if(this.res_arr[c]["housenumber"]!=f.housenumber){f.housenumber=""}if(this.res_arr[c]["street1"]!=f.street1){f.street1=""}if(this.res_arr[c]["street2"]!=f.street2){f.street2=""}if(this.res_arr[c]["locality_dep"]!=f.locality_dep){f.locality_dep=""}if(this.res_arr[c]["locality"]!=f.locality){f.locality=""}if(this.res_arr[c]["town"]!=f.town){f.town=""}if(this.res_arr[c]["county"]!=f.county){f.county=""}if(this.res_arr[c]["postcode"]!=f.postcode){f.postcode=""}if(this.res_arr[c]["udprn"]!=f.udprn){f.udprn=""}}this.populate_form_fields(f)}};this.get_elem=function(a){var d="";var c=null;if(""!=this.config.elements){var b=this.config.elements.split(",");d=b[a]}else{switch(a){case 0:d=this.config.elem_company;break;case 1:d=this.config.elem_street1;break;case 2:d=this.config.elem_street2;break;case 3:d=this.config.elem_street3;break;case 4:d=this.config.elem_town;break;case 5:d=this.config.elem_county;break;case 6:default:d=this.config.elem_postcode;break;case 7:d=this.config.elem_house_num;break;case 8:d=this.config.elem_search_house;break;case 9:d=this.config.elem_search_street;break;case 10:d=this.config.elem_search_town;break;case 11:d=this.config.elem_udprn;break}}if(""!=d){if(""!=this.config.form){c=document.forms[this.config.form].elements[d]}else{if(document.getElementById){c=document.getElementById(d)}}}return(c)};this.doHouseSearch=function(){var a=this.get_elem(8);if(a&&0<a.value.length){this.house_search=1}this.doLookup()};this.doLookup=function(){this.xmlhttp=null;var a=this.get_elem(6);var b=null;if(a){this.show_busy();this.lookup_timeout=setTimeout("_cp_instances["+this.obj_idx+"].lookup_timeout_err()",this.config.lookup_timeout);b=this.validate_pc(a.value)}if(null!=b){this.direct_xml_fetch(0,b)}else{this.disp_err("0002","invalid postcode format")}};this.flexiSearch=function(){this.xmlhttp=null;var a="";if(this.get_elem(8)&&""!=this.get_elem(8).value){a+="&search_house="+this.get_elem(8).value}if(this.get_elem(9)&&""!=this.get_elem(9).value){a+="&search_street="+this.get_elem(9).value}if(this.get_elem(10)&&""!=this.get_elem(10).value){a+="&search_town="+this.get_elem(10).value}if(""!=a){this.show_busy();this.lookup_timeout=setTimeout("_cp_instances["+this.obj_idx+"].lookup_timeout_err()",this.config.lookup_timeout);this.direct_xml_fetch(1,a)}else{this.disp_err("0003","search string too short")}};this.validate_pc=function(c){var b="";do{b=c;c=c.replace(/[^A-Za-z0-9]/,"")}while(b!=c);b=c.toUpperCase();if(7>=b.length&&5<=b.length){var d=b.substring(b.length-3,b.length);var a=b.substring(0,b.length-3);if(true==/[CIKMOV]/.test(d)){return null}if("0"<=d.charAt(0)&&"9">=d.charAt(0)&&"A"<=d.charAt(1)&&"Z">=d.charAt(1)&&"A"<=d.charAt(2)&&"Z">=d.charAt(2)){switch(a.length){case 2:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)&&"0"<=a.charAt(1)&&"9">=a.charAt(1)){return(b)}break;case 3:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)){if("0"<=a.charAt(1)&&"9">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){return(b)}else{if("A"<=a.charAt(1)&&"Z">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){return(b)}else{if("0"<=a.charAt(1)&&"9">=a.charAt(1)&&"A"<=a.charAt(2)&&"Z">=a.charAt(2)){return(b)}}}}break;case 4:if("A"<=a.charAt(0)&&"Z">=a.charAt(0)&&"A"<=a.charAt(1)&&"Z">=a.charAt(1)&&"0"<=a.charAt(2)&&"9">=a.charAt(2)){if("0"<=a.charAt(3)&&"9">=a.charAt(3)){return(b)}else{if("A"<=a.charAt(3)&&"Z">=a.charAt(3)){return(b)}}}break;default:break}}}return null};this.direct_xml_fetch=function(d,a){try{var e=document.getElementById(this.config.result_elem_id);var b="";if("https:"==document.location.protocol){b="https://"}else{b="http://"}if(0==d){b+=this.config.lookup_url;if(this.config.basic_address){b+="basicaddress"}else{b+="rapidaddress"}b+="?postcode="+a+"&callback=_cp_instances["+this.obj_idx+"].handle_js_response&callback_id=0"}else{if(this.config.basic_address){this.disp_err("1207","BasicAddress can't be used for Flexi Search!");return}else{b+=this.config.lookup_url+"flexiaddress?callback=_cp_instances["+this.obj_idx+"].handle_js_response&callback_id=1";b+="&max_results="+this.config.max_results;b+=a}}if(""!=this.config.access_token){b+="&key="+this.config.access_token}var c=document.createElement("script");c.src=encodeURI(b);c.type="text/javascript";e.appendChild(c)}catch(f){this.disp_err("1206",f)}};this.handle_js_response=function(c,d,e){if(!d){var f=e.error_code;var a=e.error_msg;this.disp_err(f,a)}else{this.res_arr=[];this.res_arr_idx=0;if(0==c){this.flexi_search=0;if(this.house_search){e=this.filter_data_by_house_name(e);if(null==e){this.disp_err_msg(this.config.err_msg5);return}}this.add_to_res_array(e)}else{this.flexi_search=1;this.res_arr.total_postcode_count=e.total_postcode_count;this.res_arr.total_thoroughfare_count=e.total_thoroughfare_count;this.res_arr.total_delivery_point_count=e.total_delivery_point_count;for(var i=1;i<=e.total_postcode_count;i++){this.add_to_res_array(e[i])}}if(this.res_arr_idx){var b=false;if(1==this.res_arr_idx&&this.config.single_res_autoselect){var g=null;if(""!=this.config.single_res_notice){g=document.createTextNode(this.config.single_res_notice)}this.update_res(g);this.populate_form_fields(this.res_arr[0]);b=true}else{this.disp_res_arr();document.getElementById("crafty_postcode_lookup_result_option"+this.obj_idx).focus()}if(0==c&&""!=e.postcode){var h=this.get_elem(6);h.value=e.postcode}if(this.config.on_result_ready){this.config.on_result_ready()}if(b&&this.config.on_result_selected){this.config.on_result_selected(0)}}else{this.disp_err("1205","no result to display")}}};this.add_to_res_array=function(f){for(var d=1;d<=f.thoroughfare_count;d++){var e=f[d]["thoroughfare_name"];if(""!=f[d]["thoroughfare_descriptor"]){e+=" "+f[d]["thoroughfare_descriptor"]}e=this.leading_caps(e,this.config.addr_uppercase);var c=f[d]["dependent_thoroughfare_name"];if(""!=f[d]["dependent_thoroughfare_descriptor"]){c+=" "+f[d]["dependent_thoroughfare_descriptor"]}c=this.leading_caps(c,this.config.addr_uppercase);if("delivery_point_count" in f[d]&&0<f[d]["delivery_point_count"]){for(var a=1;a<=f[d]["delivery_point_count"];a++){var g=this.new_res_line();g.street1=e;g.street2=c;var b=f[d][a];if("match_quality" in b){g.match_quality=b.match_quality}else{g.match_quality=1}g.housenumber=b.building_number;g.housename2=this.leading_caps(b.sub_building_name,this.config.addr_uppercase);g.housename1=this.leading_caps(b.building_name,this.config.addr_uppercase);g.org=b.department_name;if(""!=g.org&&""!=b.organisation_name){g.org+=this.config.delimiter}g.org=this.leading_caps(g.org+b.organisation_name,this.config.org_uppercase);g.pobox=this.leading_caps(b.po_box_number,this.config.addr_uppercase);g.postcode=f.postcode;g.town=this.leading_caps(f.town,this.config.town_uppercase);g.locality=this.leading_caps(f.dependent_locality,this.config.addr_uppercase);g.locality_dep=this.leading_caps(f.double_dependent_locality,this.config.addr_uppercase);if(this.config.traditional_county){g.county=this.leading_caps(f.traditional_county,this.config.county_uppercase)}else{g.county=this.leading_caps(f.postal_county,this.config.county_uppercase)}g.udprn=b.udprn;this.res_arr[this.res_arr_idx]=g;this.res_arr_idx++}}else{var g=this.new_res_line();g.street1=e;g.street2=c;g.postcode=f.postcode;g.town=this.leading_caps(f.town,this.config.town_uppercase);g.locality=this.leading_caps(f.dependent_locality,this.config.addr_uppercase);g.locality_dep=this.leading_caps(f.double_dependent_locality,this.config.addr_uppercase);if(this.config.traditional_county){g.county=this.leading_caps(f.traditional_county,this.config.county_uppercase)}else{g.county=this.leading_caps(f.postal_county,this.config.county_uppercase)}g.match_quality=2;this.res_arr[this.res_arr_idx]=g;this.res_arr_idx++}}};this.filter_data_by_house_name=function(f){var g=this.get_elem(8);if(!g||!g.value.length){return f}var j=g.value.toUpperCase();var k=-1;if(parseInt(j)==j){k=parseInt(j)}var l=" "+j;var e=[];var i=1;var b=0;for(var c=1;c<=f.thoroughfare_count;c++){e[i]=[];b=0;for(var d=1;d<=f[c]["delivery_point_count"];d++){var h=f[c][d];var a=" "+h.sub_building_name+" "+h.building_name+" ";if(-1!=a.indexOf(l)||k==parseInt(h.building_number)){b++;e[i][b]=[];e[i][b]["building_number"]=h.building_number;e[i][b]["sub_building_name"]=h.sub_building_name;e[i][b]["building_name"]=h.building_name;e[i][b]["department_name"]=h.department_name;e[i][b]["organisation_name"]=h.organisation_name;e[i][b]["po_box_number"]=h.po_box_number;e[i][b]["udprn"]=h.udprn}}if(b){e[i]["delivery_point_count"]=b;e[i]["thoroughfare_name"]=f[c]["thoroughfare_name"];e[i]["thoroughfare_descriptor"]=f[c]["thoroughfare_descriptor"];e[i]["dependent_thoroughfare_name"]=f[c]["dependent_thoroughfare_name"];e[i]["dependent_thoroughfare_descriptor"]=f[c]["dependent_thoroughfare_descriptor"];i++}}if(1<i){e.thoroughfare_count=i-1;e.town=f.town;e.dependent_locality=f.dependent_locality;e.double_dependent_locality=f.double_dependent_locality;e.traditional_county=f.traditional_county;e.postal_county=f.postal_county;e.postcode=f.postcode;return e}return null};this.lookup_timeout_err=function(){this.disp_err("9001","Internal Timeout after "+this.config.lookup_timeout+"ms")}}};
js/craftyclicks/craftyclicks_gomage_lightcheckout.js ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ // This is a collection of JavaScript code to allow easy integration of
3
+ // the Crafty Clicks postcode / address finder functionality into the
4
+ // GoMage Light Checkout extension for Magento (www.gomage.com)
5
+ //
6
+ // http://www.magentocommerce.com/magento-connect/gomage-lightcheckout-v-2-4.html
7
+ //
8
+ // Provided by www.CraftyClicks.co.uk
9
+ //
10
+ // Requires standard CraftyClicks JS - tested with v4.9.1
11
+ //
12
+ // If you copy/use/modify this code - please keep this
13
+ // comment header in place
14
+ //
15
+ // Copyright (c) 2009-2012 Crafty Clicks (http://www.craftyclicks.com)
16
+ //
17
+ // This code relies on prototype js, you must have a reasonably recent version loaded
18
+ // in your template. Magento should include it as standard.
19
+ //
20
+ // If you need any help, contact support@craftyclicks.co.uk - we will help!
21
+ //
22
+ **********************************************************************************/
23
+ function CraftyClicksMagentoClass () {
24
+ this.prefix = "";
25
+ this.fields = { "postcode_id" : "", // required
26
+ "company_id" : "", // optional
27
+ "street1_id" : "", // required
28
+ "street2_id" : "", // optional
29
+ "street3_id" : "", // optional
30
+ "street4_id" : "", // optional
31
+ "town_id" : "", // required
32
+ "county_id" : "", // optional
33
+ "country_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
+
43
+ this.elem_move = function(e1, e2) {
44
+ e1.insert({after : e2});
45
+ }
46
+
47
+ // test div depth - some magento templates wrap fields in two layers of div in a li
48
+ this.set_div_depth = function() {
49
+ if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('li'))) {
50
+ this.div_depth = 1;
51
+ }
52
+ }
53
+
54
+ this.rearrange_fields = function() {
55
+ var fields = this.fields;
56
+
57
+ // check we have a postcode field
58
+ if ($(fields.postcode_id)) {
59
+ if ('' != $(fields.town_id).getValue()) {
60
+ _cp_hide_fields = false;
61
+ }
62
+
63
+ // postcode could be bundled with county/state in the same li on the gomage 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)) {
73
+ $(fields.company_id).up('li').addClassName(this.prefix+'_cp_address_class');
74
+ }
75
+ if ($(fields.street1_id)) {
76
+ $(fields.street1_id).up('li').addClassName(this.prefix+'_cp_address_class');
77
+ }
78
+ if ($(fields.street2_id)) {
79
+ $(fields.street2_id).up('li').addClassName(this.prefix+'_cp_address_class');
80
+ }
81
+ if ($(fields.street3_id)) {
82
+ $(fields.street3_id).up('li').addClassName(this.prefix+'_cp_address_class');
83
+ }
84
+ if ($(fields.street4_id)) {
85
+ $(fields.street4_id).up('li').addClassName(this.prefix+'_cp_address_class');
86
+ }
87
+ if ($(fields.town_id)) {
88
+ $(fields.town_id).up('li').addClassName(this.prefix+'_cp_address_class');
89
+ }
90
+ if ($(fields.county_id)) {
91
+ $(fields.county_id).up('li').addClassName(this.prefix+'_cp_address_class');
92
+ }
93
+
94
+ return (true);
95
+ } else {
96
+ return (false);
97
+ }
98
+ }
99
+
100
+ this.setup_for_uk = function() {
101
+ // check if we need to do anything
102
+ if ('uk' != this.current_setup) {
103
+ // do the magic for UK
104
+ // move postcode to the uk position after the country li
105
+ $(this.fields.country_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
106
+ // add result box
107
+ if (!$(this.prefix+'_cp_result_display')) {
108
+ var tmp_html = '<li class="'+this.li_class+'" style="display: none"><div class="input-box" id="'+this.prefix+'_cp_result_display">&nbsp;</div></li>';
109
+ $(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
110
+ }
111
+ // show result box
112
+ $(this.prefix+"_cp_result_display").up('li').show();
113
+ // add button
114
+ if (!$(this.prefix+'_cp_button_div_id')) {
115
+ var tmp_html = '';
116
+ if (0 == this.div_depth) {
117
+ tmp_html = '<div class="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label><br/>';
118
+ } else {
119
+ tmp_html = '<div class="field field-last" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label><div class="input-box">';
120
+ }
121
+ if ('' != _cp_button_image) {
122
+ tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
123
+ } else {
124
+ tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
125
+ }
126
+ if (0 == this.div_depth) {
127
+ tmp_html += '</div>';
128
+ } else {
129
+ tmp_html += '</div></div>';
130
+ }
131
+ $(this.fields.postcode_id).up('div', this.div_depth).insert( {after : tmp_html} );
132
+ $(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
133
+ }
134
+ // show button
135
+ $(this.prefix+"_cp_button_div_id").show();
136
+
137
+ // shrink postcode field if needed
138
+ if ('' != this.uk_postcode_width) {
139
+ this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
140
+ $(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
141
+ }
142
+
143
+ // hide county if requested (and if it exists in the html at all)
144
+ if (_cp_hide_county) {
145
+ ne = $(this.fields.county_id);
146
+ if (ne) {
147
+ ne.up('div', this.div_depth).hide();
148
+ }
149
+ }
150
+ }
151
+
152
+ if ('initial' == this.current_setup && _cp_hide_fields) {
153
+ // first time and default to UK, hide address fields
154
+ $$('.'+this.prefix+'_cp_address_class').invoke('hide');
155
+ }
156
+
157
+ // set state
158
+ this.current_setup = 'uk';
159
+ }
160
+
161
+ this.setup_for_non_uk = function() {
162
+ // check if we need to do anything
163
+ if ('non_uk' != this.current_setup) {
164
+ // hide result box (if it exist already)
165
+ if ($(this.prefix+"_cp_result_display")) {
166
+ this.cp_obj.update_res(null);
167
+ $(this.prefix+"_cp_result_display").up('li').hide();
168
+ }
169
+ // hide button (if it exist already)
170
+ if ($(this.prefix+"_cp_button_div_id")) {
171
+ $(this.prefix+"_cp_button_div_id").hide();
172
+ }
173
+ // move postcode to the non-uk position after the town/county li
174
+ if ($(this.fields.county_id)) {
175
+ $(this.fields.county_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
176
+ } else if ($(this.fields.town_id)) {
177
+ $(this.fields.town_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
178
+ }
179
+ // restore postcode field width if needed
180
+ if ('' != this.old_postcode_width) {
181
+ $(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
182
+ }
183
+ // show county if it was hidden (and exists in the html at all)
184
+ if (_cp_hide_county) {
185
+ ne = $(this.fields.county_id);
186
+ if (ne) {
187
+ ne.up('div', this.div_depth).show();
188
+ }
189
+ }
190
+
191
+ // show all other addres lines
192
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
193
+ // set state
194
+ this.current_setup = 'non_uk';
195
+ }
196
+ }
197
+
198
+ this.add_lookup = function(setup) {
199
+ cp_obj = CraftyPostcodeCreate();
200
+ this.cp_obj = cp_obj;
201
+ // config
202
+ this.prefix = setup.prefix;
203
+ this.fields = setup.fields;
204
+ cp_obj.set("access_token", _cp_token_fe);
205
+ cp_obj.set("res_autoselect", "0");
206
+ cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
207
+ cp_obj.set("form", "");
208
+ cp_obj.set("elem_company" , this.fields.company_id); // optional
209
+ cp_obj.set("elem_street1" , this.fields.street1_id);
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
+ cp_obj.set("elem_county" , this.fields.county_id); // optional
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);
217
+ if (1 < _cp_result_box_height) {
218
+ cp_obj.set("first_res_line", "");
219
+ cp_obj.set("max_lines" , _cp_result_box_height);
220
+ } else {
221
+ cp_obj.set("first_res_line", "----- please select your address ----");
222
+ cp_obj.set("max_lines" , 1);
223
+ }
224
+ cp_obj.set("busy_img_url" , _cp_busy_img_url);
225
+ cp_obj.set("hide_result" , _cp_clear_result);
226
+ cp_obj.set("traditional_county" , 1);
227
+ cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
228
+ cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
229
+ cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
230
+ cp_obj.set("first_res_line", _cp_1st_res_line);
231
+ cp_obj.set("err_msg1", _cp_err_msg1);
232
+ cp_obj.set("err_msg2", _cp_err_msg2);
233
+ cp_obj.set("err_msg3", _cp_err_msg3);
234
+ cp_obj.set("err_msg4", _cp_err_msg4);
235
+ // initial page setup
236
+ this.set_div_depth();
237
+ if (this.rearrange_fields()) {
238
+ if (_cp_enable_for_uk_only) {
239
+ this.country_changed();
240
+ $(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
241
+ } else {
242
+ this.setup_for_uk();
243
+ }
244
+ } else {
245
+ // alert ('Postcode Lookup could not be added!');
246
+ }
247
+ }
248
+
249
+ this.country_changed = function(e) {
250
+ // show postcode lookup for:
251
+ // "GB" UK
252
+ // "JE" Jersey
253
+ // "GG" Guernsey
254
+ // "IM" Isle of Man
255
+ var curr_country = $(this.fields.country_id).getValue();
256
+ if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
257
+ this.setup_for_uk();
258
+ } else {
259
+ this.setup_for_non_uk();
260
+ }
261
+ }
262
+
263
+ this.button_clicked = function(e) {
264
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
265
+ this.cp_obj.doLookup();
266
+ }
267
+
268
+ this.result_ready = function() {
269
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
270
+ }
271
+
272
+ this.result_selected = function() {
273
+ if (_cp_clear_result) this.cp_obj.update_res(null);
274
+ }
275
+
276
+ this.result_error = function() {
277
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
278
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
279
+ }
280
+ }
281
+
282
+ document.observe("dom:loaded", function() {
283
+
284
+ if (!_cp_integrate) return;
285
+
286
+ if ($("billing_postcode")) {
287
+ var cc1 = new CraftyClicksMagentoClass();
288
+ cc1.add_lookup({
289
+ "prefix" : "billing",
290
+ "fields" : { "postcode_id" : "billing_postcode",
291
+ "company_id" : "billing_company",
292
+ "street1_id" : "billing_street1",
293
+ "street2_id" : "billing_street2",
294
+ "street3_id" : "billing_street3",
295
+ "street4_id" : "billing_street4",
296
+ "town_id" : "billing_city",
297
+ "county_id" : "billing_region",
298
+ "country_id" : "billing_country_id" }
299
+ });
300
+ }
301
+
302
+ if ($("shipping_postcode")) {
303
+ var cc2 = new CraftyClicksMagentoClass();
304
+ cc2.add_lookup({
305
+ "prefix" : "shipping",
306
+ "fields" : { "postcode_id" : "shipping_postcode",
307
+ "company_id" : "shipping_company",
308
+ "street1_id" : "shipping_street1",
309
+ "street2_id" : "shipping_street2",
310
+ "street3_id" : "shipping_street3",
311
+ "street4_id" : "shipping_street4",
312
+ "town_id" : "shipping_city",
313
+ "county_id" : "shipping_region",
314
+ "country_id" : "shipping_country_id" }
315
+ });
316
+ }
317
+ });
318
+
js/craftyclicks/craftyclicks_magento.js ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = '';
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 class="'+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 class="'+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 class="'+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 class="'+this.li_class+'" style="display: none"><label>&nbsp;</label><div class="input-box" id="'+this.prefix+'_cp_result_display">&nbsp;</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="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label>';
151
+ } else {
152
+ tmp_html = '<div class="field" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label><div class="input-box">';
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
+
js/craftyclicks/craftyclicks_magento.js~ ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>&nbsp;</label><div class="input-box" id="'+this.prefix+'_cp_result_display">&nbsp;</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">&nbsp;</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">&nbsp;</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
+
js/craftyclicks/craftyclicks_magento_admin.js ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ };
32
+
33
+ this.current_setup = 'initial'; // can be 'uk' or 'non_uk'
34
+ this.uk_postcode_width = '75px'
35
+ this.old_postcode_width = '';
36
+ this.cp_obj = 0;
37
+
38
+ this.elem_move = function(e1, e2) {
39
+ e1.insert({after : e2});
40
+ }
41
+
42
+ this.rearrange_fields = function() {
43
+ var fields = this.fields;
44
+
45
+ if (!$(fields.town_id)) {
46
+ _cp_hide_fields = false;
47
+ } else if ('' != $(fields.town_id).getValue()) {
48
+ _cp_hide_fields = false;
49
+ }
50
+
51
+ var tr_list = [ $(fields.country_id).up('tr') ];
52
+ var idx = 1;
53
+ tr_list[idx] = $(fields.postcode_id).up('tr'); idx++;
54
+
55
+ var ne = $(fields.company_id);
56
+ if (ne) {
57
+ tr_list[idx] = ne.up('tr'); idx++;
58
+ ne.up('tr').addClassName(this.prefix+'_cp_address_class');
59
+ }
60
+
61
+ tr_list[idx] = $(fields.street1_id).up('tr'); idx++;
62
+ $(fields.street1_id).up('tr').addClassName(this.prefix+'_cp_address_class');
63
+
64
+ ne = $(fields.street2_id);
65
+ if (ne) {
66
+ tr_list[idx] = ne.up('tr'); idx++;
67
+ ne.up('tr').addClassName(this.prefix+'_cp_address_class');
68
+ }
69
+
70
+ ne = $(fields.street3_id);
71
+ if (ne) {
72
+ tr_list[idx] = ne.up('tr'); idx++;
73
+ ne.up('tr').addClassName(this.prefix+'_cp_address_class');
74
+ }
75
+
76
+ ne = $(fields.street4_id);
77
+ if (ne) {
78
+ tr_list[idx] = ne.up('tr'); idx++;
79
+ ne.up('tr').addClassName(this.prefix+'_cp_address_class');
80
+ }
81
+
82
+ tr_list[idx] = $(fields.town_id).up('tr'); idx++;
83
+ $(fields.town_id).up('tr').addClassName(this.prefix+'_cp_address_class');
84
+
85
+ ne = $(fields.county_id);
86
+ if (ne) {
87
+ tr_list[idx] = ne.up('tr'); idx++;
88
+ ne.up('tr').addClassName(this.prefix+'_cp_address_class');
89
+ }
90
+
91
+ for (var ii = 0; ii < idx; ii++) {
92
+ this.elem_move(tr_list[ii], tr_list[ii+1]);
93
+ }
94
+
95
+ return (true);
96
+ }
97
+
98
+ this.setup_for_uk = function() {
99
+ // check if we need to do anything
100
+ if ('uk' != this.current_setup) {
101
+ // do the magic for UK
102
+ // move postcode to the uk position after the country li
103
+ $(this.fields.country_id).up('tr').insert( {after: $(this.fields.postcode_id).up('tr')} );
104
+ // add result box
105
+ if (!$(this.prefix+'_cp_result_display')) {
106
+ var tmp_html = '<tr><td class="label"><label>&nbsp;</label></td><td class="value" id="'+this.prefix+'_cp_result_display">&nbsp;</td></tr>';
107
+ $(this.fields.postcode_id).up('tr').insert( {after: tmp_html} );
108
+ }
109
+
110
+ // show result box
111
+ $(this.prefix+"_cp_result_display").up('tr').show();
112
+
113
+ // shrink postcode field if needed
114
+ if ('' != this.uk_postcode_width) {
115
+ this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
116
+ $(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
117
+ }
118
+
119
+ // add button
120
+ if (!$(this.prefix+'_cp_button_id')) {
121
+ var tmp_html = '&nbsp;&nbsp;';
122
+ if ('' != _cp_button_image) {
123
+ tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
124
+ } else {
125
+ tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
126
+ }
127
+ $(this.fields.postcode_id).insert( {after : tmp_html} );
128
+ $(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
129
+ }
130
+
131
+ // show button
132
+ $(this.prefix+"_cp_button_id").show();
133
+
134
+ }
135
+
136
+ if ('initial' == this.current_setup && _cp_hide_fields) {
137
+ // first time and default to UK, hide address fields
138
+ $$('.'+this.prefix+'_cp_address_class').invoke('hide');
139
+ }
140
+
141
+ // set state
142
+ this.current_setup = 'uk';
143
+ }
144
+
145
+ this.setup_for_non_uk = function() {
146
+ // check if we need to do anything
147
+ if ('non_uk' != this.current_setup) {
148
+ // hide result box (if it exist already)
149
+ if ($(this.prefix+"_cp_result_display")) {
150
+ this.cp_obj.update_res(null);
151
+ $(this.prefix+"_cp_result_display").up('tr').hide();
152
+ }
153
+ // hide button (if it exist already)
154
+ if ($(this.prefix+"_cp_button_id")) {
155
+ $(this.prefix+"_cp_button_id").hide();
156
+ }
157
+
158
+ // move postcode to the non-uk position after the town
159
+ $(this.fields.town_id).up('tr').insert( {after: $(this.fields.postcode_id).up('tr')} );
160
+
161
+ // show all other addres lines
162
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
163
+ // set state
164
+ this.current_setup = 'non_uk';
165
+ }
166
+ }
167
+
168
+ this.add_lookup = function(setup) {
169
+ cp_obj = CraftyPostcodeCreate();
170
+ this.cp_obj = cp_obj;
171
+ // config
172
+ this.prefix = setup.prefix;
173
+ this.fields = setup.fields;
174
+ cp_obj.set("access_token", _cp_token_adm);
175
+ cp_obj.set("res_autoselect", "0");
176
+ cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
177
+ cp_obj.set("form", "");
178
+ cp_obj.set("elem_company" , this.fields.company_id); // optional
179
+ cp_obj.set("elem_street1" , this.fields.street1_id);
180
+ cp_obj.set("elem_street2" , this.fields.street2_id);
181
+ cp_obj.set("elem_street3" , this.fields.street3_id);
182
+ cp_obj.set("elem_town" , this.fields.town_id);
183
+ cp_obj.set("elem_county" , this.fields.county_id); // optional
184
+ cp_obj.set("elem_postcode" , this.fields.postcode_id);
185
+ cp_obj.set("single_res_autoselect" , 1); // don't show a drop down box if only one matching address is found
186
+ cp_obj.set("max_width" , _cp_result_box_width);
187
+ if (1 < _cp_result_box_height) {
188
+ cp_obj.set("first_res_line", "");
189
+ cp_obj.set("max_lines" , _cp_result_box_height);
190
+ } else {
191
+ cp_obj.set("first_res_line", "----- please select your address ----");
192
+ cp_obj.set("max_lines" , 1);
193
+ }
194
+ cp_obj.set("busy_img_url" , _cp_busy_img_url);
195
+ cp_obj.set("hide_result" , _cp_clear_result);
196
+ cp_obj.set("traditional_county" , 1);
197
+ cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
198
+ cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
199
+ cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
200
+ cp_obj.set("first_res_line", _cp_1st_res_line);
201
+ cp_obj.set("err_msg1", _cp_err_msg1);
202
+ cp_obj.set("err_msg2", _cp_err_msg2);
203
+ cp_obj.set("err_msg3", _cp_err_msg3);
204
+ cp_obj.set("err_msg4", _cp_err_msg4);
205
+ // initial page setup
206
+ if (this.rearrange_fields()) {
207
+ if (_cp_enable_for_uk_only) {
208
+ this.country_changed();
209
+ $(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
210
+ } else {
211
+ this.setup_for_uk();
212
+ }
213
+ } else {
214
+ // alert ('Postcode Lookup could not be added!');
215
+ }
216
+ }
217
+
218
+ this.country_changed = function(e) {
219
+ // show postcode lookup for:
220
+ // "GB" UK
221
+ // "JE" Jersey
222
+ // "GG" Guernsey
223
+ // "IM" Isle of Man
224
+ var curr_country = $(this.fields.country_id).getValue();
225
+ if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
226
+ this.setup_for_uk();
227
+ } else {
228
+ this.setup_for_non_uk();
229
+ }
230
+ }
231
+
232
+ this.button_clicked = function(e) {
233
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
234
+ this.cp_obj.doLookup();
235
+ }
236
+
237
+ this.result_ready = function() {
238
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
239
+ }
240
+
241
+ this.result_selected = function() {
242
+ if (_cp_clear_result) this.cp_obj.update_res(null);
243
+ }
244
+
245
+ this.result_error = function() {
246
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
247
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
248
+ }
249
+ }
250
+
251
+ document.observe("dom:loaded", function() {
252
+
253
+ if (!_cp_integrate) return;
254
+
255
+ if ($('address_list')) {
256
+ // looks like we are on the customer edit page, check and attach to all existing address forms (there could be many!)
257
+ var add_list = $$("#address_list > li");
258
+
259
+ if (add_list && 0 < add_list.length) {
260
+ var max_id = 0;
261
+ for (var ii = 0; ii < add_list.length; ii++) {
262
+ var item = add_list[ii];
263
+ var item_id = '';
264
+ var item_html_id = '';
265
+ if ('address_item_' == item.id.substr(0,13)) {
266
+ item_id = item.id.substr(13);
267
+ } else if ('new_item' == item.id.substr(0,8)) {
268
+ item_id = item.id.substr(8);
269
+ }
270
+ // old magento templates can have "idX", new ones have "_itemX", se we test for this here
271
+ if ($('id'+item_id+'postcode')) {
272
+ item_html_id = 'id'+item_id;
273
+ } if ($('_item'+item_id+'postcode')) {
274
+ item_html_id = '_item'+item_id;
275
+ }
276
+
277
+ if ('' != item_html_id) {
278
+ var cc_tmp = new CraftyClicksMagentoClass();
279
+ cc_tmp.add_lookup({
280
+ "prefix" : item_html_id,
281
+ "fields" : { "postcode_id" : item_html_id+"postcode",
282
+ "company_id" : item_html_id+"company",
283
+ "street1_id" : item_html_id+"street0",
284
+ "street2_id" : item_html_id+"street1",
285
+ "street3_id" : item_html_id+"street2",
286
+ "street4_id" : item_html_id+"street3",
287
+ "town_id" : item_html_id+"city",
288
+ "county_id" : item_html_id+"region",
289
+ "country_id" : item_html_id+"country_id" }
290
+ });
291
+ }
292
+
293
+ if (item_id > max_id) max_id = item_id;
294
+ }
295
+
296
+ // check for magento bug in address numbering
297
+ if (customerAddresses.itemCount <= max_id) customerAddresses.itemCount = max_id;
298
+ }
299
+
300
+ // make sure lookup is added when a new adress form is created....
301
+ $('add_address_button').observe('click', function() {
302
+ var item_html_id = '_item'+(customerAddresses.itemCount);
303
+ var cc_tmp = new CraftyClicksMagentoClass();
304
+ cc_tmp.add_lookup({
305
+ "prefix" : item_html_id,
306
+ "fields" : { "postcode_id" : item_html_id+"postcode",
307
+ "company_id" : item_html_id+"company",
308
+ "street1_id" : item_html_id+"street0",
309
+ "street2_id" : item_html_id+"street1",
310
+ "street3_id" : item_html_id+"street2",
311
+ "street4_id" : item_html_id+"street3",
312
+ "town_id" : item_html_id+"city",
313
+ "county_id" : item_html_id+"region",
314
+ "country_id" : item_html_id+"country_id" }
315
+ });
316
+ });
317
+ } else {
318
+ // probably on the new order page, check and attach
319
+ _cp_check_and_attach();
320
+ }
321
+ });
322
+
323
+ var _cp_last_billing_attachement = null;
324
+ var _cp_last_shipping_attachement = null;
325
+ function _cp_check_and_attach() {
326
+
327
+ if ($('order-billing_address_postcode') && _cp_last_billing_attachement != $('order-billing_address_postcode')) {
328
+ _cp_last_billing_attachement = $('order-billing_address_postcode');
329
+ var item_html_id = 'order-billing_address_';
330
+ var cc_tmp = new CraftyClicksMagentoClass();
331
+ cc_tmp.add_lookup({
332
+ "prefix" : item_html_id,
333
+ "fields" : { "postcode_id" : item_html_id+"postcode",
334
+ "company_id" : item_html_id+"company",
335
+ "street1_id" : item_html_id+"street0",
336
+ "street2_id" : item_html_id+"street1",
337
+ "street3_id" : item_html_id+"street2",
338
+ "street4_id" : item_html_id+"street3",
339
+ "town_id" : item_html_id+"city",
340
+ "county_id" : item_html_id+"region",
341
+ "country_id" : item_html_id+"country_id" }
342
+ });
343
+ }
344
+
345
+ if ($('order-shipping_address_postcode') && !$('order-shipping_address_postcode').disabled && _cp_last_shipping_attachement != $('order-shipping_address_postcode')) {
346
+ _cp_last_shipping_attachement = $('order-shipping_address_postcode');
347
+ var item_html_id = 'order-shipping_address_';
348
+ var cc_tmp = new CraftyClicksMagentoClass();
349
+ cc_tmp.add_lookup({
350
+ "prefix" : item_html_id,
351
+ "fields" : { "postcode_id" : item_html_id+"postcode",
352
+ "company_id" : item_html_id+"company",
353
+ "street1_id" : item_html_id+"street0",
354
+ "street2_id" : item_html_id+"street1",
355
+ "street3_id" : item_html_id+"street2",
356
+ "street4_id" : item_html_id+"street3",
357
+ "town_id" : item_html_id+"city",
358
+ "county_id" : item_html_id+"region",
359
+ "country_id" : item_html_id+"country_id" }
360
+ });
361
+ }
362
+
363
+ window.setTimeout(function() { _cp_check_and_attach(); }, 500);
364
+ }
365
+
js/craftyclicks/craftyclicks_magento_multiship.js~ ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>&nbsp;</label><div class="input-box" id="'+this.prefix+'_cp_result_display">&nbsp;</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">&nbsp;&nbsp;&nbsp;<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">&nbsp;</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
+
js/craftyclicks/craftyclicks_onepagecheckout.js ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ // This is a collection of JavaScript code to allow easy integration of
3
+ // the Crafty Clicks postcode / address finder functionality into the
4
+ // OneStepCheckout extension for Magento (www.onestepcheckout.com)
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
11
+ //
12
+ // If you copy/use/modify this code - please keep this
13
+ // comment header in place
14
+ //
15
+ // Copyright (c) 2009-2012 Crafty Clicks (http://www.craftyclicks.com)
16
+ //
17
+ // This code relies on prototype js, you must have a reasonably recent version loaded
18
+ // in your template. Magento should include it as standard.
19
+ //
20
+ // If you need any help, contact support@craftyclicks.co.uk - we will help!
21
+ //
22
+ **********************************************************************************/
23
+ function CraftyClicksMagentoClass () {
24
+ this.prefix = "";
25
+ this.fields = { "postcode_id" : "", // required
26
+ "company_id" : "", // optional
27
+ "street1_id" : "", // required
28
+ "street2_id" : "", // optional
29
+ "street3_id" : "", // optional
30
+ "street4_id" : "", // optional
31
+ "town_id" : "", // required
32
+ "county_id" : "", // optional
33
+ "country_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 = "clearfix";
42
+
43
+ this.elem_move = function(e1, e2) {
44
+ e1.insert({after : e2});
45
+ }
46
+
47
+ // test div depth - some magento templates wrap fields in two layers of div in a li
48
+ this.set_div_depth = function() {
49
+ if ($(this.fields.postcode_id).up('div', 1).descendantOf($(this.fields.postcode_id).up('li'))) {
50
+ this.div_depth = 1;
51
+ }
52
+ }
53
+
54
+ this.rearrange_fields = function() {
55
+ var fields = this.fields;
56
+
57
+ // check we have a postcode field
58
+ if ($(fields.postcode_id)) {
59
+ if ('' != $(fields.town_id).getValue()) {
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)) {
73
+ $(fields.company_id).up('li').addClassName(this.prefix+'_cp_address_class');
74
+ }
75
+ if ($(fields.street1_id)) {
76
+ $(fields.street1_id).up('li').addClassName(this.prefix+'_cp_address_class');
77
+ }
78
+ if ($(fields.street2_id)) {
79
+ $(fields.street2_id).up('li').addClassName(this.prefix+'_cp_address_class');
80
+ }
81
+ if ($(fields.street3_id)) {
82
+ $(fields.street3_id).up('li').addClassName(this.prefix+'_cp_address_class');
83
+ }
84
+ if ($(fields.street4_id)) {
85
+ $(fields.street4_id).up('li').addClassName(this.prefix+'_cp_address_class');
86
+ }
87
+ if ($(fields.town_id)) {
88
+ $(fields.town_id).up('li').addClassName(this.prefix+'_cp_address_class');
89
+ }
90
+ if ($(fields.county_id)) {
91
+ $(fields.county_id).up('li').addClassName(this.prefix+'_cp_address_class');
92
+ }
93
+
94
+ return (true);
95
+ } else {
96
+ return (false);
97
+ }
98
+ }
99
+
100
+ this.setup_for_uk = function() {
101
+ // check if we need to do anything
102
+ if ('uk' != this.current_setup) {
103
+ // do the magic for UK
104
+ // move postcode to the uk position after the country li
105
+ $(this.fields.country_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
106
+ // add result box
107
+ if (!$(this.prefix+'_cp_result_display')) {
108
+ var tmp_html = '<li class="'+this.li_class+'" style="display: none"><div class="input-box" id="'+this.prefix+'_cp_result_display">&nbsp;</div></li>';
109
+ $(this.fields.postcode_id).up('li').insert( {after: tmp_html} );
110
+ }
111
+ // show result box
112
+ $(this.prefix+"_cp_result_display").up('li').show();
113
+ // add button
114
+ if (!$(this.prefix+'_cp_button_div_id')) {
115
+ var tmp_html = '';
116
+ if (0 == this.div_depth) {
117
+ tmp_html = '<div class="input-box" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label><br/>';
118
+ } else {
119
+ tmp_html = '<div class="field" id="'+this.prefix+'_cp_button_div_id"><label style="width:5px" for="'+this.prefix+'_cp_button_id">&nbsp;</label><div class="input-box">';
120
+ }
121
+ if ('' != _cp_button_image) {
122
+ tmp_html += '<img style="cursor: pointer;" src="'+_cp_button_image+'" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'" title="'+_cp_button_text+'"/>';
123
+ } else {
124
+ tmp_html += '<button type="button" id="'+this.prefix+'_cp_button_id" class="'+_cp_button_class+'"><span><span>'+_cp_button_text+'</span></span></button>';
125
+ }
126
+ if (0 == this.div_depth) {
127
+ tmp_html += '</div>';
128
+ } else {
129
+ tmp_html += '</div></div>';
130
+ }
131
+ $(this.fields.postcode_id).up('div', this.div_depth).insert( {after : tmp_html} );
132
+ $(this.prefix+"_cp_button_id").observe('click', this.button_clicked.bindAsEventListener(this));
133
+ }
134
+ // show button
135
+ $(this.prefix+"_cp_button_div_id").show();
136
+
137
+ // shrink postcode field if needed
138
+ if ('' != this.uk_postcode_width) {
139
+ this.old_postcode_width = $(this.fields.postcode_id).getStyle("width");
140
+ $(this.fields.postcode_id).setStyle({width: this.uk_postcode_width});
141
+ }
142
+
143
+ // hide county if requested (and if it exists in the html at all)
144
+ if (_cp_hide_county) {
145
+ ne = $(this.fields.county_id);
146
+ if (ne) {
147
+ ne.up('div', this.div_depth).hide();
148
+ }
149
+ }
150
+ }
151
+
152
+ if ('initial' == this.current_setup && _cp_hide_fields) {
153
+ // first time and default to UK, hide address fields
154
+ $$('.'+this.prefix+'_cp_address_class').invoke('hide');
155
+ }
156
+
157
+ // set state
158
+ this.current_setup = 'uk';
159
+ }
160
+
161
+ this.setup_for_non_uk = function() {
162
+ // check if we need to do anything
163
+ if ('non_uk' != this.current_setup) {
164
+ // hide result box (if it exist already)
165
+ if ($(this.prefix+"_cp_result_display")) {
166
+ this.cp_obj.update_res(null);
167
+ $(this.prefix+"_cp_result_display").up('li').hide();
168
+ }
169
+ // hide button (if it exist already)
170
+ if ($(this.prefix+"_cp_button_div_id")) {
171
+ $(this.prefix+"_cp_button_div_id").hide();
172
+ }
173
+ // move postcode to the non-uk position after the town/county li
174
+ if ($(this.fields.county_id)) {
175
+ $(this.fields.county_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
176
+ } else if ($(this.fields.town_id)) {
177
+ $(this.fields.town_id).up('li').insert( {after: $(this.fields.postcode_id).up('li')} );
178
+ }
179
+ // restore postcode field width if needed
180
+ if ('' != this.old_postcode_width) {
181
+ $(this.fields.postcode_id).setStyle({width: this.old_postcode_width});
182
+ }
183
+ // show county if it was hidden (and exists in the html at all)
184
+ if (_cp_hide_county) {
185
+ ne = $(this.fields.county_id);
186
+ if (ne) {
187
+ ne.up('div', this.div_depth).show();
188
+ }
189
+ }
190
+
191
+ // show all other addres lines
192
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
193
+ // set state
194
+ this.current_setup = 'non_uk';
195
+ }
196
+ }
197
+
198
+ this.add_lookup = function(setup) {
199
+ cp_obj = CraftyPostcodeCreate();
200
+ this.cp_obj = cp_obj;
201
+ // config
202
+ this.prefix = setup.prefix;
203
+ this.fields = setup.fields;
204
+ cp_obj.set("access_token", _cp_token_fe);
205
+ cp_obj.set("res_autoselect", "0");
206
+ cp_obj.set("result_elem_id", this.prefix+"_cp_result_display");
207
+ cp_obj.set("form", "");
208
+ cp_obj.set("elem_company" , this.fields.company_id); // optional
209
+ cp_obj.set("elem_street1" , this.fields.street1_id);
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
+ cp_obj.set("elem_county" , this.fields.county_id); // optional
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);
217
+ if (1 < _cp_result_box_height) {
218
+ cp_obj.set("first_res_line", "");
219
+ cp_obj.set("max_lines" , _cp_result_box_height);
220
+ } else {
221
+ cp_obj.set("first_res_line", "----- please select your address ----");
222
+ cp_obj.set("max_lines" , 1);
223
+ }
224
+ cp_obj.set("busy_img_url" , _cp_busy_img_url);
225
+ cp_obj.set("hide_result" , _cp_clear_result);
226
+ cp_obj.set("traditional_county" , 1);
227
+ cp_obj.set("on_result_ready", this.result_ready.bindAsEventListener(this));
228
+ cp_obj.set("on_result_selected", this.result_selected.bindAsEventListener(this));
229
+ cp_obj.set("on_error", this.result_error.bindAsEventListener(this));
230
+ cp_obj.set("first_res_line", _cp_1st_res_line);
231
+ cp_obj.set("err_msg1", _cp_err_msg1);
232
+ cp_obj.set("err_msg2", _cp_err_msg2);
233
+ cp_obj.set("err_msg3", _cp_err_msg3);
234
+ cp_obj.set("err_msg4", _cp_err_msg4);
235
+ // initial page setup
236
+ this.set_div_depth();
237
+ if (this.rearrange_fields()) {
238
+ if (_cp_enable_for_uk_only) {
239
+ this.country_changed();
240
+ $(this.fields.country_id).observe('change', this.country_changed.bindAsEventListener(this));
241
+ } else {
242
+ this.setup_for_uk();
243
+ }
244
+ } else {
245
+ // alert ('Postcode Lookup could not be added!');
246
+ }
247
+ }
248
+
249
+ this.country_changed = function(e) {
250
+ // show postcode lookup for:
251
+ // "GB" UK
252
+ // "JE" Jersey
253
+ // "GG" Guernsey
254
+ // "IM" Isle of Man
255
+ var curr_country = $(this.fields.country_id).getValue();
256
+ if ('GB' == curr_country || 'JE' == curr_country || 'GG' == curr_country || 'IM' == curr_country) {
257
+ this.setup_for_uk();
258
+ } else {
259
+ this.setup_for_non_uk();
260
+ }
261
+ }
262
+
263
+ this.button_clicked = function(e) {
264
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').removeClassName(_cp_error_class);
265
+ this.cp_obj.doLookup();
266
+ }
267
+
268
+ this.result_ready = function() {
269
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
270
+ }
271
+
272
+ this.result_selected = function() {
273
+ if (_cp_clear_result) this.cp_obj.update_res(null);
274
+ }
275
+
276
+ this.result_error = function() {
277
+ $$('.'+this.prefix+'_cp_address_class').invoke('show');
278
+ if ('' != _cp_error_class) $(this.prefix+'_cp_result_display').addClassName(_cp_error_class);
279
+ }
280
+ }
281
+
282
+ document.observe("dom:loaded", function() {
283
+
284
+ if (!_cp_integrate) return;
285
+
286
+ if ($("billing:postcode")) {
287
+ var cc1 = new CraftyClicksMagentoClass();
288
+ cc1.add_lookup({
289
+ "prefix" : "billing",
290
+ "fields" : { "postcode_id" : "billing:postcode",
291
+ "company_id" : "billing:company",
292
+ "street1_id" : "billing:street1",
293
+ "street2_id" : "billing:street2",
294
+ "street3_id" : "billing:street3",
295
+ "street4_id" : "billing:street4",
296
+ "town_id" : "billing:city",
297
+ "county_id" : "billing:region",
298
+ "country_id" : "billing:country_id" }
299
+ });
300
+ }
301
+
302
+ if ($("shipping:postcode")) {
303
+ var cc2 = new CraftyClicksMagentoClass();
304
+ cc2.add_lookup({
305
+ "prefix" : "shipping",
306
+ "fields" : { "postcode_id" : "shipping:postcode",
307
+ "company_id" : "shipping:company",
308
+ "street1_id" : "shipping:street1",
309
+ "street2_id" : "shipping:street2",
310
+ "street3_id" : "shipping:street3",
311
+ "street4_id" : "shipping:street4",
312
+ "town_id" : "shipping:city",
313
+ "county_id" : "shipping:region",
314
+ "country_id" : "shipping:country_id" }
315
+ });
316
+ }
317
+
318
+ });
319
+
package.xml CHANGED
@@ -1,22 +1,24 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>UK_Postcode_Address_Finder</name>
4
- <version>2.3.3</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.opensource.org/licenses/osl-3.0.php">Open Software License ("OSL") v. 3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>UK address auto completion functionality. Uses CraftyClicks.co.uk web service to lookup address from a postcode.</summary>
10
- <description>This extension provides auto completion functionality on all postal address forms. Shoppers simply enter their postcode and are given a list of matching addresses to select from. Address entry is greatly speeded up thus improving the user experience.&#xD;
11
  &#xD;
12
- The benefits for the merchant are lower drop off rates on checkout/registration and improved quality of address data captured.&#xD;
13
  &#xD;
14
- Please note:&#xD;
15
  &#xD;
16
- 1. This extension currently only works for UK postcodes. If country selected is not UK, the 'find address' button is not shown.&#xD;
17
- &#xD;
18
- 2. The extension is free to try and install, but to go live a paid up account with CraftyClicks will be required. For current prices please go to http://www.craftyclicks.co.uk/prices</description>
19
  <notes>Release History :&#xD;
 
 
 
 
20
  v2.3.3&#xD;
21
  * no changes - repackaged to keep Magento Connect happy&#xD;
22
  &#xD;
@@ -47,12 +49,12 @@ v 2.0&#xD;
47
  * pressing enter key in the postcode input field does a search&#xD;
48
  &#xD;
49
  v 1.6.2&#xD;
50
- * fix for Internet Explorer in admin panel -&gt; new customer page; the add address button didn't always work&#xD;
51
  * use default country in admin pannel - Magento doesn't do this by default&#xD;
52
  * 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&#xD;
53
  &#xD;
54
  v 1.6.1&#xD;
55
- * fix for admin panel -&gt; sales pages; Added a 1s delay before CraftyClicks stuff is added to a form.&#xD;
56
  In some rare cases the timing was such that the form may not yet exist in DOM when we tried to add&#xD;
57
  address finder button etc.&#xD;
58
  &#xD;
@@ -99,10 +101,10 @@ v 1.1.0 &#xD;
99
  * add address lookup to multiship checkout pages&#xD;
100
  &#xD;
101
  v 1.0.0 - Initial Release</notes>
102
- <authors><author><name>Adam Stylo</name><user>auto-converted</user><email>adam@craftyclicks.co.uk</email></author></authors>
103
- <date>2011-05-17</date>
104
- <time>22:26:38</time>
105
- <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="96a31897ea71713771d937caa469acf8"/><file name="system.xml" hash="e1ce47e185d5e6a272cd0cecaaf84310"/></dir></dir><dir name="GoMage"><dir name="Checkout"><dir name="Block"><dir name="Onepage"><file name="Abstract.php" hash="1f664f62c8a7ec7aa94c327477a42d24"/></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="craftyclicks"><dir name="checkout"><dir name="onepage"><file name="billing.phtml" hash="97a1876612a1b8fe822d10c5e97d36bf"/><file name="shipping.phtml" hash="4c4fa3c1b2c106b9b9de0181cffe436c"/></dir></dir><dir name="customer"><dir name="address"><file name="edit.phtml" hash="e3ed50dc65b227092ddc93285a4a1fc8"/></dir></dir><file name="address_form.phtml" hash="ce78db884ae5a8e07077cb784ec23396"/><file name="checkout_onepage.phtml" hash="ae61a2ddca442037f1ec7c0d27f39e15"/><file name="crafty_template_helper.php" hash="07472c8777556ef6cf3a4f44d3135e8a"/><file name="gomage_lightcheckout.phtml" hash="02ebe07fb572db76d780ae57297458f6"/><file name="single_page_checkout.phtml" hash="f698c197a5817072b9f1f4ddb91dfc29"/></dir><dir name="onestepcheckout"><dir name="__orig_files_cc"><file name="billing_fields.phtml" hash="b1d163ad380094550685b81850d44ecf"/><file name="shipping_fields.phtml" hash="472ff7a3eebcd4a4869af1c3291ec720"/></dir><file name="billing_fields.phtml" hash="de0f72ce17353c66851bf07cc94f1186"/><file name="shipping_fields.phtml" hash="a9925881e75fcbbdca736aca8a7f103b"/></dir></dir><dir name="layout"><file name="craftyclicks.xml" hash="24b821373c927e48d8792926d4c08a3e"/></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="CraftyClicks.xml" hash="643f206f696f9802fe2d895e2831452d"/></dir></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><target name="mageweb"><dir name="js"><dir name="craftyclicks"><file name="crafty_postcode.class.js" hash="024e6b082bb44effe931e014aeab7283"/></dir></dir></target></contents>
106
  <compatible/>
107
  <dependencies/>
108
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>UK_Postcode_Address_Finder</name>
4
+ <version>2.4.0</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>
8
  <extends/>
9
+ <summary>UK address auto completion functionality. Uses the Crafty Clicks web service to lookup address from a postcode.</summary>
10
+ <description>This extension provides auto completion functionality on all postal address forms. Shoppers simply enter a UK postcode and are given a list of matching addresses to select from.&#xD;
11
  &#xD;
12
+ This is a must-have for any webiste targeting the UK. The shoppers in the UK are used to the convenience of postcode lookup and expect to see it.&#xD;
13
  &#xD;
14
+ UK address entry is greatly speeded up thus improving the user experience. The benefits for the merchant are lower drop off rates on checkout/registration and improved quality of address data captured.&#xD;
15
  &#xD;
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 :&#xD;
18
+ v2.4.0&#xD;
19
+ * major rework. Keeping compatible with the growing list of one-page-checkout extensions was a pain. &#xD;
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.&#xD;
21
+ &#xD;
22
  v2.3.3&#xD;
23
  * no changes - repackaged to keep Magento Connect happy&#xD;
24
  &#xD;
49
  * pressing enter key in the postcode input field does a search&#xD;
50
  &#xD;
51
  v 1.6.2&#xD;
52
+ * fix for Internet Explorer in admin panel - new customer page; the add address button didn't always work&#xD;
53
  * use default country in admin pannel - Magento doesn't do this by default&#xD;
54
  * 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&#xD;
55
  &#xD;
56
  v 1.6.1&#xD;
57
+ * fix for admin panel - sales pages; Added a 1s delay before CraftyClicks stuff is added to a form.&#xD;
58
  In some rare cases the timing was such that the form may not yet exist in DOM when we tried to add&#xD;
59
  address finder button etc.&#xD;
60
  &#xD;
101
  * add address lookup to multiship checkout pages&#xD;
102
  &#xD;
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-02-13</date>
106
+ <time>07:29:32</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="aa2757a95f6cd4a176b133e26724650f"/><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="1de8b571d21780f2208b8a7b01e5d7a2"/></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_mage_onepage.js~" hash="70e8f88943a3fbf69747bb91327ca4a4"/><file name="crafty_postcode.class.js" hash="44593e9ea50fbfb6a6a35760b878331f"/><file name="craftyclicks_gomage_lightcheckout.js" hash="ad89070980c98e816a6684aa1f9fbb86"/><file name="craftyclicks_magento.js" hash="2bffc2139a653f628dd5d24115598648"/><file name="craftyclicks_magento.js~" hash="5d9c2bfc50cc73b86bc0e04e2baf1b40"/><file name="craftyclicks_magento_admin.js" hash="7c64061e12c7946133205656392baa2d"/><file name="craftyclicks_magento_multiship.js~" hash="6793b51960f5cbf2a4eef2b2293e6c9c"/><file name="craftyclicks_onepagecheckout.js" hash="355373854dc7232c8379854da7166041"/></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>
108
  <compatible/>
109
  <dependencies/>
110
  </package>