X7ROOT File Manager
Current Path:
/home/cbholdings/pasukulu/h5p/h5plib/v124/joubel/editor/scripts
home
/
cbholdings
/
pasukulu
/
h5p
/
h5plib
/
v124
/
joubel
/
editor
/
scripts
/
📁
..
📄
h5p-hub-client.js
(331.61 KB)
📄
h5peditor-av.js
(21.38 KB)
📄
h5peditor-boolean.js
(1.99 KB)
📄
h5peditor-coordinates.js
(5.1 KB)
📄
h5peditor-dimensions.js
(4.26 KB)
📄
h5peditor-editor.js
(18.25 KB)
📄
h5peditor-file-uploader.js
(3.69 KB)
📄
h5peditor-file.js
(8.54 KB)
📄
h5peditor-form.js
(14 KB)
📄
h5peditor-fullscreen-bar.js
(2.7 KB)
📄
h5peditor-group.js
(10.39 KB)
📄
h5peditor-html.js
(17.01 KB)
📄
h5peditor-image-popup.js
(12.1 KB)
📄
h5peditor-image.js
(8.09 KB)
📄
h5peditor-init.js
(3.72 KB)
📄
h5peditor-library-list-cache.js
(3.38 KB)
📄
h5peditor-library-selector.js
(9.97 KB)
📄
h5peditor-library.js
(16.98 KB)
📄
h5peditor-list-editor.js
(10.4 KB)
📄
h5peditor-list.js
(9.08 KB)
📄
h5peditor-metadata-author-widget.js
(3.91 KB)
📄
h5peditor-metadata-changelog-widget.js
(7.5 KB)
📄
h5peditor-metadata.js
(14.66 KB)
📄
h5peditor-none.js
(918 B)
📄
h5peditor-number.js
(4.79 KB)
📄
h5peditor-pre-save.js
(3.62 KB)
📄
h5peditor-select.js
(3.24 KB)
📄
h5peditor-selector-hub.js
(7.76 KB)
📄
h5peditor-selector-legacy.js
(3.11 KB)
📄
h5peditor-semantic-structure.js
(7.39 KB)
📄
h5peditor-text.js
(3.15 KB)
📄
h5peditor-textarea.js
(2.68 KB)
📄
h5peditor.js
(53.53 KB)
Editing: h5peditor-text.js
/* global ns */ /** * Create a text field for the form. * * @param {mixed} parent * @param {Object} field * @param {mixed} params * @param {function} setValue * @returns {ns.Text} */ ns.Text = function (parent, field, params, setValue) { this.field = field; this.value = params; this.setValue = setValue; this.changeCallbacks = []; }; /** * Append field to wrapper. * * @param {type} $wrapper * @returns {undefined} */ ns.Text.prototype.appendTo = function ($wrapper) { var that = this; this.$item = ns.$(this.createHtml()).appendTo($wrapper); this.$input = this.$item.find('input'); this.$errors = this.$item.children('.h5p-errors'); this.$input.change(function () { // Validate var value = that.validate(); if (value !== false) { // Set param if (H5P.trim(value) === '') { // Avoid storing empty strings. (will be valid if field is optional) delete that.value; that.setValue(that.field); } else { that.value = value; that.setValue(that.field, ns.htmlspecialchars(value)); } for (var i = 0; i < that.changeCallbacks.length; i++) { that.changeCallbacks[i](value); } } }); }; /** * Run callback when value changes. * * @param {function} callback * @returns {Number|@pro;length@this.changeCallbacks} */ ns.Text.prototype.change = function (callback) { this.changeCallbacks.push(callback); callback(); return this.changeCallbacks.length - 1; }; /** * Create HTML for the text field. */ ns.Text.prototype.createHtml = function () { const id = ns.getNextFieldId(this.field); const descriptionId = (this.field.description !== undefined ? ns.getDescriptionId(id) : undefined) var input = ns.createText(this.value, this.field.maxLength, this.field.placeholder, id, descriptionId); return ns.createFieldMarkup(this.field, input, id); }; /** * Validate the current text field. */ ns.Text.prototype.validate = function () { var that = this; var value = H5P.trim(this.$input.val()); var valid = true; // Clear errors before showing new ones this.$errors.html(''); if ((that.field.optional === undefined || !that.field.optional) && !value.length) { this.$errors.append(ns.createError(ns.t('core', 'requiredProperty', {':property': ns.t('core', 'textField')}))); valid = false; } else if (value.length > this.field.maxLength) { this.$errors.append(ns.createError(ns.t('core', 'tooLong', {':max': this.field.maxLength}))); valid = false; } else if (this.field.regexp !== undefined && value.length && !value.match(new RegExp(this.field.regexp.pattern, this.field.regexp.modifiers))) { this.$errors.append(ns.createError(ns.t('core', 'invalidFormat'))); valid = false; } this.$input.toggleClass('error', !valid); return ns.checkErrors(this.$errors, this.$input, value); }; /** * Remove this item. */ ns.Text.prototype.remove = function () { this.$item.remove(); }; /** * When someone from the outside wants to set a value. * * @param {string} value */ ns.Text.prototype.forceValue = function (value) { this.$input.val(value).change(); }; // Tell the editor what widget we are. ns.widgets.text = ns.Text;
Upload File
Create Folder