/* global ns */ /** * Create a text field for the form. * * @param {mixed} parent * @param {Object} field * @param {mixed} params * @param {function} setValue * @returns {ns.Textarea} */ ns.Textarea = function (parent, field, params, setValue) { this.parent = parent; this.field = field; this.value = params; this.setValue = setValue; }; /** * Append field to wrapper. * * @param {jQuery} $wrapper * @returns {undefined} */ ns.Textarea.prototype.appendTo = function ($wrapper) { var that = this; this.$item = ns.$(this.createHtml()).appendTo($wrapper); this.$input = this.$item.find('textarea'); this.$errors = this.$item.find('.h5p-errors'); ns.bindImportantDescriptionEvents(this, this.field.name, this.parent); this.$input.change(function () { // Validate var value = that.validate(); if (value !== false) { // Set param that.setValue(that.field, ns.htmlspecialchars(value)); } }); }; /** * Create HTML for the text field. */ ns.Textarea.prototype.createHtml = function () { const id = ns.getNextFieldId(this.field); var input = '