// https://civicrm.org/licensing (function($, _) { 'use strict'; /* jshint validthis: true */ var configRowTpl = _.template($('#config-row-tpl').html()), options; // Weird conflict with drupal styles $('body').removeClass('toolbar'); function format(item) { var icon = ''; if (item.icon) { icon = ''; } return icon + ' ' + item.text; } function initOptions(data) { options = _.filter(data, function(n) { return $.inArray(n.id, CRM.vars.ckConfig.blacklist) < 0; }); addOption(); $.each(CRM.vars.ckConfig.settings, function(key, val) { if ($.inArray(key, CRM.vars.ckConfig.blacklist) < 0) { var $opt = $('.crm-config-option-row:last input.crm-config-option-name'); $opt.val(key).change(); $opt.siblings('span').find(':input').val(val); } }); } function changeOptionName() { var $el = $(this), name = $el.val(); $el.next('span').remove(); if (name) { if (($('input.crm-config-option-name').filter(function() {return !this.value;})).length < 1) { addOption(); } var type = $el.select2('data').type; if (type === 'Boolean') { $el.after(' = '); } else { $el.after(' = '); } } else { $el.closest('div').remove(); } } function addOption() { $('#crm-custom-config-options').append($(configRowTpl({}))); $('div:last input.crm-config-option-name', '#crm-custom-config-options').crmSelect2({ data: {results: options, text: 'id'}, formatSelection: function(field) { return '' + field.id + ' (' + field.type + ')'; }, formatResult: function(field) { return '' + field.id + ' (' + field.type + ')' + '