Commit eba318d0 authored by mattwire's avatar mattwire
Browse files

Format postcode before searching. Re-enable loading indicator and reduce search delay to 200ms

parent 918accb1
......@@ -2,7 +2,7 @@
require_once 'CRM/Core/Page.php';
class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Core_Page {
class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Civicrmpostcodelookup_Page_Postcode {
/*
* Function to get the Server URL and login credentials
......@@ -41,7 +41,7 @@ class CRM_Civicrmpostcodelookup_Page_Afd extends CRM_Core_Page {
* Function to get address list based on a Post code
*/
public static function search() {
$postcode = CRM_Utils_Request::retrieve('term', 'String', $this, true);
$postcode = self::getPostcode();
$number = CRM_Utils_Request::retrieve('number', 'String', $this, false);
$querystring = self::getAFDCredentials(1);
......
......@@ -2,7 +2,7 @@
require_once 'CRM/Core/Page.php';
class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Core_Page {
class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Civicrmpostcodelookup_Page_Postcode {
/*
* Function to get the Server URL and login credentials
......@@ -40,7 +40,7 @@ class CRM_Civicrmpostcodelookup_Page_Civipostcode extends CRM_Core_Page {
* Function to get address list based on a Post code
*/
public static function search() {
$postcode = CRM_Utils_Request::retrieve('term', 'String', $this, true);
$postcode = self::getPostcode();
$number = CRM_Utils_Request::retrieve('number', 'String', $this, false);
$querystring = self::getCivipostcodeCredentials(1);
......
......@@ -5,7 +5,7 @@ require_once 'CRM/Core/Page.php';
// Access the QAS library via the dependency 'llr_qas_library' module
require_once '/lib/QASCapture.php';
class CRM_PostcodeLookup_Page_Ajax extends CRM_Core_Page {
class CRM_PostcodeLookup_Page_Ajax extends CRM_Civicrmpostcodelookup_Page_Postcode {
static private $qacampture;
public static function getQasCredentials($account_type) {
......@@ -43,7 +43,7 @@ class CRM_PostcodeLookup_Page_Ajax extends CRM_Core_Page {
}
public static function search() {
$postcode = CRM_Utils_Request::retrieve('term', 'String', $this, true);
$postcode = self::getPostcode();
$number = CRM_Utils_Request::retrieve('number', 'String', $this, true);
$qaCapture = self::getQACapture();
......
......@@ -2,7 +2,7 @@
require_once 'CRM/Core/Page.php';
class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Core_Page {
class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Civicrmpostcodelookup_Page_Postcode {
/*
* Function to get the Server URL and login credentials
......@@ -41,7 +41,7 @@ class CRM_Civicrmpostcodelookup_Page_PostcodeAnywhere extends CRM_Core_Page {
* Function to get address list based on a Post code
*/
public static function search() {
$postcode = CRM_Utils_Request::retrieve('term', 'String', $this, true);
$postcode = self::getPostcode();
$querystring = self::getPostcodeAnywhereCredentials(1);
$querystring = $querystring . "&SearchTerm=" . urlencode($postcode);
......
......@@ -55,6 +55,7 @@ cj(document).ready(function(){
var addressResultElement = '#addressResult_'+blockNo;
var addressResultsElement = '#addressResults_'+blockNo;
var minCharacters = 4;
var delay = 200;
var postcodeProvider = '{/literal}{$civiPostCodeLookupProvider}{literal}';
if (postcodeProvider !== 'civipostcode') {
......@@ -72,7 +73,7 @@ cj(document).ready(function(){
selectFirst: false,
minChars: minCharacters,
matchContains: true,
delay: 400,
delay: delay,
max: 1000,
extraParams:{
term:function () {
......@@ -95,7 +96,7 @@ cj(document).ready(function(){
selectFirst: false,
minChars: minCharacters,
matchContains: true,
delay: 400,
delay: delay,
max: 1000,
extraParams:{
term:function () {
......@@ -119,15 +120,15 @@ cj(document).ready(function(){
minLength: minCharacters,
data: {postcode: cj( postcodeElement ).val(), number: cj(houseElement).val(), mode: '0'},
search: function( event, ui ) {
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
},
response: function( event, ui ) {
//cj('#loaderimage_'+blockNo).hide();
cj('#loaderimage_'+blockNo).hide();
},
select: function(event, ui) {
if (ui.item.id != '') {
findAddressValues(ui.item.id, blockNo, blockPrefix = '');
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
}
return false;
},
......@@ -147,15 +148,15 @@ cj(document).ready(function(){
minLength: minCharacters,
data: {postcode: cj( billingPostcodeElement ).val(), number: cj(houseElement).val(), mode: '0'},
search: function( event, ui ) {
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
},
response: function( event, ui ) {
//cj('#loaderimage_'+blockNo).hide();
cj('#loaderimage_'+blockNo).hide();
},
select: function(event, ui) {
if (ui.item.id != '') {
findAddressValues(ui.item.id, '5', blockPrefix = 'billing_');
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
}
return false;
},
......
......@@ -46,6 +46,7 @@ cj(document).ready(function() {
var addressResultElement = '#addressResult_'+blockNo;
var addressResultsElement = '#addressResults_'+blockNo;
var minCharacters = 4;
var delay = 200;
var postcodeProvider = '{/literal}{$civiPostCodeLookupProvider}{literal}';
if (postcodeProvider !== 'civipostcode') {
......@@ -63,7 +64,7 @@ cj(document).ready(function() {
selectFirst: false,
minChars: minCharacters,
matchContains: true,
delay: 400,
delay: delay,
max: 1000,
extraParams:{
term:function () {
......@@ -84,18 +85,19 @@ cj(document).ready(function() {
cj(postcodeElement).autocomplete({
source: sourceUrl,
minLength: minCharacters,
delay: delay,
data: {postcode: cj( postcodeElement ).val(), number: cj(houseElement).val(), mode: '0'},
//max: {/literal}{crmSetting name="search_autocomplete_count" group="Search Preferences"}{literal},
search: function( event, ui ) {
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
},
response: function( event, ui ) {
//cj('#loaderimage_'+blockNo).hide();
cj('#loaderimage_'+blockNo).hide();
},
select: function(event, ui) {
if (ui.item.id != '') {
findAddressValues(ui.item.id, blockNo);
//cj('#loaderimage_'+blockNo).show();
cj('#loaderimage_'+blockNo).show();
}
return false;
},
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment