CRM-13863 - Ajaxify option value admin screens
authorColeman Watts <coleman@civicrm.org>
Thu, 12 Dec 2013 22:13:58 +0000 (14:13 -0800)
committerColeman Watts <coleman@civicrm.org>
Thu, 12 Dec 2013 22:15:39 +0000 (14:15 -0800)
CRM/Admin/Page/Options.php
CRM/Core/Form.php
CRM/Custom/Page/Field.php
js/crm.livePage.js [moved from templates/CRM/Custom/Page/Field.js with 51% similarity]

index 4c4667feca305a25e1e2d98eae469f775cd45fea..2a2acc7112a51d7e031ab267f543c120236bad82 100644 (file)
@@ -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);
   }
 
index 5c84c5027e82b185c63110d08a0f21d387656c30..9809e495840a60c72a02d71a9f07441a7ae2ad46 100644 (file)
@@ -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) {
index 06aa1cbc529a5e0d41a489ed11405c92582f3d1c..2ca0f5901e3440f030d667facec7d1261d730297 100644 (file)
@@ -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();
     }
 
similarity index 51%
rename from templates/CRM/Custom/Page/Field.js
rename to js/crm.livePage.js
index 6c870aaab2b54dbd8237e26a91ed876b2ba121a0..0d313b3af6451b9a02022f85f793d375899dcba8 100644 (file)
@@ -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');
       });