Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
$data.find(':input').each(_.bind(function(index, element) {
const $element = $(element);
let inputName = $element.attr('name');
inputName = inputName.substr(inputName.indexOf('['));
let $modifiedField = this.$newEntity.find('[name$="' + inputName + '"]');
if ($element.is(':checkbox') || $element.is(':radio')) {
$modifiedField = this.$newEntity.find(
'[name$="' + inputName + '"][value="' + $element.val() + '"]'
);
$modifiedField.prop('checked', $element.is(':checked')).change();
} else {
const editor = tinyMCE.get($modifiedField.attr('id'));
if (editor) {
editor.setContent($element.val());
} else {
$modifiedField.val($element.val()).change();
}
}
}, this));
$(textareas).each(function(i, el) {
var editor = tinyMCE.get(el.id);
if (editor) {
editor.setMode($(el).prop('disabled') ? 'readonly' : 'code');
}
});
}
_.each(this.fields, function(el) {
const editor = tinyMCE.get(el.id);
if (editor) {
editor.setContent('');
} else if (el.value) {
el.value = '';
}
});
},
this.$newEntity.find(':input').each(function() {
const $input = $(this);
const editor = tinyMCE.get($input.attr('id'));
$input.data('saved-disabled', $input.prop('disabled'));
$input.prop('disabled', true);
if (editor && !$input.data('saved-disabled')) {
editor.setMode('readonly');
$(editor.editorContainer).addClass('disabled');
$(editor.editorContainer).append('<div class="disabled-overlay"></div>');
}
});
}
enableDisableValue: function($element, enable) {
const $$elementContainer = $element.closest(this.options.selectors.itemValue);
let editor;
if ($$elementContainer.find('.mce-tinymce').length > 0) {
editor = tinyMCE.get($$elementContainer.find('textarea').attr('id'));
}
if (enable) {
$element.removeAttr('disabled');
if (editor) {
editor.setMode('design');
$(editor.editorContainer).removeClass('disabled');
$(editor.editorContainer).children('.disabled-overlay').remove();
}
} else {
$element.attr('disabled', 'disabled');
if (editor) {
editor.setMode('readonly');
$(editor.editorContainer).addClass('disabled');
this.$el.find(this.options.selectors.itemValue).find('.mce-tinymce').each(function() {
tinyMCE.get(self.getValueEl(self.getItemEl(this)).attr('id'))
.on('change', function() {
$(this.targetElm).change();
})
.on('keyup', function() {
$(this.targetElm).change();
});
});
$textareas.each(function(i, el) {
const editor = tinyMCE.get(el.id);
if (editor) {
editor.setMode($(el).prop('disabled') ? 'readonly' : 'code');
}
});
}
this.$el.find(this.options.selectors.itemValue).find('.mce-tinymce').each(function() {
tinyMCE.get(self.getValueEl(self.getItemEl(this)).attr('id'))
.on('change', function() {
$(this.targetElm).change();
})
.on('keyup', function() {
$(this.targetElm).change();
});
});