From 8547369d6109f7173a7d7a6cc6d810b3b81258bc Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 17 Dec 2013 20:06:11 -0800 Subject: [PATCH] CRM-13997 CRM-13863 - Use CRM.loadPage for ajax tabs --- CRM/Campaign/Form/Survey.php | 2 +- CRM/Campaign/Form/Survey/TabHeader.php | 2 +- CRM/Contribute/Form/ContributionPage.php | 2 +- .../Form/ContributionPage/TabHeader.php | 2 +- CRM/Event/Form/ManageEvent.php | 2 +- CRM/Event/Form/ManageEvent/TabHeader.php | 2 +- js/Common.js | 16 ++-- js/jquery/jquery.crmProfileSelector.js | 7 +- .../CRM/Campaign/Form/Survey/Results.tpl | 1 + templates/CRM/common/TabHeader.tpl | 73 +++++++------------ 10 files changed, 46 insertions(+), 63 deletions(-) diff --git a/CRM/Campaign/Form/Survey.php b/CRM/Campaign/Form/Survey.php index df7318d187..86a09d82c7 100644 --- a/CRM/Campaign/Form/Survey.php +++ b/CRM/Campaign/Form/Survey.php @@ -172,7 +172,7 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { } function getTemplateFileName() { - if ($this->controller->getPrint() == CRM_Core_Smarty::PRINT_NOFORM || + if ($this->controller->getPrint() === CRM_Core_Smarty::PRINT_JSON || $this->getVar('_surveyId') <= 0 ) { return parent::getTemplateFileName(); } diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index db02ba33d2..779eb4e9be 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -98,7 +98,7 @@ class CRM_Campaign_Form_Survey_TabHeader { } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/survey/configure/{$key}", - "{$reset}action=update&snippet=5&id={$surveyID}{$tabs[$key]['qfKey']}" + "{$reset}action=update&id={$surveyID}{$tabs[$key]['qfKey']}" ); $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index dbcdf4dac2..1706197232 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -436,7 +436,7 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } function getTemplateFileName() { - if ($this->controller->getPrint() == CRM_Core_Smarty::PRINT_NOFORM || + if ($this->controller->getPrint() === CRM_Core_Smarty::PRINT_JSON || $this->getVar('_id') <= 0 || ($this->_action & CRM_Core_Action::DELETE) || (CRM_Utils_String::getClassName($this->_name) == 'AddProduct') diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index 5676542b22..9385bb9994 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -149,7 +149,7 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { $tabs[$key]['link'] = CRM_Utils_System::url( "civicrm/admin/contribute/{$key}", - "{$reset}action=update&snippet=5&id={$contribPageId}{$tabs[$key]['qfKey']}" + "{$reset}action=update&id={$contribPageId}{$tabs[$key]['qfKey']}" ); $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 313088ed56..5fbd7050fe 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -372,7 +372,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } function getTemplateFileName() { - if ($this->controller->getPrint() == CRM_Core_Smarty::PRINT_NOFORM || + if ($this->controller->getPrint() === CRM_Core_Smarty::PRINT_JSON || $this->getVar('_id') <= 0 || ($this->_action & CRM_Core_Action::DELETE) ) { diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 656eb3f8be..7c071baf42 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -193,7 +193,7 @@ WHERE e.id = %1 } $tabs[$key]['link'] = CRM_Utils_System::url("civicrm/event/manage/{$key}", - "{$reset}action=update&snippet=5&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}" + "{$reset}action=update&id={$eventID}&component=event{$new}{$tabs[$key]['qfKey']}" ); } } diff --git a/js/Common.js b/js/Common.js index 6a4af6df4d..4e38c1e704 100644 --- a/js/Common.js +++ b/js/Common.js @@ -860,6 +860,8 @@ CRM.validate = CRM.validate || { // Add snippet argument to url if (url.search(/[&?]snippet=/) < 0) { url += (url.indexOf('?') < 0 ? '?' : '&') + 'snippet=json'; + } else { + url = url.replace(/snippet=[^&]*/, 'snippet=json'); } return url; }, @@ -898,7 +900,10 @@ CRM.validate = CRM.validate || { CRM.loadPage = function(url, options) { var settings = { target: '#crm-ajax-dialog-' + (dialogCount++), - dialog: { + dialog: false + }; + if (!options || !options.target) { + settings.dialog = { modal: true, width: '65%', height: parseInt($(window).height() * .75), @@ -906,12 +911,12 @@ CRM.validate = CRM.validate || { $(this).dialog('destroy'); $(this).remove(); } - } - }; + }; + } options && $.extend(true, settings, options); settings.url = url; // Create new dialog - if (settings.dialog !== false && settings.target[0] == '#') { + if (settings.dialog) { $('
' + ts('Loading') + '...
').dialog(settings.dialog); } if (settings.dialog && !settings.dialog.title) { @@ -1030,13 +1035,12 @@ CRM.validate = CRM.validate || { $(function () { // Trigger crmLoad on initial content for consistency. It will also be triggered for ajax-loaded content. - $('#crm-container').trigger('crmLoad'); + $('.crm-container').trigger('crmLoad'); if ($('#crm-notification-container').length) { // Initialize notifications $('#crm-notification-container').notify(); messagesFromMarkup.call($('#crm-container')); - $('#crm-container').on('crmFormLoad', '*', messagesFromMarkup); } // bind the event for image popup diff --git a/js/jquery/jquery.crmProfileSelector.js b/js/jquery/jquery.crmProfileSelector.js index e150277535..3c09e7f460 100644 --- a/js/jquery/jquery.crmProfileSelector.js +++ b/js/jquery/jquery.crmProfileSelector.js @@ -54,14 +54,13 @@ }); }; - // FIXME: this needs a better place to live - CRM.scanProfileSelectors = function() { - $('.crm-profile-selector').each(function(){ + $('#crm-container').on('crmLoad', function() { + $('.crm-profile-selector:not(.rendered)', this).addClass('rendered').each(function() { $(this).crmProfileSelector({ groupTypeFilter: $(this).attr('data-group-type'), entities: $(this).data('entities') }); }); - }; + }); })(cj); diff --git a/templates/CRM/Campaign/Form/Survey/Results.tpl b/templates/CRM/Campaign/Form/Survey/Results.tpl index 2182832b1b..6e996e2ff9 100644 --- a/templates/CRM/Campaign/Form/Survey/Results.tpl +++ b/templates/CRM/Campaign/Form/Survey/Results.tpl @@ -60,3 +60,4 @@
{include file="CRM/common/formButtons.tpl" location="bottom"}
+ diff --git a/templates/CRM/common/TabHeader.tpl b/templates/CRM/common/TabHeader.tpl index edb0305682..e528d7df07 100644 --- a/templates/CRM/common/TabHeader.tpl +++ b/templates/CRM/common/TabHeader.tpl @@ -48,56 +48,35 @@ {* crm-content-block ends here *} -- 2.25.1