From 75e14bbf8681f164c5a9f871f010d7ebfd7b1205 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 7 Dec 2013 22:45:57 -0800 Subject: [PATCH] CRM-13933 - Refactor out jquery.chainedSelects --- CRM/Contact/Form/Search/Simple.php | 2 +- CRM/Core/BAO/UFGroup.php | 2 +- CRM/Core/Page/AJAX/Location.php | 36 ++++----- templates/CRM/common/jquery.files.tpl | 2 - templates/CRM/common/stateCountry.tpl | 105 +++++++++----------------- 5 files changed, 52 insertions(+), 95 deletions(-) diff --git a/CRM/Contact/Form/Search/Simple.php b/CRM/Contact/Form/Search/Simple.php index d378f7abf1..7c0efacbc1 100644 --- a/CRM/Contact/Form/Search/Simple.php +++ b/CRM/Contact/Form/Search/Simple.php @@ -46,7 +46,7 @@ class CRM_Contact_Form_Search_Simple extends CRM_Core_Form { } public function buildQuickForm() { - $config = CRM_Core_Config::singleton(); + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jquery.chainedSelects.js', 0, 'html-header', FALSE); $this->add('select', 'country_id', diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 1f8a12d1fe..cb6ab8d15a 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -1803,7 +1803,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if ($addressOptions['county']) { $form->add('select', $name, $title, array( - '' => ts('- select state -')), $required + '' => ts('(choose state first)')), $required ); } } diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php index 0d21c1b778..150cffc5c0 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -219,21 +219,17 @@ class CRM_Core_Page_AJAX_Location { CRM_Utils_System::civiExit(); } - static function jqState($config) { - if ( - !isset($_GET['_value']) || - empty($_GET['_value']) - ) { + static function jqState() { + if (empty($_GET['_value'])) { CRM_Utils_System::civiExit(); } $result = CRM_Core_PseudoConstant::stateProvinceForCountry($_GET['_value']); - $elements = array( - array('name' => ts('- select a state -'), - 'value' => '', - ) - ); + $elements = array(array( + 'name' => $result ? ts('- select a state -') : ts('- N/A -'), + 'value' => '', + )); foreach ($result as $id => $name) { $elements[] = array( 'name' => $name, @@ -245,31 +241,25 @@ class CRM_Core_Page_AJAX_Location { CRM_Utils_System::civiExit(); } - static function jqCounty($config) { - if (CRM_Utils_System::isNull($_GET['_value'])) { + static function jqCounty() { + if (!isset($_GET['_value']) || CRM_Utils_System::isNull($_GET['_value'])) { $elements = array( - array('name' => ts('- select state -'), 'value' => '') + array('name' => ts('(choose state first)'), 'value' => '') ); } else { $result = CRM_Core_PseudoConstant::countyForState($_GET['_value']); - $elements = array( - array('name' => ts('- select -'), 'value' => '') - ); + $elements = array(array( + 'name' => $result ? ts('- select -') : ts('- N/A -'), + 'value' => '', + )); foreach ($result as $id => $name) { $elements[] = array( 'name' => $name, 'value' => $id, ); } - - if ($elements == array( - array('name' => ts('- select -'), 'value' => ''))) { - $elements = array( - array('name' => ts('- no counties -'), 'value' => '') - ); - } } echo json_encode($elements); diff --git a/templates/CRM/common/jquery.files.tpl b/templates/CRM/common/jquery.files.tpl index e76cfd287c..2d41af8445 100644 --- a/templates/CRM/common/jquery.files.tpl +++ b/templates/CRM/common/jquery.files.tpl @@ -33,8 +33,6 @@ packages/jquery/css/jquery.autocomplete.css packages/jquery/plugins/jquery.menu.pack.js packages/jquery/css/menu.css -packages/jquery/plugins/jquery.chainedSelects.js - packages/jquery/plugins/jquery.tableHeader.js packages/jquery/plugins/jquery.textarearesizer.js diff --git a/templates/CRM/common/stateCountry.tpl b/templates/CRM/common/stateCountry.tpl index 2f9d211ec7..adf578eebc 100644 --- a/templates/CRM/common/stateCountry.tpl +++ b/templates/CRM/common/stateCountry.tpl @@ -24,75 +24,44 @@ +--------------------------------------------------------------------+ *} {if $config->stateCountryMap} - {/if} -- 2.25.1