$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL,
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
*/
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox',
*/
function buildQuickForm() {
CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'js/crm.livePage.js')
->addScriptFile('civicrm', 'js/crm.searchForm.js')
// jsTree is needed for tags popup
->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox',
*/
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
$lineItems = $eventIds = array();
if (!$this->_single) {
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onchange' => "toggleTaskAction( true );", 'class' => 'select-rows'));
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
*/
$rows = $this->get('rows');
if (is_array($rows)) {
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.searchForm.js');
if (!$this->_single) {
$this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('onclick' => "toggleTaskAction( true );", 'class' => 'select-rows'));
settings.dialog = {
modal: true,
width: '65%',
- height: parseInt($(window).height() * .75)
+ height: '75%'
};
}
options && $.extend(true, settings, options);
settings.url = url;
// Create new dialog
if (settings.dialog) {
+ // HACK: jQuery UI doesn't support relative height
+ if (settings.dialog.height && settings.dialog.height.indexOf('%') > 0) {
+ settings.dialog.height = parseInt($(window).height() * (parseFloat(settings.dialog.height)/100), 10);
+ }
$('<div id="'+ settings.target.substring(1) +'"><div class="crm-loading-element">' + ts('Loading') + '...</div></div>').dialog(settings.dialog);
$(settings.target).on('dialogclose', function() {
$(this).crmSnippet('destroy').dialog('destroy').remove();
}
}
};
- // Hack to make delete dialogs smaller
- if (url.indexOf('/delete') > 0 || url.indexOf('action=delete') > 0) {
- settings.dialog = {
- width: 400,
- height: 300
- };
- }
// Move options that belong to crmForm. Others will be passed through to crmSnippet
options && $.each(options, function(key, value) {
if (typeof(settings.crmForm[key]) !== 'undefined') {
});
return widget;
};
+ /**
+ * @see https://wiki.civicrm.org/confluence/display/CRMDOC/Ajax+Pages+and+Forms
+ */
+ $.fn.crmPopup = function(listeners) {
+ var $el = this.first(),
+ url = $el.attr('href'),
+ popup = $el.data('popup-type') === 'page' ? CRM.loadPage : CRM.loadForm,
+ settings = $el.data('popup-settings') || {};
+ settings.dialog = settings.dialog || {};
+ if (!CRM.ajax_popups_enabled || !url || url.charAt(0) === '#' || $el.attr('onclick') || $el.hasClass('no-popup')) {
+ return false;
+ }
+ // Hack to make delete dialogs smaller
+ if ($el.hasClass('small-popup') || url.indexOf('/delete') > 0 || url.indexOf('action=delete') > 0) {
+ settings.dialog.width = 400;
+ settings.dialog.height = 300;
+ }
+ else if ($el.hasClass('medium-popup')) {
+ settings.dialog.width = '50%';
+ settings.dialog.height = '50%';
+ }
+ else if ($el.hasClass('huge-popup')) {
+ settings.dialog.height = '95%';
+ }
+ var dialog = popup(url, settings);
+ $.each(listeners || {}, function(k, v) {
+ dialog.on(k, v);
+ });
+ return dialog;
+ };
// Preprocess all cj ajax calls to display messages
$(document).ajaxSuccess(function(event, xhr, settings) {
var
link = $(this),
optionsChanged = false;
- CRM.loadForm(this.href, {openInline: 'a:not("[href=#], .no-popup")'})
- .on('crmFormSuccess', function() {
+ return !link.crmPopup({
+ crmFormSuccess: function() {
optionsChanged = true;
- })
- .on('dialogclose', function() {
+ },
+ dialogclose: function() {
if (optionsChanged) {
link.trigger('crmOptionsEdited');
var $elects = $('select[data-option-edit-path="' + link.data('option-edit-path') + '"]');
});
}
}
- });
- return false;
+ }
+ });
})
// Handle clear button for form elements
.on('click', 'a.crm-clear-link', function() {
// 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).on('crmFormSuccess', function(e, data) {
- // Refresh page when form completes
- $('#crm-main-content-wrapper').crmSnippet('refresh');
+ return !$(this).crmPopup({
+ crmFormSuccess: function() {
+ // Refresh page when form completes
+ $('#crm-main-content-wrapper').crmSnippet('refresh');
+ }
});
- return false;
});
});
// http://civicrm.org/licensing
-// Controls search form action links and refreshes
-cj(function($) {
- $('#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).on('crmFormSuccess', function (e, data) {
- // Refresh page when form completes
- $('#crm-main-content-wrapper').crmSnippet('refresh');
- });
- return false;
- });
- }
-});
function countSelectedCheckboxes(fldPrefix, form) {
fieldCount = 0;
var buttons = {};
buttons[$link.text()] = function() {
var form2 = CRM.loadForm($link.attr('href'), {
- cancelButton: '.cancel.form-submit, #done',
openInline: 'a.action-item:not([href="#"])',
dialog: {
width: '60%',
- height: parseInt($(window).height() * .8)
+ height: '70%'
}
- }).on('crmLoad', function() {
- $('#done', this).removeAttr('onclick');
- });
+ });
}
$(this).dialog('option', 'buttons', buttons);
}
});
});
cj('#new-menu-item a.button').click(function() {
- CRM.loadForm(this.href).on('crmFormSuccess', function() {
- cj("#navigation-tree").jstree('refresh');
- cj("#reset-menu").show( );
+ return !$(this).crmPopup({
+ crmFormSuccess: function() {
+ cj("#navigation-tree").jstree('refresh');
+ cj("#reset-menu").show( );
+ }
});
- return false;
- })
+ });
});
</script>
{/literal}
});
// Add livePage functionality
$('#crm-container').on('click', 'a.button, a.action-item[href*="action=update"], a.action-item[href*="action=delete"]', function() {
- CRM.loadForm($(this).attr('href'))
- .on('crmFormSuccess', function(e, data) {
+ return !$(this).crmPopup({
+ crmFormSuccess: function() {
// Refresh datatable when form completes
$('#crm-group-selector').dataTable().fnDraw();
- });
- return false;
+ }
+ });
});
});
{* Actions: 1=add, 2=edit, browse=16, delete=8 *}
{if $action ne 1 and $action ne 2 and $action ne 8 and $groupPermission eq 1}
<div class="crm-submit-buttons">
- <a accesskey="N" href="{crmURL p='civicrm/group/add' q='reset=1'}" id="newGroup" class="button"><span><div class="icon add-icon"></div>{ts}Add Group{/ts}</span></a><br/>
+ <a accesskey="N" href="{crmURL p='civicrm/group/add' q='reset=1'}" data-popup-type="page" class="newGroup button"><span><div class="icon add-icon"></div>{ts}Add Group{/ts}</span></a><br/>
</div>
{/if} {* action ne add or edit *}
<div class="crm-block crm-content-block">
{if $action ne 1 and $action ne 2 and $action ne 8 and $groupPermission eq 1}
<div class="crm-submit-buttons">
- <a accesskey="N" href="{crmURL p='civicrm/group/add' q='reset=1'}" id="newGroup" class="button"><span><div class="icon add-icon"></div>{ts}Add Group{/ts}</span></a><br/>
+ <a accesskey="N" href="{crmURL p='civicrm/group/add' q='reset=1'}" data-popup-type="page" class="newGroup button"><span><div class="icon add-icon"></div>{ts}Add Group{/ts}</span></a><br/>
</div>
{/if} {* action ne add or edit *}
</div>
ui.panel
.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 when form completes
+ return !$(this).crmPopup({
+ crmFormSuccess: function() {
+ // Refresh panel when form completes
ui.panel.crmSnippet('refresh');
- });
- return false;
+ }
+ });
});
}
ui.panel