}
if ($controller->_QFResponseType == 'json') {
- $response = array(
- 'content' => $html,
- );
+ $response = array('content' => $html);
+ if (!empty($page->ajaxResponse)) {
+ $response += $page->ajaxResponse;
+ }
if (!empty($form['errors'])) {
$response['status'] = 'form_error';
$response['errors'] = $form['errors'];
CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the <a href="%1">Event Templates</a> feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info');
}
if (!CRM_Utils_System::isNull($eventTemplates)) {
- $this->add('select', 'template_id', ts('From Template'), array(
- '' => ts('- select -')) + $eventTemplates,
- FALSE, array('onchange' => "reloadWindow(this.value);")
- );
+ $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates);
}
}
CRM_Event_BAO_Event::add($params);
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = !empty($params['is_monetary']);
parent::endPostProcess();
}
function setDefaultValues() {
$defaults = $this->_values;
- if (CRM_Utils_Array::value('loc_block_id', $defaults)) {
+ if (!empty($defaults['loc_block_id'])) {
$defaults['loc_event_id'] = $defaults['loc_block_id'];
$countLocUsed = CRM_Event_BAO_Event::countEventsUsingLocBlockId($defaults['loc_block_id']);
if ($countLocUsed > 1) {
$params['id'] = $this->_id;
CRM_Event_BAO_Event::add($params);
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = TRUE;
parent::endPostProcess();
}
//end of function
* @return void
*/
public function postProcess() {
- $params = array();
$params = $this->exportValues();
$params['id'] = $this->_id;
}
}
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = !empty($params['is_online_registration']);
+
parent::endPostProcess();
}
//end of function
$reminderList = TRUE;
}
$this->assign('rows', $reminderList);
+
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = !empty($reminderList) && is_array($reminderList);
}
}
);
$tabs = array(
- 'settings' => array('title' => ts('Info and Settings')) + $default,
+ 'settings' => array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default,
'location' => array('title' => ts('Event Location')) + $default,
'fee' => array('title' => ts('Fees')) + $default,
'registration' => array('title' => ts('Online Registration')) + $default,
if ($eventID) {
// disable tabs based on their configuration status
$sql = "
-SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.id as is_pcp, sch.id as is_reminder
+SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder
FROM civicrm_event e
LEFT JOIN civicrm_tell_friend taf ON ( taf.entity_table = 'civicrm_event' AND taf.entity_id = e.id )
LEFT JOIN civicrm_pcp_block pcp ON ( pcp.entity_table = 'civicrm_event' AND pcp.entity_id = e.id )
* @return void
*/
function browse() {
- CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$this->_sortByCharacter = CRM_Utils_Request::retrieve('sortByCharacter',
'String',
$this
CRM_Friend_BAO_Friend::addTellAFriend($formValues);
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = !empty($formValues['tf_is_active']);
+
parent::endPostProcess();
}
$dao = CRM_PCP_BAO_PCP::add($params);
+ // Update tab "disabled" css class
+ $this->ajaxResponse['tabValid'] = !empty($params['is_active']);
+
parent::endPostProcess();
}
this.element.addClass('crm-container');
}
this._handleOrderLinks();
- this.options.url ? this.refresh() : this.options.url = document.location.href;
+ // Set default if not supplied
+ this.options.url = this.options.url || document.location.href;
this._originalUrl = this.options.url;
},
_onFailure: function(data) {
return;
}
data.url = url;
- that.element.html(data.content);
+ that.element.trigger('crmBeforeLoad', data).html(data.content);
that._handleOrderLinks();
that.element.trigger('crmLoad', data);
that.options.crmForm && that.element.trigger('crmFormLoad', data);
data.title && $(this).dialog('option', 'title', data.title);
});
}
- return $(settings.target).crmSnippet(settings);
+ $(settings.target).crmSnippet(settings).crmSnippet('refresh');
+ return $(settings.target);
};
CRM.loadForm = function(url, options) {
onCancel: function(event) {},
onError: function(data) {
var $el = $(this);
- $el.html(data.content).trigger('crmLoad', data).trigger('crmFormLoad', data);
+ $el.html(data.content).trigger('crmLoad', data).trigger('crmFormLoad', data).trigger('crmFormError', data);
if (typeof(data.errors) == 'object') {
$.each(data.errors, function(formElement, msg) {
$('[name="'+formElement+'"]', $el).crmError(msg);
<div class="status">
{ts}There are currently no active Campaigns.{/ts}
{if $campaignInfo.addCampaignURL}
- {ts 1=$campaignInfo.addCampaignURL}If you want to associate this record with a campaign, you can <a href="%1">create a campaign here</a>.{/ts}
+ {capture assign="link"}href="{$campaignInfo.addCampaignURL}" class="action-item action-item-first"{/capture}
+ {ts 1=$link}If you want to associate this record with a campaign, you can <a %1>create a campaign here</a>.{/ts}
{/if} {help id="id-campaign_id" file="CRM/Campaign/Form/addCampaignToComponent.hlp"}
</div>
{/if}
</div>
{literal}
<script type="text/javascript">
-
-function reloadWindow(tempId) {
-
- //ignore form navigation, CRM-6815
- global_formNavigate = true;
-
- //freeze the event type element
- //when template form is loading.
- cj( "#event_type_id" ).prop('disabled', true );
-
- window.location += '&template_id=' + tempId;
-}
-
+ cj(function($) {
+ $('#template_id', '#EventInfo').change(function() {
+ $('#crm-main-content-wrapper')
+ .crmSnippet({url: CRM.url('civicrm/event/add', {action: 'add', reset: 1, template_id: $(this).val()})})
+ .crmSnippet('refresh');
+ })
+ });
</script>
{/literal}
{literal}
<script>
-
-cj('body').click(function() {
- cj('#crm-event-links-list').hide();
- cj('#crm-participant-list').hide();
+cj(function($) {
+ $('body').click(function() {
+ $('#crm-event-links-list, #crm-participant-list').hide();
});
-cj('#crm-event-links-link').click(function(event) {
- cj('#crm-event-links-list').toggle();
- cj('#crm-participant-list').hide();
- event.stopPropagation();
- return false;
-});
+ $('#crm-event-links-link').click(function(event) {
+ $('#crm-event-links-list').toggle();
+ $('#crm-participant-list').hide();
+ event.stopPropagation();
+ return false;
+ });
+
+ $('#crm-participant-link').click(function(event) {
+ $('#crm-participant-list').toggle();
+ $('#crm-event-links-list').hide();
+ event.stopPropagation();
+ return false;
+ });
-cj('#crm-participant-link').click(function(event) {
- cj('#crm-participant-list').toggle();
- cj('#crm-event-links-list').hide();
- event.stopPropagation();
- return false;
+ // Update title dynamically
+ $('h1').each(function() {
+ var title = {/literal}{$title|json_encode}{literal};
+ $(this).html($(this).html().replace(title, '<span id="crm-event-name-page-title">' + title + '</span>'));
+ });
+ $('#crm-main-content-wrapper').on('keyup change', 'input#title', function() {
+ $('#crm-event-name-page-title').text($(this).val());
+ });
+
+ $().crmAccordions();
});
-
-cj().crmAccordions();
-
</script>
{/literal}
});
}
ui.panel
- .off('crmLoad.tabCount')
- .on('crmLoad.tabCount', function(e, data) {
+ .off('.tabInfo')
+ .on('crmLoad.tabInfo crmFormSuccess.tabInfo', function(e, data) {
if (typeof(data.tabCount) !== 'undefined') {
CRM.tabHeader.updateCount(ui.tab, data.tabCount);
}
+ if (typeof(data.tabValid) !== 'undefined') {
+ var method = data.tabValid ? 'removeClass' : 'addClass';
+ ui.tab[method]('disabled');
+ }
});
CRM[method]($('a', ui.tab).attr('href'), params);
}