X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=js%2FCommon.js;h=c2134fa8023c70e7a2767e77d91ddac82819d7b9;hb=972bd8974a95be4fc46957a7f748e5beab1583dc;hp=dcf7b18e3fcdc590d0004db8710965007f7f5cbe;hpb=0f1428e71dd43dc0b146d18a64aa51cd7ac832da;p=civicrm-core.git
diff --git a/js/Common.js b/js/Common.js
index dcf7b18e3f..c2134fa802 100644
--- a/js/Common.js
+++ b/js/Common.js
@@ -201,8 +201,9 @@ function showHideRow(index) {
/* jshint ignore:end */
-CRM.utils = CRM.utils || {};
-CRM.strings = CRM.strings || {};
+if (!CRM.utils) CRM.utils = {};
+if (!CRM.strings) CRM.strings = {};
+if (!CRM.vars) CRM.vars = {};
(function ($, _, undefined) {
"use strict";
@@ -590,6 +591,9 @@ CRM.strings = CRM.strings || {};
});
}
+ /**
+ * @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker
+ */
$.fn.crmDatepicker = function(options) {
return $(this).each(function() {
if ($(this).is('.crm-form-date-wrapper .crm-hidden-date')) {
@@ -603,8 +607,8 @@ CRM.strings = CRM.strings || {};
$timeField = $(),
$clearLink = $();
- if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.hasClass('required')) {
- $clearLink = $('')
+ if (settings.allowClear !== undefined ? settings.allowClear : !$dataField.is('.required, [required]')) {
+ $clearLink = $('')
.insertAfter($dataField);
}
if (settings.time !== false) {
@@ -623,15 +627,15 @@ CRM.strings = CRM.strings || {};
$dateField = $('').insertAfter($dataField);
copyAttributes($dataField, $dateField, ['placeholder', 'style', 'class', 'disabled']);
$dateField.addClass('crm-form-text crm-form-date');
- settings.dateFormat = settings.dateFormat || CRM.config.dateInputFormat;
- settings.changeMonth = _.includes('m', settings.dateFormat);
- settings.changeYear = _.includes('y', settings.dateFormat);
+ settings.date = typeof settings.date === 'string' ? settings.date : CRM.config.dateInputFormat;
+ settings.changeMonth = _.includes('m', settings.date);
+ settings.changeYear = _.includes('y', settings.date);
$dateField.datepicker(settings).change(updateDataField);
}
// Rudimentary validation. TODO: Roll into use of jQUery validate and ui.datepicker.validation
function isValidDate() {
try {
- $.datepicker.parseDate(settings.dateFormat, $dateField.val());
+ $.datepicker.parseDate(settings.date, $dateField.val());
return true;
} catch (e) {
return false;
@@ -873,7 +877,19 @@ CRM.strings = CRM.strings || {};
})
.find('input.select-row:checked').parents('tr').addClass('crm-row-selected');
$('table.crm-sortable', e.target).DataTable();
- $('table.crm-ajax-table', e.target).crmAjaxTable();
+ $('table.crm-ajax-table', e.target).each(function() {
+ var
+ $table = $(this),
+ $accordion = $table.closest('.crm-accordion-wrapper.collapsed, .crm-collapsible.collapsed');
+ // For tables hidden by collapsed accordions, wait.
+ if ($accordion.length) {
+ $accordion.one('crmAccordion:open', function() {
+ $table.crmAjaxTable();
+ });
+ } else {
+ $table.crmAjaxTable();
+ }
+ });
if ($("input:radio[name=radio_ts]").size() == 1) {
$("input:radio[name=radio_ts]").prop("checked", true);
}
@@ -904,7 +920,7 @@ CRM.strings = CRM.strings || {};
}
// Add resize button
if ($el.parent().hasClass('crm-container') && $el.dialog('option', 'resizable')) {
- $el.parent().find('.ui-dialog-titlebar').append($('').button({icons: {primary: 'ui-icon-newwin'}, text: false}));
+ $el.parent().find('.ui-dialog-titlebar').append($('').button({icons: {primary: 'fa-expand'}, text: false}));
$('.crm-dialog-titlebar-resize', $el.parent()).click(function(e) {
if ($el.data('origSize')) {
$el.dialog('option', $el.data('origSize'));
@@ -944,8 +960,7 @@ CRM.strings = CRM.strings || {};
$.fn.crmtooltip = function () {
$(document)
.on('mouseover', 'a.crm-summary-link:not(.crm-processed)', function (e) {
- $(this).addClass('crm-processed');
- $(this).addClass('crm-tooltip-active');
+ $(this).addClass('crm-processed crm-tooltip-active');
var topDistance = e.pageY - $(window).scrollTop();
if (topDistance < 300 || topDistance < $(this).children('.crm-tooltip-wrapper').height()) {
$(this).addClass('crm-tooltip-down');
@@ -958,8 +973,7 @@ CRM.strings = CRM.strings || {};
}
})
.on('mouseout', 'a.crm-summary-link', function () {
- $(this).removeClass('crm-processed');
- $(this).removeClass('crm-tooltip-active crm-tooltip-down');
+ $(this).removeClass('crm-processed crm-tooltip-active crm-tooltip-down');
})
.on('click', 'a.crm-summary-link', false);
};
@@ -1135,7 +1149,7 @@ CRM.strings = CRM.strings || {};
buttons.push({
text: label,
'data-op': op,
- icons: {primary: op === 'no' ? 'ui-icon-close' : 'ui-icon-check'},
+ icons: {primary: op === 'no' ? 'fa-times' : 'fa-check'},
click: function() {
var event = $.Event('crmConfirm:' + op);
$(this).trigger(event);
@@ -1314,15 +1328,6 @@ CRM.strings = CRM.strings || {};
messagesFromMarkup.call($('#crm-container'));
}
- // Hide CiviCRM menubar when editor is fullscreen
- if (window.CKEDITOR) {
- CKEDITOR.on('instanceCreated', function (e) {
- e.editor.on('maximize', function (e) {
- $('#civicrm-menu').toggle(e.data === 2);
- });
- });
- }
-
$('body')
// bind the event for image popup
.on('click', 'a.crm-image-popup', function(e) {
@@ -1361,13 +1366,15 @@ CRM.strings = CRM.strings || {};
})
// Handle accordions
.on('click.crmAccordions', '.crm-accordion-header, .crm-collapsible .collapsible-title', function (e) {
+ var action = 'open';
if ($(this).parent().hasClass('collapsed')) {
$(this).next().css('display', 'none').slideDown(200);
}
else {
$(this).next().css('display', 'block').slideUp(200);
+ action = 'close';
}
- $(this).parent().toggleClass('collapsed');
+ $(this).parent().toggleClass('collapsed').trigger('crmAccordion:' + action);
e.preventDefault();
});
@@ -1380,13 +1387,15 @@ CRM.strings = CRM.strings || {};
*/
$.fn.crmAccordionToggle = function (speed) {
$(this).each(function () {
+ var action = 'open';
if ($(this).hasClass('collapsed')) {
$('.crm-accordion-body', this).first().css('display', 'none').slideDown(speed);
}
else {
$('.crm-accordion-body', this).first().css('display', 'block').slideUp(speed);
+ action = 'close';
}
- $(this).toggleClass('collapsed');
+ $(this).toggleClass('collapsed').trigger('crmAccordion:' + action);
});
};