From f1cf499b20ab699bdd28e49b6911bbb102cfc77e Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 13 Mar 2014 19:10:22 -0400 Subject: [PATCH] CRM-13863 - Added setting to disable ajax popups --- CRM/ACL/Page/ACL.php | 6 ++- CRM/ACL/Page/EntityRole.php | 8 +++- CRM/Admin/Form/Preferences/Display.php | 5 +++ CRM/Admin/Page/ContactType.php | 4 +- CRM/Admin/Page/LabelFormats.php | 4 +- CRM/Admin/Page/LocationType.php | 4 +- CRM/Admin/Page/MessageTemplates.php | 4 +- CRM/Admin/Page/Options.php | 4 +- CRM/Admin/Page/ParticipantStatus.php | 4 +- CRM/Admin/Page/PdfFormats.php | 4 +- CRM/Admin/Page/RelationshipType.php | 4 +- CRM/Admin/Page/ScheduleReminders.php | 4 +- CRM/Admin/Page/Tag.php | 4 +- CRM/Campaign/Page/Campaign.php | 4 +- CRM/Campaign/Page/Survey.php | 4 +- CRM/Campaign/Page/SurveyType.php | 4 +- CRM/Contribute/Page/ManagePremiums.php | 4 +- CRM/Contribute/Page/Tab.php | 4 +- CRM/Core/Resources.php | 3 ++ CRM/Custom/Page/Field.php | 4 +- CRM/Custom/Page/Option.php | 4 +- CRM/Event/Form/Participant.php | 4 +- CRM/Event/Form/ParticipantFeeSelection.php | 4 +- CRM/Event/Form/ParticipantView.php | 4 +- CRM/Financial/Page/FinancialAccount.php | 4 +- CRM/Financial/Page/FinancialType.php | 4 +- CRM/Member/Page/MembershipStatus.php | 4 +- CRM/Member/Page/MembershipType.php | 4 +- CRM/Price/Page/Field.php | 4 +- CRM/Price/Page/Option.php | 4 +- CRM/Report/Page/Options.php | 4 +- CRM/SMS/Page/Provider.php | 4 +- CRM/UF/Page/Field.php | 4 +- js/crm.searchForm.js | 37 ++++++++++--------- settings/Core.setting.php | 14 +++++++ .../CRM/Admin/Form/Preferences/Display.tpl | 10 +++++ templates/CRM/Contact/Page/View/Summary.js | 18 ++++----- templates/CRM/common/TabHeader.js | 10 ++++- 38 files changed, 166 insertions(+), 61 deletions(-) diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index aa7f0c9d10..e4ff23d7be 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -156,7 +156,11 @@ class CRM_ACL_Page_ACL extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } + } // get all acl's sorted by weight $acl = array(); diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 806c6d6a95..4acc15923a 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -139,7 +139,9 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { // finally browse the acl's if ($action & CRM_Core_Action::BROWSE) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } } // parent run @@ -154,7 +156,9 @@ class CRM_ACL_Page_EntityRole extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all acl's sorted by weight $entityRoles = array(); diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 6f5e00a585..1c37bd8766 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -98,6 +98,11 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'html_type' => NULL, 'weight' => 11, ), + 'ajax_popups_enabled' => array( + 'html_type' => 'checkbox', + 'title' => ts('Enable Popup Forms'), + 'weight' => 12, + ), ), ); diff --git a/CRM/Admin/Page/ContactType.php b/CRM/Admin/Page/ContactType.php index 1b3b21602b..622a527471 100644 --- a/CRM/Admin/Page/ContactType.php +++ b/CRM/Admin/Page/ContactType.php @@ -105,7 +105,9 @@ class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic { } function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $rows = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); foreach ($rows as $key => $value) { $mask = NULL; diff --git a/CRM/Admin/Page/LabelFormats.php b/CRM/Admin/Page/LabelFormats.php index 5aab022c31..3fc46604a5 100644 --- a/CRM/Admin/Page/LabelFormats.php +++ b/CRM/Admin/Page/LabelFormats.php @@ -124,7 +124,9 @@ class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic { * @static */ function browse($action = NULL) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // Get list of configured Label Formats $labelFormatList= CRM_Core_BAO_LabelFormat::getList(); $nameFormatList= CRM_Core_BAO_LabelFormat::getList(false, 'name_badge'); diff --git a/CRM/Admin/Page/LocationType.php b/CRM/Admin/Page/LocationType.php index cad2e1cadf..61739f2f1c 100644 --- a/CRM/Admin/Page/LocationType.php +++ b/CRM/Admin/Page/LocationType.php @@ -61,7 +61,9 @@ class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic { * @return array (reference) of action links */ function &links() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } if (!(self::$_links)) { self::$_links = array( CRM_Core_Action::UPDATE => array( diff --git a/CRM/Admin/Page/MessageTemplates.php b/CRM/Admin/Page/MessageTemplates.php index d9a75806e5..36f2fa671a 100644 --- a/CRM/Admin/Page/MessageTemplates.php +++ b/CRM/Admin/Page/MessageTemplates.php @@ -223,7 +223,9 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $action = func_num_args() ? func_get_arg(0) : NULL; if ($this->_action & CRM_Core_Action::ADD) { return; diff --git a/CRM/Admin/Page/Options.php b/CRM/Admin/Page/Options.php index dfe1102de1..8699526772 100644 --- a/CRM/Admin/Page/Options.php +++ b/CRM/Admin/Page/Options.php @@ -228,7 +228,9 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { if (!self::$_gName) { return parent::browse(); } - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + 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'); $gName = self::$_gName; diff --git a/CRM/Admin/Page/ParticipantStatus.php b/CRM/Admin/Page/ParticipantStatus.php index 5140c14b75..6eeefd2b05 100644 --- a/CRM/Admin/Page/ParticipantStatus.php +++ b/CRM/Admin/Page/ParticipantStatus.php @@ -69,7 +69,9 @@ class CRM_Admin_Page_ParticipantStatus extends CRM_Core_Page_Basic { } function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $statusTypes = array(); $dao = new CRM_Event_DAO_ParticipantStatusType; diff --git a/CRM/Admin/Page/PdfFormats.php b/CRM/Admin/Page/PdfFormats.php index d93602e415..d8b0cea4e8 100644 --- a/CRM/Admin/Page/PdfFormats.php +++ b/CRM/Admin/Page/PdfFormats.php @@ -118,7 +118,9 @@ class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic { * @static */ function browse($action = NULL) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // Get list of configured PDF Page Formats $pdfFormatList = CRM_Core_BAO_PdfFormat::getList(); diff --git a/CRM/Admin/Page/RelationshipType.php b/CRM/Admin/Page/RelationshipType.php index 8034733f58..fb9a5d9aa8 100644 --- a/CRM/Admin/Page/RelationshipType.php +++ b/CRM/Admin/Page/RelationshipType.php @@ -61,7 +61,9 @@ class CRM_Admin_Page_RelationshipType extends CRM_Core_Page_Basic { * @return array (reference) of action links */ function &links() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } if (!(self::$_links)) { self::$_links = array( CRM_Core_Action::VIEW => array( diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php index b42ee60901..1e88f71f8b 100644 --- a/CRM/Admin/Page/ScheduleReminders.php +++ b/CRM/Admin/Page/ScheduleReminders.php @@ -128,7 +128,9 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { * @static */ function browse($action = NULL) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // Get list of configured reminders $reminderList = CRM_Core_BAO_ActionSchedule::getList(); diff --git a/CRM/Admin/Page/Tag.php b/CRM/Admin/Page/Tag.php index 46ae2f3095..f3bc45e733 100644 --- a/CRM/Admin/Page/Tag.php +++ b/CRM/Admin/Page/Tag.php @@ -134,7 +134,9 @@ class CRM_Admin_Page_Tag extends CRM_Core_Page_Basic { * override function browse() */ function browse($action = NULL, $sort = NULL) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $adminTagSet = FALSE; if (CRM_Core_Permission::check('administer Tagsets')) { $adminTagSet = TRUE; diff --git a/CRM/Campaign/Page/Campaign.php b/CRM/Campaign/Page/Campaign.php index d17f23ec3b..693faea46b 100644 --- a/CRM/Campaign/Page/Campaign.php +++ b/CRM/Campaign/Page/Campaign.php @@ -84,7 +84,9 @@ class CRM_Campaign_Page_Campaign extends CRM_Core_Page { } function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary(); diff --git a/CRM/Campaign/Page/Survey.php b/CRM/Campaign/Page/Survey.php index 02bca24b49..9dea4ea65f 100644 --- a/CRM/Campaign/Page/Survey.php +++ b/CRM/Campaign/Page/Survey.php @@ -73,7 +73,9 @@ class CRM_Campaign_Page_Survey extends CRM_Core_Page { } function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $surveys = CRM_Campaign_BAO_Survey::getSurveySummary(); diff --git a/CRM/Campaign/Page/SurveyType.php b/CRM/Campaign/Page/SurveyType.php index 5bce5088bd..2c4cda344b 100644 --- a/CRM/Campaign/Page/SurveyType.php +++ b/CRM/Campaign/Page/SurveyType.php @@ -155,7 +155,9 @@ class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $this->assign('includeWysiwygEditor', TRUE); $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign'); diff --git a/CRM/Contribute/Page/ManagePremiums.php b/CRM/Contribute/Page/ManagePremiums.php index 6ac87f541e..b6bdffd2b7 100644 --- a/CRM/Contribute/Page/ManagePremiums.php +++ b/CRM/Contribute/Page/ManagePremiums.php @@ -141,7 +141,9 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all custom groups sorted by weight $premiums = array(); $dao = new CRM_Contribute_DAO_Product(); diff --git a/CRM/Contribute/Page/Tab.php b/CRM/Contribute/Page/Tab.php index 4ca98ea170..19b5e572bf 100644 --- a/CRM/Contribute/Page/Tab.php +++ b/CRM/Contribute/Page/Tab.php @@ -109,7 +109,9 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // add annual contribution $annual = array(); diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index e13eb914bd..033c97a012 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -455,6 +455,9 @@ class CRM_Core_Resources { 'userFramework' => $config->userFramework, 'resourceBase' => $config->resourceBase, 'lcMessages' => $config->lcMessages, + 'ajax_popups_enabled' => (bool) CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'ajax_popups_enabled', NULL, TRUE + ) ); $this->addSetting(array('config' => $settings)); diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index a31ae10f4d..d91fe415bb 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -124,7 +124,9 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $customField = array(); $customFieldBAO = new CRM_Core_BAO_CustomField(); diff --git a/CRM/Custom/Page/Option.php b/CRM/Custom/Page/Option.php index 73cdb12c6a..e3664f4466 100644 --- a/CRM/Custom/Page/Option.php +++ b/CRM/Custom/Page/Option.php @@ -120,7 +120,9 @@ class CRM_Custom_Page_Option extends CRM_Core_Page { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } //get the default value from custom fields $customFieldBAO = new CRM_Core_BAO_CustomField(); $customFieldBAO->id = $this->_fid; diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 8e8ae29ea5..d2d94eabda 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -671,7 +671,9 @@ SELECT civicrm_custom_group.name as name, * @access public */ public function buildQuickForm() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $partiallyPaidStatusId = array_search('Partially paid', $participantStatuses); $this->assign('partiallyPaidStatusId', $partiallyPaidStatusId); diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index 10d9d22d09..f5eddbd107 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -125,7 +125,9 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { } public function buildQuickForm() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $statuses = CRM_Event_PseudoConstant::participantStatus(); $this->assign('partiallyPaid', array_search('Partially paid', $statuses)); diff --git a/CRM/Event/Form/ParticipantView.php b/CRM/Event/Form/ParticipantView.php index dc38494c24..3f4e1e125a 100644 --- a/CRM/Event/Form/ParticipantView.php +++ b/CRM/Event/Form/ParticipantView.php @@ -208,7 +208,9 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { * @access public */ public function buildQuickForm() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $this->addButtons(array( array( 'type' => 'cancel', diff --git a/CRM/Financial/Page/FinancialAccount.php b/CRM/Financial/Page/FinancialAccount.php index 9a2892e482..572bee71a8 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -126,7 +126,9 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all custom groups sorted by weight $contributionType = array(); $dao = new CRM_Financial_DAO_FinancialAccount(); diff --git a/CRM/Financial/Page/FinancialType.php b/CRM/Financial/Page/FinancialType.php index f8fd2ffdfc..af77fdfcd1 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -132,7 +132,9 @@ class CRM_Financial_Page_FinancialType extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all financial types sorted by weight $financialType = array(); $dao = new CRM_Financial_DAO_FinancialType(); diff --git a/CRM/Member/Page/MembershipStatus.php b/CRM/Member/Page/MembershipStatus.php index 07c5b07579..6f519d0b2d 100644 --- a/CRM/Member/Page/MembershipStatus.php +++ b/CRM/Member/Page/MembershipStatus.php @@ -134,7 +134,9 @@ class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all custom groups sorted by weight $membershipStatus = array(); $dao = new CRM_Member_DAO_MembershipStatus(); diff --git a/CRM/Member/Page/MembershipType.php b/CRM/Member/Page/MembershipType.php index 0ad3122ced..559308baed 100644 --- a/CRM/Member/Page/MembershipType.php +++ b/CRM/Member/Page/MembershipType.php @@ -108,7 +108,9 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } // get all membership types sorted by weight $membershipType = array(); $dao = new CRM_Member_DAO_MembershipType(); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index f78efa343d..e5cd3b43ca 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -122,7 +122,9 @@ class CRM_Price_Page_Field extends CRM_Core_Page { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $priceField = array(); $priceFieldBAO = new CRM_Price_BAO_PriceField(); diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index 5455594770..a837c74d78 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -127,7 +127,9 @@ class CRM_Price_Page_Option extends CRM_Core_Page { * @access public */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $customOption = array(); CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption); $config = CRM_Core_Config::singleton(); diff --git a/CRM/Report/Page/Options.php b/CRM/Report/Page/Options.php index 9adf3b1ed6..a7d54373f0 100644 --- a/CRM/Report/Page/Options.php +++ b/CRM/Report/Page/Options.php @@ -165,7 +165,9 @@ class CRM_Report_Page_Options extends CRM_Core_Page_Basic { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $groupParams = array('name' => self::$_gName); $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight'); $gName = self::$_gName; diff --git a/CRM/SMS/Page/Provider.php b/CRM/SMS/Page/Provider.php index 9811cfa001..cc925a0a64 100644 --- a/CRM/SMS/Page/Provider.php +++ b/CRM/SMS/Page/Provider.php @@ -129,7 +129,9 @@ class CRM_SMS_Page_Provider extends CRM_Core_Page_Basic { * @static */ function browse($action = NULL) { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $providers = CRM_SMS_BAO_Provider::getProviders(); $rows = array(); foreach ($providers as $provider) { diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index f1fa6bd3ef..723e1f343b 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -108,7 +108,9 @@ class CRM_UF_Page_Field extends CRM_Core_Page { * @static */ function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'ajax_popups_enabled', NULL, TRUE)) { + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); + } $ufField = array(); $ufFieldBAO = new CRM_Core_BAO_UFField(); diff --git a/js/crm.searchForm.js b/js/crm.searchForm.js index df5a2a7db0..289ef57d7b 100644 --- a/js/crm.searchForm.js +++ b/js/crm.searchForm.js @@ -1,25 +1,26 @@ // http://civicrm.org/licensing // Controls search form action links and refreshes cj(function($) { - $('#crm-main-content-wrapper') - // Widgetize the content area - .crmSnippet() - // Open action links in a popup - .off('click.crmLivePage') - .on('click.crmLivePage', 'a.button, a.action-item', function() { - var url = $(this).attr('href'); - // only follow real links not javascript buttons - if (url === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) { - return; - } - CRM.loadForm(url, { - openInline: 'a:not("[href=#], .no-popup")' - }).on('crmFormSuccess', function(e, data) { - // Refresh page when form completes - $('#crm-main-content-wrapper').crmSnippet('refresh'); + $('#crm-main-content-wrapper').crmSnippet(); + if (CRM.config.ajax_popups_enabled) { + $('#crm-main-content-wrapper') + // Open action links in a popup + .off('click.crmLivePage') + .on('click.crmLivePage', 'a.button, a.action-item', function () { + var url = $(this).attr('href'); + // only follow real links not javascript buttons + if (url === '#' || $(this).attr('onclick') || $(this).hasClass('no-popup')) { + return; + } + CRM.loadForm(url, { + openInline: 'a:not("[href=#], .no-popup")' + }).on('crmFormSuccess', function (e, data) { + // Refresh page when form completes + $('#crm-main-content-wrapper').crmSnippet('refresh'); + }); + return false; }); - return false; - }); + } }); function countSelectedCheckboxes(fldPrefix, form) { diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 8ac37c239a..680560aded 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -205,6 +205,20 @@ return array ( 'description' => null, 'help_text' => null, ), + 'ajax_popups_enabled' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'ajax_popups_enabled', + 'type' => 'Boolean', + 'quick_form_type' => 'YesNo', + 'default' => 1, + 'add' => '4.5', + 'title' => null, + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => null, + 'help_text' => null, + ), 'activity_assignee_notification' => array( 'group_name' => 'CiviCRM Preferences', 'group' => 'core', diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index 104a07ea6b..bb8bdb1586 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -195,6 +195,16 @@ fields).{/ts} {help id="id-editor_id"} + + {$form.ajax_popups_enabled.label} + {$form.ajax_popups_enabled.html} + + +   + + {ts}If you disable this option, the CiviCRM interface will be limited to traditional browsing. Opening a form will refresh the page rather than opening a popup dialog.{/ts} + + {$form.display_name_format.label} {$form.display_name_format.html} diff --git a/templates/CRM/Contact/Page/View/Summary.js b/templates/CRM/Contact/Page/View/Summary.js index 4155600f0a..062d7ef194 100644 --- a/templates/CRM/Contact/Page/View/Summary.js +++ b/templates/CRM/Contact/Page/View/Summary.js @@ -298,21 +298,19 @@ var tabName = $(this).data('tab') || 'summary', $tab = $('#tab_' + tabName), - $panel = $('#' + $tab.attr('aria-controls')), url = $(this).attr('href'); - if (url !== '#') { + $('#crm-contact-actions-list').hide(); + if (url === '#') { + CRM.tabHeader.focus($tab); + return false; + } else if (CRM.config.ajax_popups_enabled) { CRM.loadForm(url) .on('crmFormSuccess', function() { - if ($panel.data('civiCrmSnippet')) { - $panel.crmSnippet('refresh'); - } - $('#mainTabContainer').tabs('option', 'active', $tab.prevAll().length); + CRM.tabHeader.resetTab($tab); + CRM.tabHeader.focus($tab); }); - } else { - $('#mainTabContainer').tabs('option', 'active', $tab.prevAll().length); + return false; } - $('#crm-contact-actions-list').hide(); - return false; }); $(document) // Actions menu diff --git a/templates/CRM/common/TabHeader.js b/templates/CRM/common/TabHeader.js index 20b559c521..93c40692d8 100644 --- a/templates/CRM/common/TabHeader.js +++ b/templates/CRM/common/TabHeader.js @@ -29,7 +29,7 @@ cj(function($) { }) }); } - if (ui.tab.hasClass('livePage')) { + if (ui.tab.hasClass('livePage') && CRM.config.ajax_popups_enabled) { ui.panel .off('click.crmLivePage') .on('click.crmLivePage', 'a.button, a.action-item', function() { @@ -77,6 +77,14 @@ cj(function($) { // Utility functions CRM.tabHeader = CRM.tabHeader || {}; + /** + * Make a given tab the active one + * @param tab jQuery selector + */ + CRM.tabHeader.focus = function(tab) { + $('#mainTabContainer').tabs('option', 'active', $(tab).prevAll().length); + }; + /** * @param tab jQuery selector * @returns panel jQuery object -- 2.25.1