'click .crm-profile-selector-edit': 'doEdit',
'click .crm-profile-selector-copy': 'doCopy',
'click .crm-profile-selector-create': 'doCreate',
+ 'click .crm-profile-selector-preview': 'doShowPreview',
// prevent interaction with preview form
'click .crm-profile-selector-preview-pane': false,
'crmLoad .crm-profile-selector-preview-pane': 'disableForm'
this.selectRegion.show(view);
this.setUfGroupId(this.options.ufGroupId, {silent: true});
this.toggleButtons();
+ this.$('.crm-profile-selector-select select').css('width', '25em').crmSelect2();
+ this.doShowPreview();
},
onChangeUfGroupId: function(event) {
this.options.ufGroupId = $(event.target).val();
setUfGroupId: function(value, options) {
this.options.ufGroupId = value;
this.$('.crm-profile-selector-select select').val(value);
- if (!options || !options.silent) {
- this.$('.crm-profile-selector-select select').change();
- }
+ this.$('.crm-profile-selector-select select').select2('val', value, (!options || !options.silent));
},
getUfGroupId: function() {
return this.options.ufGroupId;
CRM.loadPage(CRM.url("civicrm/ajax/inline", {class_name: 'CRM_UF_Form_Inline_PreviewById', id: this.getUfGroupId()}), {target: $pane});
}
},
+ doShowPreview: function() {
+ var $preview = this.$('.crm-profile-selector-preview');
+ var $pane = this.$('.crm-profile-selector-preview-pane');
+ if ($preview.hasClass('crm-profile-selector-preview-show')) {
+ $preview.removeClass('crm-profile-selector-preview-show');
+ $pane.show();
+ } else {
+ $preview.addClass('crm-profile-selector-preview-show');
+ $pane.hide();
+ }
+ },
disableForm: function() {
this.$(':input', '.crm-profile-selector-preview-pane').prop('readOnly', true);
},