From: Alexander Ebert Date: Tue, 28 Jun 2016 21:36:45 +0000 (+0200) Subject: Improved debugging ability X-Git-Tag: 3.0.0_Beta_1~1320 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b200fab049e35c103b60d1b363e00e4f9f44416e;p=GitHub%2FWoltLab%2FWCF.git Improved debugging ability --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js index 4cc46b874b..452bd3da77 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js @@ -21,21 +21,21 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges /** * @exports WoltLab/WCF/Ui/ItemList */ - var UiItemList = { + return { /** * Initializes an item list. * * The `values` argument must be empty or contain a list of strings or object, e.g. * `['foo', 'bar']` or `[{ objectId: 1337, value: 'baz'}, {...}]` * - * @param {string} elementId input element id - * @param {array} values list of existing values - * @param {object} options option list + * @param {string} elementId input element id + * @param {Array} values list of existing values + * @param {Object} options option list */ init: function(elementId, values, options) { var element = elById(elementId); if (element === null) { - throw new Error("Expected a valid element id."); + throw new Error("Expected a valid element id, '" + elementId + "' is invalid."); } options = Core.extend({ @@ -95,7 +95,8 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges this._setup(); - var data = this._createUI(element, options, values); + var data = this._createUI(element, options); + //noinspection JSUnresolvedVariable var suggestion = new UiSuggestion(elementId, { ajax: options.ajax, callbackSelect: this._addItem.bind(this), @@ -129,8 +130,8 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges /** * Returns the list of current values. * - * @param {string} elementId input element id - * @return {array} list of objects containing object id and value + * @param {string} elementId input element id + * @return {Array} list of objects containing object id and value */ getValues: function(elementId) { if (!_data.has(elementId)) { @@ -156,8 +157,8 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges /** * Sets the list of current values. * - * @param {string} elementId input element id - * @param {array} values list of objects containing object id and value + * @param {string} elementId input element id + * @param {Array} values list of objects containing object id and value */ setValues: function(elementId, values) { if (!_data.has(elementId)) { @@ -167,13 +168,14 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges var data = _data.get(elementId); // remove all existing items first + var i, length; var items = DomTraverse.childrenByClass(data.list, 'item'); - for (var i = 0, length = items.length; i < length; i++) { + for (i = 0, length = items.length; i < length; i++) { this._removeItem(null, items[i], true); } // add new items - for (var i = 0, length = values.length; i < length; i++) { + for (i = 0, length = values.length; i < length; i++) { this._addItem(elementId, values[i]); } }, @@ -198,15 +200,18 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges * Creates the DOM structure for target element. If `element` is a `