PostcodeNl_Api - Version 1.0.3.0

Version Notes

- Improved

Download this release

Release Info

Developer Magento Core Team
Extension PostcodeNl_Api
Version 1.0.3.0
Comparing to
See all releases


Code changes from version 1.0.2.0 to 1.0.3.0

app/code/community/PostcodeNl/Api/controllers/JsonController.php CHANGED
@@ -3,6 +3,38 @@ class PostcodeNl_Api_JsonController extends Mage_Core_Controller_Front_Action
3
  {
4
  const API_TIMEOUT = 3;
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  public function lookupAction()
7
  {
8
  if (!Mage::getStoreConfig('postcodenl/config/enabled'))
@@ -11,11 +43,14 @@ class PostcodeNl_Api_JsonController extends Mage_Core_Controller_Front_Action
11
  return;
12
  }
13
 
14
- $serviceUrl = Mage::getStoreConfig('postcodenl/config/api_url');
15
- $serviceKey = Mage::getStoreConfig('postcodenl/config/api_key');
16
- $serviceSecret = Mage::getStoreConfig('postcodenl/config/api_secret');
17
  $serviceShowcase = Mage::getStoreConfig('postcodenl/config/api_showcase');
18
 
 
 
 
19
  if (!$serviceUrl || !$serviceKey || !$serviceSecret)
20
  {
21
  echo json_encode(array('message' => $this->__('Postcode.nl API not configured.')));
@@ -29,6 +64,7 @@ class PostcodeNl_Api_JsonController extends Mage_Core_Controller_Front_Action
29
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::API_TIMEOUT);
30
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
31
  curl_setopt($ch, CURLOPT_USERPWD, $serviceKey .':'.$serviceSecret);
 
32
  $jsonResponse = curl_exec($ch);
33
  curl_close($ch);
34
 
3
  {
4
  const API_TIMEOUT = 3;
5
 
6
+ protected $_modules;
7
+
8
+ protected function _getMagentoVersion()
9
+ {
10
+ if ($this->_getModuleInfo('Enterprise_CatalogPermissions') !== null)
11
+ {
12
+ // Detect enterprise
13
+ return 'MagentoEnterprise/'. Mage::getVersion();
14
+ }
15
+ elseif ($this->_getModuleInfo('Enterprise_Enterprise') !== null)
16
+ {
17
+ // Detect professional
18
+ return 'MagentoProfessional/'. Mage::getVersion();
19
+ }
20
+ else
21
+ {
22
+ // Rest
23
+ return 'Magento/'. Mage::getVersion();
24
+ }
25
+ }
26
+
27
+ protected function _getModuleInfo($moduleName)
28
+ {
29
+ if (!isset($this->_modules))
30
+ $this->_modules = (array)Mage::getConfig()->getNode('modules')->children();
31
+
32
+ if (!isset($this->_modules[$moduleName]))
33
+ return null;
34
+
35
+ return $this->_modules[$moduleName];
36
+ }
37
+
38
  public function lookupAction()
39
  {
40
  if (!Mage::getStoreConfig('postcodenl/config/enabled'))
43
  return;
44
  }
45
 
46
+ $serviceUrl = trim(Mage::getStoreConfig('postcodenl/config/api_url'));
47
+ $serviceKey = trim(Mage::getStoreConfig('postcodenl/config/api_key'));
48
+ $serviceSecret = trim(Mage::getStoreConfig('postcodenl/config/api_secret'));
49
  $serviceShowcase = Mage::getStoreConfig('postcodenl/config/api_showcase');
50
 
51
+ $extensionInfo = $this->_getModuleInfo('PostcodeNl_Api');
52
+ $extensionVersion = $extensionInfo ? $extensionInfo->version : 'unknown';
53
+
54
  if (!$serviceUrl || !$serviceKey || !$serviceSecret)
55
  {
56
  echo json_encode(array('message' => $this->__('Postcode.nl API not configured.')));
64
  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::API_TIMEOUT);
65
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
66
  curl_setopt($ch, CURLOPT_USERPWD, $serviceKey .':'.$serviceSecret);
67
+ curl_setopt($ch, CURLOPT_USERAGENT, 'PostcodeNl_Api_MagentoPlugin/' . $extensionVersion .' '. $this->_getMagentoVersion());
68
  $jsonResponse = curl_exec($ch);
69
  curl_close($ch);
70
 
app/code/community/PostcodeNl/Api/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <PostcodeNl_Api>
5
- <version>1.0.0.0</version>
6
  </PostcodeNl_Api>
7
  </modules>
8
  <frontend>
2
  <config>
3
  <modules>
4
  <PostcodeNl_Api>
5
+ <version>1.0.3.0</version>
6
  </PostcodeNl_Api>
7
  </modules>
8
  <frontend>
app/design/adminhtml/default/default/template/postcodenl/api/jsinit.phtml CHANGED
@@ -1,23 +1,31 @@
1
  <script type="text/javascript">
2
  //<![CDATA[
3
  var PCNLAPI_CONFIG = {
4
- baseUrl: "<?php echo htmlspecialchars(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)) ?>",
5
  showcase: <?php echo Mage::getStoreConfig('postcodenl/config/api_showcase') ? 'true' : 'false' ?>,
 
 
6
  translations: {
7
  defaultError: "<?php echo htmlspecialchars($this->__('Unknown postcode + housenumber combination.')) ?>",
8
  postcodeInputLabel: "<?php echo htmlspecialchars($this->__('Postcode (auto-validating)')) ?>",
9
  postcodeInputTitle: "<?php echo htmlspecialchars($this->__('Postcode')) ?>",
10
  houseNumberAdditionUnknown: "<?php echo htmlspecialchars($this->__('Housenumber addition `{addition}` is unknown.')) ?>",
11
  houseNumberAdditionRequired: "<?php echo htmlspecialchars($this->__('Housenumber addition required.')) ?>",
12
- houseNumberLabel: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
13
  houseNumberTitle: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
14
- houseNumberAdditionLabel: "<?php echo htmlspecialchars($this->__('Houseno addition')) ?>",
15
  houseNumberAdditionTitle: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
16
  selectAddition: "<?php echo htmlspecialchars($this->__('Select...')) ?>",
17
  noAdditionSelect: "<?php echo htmlspecialchars($this->__('No addition.')) ?>",
18
- noAdditionSelectCustom: "<?php echo htmlspecialchars($this->__('Do not use any addition anyway.')) ?>",
19
- additionSelectCustom: "<?php echo htmlspecialchars($this->__('Use `{addition}` anyway.')) ?>",
20
  apiShowcase: "<?php echo htmlspecialchars($this->__('API Showcase')) ?>",
 
 
 
 
 
 
21
  }
22
  };
23
  //]]>
1
  <script type="text/javascript">
2
  //<![CDATA[
3
  var PCNLAPI_CONFIG = {
4
+ baseUrl: "<?php echo htmlspecialchars(Mage::getUrl('', array('_secure' => true))) ?>",
5
  showcase: <?php echo Mage::getStoreConfig('postcodenl/config/api_showcase') ? 'true' : 'false' ?>,
6
+ useStreet2AsHouseNumber: <?php echo Mage::getStoreConfig('postcodenl/config/use_street2_as_housenumber') ? 'true' : 'false' ?>,
7
+ adminValidationDisabled: <?php echo Mage::getStoreConfig('postcodenl/config/admin_validation_disabled') ? 'true' : 'false' ?>,
8
  translations: {
9
  defaultError: "<?php echo htmlspecialchars($this->__('Unknown postcode + housenumber combination.')) ?>",
10
  postcodeInputLabel: "<?php echo htmlspecialchars($this->__('Postcode (auto-validating)')) ?>",
11
  postcodeInputTitle: "<?php echo htmlspecialchars($this->__('Postcode')) ?>",
12
  houseNumberAdditionUnknown: "<?php echo htmlspecialchars($this->__('Housenumber addition `{addition}` is unknown.')) ?>",
13
  houseNumberAdditionRequired: "<?php echo htmlspecialchars($this->__('Housenumber addition required.')) ?>",
14
+ houseNumberLabel: "<?php echo htmlspecialchars($this->__('Housenumber (auto-validating)')) ?>",
15
  houseNumberTitle: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
16
+ houseNumberAdditionLabel: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
17
  houseNumberAdditionTitle: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
18
  selectAddition: "<?php echo htmlspecialchars($this->__('Select...')) ?>",
19
  noAdditionSelect: "<?php echo htmlspecialchars($this->__('No addition.')) ?>",
20
+ noAdditionSelectCustom: "<?php echo htmlspecialchars($this->__('`No addition`')) ?>",
21
+ additionSelectCustom: "<?php echo htmlspecialchars($this->__('`{addition}`')) ?>",
22
  apiShowcase: "<?php echo htmlspecialchars($this->__('API Showcase')) ?>",
23
+ disabledText: "<?php echo htmlspecialchars($this->__('- disabled -')) ?>",
24
+ infoLabel: "<?php echo htmlspecialchars($this->__('Validation')) ?>",
25
+ infoText: "<?php echo htmlspecialchars($this->__('Fill out your postcode and housenumber to auto-complete your address. You can also manually set your address information.')) ?>",
26
+ manualInputLabel: "<?php echo htmlspecialchars($this->__('Manual input')) ?>",
27
+ manualInputText: "<?php echo htmlspecialchars($this->__('Fill out address information manually')) ?>",
28
+ outputLabel: "<?php echo htmlspecialchars($this->__('Validated address')) ?>"
29
  }
30
  };
31
  //]]>
app/design/frontend/default/default/layout/postcodenl/api/lookup.xml CHANGED
@@ -9,6 +9,15 @@
9
  <block type="postcodenl/jsinit" name="postcodenl.jsinit" template="postcodenl/api/jsinit.phtml" />
10
  </reference>
11
  </checkout_onepage_index>
 
 
 
 
 
 
 
 
 
12
  <customer_address_form>
13
  <reference name="head">
14
  <action method="addCss" ifconfig="postcodenl/config/enabled"><script>postcodenl/api/css/lookup.css</script></action>
9
  <block type="postcodenl/jsinit" name="postcodenl.jsinit" template="postcodenl/api/jsinit.phtml" />
10
  </reference>
11
  </checkout_onepage_index>
12
+ <onestepcheckout_index_index>
13
+ <reference name="head">
14
+ <action method="addCss" ifconfig="postcodenl/config/enabled"><script>postcodenl/api/css/lookup.css</script></action>
15
+ <action method="addJs" ifconfig="postcodenl/config/enabled"><script>postcodenl/api/lookup.js</script></action>
16
+ </reference>
17
+ <reference name="content">
18
+ <block type="postcodenl/jsinit" name="postcodenl.jsinit" template="postcodenl/api/jsinit.phtml" />
19
+ </reference>
20
+ </onestepcheckout_index_index>
21
  <customer_address_form>
22
  <reference name="head">
23
  <action method="addCss" ifconfig="postcodenl/config/enabled"><script>postcodenl/api/css/lookup.css</script></action>
app/design/frontend/default/default/template/postcodenl/api/jsinit.phtml CHANGED
@@ -1,24 +1,31 @@
1
  <script type="text/javascript">
2
  //<![CDATA[
3
  var PCNLAPI_CONFIG = {
4
- baseUrl: "<?php echo htmlspecialchars(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)) ?>",
5
  showcase: <?php echo Mage::getStoreConfig('postcodenl/config/api_showcase') ? 'true' : 'false' ?>,
6
  useStreet2AsHouseNumber: <?php echo Mage::getStoreConfig('postcodenl/config/use_street2_as_housenumber') ? 'true' : 'false' ?>,
 
7
  translations: {
8
  defaultError: "<?php echo htmlspecialchars($this->__('Unknown postcode + housenumber combination.')) ?>",
9
- postcodeInputLabel: "<?php echo htmlspecialchars($this->__('Postcode (auto-validating)')) ?>",
10
  postcodeInputTitle: "<?php echo htmlspecialchars($this->__('Postcode')) ?>",
11
  houseNumberAdditionUnknown: "<?php echo htmlspecialchars($this->__('Housenumber addition `{addition}` is unknown.')) ?>",
12
  houseNumberAdditionRequired: "<?php echo htmlspecialchars($this->__('Housenumber addition required.')) ?>",
13
- houseNumberLabel: "<?php echo htmlspecialchars($this->__('Housenumber (with any additions)')) ?>",
14
  houseNumberTitle: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
15
  houseNumberAdditionLabel: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
16
  houseNumberAdditionTitle: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
17
  selectAddition: "<?php echo htmlspecialchars($this->__('Select...')) ?>",
18
  noAdditionSelect: "<?php echo htmlspecialchars($this->__('No addition.')) ?>",
19
- noAdditionSelectCustom: "<?php echo htmlspecialchars($this->__('Do not use any addition anyway.')) ?>",
20
- additionSelectCustom: "<?php echo htmlspecialchars($this->__('Use `{addition}` anyway.')) ?>",
21
  apiShowcase: "<?php echo htmlspecialchars($this->__('API Showcase')) ?>",
 
 
 
 
 
 
22
  }
23
  };
24
  //]]>
1
  <script type="text/javascript">
2
  //<![CDATA[
3
  var PCNLAPI_CONFIG = {
4
+ baseUrl: "<?php echo htmlspecialchars(Mage::getUrl('', array('_secure' => true))) ?>",
5
  showcase: <?php echo Mage::getStoreConfig('postcodenl/config/api_showcase') ? 'true' : 'false' ?>,
6
  useStreet2AsHouseNumber: <?php echo Mage::getStoreConfig('postcodenl/config/use_street2_as_housenumber') ? 'true' : 'false' ?>,
7
+ adminValidationDisabled: <?php echo Mage::getStoreConfig('postcodenl/config/admin_validation_disabled') ? 'true' : 'false' ?>,
8
  translations: {
9
  defaultError: "<?php echo htmlspecialchars($this->__('Unknown postcode + housenumber combination.')) ?>",
10
+ postcodeInputLabel: "<?php echo htmlspecialchars($this->__('Postcode')) ?>",
11
  postcodeInputTitle: "<?php echo htmlspecialchars($this->__('Postcode')) ?>",
12
  houseNumberAdditionUnknown: "<?php echo htmlspecialchars($this->__('Housenumber addition `{addition}` is unknown.')) ?>",
13
  houseNumberAdditionRequired: "<?php echo htmlspecialchars($this->__('Housenumber addition required.')) ?>",
14
+ houseNumberLabel: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
15
  houseNumberTitle: "<?php echo htmlspecialchars($this->__('Housenumber')) ?>",
16
  houseNumberAdditionLabel: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
17
  houseNumberAdditionTitle: "<?php echo htmlspecialchars($this->__('Housenumber addition')) ?>",
18
  selectAddition: "<?php echo htmlspecialchars($this->__('Select...')) ?>",
19
  noAdditionSelect: "<?php echo htmlspecialchars($this->__('No addition.')) ?>",
20
+ noAdditionSelectCustom: "<?php echo htmlspecialchars($this->__('`No addition`')) ?>",
21
+ additionSelectCustom: "<?php echo htmlspecialchars($this->__('`{addition}`')) ?>",
22
  apiShowcase: "<?php echo htmlspecialchars($this->__('API Showcase')) ?>",
23
+ disabledText: "<?php echo htmlspecialchars($this->__('- disabled -')) ?>",
24
+ infoLabel: "<?php echo htmlspecialchars($this->__('Validation')) ?>",
25
+ infoText: "<?php echo htmlspecialchars($this->__('Fill out your postcode and housenumber to auto-complete your address. You can also manually set your address information.')) ?>",
26
+ manualInputLabel: "<?php echo htmlspecialchars($this->__('Manual input')) ?>",
27
+ manualInputText: "<?php echo htmlspecialchars($this->__('Fill out address information manually')) ?>",
28
+ outputLabel: "<?php echo htmlspecialchars($this->__('Validated address')) ?>"
29
  }
30
  };
31
  //]]>
app/locale/en_US/PostcodeNl_Api.csv CHANGED
@@ -9,8 +9,14 @@
9
  "Housenumber addition","Housenumber addition"
10
  "Select...","Select..."
11
  "No addition.","No addition."
12
- "Do not use any addition anyway.","Do not use any addition anyway."
13
- "Use `{addition}` anyway.","Use `{addition}` anyway."
14
  "Housenumber (with any additions)","Housenumber (with any additions)"
15
  "Postcode.nl API not configured.","Postcode.nl API not configured."
16
- "Postcode.nl API not enabled.","Postcode.nl API not enabled."
 
 
 
 
 
 
9
  "Housenumber addition","Housenumber addition"
10
  "Select...","Select..."
11
  "No addition.","No addition."
12
+ "`No addition.`","`No addition`"
13
+ "`{addition}`","`{addition}`"
14
  "Housenumber (with any additions)","Housenumber (with any additions)"
15
  "Postcode.nl API not configured.","Postcode.nl API not configured."
16
+ "Postcode.nl API not enabled.","Postcode.nl API not enabled."
17
+ "- disabled -","- disabled -"
18
+ "Validation","Validation"
19
+ "Fill out your postcode and housenumber to auto-complete your address. You can also manually set your address information.","Fill out your postcode and housenumber to auto-complete your address. You can also manually set your address information."
20
+ "Manual input","Manual input"
21
+ "Fill out address information manually","Fill out address information manually"
22
+ "Validated address","Validated address"
app/locale/nl_NL/PostcodeNl_Api.csv CHANGED
@@ -1,7 +1,7 @@
1
  "Unknown postcode + housenumber combination.","Onbekende postcode + huisnummer combinatie."
2
  "Housenumber addition `{addition}` is unknown.","Huisnummer toevoeging `{addition}` is onbekend."
3
  "Housenumber addition required.","Huisnummer toevoeging vereist."
4
- "Invalid postcode format, use `1234AB` format.","Invalide postcode formaat, gebruik het `1234AB` formaat."
5
  "Postcode","Postcode"
6
  "Postcode (auto-validating)","Postcode (automatisch validerend)"
7
  "Housenumber","Huisnummer"
@@ -9,8 +9,14 @@
9
  "Housenumber addition","Huisnummer toevoeging"
10
  "Select...","Selecteer..."
11
  "No addition.","Geen toevoeging."
12
- "Do not use any addition anyway.","Gebruik toch geen toevoeging."
13
- "Use `{addition}` anyway.","Gebruik toch `{addition}`."
14
  "Housenumber (with any additions)","Huisnummer (met toevoeging)"
15
  "Postcode.nl API not configured.","Postcode.nl API niet configureerd."
16
- "Postcode.nl API not enabled.","Postcode.nl API niet ingeschakeld."
 
 
 
 
 
 
1
  "Unknown postcode + housenumber combination.","Onbekende postcode + huisnummer combinatie."
2
  "Housenumber addition `{addition}` is unknown.","Huisnummer toevoeging `{addition}` is onbekend."
3
  "Housenumber addition required.","Huisnummer toevoeging vereist."
4
+ "Invalid postcode format, use `1234AB` format.","Onbekend postcode formaat, gebruik het `1234AB` formaat."
5
  "Postcode","Postcode"
6
  "Postcode (auto-validating)","Postcode (automatisch validerend)"
7
  "Housenumber","Huisnummer"
9
  "Housenumber addition","Huisnummer toevoeging"
10
  "Select...","Selecteer..."
11
  "No addition.","Geen toevoeging."
12
+ "`No addition`","Toch geen toevoeging"
13
+ "`{addition}`","`{addition}`"
14
  "Housenumber (with any additions)","Huisnummer (met toevoeging)"
15
  "Postcode.nl API not configured.","Postcode.nl API niet configureerd."
16
+ "Postcode.nl API not enabled.","Postcode.nl API niet ingeschakeld."
17
+ "- disabled -","- uitgeschakeld -"
18
+ "Validation","Validatie"
19
+ "Fill out your postcode and housenumber to auto-complete your address. You can also manually set your address information.","Vul uw postcode en huisnummer in en uw adres wordt automatisch en foutloos aangevuld. Handmatig invullen kan natuurlijk ook."
20
+ "Manual input","Handmatige invoer"
21
+ "Fill out address information manually","Handmatig adres invullen"
22
+ "Validated address","Gevalideerd adres"
js/postcodenl/api/lookup.js CHANGED
@@ -1,410 +1,689 @@
1
- document.observe("dom:loaded", function() {
 
 
2
  if (typeof PCNLAPI_CONFIG == 'undefined')
3
  return;
4
 
5
- function lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, event)
6
  {
7
- if (!$(prefix + 'postcode_housenumber'))
8
  {
9
- return;
10
  }
 
11
 
12
- var postcode = $(prefix + 'postcode_input').getValue().replace(/\s+/, '');
13
- var housenumber_mixed = $(prefix + 'postcode_housenumber').getValue().trim();
14
- // Number, followed by non alphanumberic chars, and then additional number ("123 A", "123-rood", etc)
15
- // or: Number, followed directly by a letter and then alphanumeric/space charcters ("123b3", "123berk 23", etc)
16
- var housenumber_match = housenumber_mixed.match(/^([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]*)))?$/);
17
- var housenumber_addition_select = $(prefix +'postcode_housenumber_addition') ? $(prefix +'postcode_housenumber_addition').getValue() : null;
18
-
19
- var housenumber = housenumber_match ? housenumber_match[1].trim() : '';
20
-
21
- var housenumber_addition = '';
22
-
23
- if (!housenumber_match)
24
- housenumber_addition = '';
25
- else if (housenumber_match[3])
26
- housenumber_addition = housenumber_match[3].trim();
27
- else if (housenumber_match[4])
28
- housenumber_addition = housenumber_match[4].trim();
29
-
30
- if (housenumber_addition == '' && housenumber_addition_select != '__none__' && housenumber_addition_select != '__select__' && housenumber_addition_select != null)
31
- housenumber_addition = housenumber_addition_select;
32
-
33
- if ($(prefix + countryFieldId).getValue() != 'NL' || postcode == '' || housenumber_mixed == '')
34
- return;
35
-
36
- var url = PCNLAPI_CONFIG.baseUrl +'postcodenl/json/lookup?postcode=' + postcode + '&houseNumber=' + housenumber + '&houseNumberAddition=' + housenumber_addition;
37
- new Ajax.Request(url, {
38
- method: 'get',
39
- onComplete: function(transport) {
40
- var json = transport.responseText.evalJSON();
41
-
42
- if (PCNLAPI_CONFIG.showcase)
43
  {
44
- if ($(prefix +'showcase'))
45
- $(prefix +'showcase').remove();
46
-
47
- var info = '';
48
- for (var prop in json.showcaseResponse)
49
  {
50
- var name = prop.charAt(0).toUpperCase() + prop.slice(1);
51
- info += '<dt>'+ name.escapeHTML() +'</dt><dd>'+ String(json.showcaseResponse[prop] === null ? '- none -' : json.showcaseResponse[prop]).escapeHTML() +'</dd>';
52
  }
53
-
54
- var map = '';
55
- if (json.showcaseResponse.longitude && json.showcaseResponse.latitude)
56
  {
57
- map = '<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" class="map" src="http://maps.google.com/maps?t=h&amp;q='+ json.showcaseResponse.latitude +','+ json.showcaseResponse.longitude +'+(Location found)&amp;z=19&amp;output=embed&amp;iwloc=near"></iframe>';
58
  }
 
 
 
59
 
60
- if ($(prefix + countryFieldId).parentNode.tagName == 'TD')
 
 
 
 
 
 
 
 
 
61
  {
62
- // We're probably in the admin
63
- $(prefix + street1).parentNode.parentNode.parentNode.insert({before: '<tr id="' + prefix + 'showcase"><td class="label">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</label></td><td class="value"><h4 class="showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase +'</h4><dl class="showcase">'+ info + '</dl></td></tr>'});
64
  }
65
- else
66
  {
67
- $(prefix + street1).up('li').insert({before: '<li id="' + prefix +'showcase" class="wide"><div class="input-box"><h4 class="showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4><dl class="showcase">'+ info + map + '</dl></div></li>'});
68
  }
69
  }
 
 
70
 
71
- var advice = Validation.getAdvice('invalid-postcode', $(prefix +'postcode_housenumber'));
72
- if (advice) {
73
- Validation.hideAdvice($(prefix +'postcode_housenumber'), advice, 'invalid-postcode');
74
- }
75
- var advice = Validation.getAdvice('invalid-postcode', $(prefix +'postcode_input'));
76
- if (advice) {
77
- Validation.hideAdvice($(prefix +'postcode_input'), advice, 'invalid-postcode');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
 
 
79
 
80
- if ($(prefix +'postcode_housenumber_addition'))
 
 
 
 
 
 
 
 
81
  {
82
- var additionAdvice = Validation.getAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'));
83
- if (additionAdvice) {
84
- Validation.hideAdvice($(prefix +'postcode_housenumber_addition'), additionAdvice, 'invalid-addition');
85
- }
86
  }
87
- if (json.postcode != undefined)
88
  {
89
- $(prefix + postcodeFieldId).setValue(json.postcode);
90
- $(prefix + 'postcode_input').setValue(json.postcode);
91
- if (PCNLAPI_CONFIG.useStreet2AsHouseNumber)
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  {
93
- $(prefix + street1).setValue((json.street).trim());
94
- $(prefix + street2).setValue((json.houseNumber +' '+ (json.houseNumberAddition ? json.houseNumberAddition : housenumber_addition)).trim());
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
96
  else
97
  {
98
- $(prefix + street1).setValue((json.street +' '+ json.houseNumber +' '+ (json.houseNumberAddition ? json.houseNumberAddition : housenumber_addition)).trim());
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
- $(prefix +'city').setValue(json.city);
102
- $(prefix +'region').setValue(json.province);
103
 
104
- if (json.houseNumberAddition == null && (housenumber_addition_select == housenumber_addition || (housenumber_addition_select == '__none__' && housenumber_addition == '')))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  {
106
- $(prefix +'postcode_housenumber').setValue(json.houseNumber);
 
107
 
108
- var additionSelect = createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, json.houseNumberAdditions, housenumber_addition_select);
109
- if (event && event.element().id == prefix +'postcode_housenumber_addition')
110
- additionSelect.setValue(housenumber_addition_select);
111
- if (additionSelect.getValue() != housenumber_addition_select)
112
  {
113
- newAdvice = Validation.createAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'), false, (housenumber_addition != '' ? PCNLAPI_CONFIG.translations.houseNumberAdditionUnknown.replace('{addition}', housenumber_addition) : PCNLAPI_CONFIG.translations.houseNumberAdditionRequired));
114
- Validation.showAdvice($(prefix +'postcode_housenumber_addition'), newAdvice, 'invalid-addition');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
  }
117
- else if (json.houseNumberAddition == null)
 
 
 
 
118
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  $(prefix +'postcode_housenumber').setValue(json.houseNumber);
120
 
121
- var additionSelect = createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, json.houseNumberAdditions, housenumber_addition);
 
 
 
 
 
122
 
123
- newAdvice = Validation.createAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'), false, (housenumber_addition != '' ? PCNLAPI_CONFIG.translations.houseNumberAdditionUnknown.replace('{addition}', housenumber_addition) : PCNLAPI_CONFIG.translations.houseNumberAdditionRequired));
124
- Validation.showAdvice($(prefix +'postcode_housenumber_addition'), newAdvice, 'invalid-addition');
125
- }
126
- else
127
- {
128
- if (json.houseNumberAdditions.length > 1)
129
  {
130
- var additionSelect = createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, json.houseNumberAdditions);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  additionSelect.setValue(json.houseNumberAddition);
132
- $(prefix +'postcode_housenumber').setValue(json.houseNumber);
133
  }
134
- else if ($(prefix +'postcode_housenumber_addition'))
135
  {
136
- $(prefix +'postcode_housenumber').setValue((json.houseNumber +' '+ json.houseNumberAddition).trim());
137
- Element.remove($(prefix +'postcode_housenumber_addition'));
138
  }
139
  }
140
- }
141
- else if (json.message != undefined)
142
- {
143
- newAdvice = Validation.createAdvice('invalid-postcode', $(prefix + (json.messageTarget == 'postcode' ? 'postcode_input' : 'postcode_housenumber')), false, json.message);
144
- Validation.showAdvice($(prefix +'postcode_housenumber'), newAdvice, 'invalid-postcode');
145
 
146
- if ($(prefix +'postcode_housenumber_addition'))
147
- Element.remove($(prefix +'postcode_housenumber_addition'));
148
- }
149
- else
150
- {
151
- newAdvice = Validation.createAdvice('invalid-postcode', $(prefix + (json.messageTarget == 'postcode' ? 'postcode_input' : 'postcode_housenumber')), false, '');
152
- Validation.showAdvice($(prefix +'postcode_housenumber'), newAdvice, 'invalid-postcode');
153
 
154
- if ($(prefix +'postcode_housenumber_addition'))
155
- Element.remove($(prefix +'postcode_housenumber_addition'));
156
- }
 
 
157
 
158
- $(prefix + postcodeFieldId).fire('postcode:updated');
159
- }
160
- });
161
- };
 
162
 
163
- function toggleCountryPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2) {
164
- if (!$(prefix + countryFieldId))
165
- alert(prefix + countryFieldId);
166
- if ($(prefix + countryFieldId).getValue() == 'NL')
 
 
 
 
 
167
  {
168
- var street2element = $(prefix + street2);
169
- if (street2element)
170
  {
171
- $(street2element).setAttribute('readonly', true);
172
- $(street2element).addClassName('readonly');
173
- $(street2element).removeClassName('required-entry');
174
- }
175
 
176
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('setAttribute', 'readonly', true);
177
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('addClassName', 'readonly');
178
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('removeClassName', 'required-entry');
179
- if (!$(prefix +'postcode_input:wrapper'))
180
- {
181
- if ($(prefix + postcodeFieldId).parentNode.tagName == 'TD')
182
  {
183
- // We're probably in the admin
184
- $($(prefix + street1).parentNode.parentNode.parentNode).insert({before: '<tr id="' + prefix + 'postcode_input:wrapper"><td class="label"><label for="' + prefix + 'postcode_input">'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +' <span class="required">*</span></label></td><td class="value"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></div></td></tr><tr id="' + prefix + 'postcode_housenumber:wrapper"><td class="label"><label for="' + prefix + 'postcode_housenumber">'+ PCNLAPI_CONFIG.translations.houseNumberLabel +' <span class="required">*</span></label></td><td class="value"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text input-text-half required-entry" /></div></td></tr>'});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
  else
187
  {
188
- $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:wrapper" class="fields"><div class="field"><label for="' + prefix + 'postcode_input" class="required"><em>*</em>'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +'</label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></div></div><div class="field"><label for="' + prefix + 'postcode_housenumber" class="required"><em>*</em>'+ PCNLAPI_CONFIG.translations.houseNumberLabel +'</label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text input-text-half required-entry" /></div></div></li>'});
189
  }
190
 
191
- $(prefix +'postcode_input').observe('change', function(e) { lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, e); });
192
- $(prefix +'postcode_housenumber').observe('change', function(e) { lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, e); });
193
- }
194
- else
195
- {
196
- $(prefix +'postcode_input:wrapper').show();
197
- if ($(prefix +'postcode_housenumber_addition'))
198
- $(prefix +'postcode_housenumber_addition').show();
199
- }
200
-
201
- if ($(prefix + postcodeFieldId).getValue() != '' && $(prefix +'postcode_input').getValue() == '')
202
- {
203
- $(prefix +'postcode_input').setValue($(prefix + postcodeFieldId).getValue());
204
-
205
- var housenumber_match;
206
- if (PCNLAPI_CONFIG.useStreet2AsHouseNumber)
207
  {
208
- housenumber_match = $(prefix + street2).getValue().match(/([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]+)))?$/);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  }
210
  else
211
  {
212
- housenumber_match = $(prefix + street1).getValue().match(/([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]+)))?$/);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  }
214
 
215
- var housenumber = housenumber_match ? housenumber_match[1].trim() : '';
 
216
 
217
- var housenumber_addition = '';
 
 
 
218
 
219
- if (!housenumber_match)
220
- housenumber_addition = '';
221
- else if (housenumber_match[3])
222
- housenumber_addition = housenumber_match[3].trim();
223
- else if (housenumber_match[4])
224
- housenumber_addition = housenumber_match[4].trim();
 
 
 
 
 
 
 
225
 
226
- $(prefix +'postcode_housenumber').setValue(housenumber +' '+ housenumber_addition);
227
- lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2);
 
 
 
 
 
 
 
 
228
  }
229
- }
230
- else
231
- {
232
- var street2element = $(prefix + street2);
233
- if (street2element)
234
  {
235
- $(street2element).removeAttribute('readonly');
236
- $(street2element).removeClassName('readonly');
237
- $(street2element).addClassName('required-entry');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
 
239
 
240
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('removeAttribute', 'readonly');
241
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('removeClassName', 'readonly');
242
- $(prefix +'city', prefix +'region', prefix + postcodeFieldId, prefix + street1).invoke('addClassName', 'required-entry');
243
- Element.remove($(prefix +'postcode_input:wrapper'));
244
- if ($(prefix +'postcode_housenumber:wrapper'))
245
- Element.remove($(prefix +'postcode_housenumber:wrapper'));
246
- if ($(prefix +'showcase'))
247
- Element.remove($(prefix +'showcase'));
248
  if ($(prefix +'postcode_housenumber_addition:wrapper'))
249
  Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
250
- else if ($(prefix +'postcode_housenumber_addition'))
251
  Element.remove($(prefix +'postcode_housenumber_addition'));
252
- }
253
- }
254
 
255
- function createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, values, custom) {
256
- if ($(prefix +'postcode_housenumber_addition:wrapper'))
257
- Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
258
- if ($(prefix +'postcode_housenumber_addition'))
259
- Element.remove($(prefix +'postcode_housenumber_addition'));
260
-
261
- var options = '';
262
- if (custom != null)
263
- {
264
- if (custom == '')
265
- custom = '__none__';
266
-
267
- options += '<option value="__select__">'+ PCNLAPI_CONFIG.translations.selectAddition +'</option>';
268
- options += '<option value="'+ custom.escapeHTML() +'">'+ (custom == '__none__' ? PCNLAPI_CONFIG.translations.noAdditionSelectCustom : PCNLAPI_CONFIG.translations.additionSelectCustom.replace('{addition}', custom.escapeHTML())) +'</option>';
269
- }
270
- else if (values.indexOf('') == -1)
271
- {
272
- options += '<option value="__none__">'+ PCNLAPI_CONFIG.translations.noAdditionSelectCustom.escapeHTML() +'</option>';
273
- }
274
 
275
- values.each(function(value) {
276
- options += '<option value="'+ value.escapeHTML() +'">'+ (value == '' ? PCNLAPI_CONFIG.translations.noAdditionSelect : value ).escapeHTML() +'</option>';
277
- });
 
 
 
 
278
 
279
- if ($(prefix + countryFieldId).parentNode.tagName == 'TD')
280
- {
281
- // We're probably in the admin
282
- $(prefix + 'postcode_housenumber').parentNode.parentNode.insert({after: '<tr id="' + prefix +'postcode_housenumber_addition:wrapper"><td class="label"><label for="'+ prefix +'postcode_housenumber_addition">'+ PCNLAPI_CONFIG.translations.houseNumberAdditionLabel +' <span class="required">*</span></label></td><td class="value"><select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="select">'+ options +'</select></td></tr>'});
283
- }
284
- else
285
- {
286
- // We're probably in the frontend
287
- $(prefix + 'postcode_housenumber').insert({after: '<select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="validate-select input-text-half">'+ options +'</select>'});
288
- }
289
 
290
- $(prefix +'postcode_housenumber_addition').observe('change', function(e) { lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, e); });
 
 
 
 
 
 
 
 
 
 
291
 
292
- return $(prefix +'postcode_housenumber_addition');
293
- }
294
 
 
 
295
 
296
- // Checkout page
297
- if ($('billing:postcode'))
298
- {
299
- $('billing:country_id').observe('change', function () {toggleCountryPostcode('billing:', 'postcode', 'country_id', 'street1', 'street2');});
300
- $('shipping:country_id').observe('change', function () {toggleCountryPostcode('shipping:', 'postcode', 'country_id', 'street1', 'street2');});
 
 
 
 
 
 
301
 
302
- if ($('billing:country_id').getValue() == 'NL')
303
- toggleCountryPostcode('billing:', 'postcode', 'country_id', 'street1', 'street2');
304
- if ($('shipping:country_id').getValue() == 'NL')
305
- toggleCountryPostcode('shipping:', 'postcode', 'country_id', 'street1', 'street2');
306
- }
307
 
308
- // Misc. account address edits
309
- if ($('zip') && $('street_1'))
310
- {
311
- $('zip').observe('change', function(e) {
312
- lookupPostcode('', 'zip', 'country', 'street_1', 'street_2', e);
313
- });
 
314
 
315
- $('country').observe('change', function () {toggleCountryPostcode('', 'zip', 'country', 'street_1', 'street_2');});
316
 
317
- if ($('country').getValue() == 'NL')
318
- toggleCountryPostcode('', 'zip', 'country', 'street_1', 'street_2');
319
- }
320
 
321
- // Default admin address edits
322
- if ($('postcode') && $('street0'))
323
- {
324
- $('postcode').observe('change', function(e) {
325
- lookupPostcode('', 'postcode', 'country_id', 'street0', 'street1', e);
326
- });
 
327
 
328
- $('country_id').observe('change', function () {toggleCountryPostcode('', 'postcode', 'country_id', 'street0', 'street1');});
329
 
330
- if ($('country_id').getValue() == 'NL')
331
- toggleCountryPostcode('', 'postcode', 'country_id', 'street0', 'street1');
332
- }
333
 
334
- // User admin address edits
335
- if ($('address_form_container'))
336
- {
337
- function observeAdminCustomerAddress()
338
- {
339
- var nr = 1;
340
- while ($('_item'+ nr +'postcode'))
341
  {
342
- $('_item'+ nr +'postcode').observe('change', function(e) {
343
- var localNr = nr;
344
- return function () { lookupPostcode('_item'+ localNr, 'postcode', 'country_id', 'street0', 'street1', e);}
345
- }());
346
 
347
- $('_item'+ nr +'country_id').observe('change', function(e) {
348
- var localNr = nr;
349
- return function () { toggleCountryPostcode('_item'+ localNr, 'postcode', 'country_id', 'street0', 'street1');}
350
- }());
351
 
352
- if ($('_item'+ nr +'country_id').getValue() == 'NL')
353
- toggleCountryPostcode('_item'+ nr, 'postcode', 'country_id', 'street0', 'street1');
 
 
 
354
 
355
- nr++;
 
 
356
  }
357
- }
358
-
359
- observeAdminCustomerAddress();
 
 
 
 
 
 
 
 
 
 
360
 
361
- $('address_form_container').observe('DOMNodeInserted', function(e) { observeAdminCustomerAddress(); });
362
- }
 
 
 
363
 
 
364
 
365
- // Admin 'create order' & 'edit order' address editting
366
- if ($('order-billing_address'))
367
- {
368
- function observeBillingAddress()
 
 
369
  {
 
370
  // Billing
371
  if ($('order-billing_address_postcode'))
372
  {
373
- $('order-billing_address_postcode').observe('change', function(e) {
374
- lookupPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1', e);
 
375
  });
376
- $('order-billing_address_country_id').observe('change', function () {
377
- toggleCountryPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1');
 
378
  });
379
  if ($('order-billing_address_country_id').getValue() == 'NL')
380
- toggleCountryPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1');
381
- $('order-billing_address_postcode').observe('postcode:updated', function(e) {
 
382
  // Custom poke Magento billing-to-shipping copy order logic.
383
- var event = { type: e.type, currentTarget: $('order-billing_address_street0'), target: $('order-billing_address_street0')};
 
 
 
 
384
  order.changeAddressField(event);
385
  });
386
  }
387
- }
388
-
389
- function observeShippingAddress()
390
  {
 
391
  // Shipping
392
  if (!$('order-shipping_same_as_billing').checked)
393
  {
394
- $('order-shipping_address_postcode').observe('change', function(e) {
395
- lookupPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1', e);
 
396
  });
397
- $('order-shipping_address_country_id').observe('change', function () {toggleCountryPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1');});
398
  if ($('order-shipping_address_country_id').getValue() == 'NL')
399
- toggleCountryPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1');
400
  }
401
  }
 
402
 
403
- observeBillingAddress();
404
- observeShippingAddress();
405
-
406
- // Re-observe blocks after they have been changed
407
- $('order-billing_address').observe('DOMNodeInserted', function(e) { observeBillingAddress(); });
408
- $('order-shipping_address').observe('DOMNodeInserted', function(e) { observeShippingAddress(); });
409
- }
410
  });
1
+ document.observe("dom:loaded", function()
2
+ {
3
+ // If we have no configuration, do not do anything
4
  if (typeof PCNLAPI_CONFIG == 'undefined')
5
  return;
6
 
7
+ if (typeof String.prototype.trim !== 'function')
8
  {
9
+ String.prototype.trim = function()
10
  {
11
+ return this.replace(/^\s+|\s+$/g, '');
12
  }
13
+ }
14
 
15
+ var PostcodeNl_Api = {
16
+ /**
17
+ * Hide multiple field-rows in forms
18
+ */
19
+ hideFields: function (fields)
20
+ {
21
+ fields.each(function (fieldId)
22
+ {
23
+ if ($(fieldId))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  {
25
+ if ($(fieldId).up('li'))
 
 
 
 
26
  {
27
+ $(fieldId).up('li').addClassName('pcnl-hidden-field');
 
28
  }
29
+ else if ($(fieldId).up('tr'))
 
 
30
  {
31
+ $(fieldId).up('tr').addClassName('pcnl-hidden-field');
32
  }
33
+ }
34
+ });
35
+ },
36
 
37
+ /**
38
+ * Un-hide multiple field-rows in forms
39
+ */
40
+ showFields: function (fields)
41
+ {
42
+ fields.each(function (fieldId)
43
+ {
44
+ if ($(fieldId))
45
+ {
46
+ if ($(fieldId).up('li'))
47
  {
48
+ $(fieldId).up('li').removeClassName('pcnl-hidden-field');
 
49
  }
50
+ else if ($(fieldId).up('tr'))
51
  {
52
+ $(fieldId).up('tr').removeClassName('pcnl-hidden-field');
53
  }
54
  }
55
+ });
56
+ },
57
 
58
+ /**
59
+ * Remove all validation messages
60
+ */
61
+ removeValidationMessages: function (prefix)
62
+ {
63
+ var advice = Validation.getAdvice('invalid-postcode', $(prefix +'postcode_housenumber'));
64
+ if (advice)
65
+ {
66
+ Validation.hideAdvice($(prefix +'postcode_housenumber'), advice, 'invalid-postcode');
67
+ }
68
+ var advice = Validation.getAdvice('invalid-postcode', $(prefix +'postcode_input'));
69
+ if (advice)
70
+ {
71
+ Validation.hideAdvice($(prefix +'postcode_input'), advice, 'invalid-postcode');
72
+ }
73
+ if ($(prefix +'postcode_housenumber_addition'))
74
+ {
75
+ var additionAdvice = Validation.getAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'));
76
+ if (additionAdvice)
77
+ {
78
+ Validation.hideAdvice($(prefix +'postcode_housenumber_addition'), additionAdvice, 'invalid-addition');
79
  }
80
+ }
81
+ },
82
 
83
+ /**
84
+ * Remove housenumber addition selectbox, and any related elements / classes.
85
+ */
86
+ removeHousenumberAddition: function (prefix)
87
+ {
88
+ if ($(prefix +'postcode_housenumber_addition'))
89
+ {
90
+ Element.remove($(prefix +'postcode_housenumber_addition'));
91
+ if ($(prefix +'postcode_housenumber_addition:wrapper'))
92
  {
93
+ Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
 
 
 
94
  }
95
+ if ($(prefix + 'postcode_housenumber').up('li'))
96
  {
97
+ $(prefix + 'postcode_housenumber').up('li').removeClassName('pcnl-with-addition');
98
+ }
99
+ }
100
+ },
101
+
102
+
103
+ /**
104
+ * Toggle 'readonly' on multiple fields. Sets class, attribute.
105
+ */
106
+ setFieldsReadonly: function (fields, readonly)
107
+ {
108
+ fields.each(function (fieldId)
109
+ {
110
+ if ($(fieldId))
111
+ {
112
+ if (readonly)
113
  {
114
+ if ($(fieldId).nodeName == 'SELECT')
115
+ {
116
+ $(fieldId).disabled = true;
117
+ }
118
+ else
119
+ {
120
+ $(fieldId).setAttribute('readonly', true);
121
+ }
122
+ $(fieldId).addClassName('pcnl-readonly');
123
+ if ($(fieldId).hasClassName('required-entry'))
124
+ {
125
+ $(fieldId).removeClassName('required-entry');
126
+ $(fieldId).addClassName('pcnl-disabled-required-entry');
127
+ }
128
  }
129
  else
130
  {
131
+ if ($(fieldId).nodeName == 'SELECT')
132
+ {
133
+ $(fieldId).disabled = false;
134
+ }
135
+ else
136
+ {
137
+ $(fieldId).removeAttribute('readonly');
138
+ }
139
+ $(fieldId).removeClassName('pcnl-readonly');
140
+ if ($(fieldId).hasClassName('pcnl-disabled-required-entry'))
141
+ {
142
+ $(fieldId).addClassName('required-entry');
143
+ $(fieldId).removeClassName('pcnl-disabled-required-entry');
144
+ }
145
  }
146
+ }
147
+ });
148
+ },
149
+
150
+ /**
151
+ * Look up the address for a form, validate & enrich target form.
152
+ */
153
+ lookupPostcode: function (prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, event)
154
+ {
155
+ var pcnlapi = this;
156
+ if (!$(prefix + 'postcode_housenumber'))
157
+ {
158
+ return;
159
+ }
160
+
161
+ var postcode = $(prefix + 'postcode_input').getValue();
162
+
163
+ postcode = postcode.replace(/\s+/, '');
164
+
165
+ var housenumber_mixed = $(prefix + 'postcode_housenumber').getValue().trim();
166
+ // Number, followed by non alphanumberic chars, and then additional number ("123 A", "123-rood", etc)
167
+ // or: Number, followed directly by a letter and then alphanumeric/space charcters ("123b3", "123berk 23", etc)
168
+ var housenumber_match = housenumber_mixed.match(/^([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]*)))?$/);
169
+ var housenumber_addition_select = $(prefix +'postcode_housenumber_addition') ? $(prefix +'postcode_housenumber_addition').getValue() : null;
170
 
171
+ var housenumber = housenumber_match ? housenumber_match[1].trim() : '';
 
172
 
173
+ var housenumber_addition = '';
174
+
175
+ if (!housenumber_match)
176
+ housenumber_addition = '';
177
+ else if (housenumber_match[3])
178
+ housenumber_addition = housenumber_match[3].trim();
179
+ else if (housenumber_match[4])
180
+ housenumber_addition = housenumber_match[4].trim();
181
+
182
+ if (housenumber_addition == '' && housenumber_addition_select != '__none__' && housenumber_addition_select != '__select__' && housenumber_addition_select != null)
183
+ housenumber_addition = housenumber_addition_select;
184
+
185
+ if ($(prefix + countryFieldId).getValue() != 'NL' || postcode == '' || housenumber_mixed == '')
186
+ return;
187
+
188
+ var url = PCNLAPI_CONFIG.baseUrl +'postcodenl/json/lookup?postcode=' + postcode + '&houseNumber=' + housenumber + '&houseNumberAddition=' + housenumber_addition;
189
+ new Ajax.Request(url,
190
+ {
191
+ method: 'get',
192
+ onComplete: function(transport)
193
+ {
194
+ var json = transport.responseText.evalJSON();
195
+
196
+ if (PCNLAPI_CONFIG.showcase)
197
  {
198
+ if ($(prefix +'showcase'))
199
+ $(prefix +'showcase').remove();
200
 
201
+ var info = '';
202
+ for (var prop in json.showcaseResponse)
 
 
203
  {
204
+ var name = prop.charAt(0).toUpperCase() + prop.slice(1);
205
+ info += '<dt>'+ name.escapeHTML() +'</dt><dd>'+ String(json.showcaseResponse[prop] === null ? '- none -' : json.showcaseResponse[prop]).escapeHTML() +'</dd>';
206
+ }
207
+
208
+ var map = '';
209
+ if (json.showcaseResponse.longitude && json.showcaseResponse.latitude)
210
+ {
211
+ map = '<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" class="map" src="http://maps.google.com/maps?t=h&amp;q='+ json.showcaseResponse.latitude +','+ json.showcaseResponse.longitude +'+(Location found)&amp;z=19&amp;output=embed&amp;iwloc=near"></iframe>';
212
+ }
213
+
214
+ if ($(prefix + countryFieldId).parentNode.tagName == 'TD')
215
+ {
216
+ // We're probably in the admin
217
+ $(prefix + street1).up('tr').insert({before: '<tr id="' + prefix + 'showcase"><td class="label">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</label></td><td class="value"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase +'</h4><dl class="pcnl-showcase">'+ info + '</dl></td></tr>'});
218
+ }
219
+ else
220
+ {
221
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix +'showcase" class="wide"><div class="input-box"><h4 class="pcnl-showcase">'+ PCNLAPI_CONFIG.translations.apiShowcase.escapeHTML() +'</h4><dl class="pcnl-showcase">'+ map + info + '</dl></div></li>'});
222
  }
223
  }
224
+
225
+ // Remove any existing error messages
226
+ pcnlapi.removeValidationMessages(prefix);
227
+
228
+ if (json.postcode != undefined)
229
  {
230
+ // Set data from request on form fields
231
+ $(prefix + postcodeFieldId).setValue(json.postcode);
232
+ $(prefix + 'postcode_input').setValue(json.postcode);
233
+ if (PCNLAPI_CONFIG.useStreet2AsHouseNumber && $(prefix + street2))
234
+ {
235
+ $(prefix + street1).setValue((json.street).trim());
236
+ $(prefix + street2).setValue((json.houseNumber +' '+ (json.houseNumberAddition ? json.houseNumberAddition : housenumber_addition)).trim());
237
+ }
238
+ else
239
+ {
240
+ $(prefix + street1).setValue((json.street +' '+ json.houseNumber +' '+ (json.houseNumberAddition ? json.houseNumberAddition : housenumber_addition)).trim());
241
+ }
242
+ $(prefix +'city').setValue(json.city);
243
+ $(prefix +'region').setValue(json.province);
244
  $(prefix +'postcode_housenumber').setValue(json.houseNumber);
245
 
246
+ // Update address result text block
247
+ if ($(prefix + 'postcode_output'))
248
+ {
249
+ pcnlapi.showFields([prefix +'postcode_output']);
250
+ $(prefix + 'postcode_output').update((json.street +' '+ json.houseNumber +' '+ (json.houseNumberAddition ? json.houseNumberAddition : housenumber_addition)).trim() + "<br>" + json.postcode + " " + json.city);
251
+ }
252
 
253
+ // Handle all housenumber addition possiblities
254
+ if (json.houseNumberAddition == null && (housenumber_addition_select == housenumber_addition || (housenumber_addition_select == '__none__' && housenumber_addition == '')))
 
 
 
 
255
  {
256
+ // Selected housenumber addition is not known, and the select dropdown already contains that value
257
+
258
+ var additionSelect = pcnlapi.createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, json.houseNumberAdditions, housenumber_addition_select);
259
+
260
+ // Re-select value if it was selected through the selectbox
261
+ if (event && event.element().id == prefix +'postcode_housenumber_addition')
262
+ additionSelect.setValue(housenumber_addition_select);
263
+
264
+ if (additionSelect.getValue() != housenumber_addition_select)
265
+ {
266
+ newAdvice = Validation.createAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'), false, (housenumber_addition != '' ? PCNLAPI_CONFIG.translations.houseNumberAdditionUnknown.replace('{addition}', housenumber_addition) : PCNLAPI_CONFIG.translations.houseNumberAdditionRequired));
267
+ Validation.showAdvice($(prefix +'postcode_housenumber_addition'), newAdvice, 'invalid-addition');
268
+ }
269
+ }
270
+ else if (json.houseNumberAddition == null)
271
+ {
272
+ // Selected housenumber addition is not known, and the select dropdown does not contain that value
273
+
274
+ var additionSelect = pcnlapi.createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, json.houseNumberAdditions, housenumber_addition);
275
+
276
+ newAdvice = Validation.createAdvice('invalid-addition', $(prefix +'postcode_housenumber_addition'), false, (housenumber_addition != '' ? PCNLAPI_CONFIG.translations.houseNumberAdditionUnknown.replace('{addition}', housenumber_addition) : PCNLAPI_CONFIG.translations.houseNumberAdditionRequired));
277
+ Validation.showAdvice($(prefix +'postcode_housenumber_addition'), newAdvice, 'invalid-addition');
278
+ }
279
+ else if (json.houseNumberAdditions.length > 1 || (json.houseNumberAdditions.length == 1 && json.houseNumberAdditions[0] != ''))
280
+ {
281
+ // Address has multiple housenumber additions
282
+ var additionSelect = pcnlapi.createPostcodeHouseNumberAddition(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, json.houseNumberAdditions);
283
  additionSelect.setValue(json.houseNumberAddition);
 
284
  }
285
+ else
286
  {
287
+ // Address has only one valid addition, and it is the 'no addition' option
288
+ pcnlapi.removeHousenumberAddition(prefix);
289
  }
290
  }
291
+ else if (json.message != undefined)
292
+ {
293
+ // Address check returned an error
 
 
294
 
295
+ newAdvice = Validation.createAdvice('invalid-postcode', $(prefix + (json.messageTarget == 'postcode' ? 'postcode_input' : 'postcode_housenumber')), false, json.message);
296
+ Validation.showAdvice($(prefix +'postcode_housenumber'), newAdvice, 'invalid-postcode');
 
 
 
 
 
297
 
298
+ pcnlapi.removeHousenumberAddition(prefix);
299
+ }
300
+ else
301
+ {
302
+ // Address check did not return an error or a postcode result (something else wrong)
303
 
304
+ newAdvice = Validation.createAdvice('invalid-postcode', $(prefix + (json.messageTarget == 'postcode' ? 'postcode_input' : 'postcode_housenumber')), false, '');
305
+ Validation.showAdvice($(prefix +'postcode_housenumber'), newAdvice, 'invalid-postcode');
306
+
307
+ pcnlapi.removeHousenumberAddition(prefix);
308
+ }
309
 
310
+ $(prefix + postcodeFieldId).fire('postcode:updated');
311
+ }
312
+ });
313
+ },
314
+
315
+ /**
316
+ * Toggle country selection for a form. Only when the Netherlands is selected, add address enrichment.
317
+ */
318
+ toggleCountryPostcode: function (prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4)
319
  {
320
+ var pcnlapi = this;
321
+ if ($(prefix + countryFieldId).getValue() == 'NL')
322
  {
323
+ // The Netherlands is selected - add our own validated inputs.
 
 
 
324
 
325
+ if (!$(prefix +'postcode_input:wrapper'))
 
 
 
 
 
326
  {
327
+ if ($(prefix + postcodeFieldId).parentNode.tagName == 'TD')
328
+ {
329
+ // We're probably in the admin
330
+ if (PCNLAPI_CONFIG.adminValidationDisabled)
331
+ {
332
+ return;
333
+ }
334
+
335
+ $(prefix + street1).up('tr').insert({before: '<tr id="' + prefix + 'postcode_input:wrapper"><td class="label"><label for="' + prefix + 'postcode_input">'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +' <span class="required">*</span></label></td><td class="value"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></td></tr><tr id="' + prefix + 'postcode_housenumber:wrapper"><td class="label"><label for="' + prefix + 'postcode_housenumber">'+ PCNLAPI_CONFIG.translations.houseNumberLabel +' <span class="required">*</span></label></td><td class="value"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text pcnl-input-text-half required-entry" /></td></tr>'});
336
+ $(prefix + street1).up('tr').insert({before: '<tr id="' + prefix + 'postcode_input:checkbox"><td class="label"><label for="' + prefix + 'postcode_input_checkbox"> '+ PCNLAPI_CONFIG.translations.manualInputLabel +' <span class="required">*</span></label></td><td class="value"><input type="checkbox" id="' + prefix + 'postcode_input_checkbox" value="" class="checkbox" /><label for="' + prefix + 'postcode_input_checkbox">'+ PCNLAPI_CONFIG.translations.manualInputText +'</label></td></tr>'});
337
+ $(prefix +'postcode_input_checkbox').observe('click', function () { pcnlapi.toggleCountryPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4); });
338
+ }
339
+ else if ($(document.body).hasClassName('onestepcheckout-index-index'))
340
+ {
341
+ // Support for OneStepCheckout extension
342
+
343
+ if (!$(prefix +'postcode_input:info'))
344
+ {
345
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:info" class="clearfix"><div class="input-box"><label class="pcnl-info-label">'+ PCNLAPI_CONFIG.translations.infoLabel +'</label><div class="pcnl-info-text">'+ PCNLAPI_CONFIG.translations.infoText +'</div></div></li>'});
346
+ }
347
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:wrapper" class="clearfix"><div class="field input-postcode"><label for="' + prefix + 'postcode_input" class="required">'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +'<em class="required">*</em></label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></div></div><div class="field input-postcode pcnl-input-housenumber"><label for="' + prefix + 'postcode_housenumber" class="required">'+ PCNLAPI_CONFIG.translations.houseNumberLabel +' <em class="required">*</em></label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text pcnl-input-text-half required-entry" /></div></div></li>'});
348
+ if (!$(prefix +'postcode_input:checkbox'))
349
+ {
350
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:checkbox" class="clearfix"><div class="field"><div class="input-box"><input type="checkbox" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input_checkbox" value="" class="checkbox" /><label for="' + prefix + 'postcode_input_checkbox">'+ PCNLAPI_CONFIG.translations.manualInputText +'</label></div></div></li>'});
351
+ $(prefix +'postcode_input_checkbox').observe('click', function () { pcnlapi.toggleCountryPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4); });
352
+ }
353
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:output" class="pcnl-hidden-field"><div class="input-box"><label>'+ PCNLAPI_CONFIG.translations.outputLabel +'</label><div id="' + prefix + 'postcode_output" class="pcnl-address-text"></div></li>'});
354
+
355
+ }
356
+ else
357
+ {
358
+ // Support for regular Magento 'one page' checkout
359
+
360
+ if (!$(prefix +'postcode_input:info'))
361
+ {
362
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:info" class="wide"><div class="input-box"><label class="pcnl-info-label">'+ PCNLAPI_CONFIG.translations.infoLabel +'</label><div class="pcnl-info-text">'+ PCNLAPI_CONFIG.translations.infoText +'</div></div></li>'});
363
+ }
364
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:wrapper" class="fields"><div class="field"><label for="' + prefix + 'postcode_input" class="required"><em>*</em>'+ PCNLAPI_CONFIG.translations.postcodeInputLabel +'</label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input" value="" class="input-text required-entry" /></div></div><div class="field"><label for="' + prefix + 'postcode_housenumber" class="required"><em>*</em>'+ PCNLAPI_CONFIG.translations.houseNumberLabel +'</label><div class="input-box"><input type="text" title="'+ PCNLAPI_CONFIG.translations.houseNumberTitle +'" name="billing[postcode_housenumber]" id="' + prefix + 'postcode_housenumber" value="" class="input-text pcnl-input-text-half required-entry" /></div></div></li>'});
365
+ if (!$(prefix +'postcode_input:checkbox'))
366
+ {
367
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:checkbox" class="wide"><div class="field"><div class="input-box"><label><input type="checkbox" title="'+ PCNLAPI_CONFIG.translations.postcodeInputTitle +'" id="' + prefix + 'postcode_input_checkbox" value="" class="checkbox" /> '+ PCNLAPI_CONFIG.translations.manualInputText +'</label></div></div></li>'});
368
+ $(prefix +'postcode_input_checkbox').observe('click', function () { pcnlapi.toggleCountryPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4); });
369
+ }
370
+ $(prefix + street1).up('li').insert({before: '<li id="' + prefix + 'postcode_input:output" class="wide pcnl-hidden-field"><div class="input-box"><label>'+ PCNLAPI_CONFIG.translations.outputLabel +'</label><div id="' + prefix + 'postcode_output" class="pcnl-address-text"></div></li>'});
371
+ }
372
+
373
+ $(prefix +'postcode_input').observe('change', function(e) { pcnlapi.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, e); });
374
+ $(prefix +'postcode_housenumber').observe('change', function(e) { pcnlapi.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, e); });
375
  }
376
  else
377
  {
378
+ this.showFields([prefix +'postcode_input', prefix +'postcode_housenumber', prefix +'postcode_housenumber_addition'])
379
  }
380
 
381
+ if (!$(prefix + 'postcode_input_checkbox').checked)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  {
383
+ this.setFieldsReadonly([
384
+ prefix + postcodeFieldId,
385
+ prefix + street1,
386
+ prefix + street2,
387
+ prefix + street3,
388
+ prefix + street4,
389
+ prefix + 'city',
390
+ prefix + 'region',
391
+ ], true);
392
+ this.hideFields([
393
+ prefix + postcodeFieldId,
394
+ prefix + street1,
395
+ prefix + street2,
396
+ prefix + street3,
397
+ prefix + street4,
398
+ prefix + 'city',
399
+ prefix + 'region',
400
+ prefix + countryFieldId,
401
+ ]);
402
+
403
+ // Set empty, will be corrected below
404
+ $(prefix +'postcode_input').value = '';
405
+ $(prefix +'postcode_housenumber').value = '';
406
+ this.setFieldsReadonly([prefix +'postcode_input', prefix + 'postcode_housenumber', prefix + 'postcode_housenumber_addition'], false);
407
+ if ($(prefix +'postcode_output') && $(prefix +'postcode_output').innerHTML != '')
408
+ {
409
+ this.showFields([prefix +'postcode_output']);
410
+ }
411
  }
412
  else
413
  {
414
+ this.removeValidationMessages(prefix);
415
+
416
+ this.setFieldsReadonly([
417
+ prefix + postcodeFieldId,
418
+ prefix + street1,
419
+ prefix + street2,
420
+ prefix + street3,
421
+ prefix + street4,
422
+ prefix + 'city',
423
+ prefix + 'region',
424
+ ], false);
425
+ this.showFields([
426
+ prefix + postcodeFieldId,
427
+ prefix + street1,
428
+ prefix + street2,
429
+ prefix + street3,
430
+ prefix + street4,
431
+ prefix + 'city',
432
+ prefix + 'region',
433
+ prefix + countryFieldId,
434
+ ]);
435
+
436
+ // Disable fields
437
+ $(prefix +'postcode_input').setValue(PCNLAPI_CONFIG.translations.disabledText);
438
+ $(prefix +'postcode_housenumber').setValue(PCNLAPI_CONFIG.translations.disabledText);
439
+ this.setFieldsReadonly([prefix +'postcode_input', prefix + 'postcode_housenumber', prefix + 'postcode_housenumber_addition'], true);
440
+ this.hideFields([prefix +'postcode_output']);
441
  }
442
 
443
+ // We're in NL, checkbox is enabled
444
+ $(prefix + 'postcode_input_checkbox').disabled = false;
445
 
446
+ // Fill postcode validation input with data from manual data fields (postcode + street)
447
+ if ($(prefix + postcodeFieldId).getValue() != '' && $(prefix +'postcode_input').getValue() == '')
448
+ {
449
+ $(prefix +'postcode_input').setValue($(prefix + postcodeFieldId).getValue());
450
 
451
+ var housenumber_match;
452
+ if (PCNLAPI_CONFIG.useStreet2AsHouseNumber && $(prefix + street2))
453
+ {
454
+ housenumber_match = $(prefix + street2).getValue().match(/([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]+)))?$/);
455
+ }
456
+ else
457
+ {
458
+ housenumber_match = $(prefix + street1).getValue().match(/([0-9]+)([^0-9a-zA-Z]+([0-9a-zA-Z ]+)|([a-zA-Z]([0-9a-zA-Z ]+)))?$/);
459
+ }
460
+
461
+ var housenumber = housenumber_match ? housenumber_match[1].trim() : '';
462
+
463
+ var housenumber_addition = '';
464
 
465
+ if (!housenumber_match)
466
+ housenumber_addition = '';
467
+ else if (housenumber_match[3])
468
+ housenumber_addition = housenumber_match[3].trim();
469
+ else if (housenumber_match[4])
470
+ housenumber_addition = housenumber_match[4].trim();
471
+
472
+ $(prefix +'postcode_housenumber').setValue((housenumber +' '+ housenumber_addition).trim());
473
+ this.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4);
474
+ }
475
  }
476
+ else
 
 
 
 
477
  {
478
+ // Address is not in the Netherlands
479
+
480
+ if ($(prefix +'postcode_input_checkbox'))
481
+ {
482
+ $(prefix +'postcode_input_checkbox').checked = true;
483
+ $(prefix +'postcode_input_checkbox').disabled = true;
484
+ }
485
+
486
+ this.setFieldsReadonly([
487
+ prefix +'city',
488
+ prefix +'region',
489
+ prefix + postcodeFieldId,
490
+ prefix + street1,
491
+ prefix + street2,
492
+ prefix + street3,
493
+ prefix + street4,
494
+ ], false);
495
+
496
+ this.setFieldsReadonly([prefix +'postcode_input', prefix +'postcode_housenumber', prefix +'postcode_housenumber_addition'], true);
497
+ this.hideFields([prefix +'postcode_input', prefix +'postcode_housenumber', prefix +'postcode_housenumber_addition']);
498
+
499
+ if ($(prefix +'showcase'))
500
+ Element.remove($(prefix +'showcase'));
501
  }
502
+ },
503
 
504
+ /**
505
+ * (re)Create the postcode housenumber addition dropdown select box.
506
+ */
507
+ createPostcodeHouseNumberAddition: function (prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, values, custom)
508
+ {
509
+ var pcnlapi = this;
 
 
510
  if ($(prefix +'postcode_housenumber_addition:wrapper'))
511
  Element.remove($(prefix +'postcode_housenumber_addition:wrapper'));
512
+ if ($(prefix +'postcode_housenumber_addition'))
513
  Element.remove($(prefix +'postcode_housenumber_addition'));
 
 
514
 
515
+ var options = '';
516
+ if (custom != null)
517
+ {
518
+ if (custom == '')
519
+ custom = '__none__';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
+ options += '<option value="__select__">'+ PCNLAPI_CONFIG.translations.selectAddition +'</option>';
522
+ options += '<option value="'+ custom.escapeHTML() +'">'+ (custom == '__none__' ? PCNLAPI_CONFIG.translations.noAdditionSelectCustom : PCNLAPI_CONFIG.translations.additionSelectCustom.replace('{addition}', custom.escapeHTML())) +'</option>';
523
+ }
524
+ else if (values.indexOf('') == -1)
525
+ {
526
+ options += '<option value="__none__">'+ PCNLAPI_CONFIG.translations.noAdditionSelectCustom.escapeHTML() +'</option>';
527
+ }
528
 
529
+ values.each(function(value)
530
+ {
531
+ options += '<option value="'+ value.escapeHTML() +'">'+ (value == '' ? PCNLAPI_CONFIG.translations.noAdditionSelect : value ).escapeHTML() +'</option>';
532
+ });
 
 
 
 
 
 
533
 
534
+ if ($(prefix + countryFieldId).parentNode.tagName == 'TD')
535
+ {
536
+ // We're probably in the admin
537
+ $(prefix + 'postcode_housenumber').up('tr').insert({after: '<tr id="' + prefix +'postcode_housenumber_addition:wrapper"><td class="label"><label for="'+ prefix +'postcode_housenumber_addition">'+ PCNLAPI_CONFIG.translations.houseNumberAdditionLabel +' <span class="required">*</span></label></td><td class="value"><select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="select">'+ options +'</select></td></tr>'});
538
+ }
539
+ else
540
+ {
541
+ // We're probably in the frontend
542
+ $(prefix + 'postcode_housenumber').insert({after: '<select title="'+ PCNLAPI_CONFIG.translations.houseNumberAdditionTitle +'" name="'+ prefix + 'postcode_housenumber_addition" id="' + prefix + 'postcode_housenumber_addition" class="validate-select pcnl-input-text-half">'+ options +'</select>'});
543
+ $(prefix + 'postcode_housenumber').up('li').addClassName('pcnl-with-addition');
544
+ }
545
 
546
+ $(prefix +'postcode_housenumber_addition').observe('change', function(e) { pcnlapi.lookupPostcode(prefix, postcodeFieldId, countryFieldId, street1, street2, street3, street4, e); });
 
547
 
548
+ return $(prefix +'postcode_housenumber_addition');
549
+ },
550
 
551
+ /**
552
+ * Inspect our current page, see where we are: configure & attach observers to input fields.
553
+ */
554
+ addAddressCheckObservers: function ()
555
+ {
556
+ var pcnlapi = this;
557
+ // Checkout page
558
+ if ($('billing:postcode'))
559
+ {
560
+ $('billing:country_id').observe('change', function () { pcnlapi.toggleCountryPostcode('billing:', 'postcode', 'country_id', 'street1', 'street2', 'street3', 'street4'); });
561
+ $('shipping:country_id').observe('change', function () { pcnlapi.toggleCountryPostcode('shipping:', 'postcode', 'country_id', 'street1', 'street2', 'street3', 'street4'); });
562
 
563
+ if (!$('billing:country_id') || $('billing:country_id').getValue() == 'NL')
564
+ this.toggleCountryPostcode('billing:', 'postcode', 'country_id', 'street1', 'street2', 'street3', 'street4');
565
+ if (!$('shipping:country_id') || $('shipping:country_id').getValue() == 'NL')
566
+ this.toggleCountryPostcode('shipping:', 'postcode', 'country_id', 'street1', 'street2', 'street3', 'street4');
567
+ }
568
 
569
+ // Misc. account address edits
570
+ if ($('zip') && $('street_1'))
571
+ {
572
+ $('zip').observe('change', function(e)
573
+ {
574
+ pcnlapi.lookupPostcode('', 'zip', 'country', 'street_1', 'street_2', 'street_3', 'street_4', e);
575
+ });
576
 
577
+ $('country').observe('change', function () { pcnlapi.toggleCountryPostcode('', 'zip', 'country', 'street_1', 'street_2', 'street_3', 'street_4'); });
578
 
579
+ if ($('country').getValue() == 'NL')
580
+ this.toggleCountryPostcode('', 'zip', 'country', 'street_1', 'street_2', 'street_3', 'street_4');
581
+ }
582
 
583
+ // Default admin address edits
584
+ if ($('postcode') && $('street0'))
585
+ {
586
+ $('postcode').observe('change', function(e)
587
+ {
588
+ pcnlapi.lookupPostcode('', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3', e);
589
+ });
590
 
591
+ $('country_id').observe('change', function () { pcnlapi.toggleCountryPostcode('', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3'); });
592
 
593
+ if ($('country_id').getValue() == 'NL')
594
+ this.toggleCountryPostcode('', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');
595
+ }
596
 
597
+ // User admin address edits
598
+ if ($('address_form_container'))
 
 
 
 
 
599
  {
600
+ this.observeAdminCustomerAddress();
 
 
 
601
 
602
+ $('address_form_container').observe('DOMNodeInserted', function(e) { pcnlapi.observeAdminCustomerAddress(); });
603
+ }
 
 
604
 
605
+ // Admin 'create order' & 'edit order' address editting
606
+ if ($('order-billing_address'))
607
+ {
608
+ this.observeBillingAddress();
609
+ this.observeShippingAddress();
610
 
611
+ // Re-observe blocks after they have been changed
612
+ $('order-billing_address').observe('DOMNodeInserted', function(e) { pcnlapi.observeBillingAddress(); });
613
+ $('order-shipping_address').observe('DOMNodeInserted', function(e) { pcnlapi.observeShippingAddress(); });
614
  }
615
+ },
616
+ observeAdminCustomerAddress: function ()
617
+ {
618
+ var pcnlapi = this;
619
+ for (nr = 1; nr < 15; nr++)
620
+ {
621
+ if ($('_item'+ nr +'postcode') && !$('_item'+ nr +'postcode').observed)
622
+ {
623
+ $('_item'+ nr +'postcode').observe('change', function(e)
624
+ {
625
+ var localNr = nr;
626
+ return function () { pcnlapi.lookupPostcode('_item'+ localNr, 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3', e);}
627
+ }());
628
 
629
+ $('_item'+ nr +'country_id').observe('change', function(e)
630
+ {
631
+ var localNr = nr;
632
+ return function () { pcnlapi.toggleCountryPostcode('_item'+ localNr, 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');}
633
+ }());
634
 
635
+ $('_item'+ nr +'postcode').observed = true;
636
 
637
+ if ($('_item'+ nr +'country_id').getValue() == 'NL')
638
+ this.toggleCountryPostcode('_item'+ nr, 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');
639
+ }
640
+ }
641
+ },
642
+ observeBillingAddress: function ()
643
  {
644
+ var pcnlapi = this;
645
  // Billing
646
  if ($('order-billing_address_postcode'))
647
  {
648
+ $('order-billing_address_postcode').observe('change', function(e)
649
+ {
650
+ pcnlapi.lookupPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3', e);
651
  });
652
+ $('order-billing_address_country_id').observe('change', function ()
653
+ {
654
+ pcnlapi.toggleCountryPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');
655
  });
656
  if ($('order-billing_address_country_id').getValue() == 'NL')
657
+ this.toggleCountryPostcode('order-billing_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');
658
+ $('order-billing_address_postcode').observe('postcode:updated', function(e)
659
+ {
660
  // Custom poke Magento billing-to-shipping copy order logic.
661
+ var event = {
662
+ type: e.type,
663
+ currentTarget: $('order-billing_address_street0'),
664
+ target: $('order-billing_address_street0')
665
+ };
666
  order.changeAddressField(event);
667
  });
668
  }
669
+ },
670
+ observeShippingAddress: function ()
 
671
  {
672
+ var pcnlapi = this;
673
  // Shipping
674
  if (!$('order-shipping_same_as_billing').checked)
675
  {
676
+ $('order-shipping_address_postcode').observe('change', function(e)
677
+ {
678
+ pcnlapi.lookupPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3', e);
679
  });
680
+ $('order-shipping_address_country_id').observe('change', function () { pcnlapi.toggleCountryPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3'); });
681
  if ($('order-shipping_address_country_id').getValue() == 'NL')
682
+ pcnlapi.toggleCountryPostcode('order-shipping_address_', 'postcode', 'country_id', 'street0', 'street1', 'street2', 'street3');
683
  }
684
  }
685
+ };
686
 
687
+ // Add observers to address fields on page
688
+ PostcodeNl_Api.addAddressCheckObservers();
 
 
 
 
 
689
  });
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>PostcodeNl_Api</name>
4
- <version>1.0.2.0</version>
5
  <stability>stable</stability>
6
  <license>Simplified BSD License</license>
7
  <channel>community</channel>
@@ -14,12 +14,12 @@
14
  &#x2022; Offer extra service for your customers with easy address entry&#xD;
15
  &#x2022; Improve sale conversion&#xD;
16
  &#xD;
17
- The postcode Magento plugin from Postcode.nl is free of charge, with a limitation of 10,000 requests per year. The use of the Postcode.nl Magento plugin is subject to our Terms and Conditions.</description>
18
- <notes>Improved compatibility with different checkout address-setups.</notes>
19
  <authors><author><name>Postcode.nl Technical Support</name><user>auto-converted</user><email>tech@postcode.nl</email></author></authors>
20
- <date>2012-09-12</date>
21
- <time>14:32:56</time>
22
- <contents><target name="magecommunity"><dir name="PostcodeNl"><dir name="Api"><dir name="Block"><file name="Jsinit.php" hash="79bb826a50ce0cf4f87cc2f958bfafa1"/></dir><dir name="Helper"><file name="Data.php" hash="86d092299190f0c57ef73e9432278306"/></dir><dir name="controllers"><file name="JsonController.php" hash="08c7624dc4c99c0153d606dc2af49f9f"/></dir><dir name="etc"><file name="config.xml" hash="a1b4244120c47f02084de73488ce68c2"/><file name="system.xml" hash="a9f001a7ecd29056679873229284fa80"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="912aa0881de03e5d7bd338a00e783215"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="8061e808dc71f96026e268d3463728fe"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="606b14bed6481aa253e60c89e75ed9e6"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="31e7380f3954b2cafcfb4f88702b8d7b"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PostcodeNl_Api.csv" hash="d13aab689872c566127cd05fa210f4cd"/></dir><dir name="nl_NL"><file name="PostcodeNl_Api.csv" hash="f61fb87d1954d2321ffbeabb578d078e"/></dir></target><target name="mageweb"><dir name="js"><dir name="postcodenl"><dir name="api"><file name="lookup.js" hash="80f9037e48a7f283af2298a4b4f0d045"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="bfb9ee43739cfec85954b1e810fc996c"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="b3565f5a31fb73b3d8c9d78c3226bdec"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PostcodeNl_Api.xml" hash="feeaf95128ffe4ad109ed8b0b8bc85ab"/></dir></target></contents>
23
  <compatible/>
24
  <dependencies/>
25
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>PostcodeNl_Api</name>
4
+ <version>1.0.3.0</version>
5
  <stability>stable</stability>
6
  <license>Simplified BSD License</license>
7
  <channel>community</channel>
14
  &#x2022; Offer extra service for your customers with easy address entry&#xD;
15
  &#x2022; Improve sale conversion&#xD;
16
  &#xD;
17
+ The postcode Magento plugin from Postcode.nl is free of charge, based on a Fair-Use policy. The use of the Postcode.nl Magento plugin is subject to our Terms and Conditions.</description>
18
+ <notes>- Improved</notes>
19
  <authors><author><name>Postcode.nl Technical Support</name><user>auto-converted</user><email>tech@postcode.nl</email></author></authors>
20
+ <date>2012-10-04</date>
21
+ <time>13:16:32</time>
22
+ <contents><target name="magecommunity"><dir name="PostcodeNl"><dir name="Api"><dir name="Block"><file name="Jsinit.php" hash="79bb826a50ce0cf4f87cc2f958bfafa1"/></dir><dir name="Helper"><file name="Data.php" hash="86d092299190f0c57ef73e9432278306"/></dir><dir name="controllers"><file name="JsonController.php" hash="dad3e355c6afa089f6a34529668b329c"/></dir><dir name="etc"><file name="config.xml" hash="3d825ee34ef943f7cc238d7bbd24eb19"/><file name="system.xml" hash="a9f001a7ecd29056679873229284fa80"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="912aa0881de03e5d7bd338a00e783215"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="6491c9645899b5ef3dacba8ffd7f1907"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><dir name="postcodenl"><dir name="api"><file name="lookup.xml" hash="dd9c9bf60ea350d6db1297cb314ed4e5"/></dir></dir></dir><dir name="template"><dir name="postcodenl"><dir name="api"><file name="jsinit.phtml" hash="6f924e1e5dc0b9c6d2a806fdb56c69ea"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PostcodeNl_Api.csv" hash="5af815dac0885d366044eb2821ca1fe0"/></dir><dir name="nl_NL"><file name="PostcodeNl_Api.csv" hash="bc73ddde82fc9f04614860b55f6384ea"/></dir></target><target name="mageweb"><dir name="js"><dir name="postcodenl"><dir name="api"><file name="lookup.js" hash="816ac665add89c972f7411552c3a72c5"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="187bded4d9ecf658a1d3d2c14e88bdd0"/></dir><dir name="images"><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="postcodenl"><dir name="api"><dir name="css"><file name="lookup.css" hash="ec47a06c962a6e7b95db979c378864e7"/></dir><dir name="images"><file name="postcode-logo-mini.png" hash="9865df949cb463bcddde5688bbb3acb7"/><file name="postcode-logo.png" hash="da02bc29be1057a0201e63f81ee4bd02"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PostcodeNl_Api.xml" hash="feeaf95128ffe4ad109ed8b0b8bc85ab"/></dir></target></contents>
23
  <compatible/>
24
  <dependencies/>
25
  </package>
skin/adminhtml/default/default/postcodenl/api/css/lookup.css CHANGED
@@ -1,20 +1,15 @@
1
- input.readonly {
2
- background-color: #EEE;
3
- }
4
-
5
- h4.showcase {
6
- margin-top: 5px;
7
- margin-bottom: 0px;
8
- }
9
 
10
- h4.showcase {
11
  background: url(../images/postcode-logo.png) left center no-repeat;
12
  padding-left: 146px;
13
  height: 22px;
14
  line-height: 25px;
 
 
15
  }
16
 
17
- dl.showcase {
18
  padding: 4px;
19
  border: 1px solid grey;
20
  border-radius: 4px;
@@ -22,9 +17,16 @@ dl.showcase {
22
  background: white;
23
  }
24
 
25
- dl.showcase dt {
26
  font-weight: bold;
27
  }
28
- dl.showcase dd {
29
  margin-left: 20px;
 
 
 
 
 
 
 
30
  }
1
+ /* Backend styles */
 
 
 
 
 
 
 
2
 
3
+ h4.pcnl-showcase {
4
  background: url(../images/postcode-logo.png) left center no-repeat;
5
  padding-left: 146px;
6
  height: 22px;
7
  line-height: 25px;
8
+ margin-top: 5px;
9
+ margin-bottom: 0px;
10
  }
11
 
12
+ dl.pcnl-showcase {
13
  padding: 4px;
14
  border: 1px solid grey;
15
  border-radius: 4px;
17
  background: white;
18
  }
19
 
20
+ dl.pcnl-showcase dt {
21
  font-weight: bold;
22
  }
23
+ dl.pcnl-showcase dd {
24
  margin-left: 20px;
25
+ }
26
+
27
+ input.pcnl-readonly,
28
+ select.pcnl-readonly {
29
+ color: grey;
30
+ font-style: italic;
31
+ background-color: #eee;
32
  }
skin/frontend/default/default/postcodenl/api/css/lookup.css CHANGED
@@ -1,19 +1,66 @@
1
- input.readonly {
 
 
2
  background-color: #EEE;
3
  }
4
 
5
- h4.showcase {
 
 
 
6
  margin-bottom: 0px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
8
 
9
- h4.showcase {
 
 
10
  background: url(../images/postcode-logo.png) left center no-repeat;
11
  padding-left: 146px;
12
  height: 22px;
13
  line-height: 25px;
 
14
  }
15
 
16
- dl.showcase {
17
  padding: 4px;
18
  border: 1px solid grey;
19
  border-radius: 4px;
@@ -22,7 +69,7 @@ dl.showcase {
22
  position: relative;
23
  }
24
 
25
- dl.showcase iframe {
26
  position: absolute;
27
  top: 5px;
28
  right: 5px;
@@ -31,13 +78,35 @@ dl.showcase iframe {
31
  border: 1px solid grey;
32
  }
33
 
34
- dl.showcase dt {
35
  font-weight: bold;
36
  }
37
- dl.showcase dd {
38
  margin-left: 20px;
39
  }
40
 
41
- .form-list .pos { width:70px; }
42
- .form-list input.input-text-half { width:100px; }
43
- .form-list select.input-text-half { margin-left:5px; width:149px; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Frontend styles */
2
+
3
+ input.pcnl-readonly {
4
  background-color: #EEE;
5
  }
6
 
7
+ label.pcnl-info-label {
8
+ display: block;
9
+ background: url(../images/postcode-logo-mini.png) left center no-repeat;
10
+ padding-left: 110px;
11
  margin-bottom: 0px;
12
+ float: none;
13
+ }
14
+
15
+ .form-list input.pcnl-input-text-half {
16
+ width: 45%;
17
+ margin-right:5px;
18
+ }
19
+ .form-list select.pcnl-input-text-half {
20
+ width: 45%;
21
+ }
22
+
23
+ input.pcnl-readonly,
24
+ select.pcnl-readonly {
25
+ color: grey;
26
+ font-style: italic;
27
+ }
28
+
29
+
30
+ .pcnl-info-text {
31
+ font-size: 90%;
32
+ }
33
+
34
+ .pcnl-address-text {
35
+ font-style: italic;
36
+ clear: both;
37
+ padding-left: 4px;
38
+ padding-right: 4px;
39
+ width: 90%;
40
+ }
41
+
42
+ /* excessive hidey-stuff? yes. blame IE (6, 7 & 9) */
43
+ .pcnl-hidden-field {
44
+ visibility: hidden;
45
+ display: block;
46
+ height: 0px !important;
47
+ width: 0px !important;
48
+ margin: 0 !important;
49
+ padding: 0 !important;
50
+ position: absolute;
51
  }
52
 
53
+ /* Showcase styles */
54
+
55
+ h4.pcnl-showcase {
56
  background: url(../images/postcode-logo.png) left center no-repeat;
57
  padding-left: 146px;
58
  height: 22px;
59
  line-height: 25px;
60
+ margin-bottom: 0px;
61
  }
62
 
63
+ dl.pcnl-showcase {
64
  padding: 4px;
65
  border: 1px solid grey;
66
  border-radius: 4px;
69
  position: relative;
70
  }
71
 
72
+ dl.pcnl-showcase iframe {
73
  position: absolute;
74
  top: 5px;
75
  right: 5px;
78
  border: 1px solid grey;
79
  }
80
 
81
+ dl.pcnl-showcase dt {
82
  font-weight: bold;
83
  }
84
+ dl.pcnl-showcase dd {
85
  margin-left: 20px;
86
  }
87
 
88
+ /* OneStepCheckout styling */
89
+ div.checkoutcontainer div.pcnl-input-housenumber {
90
+ width: 60%;
91
+ }
92
+ div.checkoutcontainer div.pcnl-input-housenumber .input-text {
93
+ width: 74%;
94
+ }
95
+ div.checkoutcontainer .pcnl-with-addition div.pcnl-input-housenumber .input-text {
96
+ width: 22%;
97
+ }
98
+ div.checkoutcontainer div.pcnl-input-housenumber select.pcnl-input-text-half {
99
+ margin-left: 4px;
100
+ width: 50%;
101
+ }
102
+ div.checkoutcontainer .pcnl-info-text {
103
+ width: 85%;
104
+ }
105
+ div.checkoutcontainer dl.pcnl-showcase iframe {
106
+ position: relative;
107
+ float: right;
108
+ width: 260px;
109
+ height: 260px;
110
+ margin-bottom: 15px;
111
+ border: 1px solid grey;
112
+ }
skin/frontend/default/default/postcodenl/api/images/postcode-logo-mini.png ADDED
Binary file