$el.crmSelect2($.extend(settings, $el.data('select-params'), selectParams))
.on('select2-selecting.crmEntity', function(e) {
if (e.val === "0") {
+ // Create a new term
e.object.label = e.object.term;
CRM.api3(entity, 'create', $.extend({name: e.object.term}, $el.data('api-params').params || {}))
.done(function(created) {
var
- multiple = !!$el.data('select-params').multiple,
val = $el.select2('val'),
data = $el.select2('data'),
item = {id: created.id, label: e.object.term};
$el.addClass('modal-dialog');
$('body').css({overflow: 'hidden'});
}
- $el.parent().find('.ui-dialog-titlebar-close').attr('title', ts('Close'));
// Add resize button
if ($el.parent().hasClass('crm-container') && $el.dialog('option', 'resizable')) {
$el.parent().find('.ui-dialog-titlebar').append($('<button class="crm-dialog-titlebar-resize ui-dialog-titlebar-close" title="'+ts('Toggle fullscreen')+'" style="right:2em;"/>').button({icons: {primary: 'ui-icon-newwin'}, text: false}));
}
advmultiselectResize();
- $(window).resize(function () {
- advmultiselectResize();
- });
+ $(window).resize(advmultiselectResize);
$.fn.crmtooltip = function () {
$(document)
* @see https://wiki.civicrm.org/confluence/display/CRMDOC/Notification+Reference
*/
CRM.confirm = function (options) {
- var dialog, url, msg, settings = {
+ var dialog, url, msg, buttons = [], settings = {
title: ts('Confirm'),
message: ts('Are you sure you want to continue?'),
url: null,
};
$.extend(settings, ($.isFunction(options) ? arguments[1] : options) || {});
if (!settings.buttons && $.isPlainObject(settings.options)) {
- settings.buttons = [];
- $.each(settings.options, function(key, label) {
- settings.buttons.push({
+ $.each(settings.options, function(op, label) {
+ buttons.push({
text: label,
- icons: {primary: key === 'no' ? 'ui-icon-close' : 'ui-icon-check'},
+ 'data-op': op,
+ icons: {primary: op === 'no' ? 'ui-icon-close' : 'ui-icon-check'},
click: function() {
- var event = $.Event('crmConfirm:' + key);
+ var event = $.Event('crmConfirm:' + op);
$(this).trigger(event);
if (!event.isDefaultPrevented()) {
dialog.dialog('close');
}
});
});
+ // Order buttons so that "no" goes on the right-hand side
+ settings.buttons = _.sortBy(buttons, 'data-op').reverse();
}
url = settings.url;
msg = settings.message;