From 96ed17aadf29d57f80340a33b71a1a63fe495740 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 2 Nov 2014 19:48:07 -0500 Subject: [PATCH] CRM-15524 - Move static js resources to the html-header region so they don't reload with ajax page refreshes --- CRM/Admin/Page/APIExplorer.php | 6 +++--- CRM/Badge/Form/Layout.php | 2 +- CRM/Batch/Form/Entry.php | 2 +- CRM/Campaign/Form/Survey/TabHeader.php | 2 +- CRM/Campaign/Page/DashBoard.php | 2 +- CRM/Campaign/Page/Vote.php | 2 +- CRM/Case/Form/CaseView.php | 4 ++-- CRM/Contact/Form/Search/Builder.php | 2 +- CRM/Contact/Page/View/Summary.php | 4 ++-- CRM/Contribute/Form/ContributionPage/TabHeader.php | 2 +- CRM/Contribute/Page/DashBoard.php | 2 +- CRM/Core/Form.php | 2 +- CRM/Core/Form/Search.php | 2 +- CRM/Core/Page.php | 2 +- CRM/Core/Page/QUnit.php | 6 +++--- CRM/Custom/Page/Field.php | 2 +- CRM/Event/Form/ManageEvent/TabHeader.php | 2 +- CRM/Price/Page/Field.php | 2 +- CRM/Profile/Form.php | 2 +- CRM/UF/Page/Field.php | 2 +- 20 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CRM/Admin/Page/APIExplorer.php b/CRM/Admin/Page/APIExplorer.php index 809fb95f84..f53532aae3 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -44,9 +44,9 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { function run() { CRM_Utils_System::setTitle(ts('API explorer and generator')); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Admin/Page/APIExplorer.js') - ->addScriptUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js', 99) - ->addStyleUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css', 99); + ->addScriptFile('civicrm', 'templates/CRM/Admin/Page/APIExplorer.js', 1, 'html-header') + ->addScriptUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js', 99, 'html-header') + ->addStyleUrl('//cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css', 99, 'html-header'); $this->assign('operators', CRM_Core_DAO::acceptedSQLOperators()); return parent::run(); } diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index 707ada6bff..7acaea4783 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -58,7 +58,7 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form { 'kcfinderPath' => $config->userFrameworkResourceURL .'packages' .DIRECTORY_SEPARATOR ) ); - $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js'); + $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js', 1, 'html-header'); $this->applyFilter('__ALL__', 'trim'); diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index 40540f4872..5780c4a563 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -107,7 +107,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { $this->_profileId = CRM_Batch_BAO_Batch::getProfileId($this->_batchInfo['type_id']); } CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js') + ->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js', 1, 'html-header') ->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id']))) ->addSetting(array('setting' => array('monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator))) ->addSetting(array('setting' => array('monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint))); diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index 0c7f4d7bdc..79574bcb8e 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -51,7 +51,7 @@ class CRM_Campaign_Form_Survey_TabHeader { } $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array('tabSettings' => array( 'active' => self::getCurrentTab($tabs), ))); diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index ee197aecf8..d60a7a7790 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -467,7 +467,7 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $this->buildTabs(); } CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array('tabSettings' => array( 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign')), ))); diff --git a/CRM/Campaign/Page/Vote.php b/CRM/Campaign/Page/Vote.php index d0a4e67652..ea6d15e33b 100644 --- a/CRM/Campaign/Page/Vote.php +++ b/CRM/Campaign/Page/Vote.php @@ -93,7 +93,7 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { $this->assign('subPageType', $subPageType); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array('tabSettings' => array( 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'reserve')), ))); diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 3b3d08eba9..2080bd08ee 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -218,8 +218,8 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { } CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'js/crm.livePage.js') - ->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js'); + ->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header') + ->addScriptFile('civicrm', 'templates/CRM/Case/Form/CaseView.js', 2, 'html-header'); $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $caseRoles = $xmlProcessor->get($this->_caseType, 'CaseRoles'); diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 380d04a269..c11efbd956 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -105,7 +105,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { } // Add javascript CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Search/Builder.js') + ->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Search/Builder.js', 1, 'html-header') ->addSetting(array( 'searchBuilder' => array( // Index of newly added/expanded block (1-based index) diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index e4efbcfa0f..2b56d3c3ce 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -134,10 +134,10 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View { function view() { // Add js for tabs, in-place editing, and jstree for tags CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js') + ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header') ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE) ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header') - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array( 'summaryPrint' => array('mode' => $this->_print), 'tabSettings' => array('active' => CRM_Utils_Request::retrieve('selectedChild', 'String', $this, FALSE, 'summary')), diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index 8aa89253dc..5c6924a569 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -50,7 +50,7 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { } $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array('tabSettings' => array( 'active' => self::getCurrentTab($tabs), ))); diff --git a/CRM/Contribute/Page/DashBoard.php b/CRM/Contribute/Page/DashBoard.php index 81335a7fe7..74332aba85 100644 --- a/CRM/Contribute/Page/DashBoard.php +++ b/CRM/Contribute/Page/DashBoard.php @@ -127,7 +127,7 @@ class CRM_Contribute_Page_DashBoard extends CRM_Core_Page { $chartForm->setEmbedded(TRUE); $chartForm->process(); $chartForm->run(); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js'); + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Contribute/Page/DashBoard.js', 1, 'html-header'); return parent::run(); } diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index f328e17fe7..c3c811cf77 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -1620,7 +1620,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->assign('selectable', $autoCompleteField['id_field']); $this->addEntityRef($autoCompleteField['id_field'], NULL, array('placeholder' => $autoCompleteField['placeholder'], 'api' => $autoCompleteField['api'])); - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/AlternateContactSelector.js') + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/AlternateContactSelector.js', 1, 'html-header') ->addSetting(array( 'form' => array('autocompletes' => $autoCompleteField), 'ids' => array('profile' => $profiles), diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index d593639c3e..9b9cbc0f7e 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -88,7 +88,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form { $this->assign('includeWysiwygEditor', TRUE); } - $resources->addScriptFile('civicrm', 'js/crm.searchForm.js'); + $resources->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header'); $this->addButtons(array( array( diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index 291c7d6297..5b93c196c3 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -228,7 +228,7 @@ class CRM_Core_Page { if ($this->useLivePageJS && CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajaxPopupsEnabled', NULL, TRUE)) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header'); $this->assign('includeWysiwygEditor', TRUE); } diff --git a/CRM/Core/Page/QUnit.php b/CRM/Core/Page/QUnit.php index 975ae8b8b0..c0b0538ffe 100644 --- a/CRM/Core/Page/QUnit.php +++ b/CRM/Core/Page/QUnit.php @@ -35,13 +35,13 @@ class CRM_Core_Page_QUnit extends CRM_Core_Page { $this->assign('qunitTpl', "qunit/$suite/test.tpl"); } if (file_exists("$path/tests/qunit/$suite/test.js")) { - CRM_Core_Resources::singleton()->addScriptFile($ext, "tests/qunit/$suite/test.js", 1000); + CRM_Core_Resources::singleton()->addScriptFile($ext, "tests/qunit/$suite/test.js", 1000, 'html-header'); } CRM_Utils_System::setTitle(ts('QUnit: %2 (%1)', array(1 => $ext, 2 => $suite))); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'packages/qunit/qunit.js') - ->addStyleFile('civicrm', 'packages/qunit/qunit.css'); + ->addScriptFile('civicrm', 'packages/qunit/qunit.js', 1, 'html-header') + ->addStyleFile('civicrm', 'packages/qunit/qunit.css', 1, 'html-header'); parent::run(); } diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 2428bc80fd..25a42d0acc 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -129,7 +129,7 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { function browse() { $resourceManager = CRM_Core_Resources::singleton(); if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { - $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header'); } $customField = array(); diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index e488114b65..0d512b99cd 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -51,7 +51,7 @@ class CRM_Event_Form_ManageEvent_TabHeader { } $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() - ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js') + ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') ->addSetting(array('tabSettings' => array( 'active' => self::getCurrentTab($tabs), ))); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 60287d91da..19f42b06fc 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -123,7 +123,7 @@ class CRM_Price_Page_Field extends CRM_Core_Page { function browse() { $resourceManager = CRM_Core_Resources::singleton(); if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { - $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header'); } $priceField = array(); diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index c8b0633ce1..4d28d2e044 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -357,7 +357,7 @@ class CRM_Profile_Form extends CRM_Core_Form { } elseif (!empty($this->_multiRecordFields) && (!$this->_multiRecord || !in_array($this->_multiRecord, array(CRM_Core_Action::DELETE, CRM_Core_Action::UPDATE)) )) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header'); //multirecord listing page $multiRecordFieldListing = TRUE; $page = new CRM_Profile_Page_MultipleRecordFieldsListing(); diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index ae3bdf8e95..4fcdf874f9 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -112,7 +112,7 @@ class CRM_UF_Page_Field extends CRM_Core_Page { function browse() { $resourceManager = CRM_Core_Resources::singleton(); if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) { - $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999); + $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header'); } $ufField = array(); -- 2.25.1