From 6eafcb194f5421990a33439afc7bd00a78d77006 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 12 Dec 2013 14:13:58 -0800 Subject: [PATCH] CRM-13863 - Ajaxify option value admin screens --- CRM/Admin/Page/Options.php | 6 ++++-- CRM/Core/Form.php | 1 + CRM/Custom/Page/Field.php | 2 +- templates/CRM/Custom/Page/Field.js => js/crm.livePage.js | 9 ++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) rename templates/CRM/Custom/Page/Field.js => js/crm.livePage.js (51%) diff --git a/CRM/Admin/Page/Options.php b/CRM/Admin/Page/Options.php index 4c4667feca..2a2acc7112 100644 --- a/CRM/Admin/Page/Options.php +++ b/CRM/Admin/Page/Options.php @@ -213,6 +213,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @static */ function browse() { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $groupParams = array('name' => self::$_gName); $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); @@ -228,9 +229,10 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { // retrieve financial account name for the payment instrument page if ($gName = "payment_instrument") { foreach ($optionValue as $key => $option) { - $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value'); } + $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value'); + } } - + $this->assign('includeWysiwygEditor', TRUE); $this->assign('rows', $optionValue); } diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 5c84c5027e..9809e49584 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -961,6 +961,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->assign('editor', $editor); // include wysiwyg editor js files + // FIXME: This code does not make any sense $includeWysiwygEditor = FALSE; $includeWysiwygEditor = $this->get('includeWysiwygEditor'); if (!$includeWysiwygEditor) { diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 06aa1cbc52..2ca0f5901e 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -290,7 +290,7 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $this->preview($id); } else { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Custom/Page/Field.js'); + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); $this->browse(); } diff --git a/templates/CRM/Custom/Page/Field.js b/js/crm.livePage.js similarity index 51% rename from templates/CRM/Custom/Page/Field.js rename to js/crm.livePage.js index 6c870aaab2..0d313b3af6 100644 --- a/templates/CRM/Custom/Page/Field.js +++ b/js/crm.livePage.js @@ -1,11 +1,14 @@ // http://civicrm.org/licensing +// Adds ajaxy behavior to a simple CiviCRM page cj(function($) { $('#crm-main-content-wrapper') // Widgetize the content area - .crmSnippet({block: false}) + .crmSnippet() // Open action links in a popup - .on('click', 'a.action-item:not(".enable-action, .disable-action")', function() { - CRM.loadForm(this.href).on('crmFormSuccess', function(e, data) { + .on('click', 'a.button, a.action-item:not(".enable-action, .disable-action")', function() { + CRM.loadForm($(this).attr('href'), { + openInline: 'a' + }).on('crmFormSuccess', function(e, data) { // Refresh page when form completes $('#crm-main-content-wrapper').crmSnippet('refresh'); }); -- 2.25.1