diff --git a/kbase-extension/static/kbase/js/kbwidget.js b/kbase-extension/static/kbase/js/kbwidget.js index 7dbac9312a..dbffc7430e 100644 --- a/kbase-extension/static/kbase/js/kbwidget.js +++ b/kbase-extension/static/kbase/js/kbwidget.js @@ -27,7 +27,7 @@ return KBWidget( version : "1.0.0", //future proofing, but completely unused _accessors : [ //optional. A list of values to automatically create setter/getters for. - 'foo' //you'll now be able to store something at $widget.foo('newValue') and access it via var foo = $widget.foo(); + 'foo' //you'll now be able to store something at $widget.foo('newValue') and access it via const foo = $widget.foo(); {name : 'bar', setter : 'setBar', getter : 'getBar'} // the setter/getter can also be overridden If these functions are not // defined in your object, you'll get default implementations. Add new methods // in the object body for specific behavior. See the caveat about bindings and notifications @@ -59,14 +59,14 @@ return KBWidget( Instantiate as follows: -var $fancy = $('some-jquery-selector').myFancyNewWidget( +const $fancy = $('some-jquery-selector').myFancyNewWidget( { bar : 7 } ); -var foo = $fancy.foo(); -var $element = $fancy.$elem; //is the same as $('some-jquery-selector'); +const foo = $fancy.foo(); +const $element = $fancy.$elem; //is the same as $('some-jquery-selector'); You get a lot of methods availabe by default: @@ -198,7 +198,7 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { }; const makeBindingBlurCallback = function (elem, $target, attribute, transformers, accessors) { - return $.proxy(function (e, vals) { + return $.proxy(function (e) { if (e.type === 'keypress' && e.which !== 13) { return; } @@ -410,15 +410,15 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { return $(tag); }; - const KBWidget = function (def) { + var KBWidget = function (def) { def = def || {}; - var Widget = function ($elem) { + const Widget = function ($elem) { let self = this; //XXX THIS IS FOR BACKWARDS COMPATIBILITY WITH JQUERY PLUGIN SYNTAX __ONLY__ if (!(this instanceof Widget)) { - var args = $elem; + const args = $elem; self = new Widget(this, args); $elem = this; if (window.console) { @@ -443,7 +443,7 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { $elem.get(0).kb_obj = self; } - var args = Array.prototype.slice.call(arguments, 1); + const args = Array.prototype.slice.call(arguments, 1); $elem[def.name] = function (method) { if (window.console) { @@ -471,7 +471,6 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { Widget.prototype.__attributes = {}; if (defCopy._accessors !== undefined) { - //for (var accessor in defCopy._accessors) { $.each( defCopy._accessors, $.proxy((idx, accessor) => { @@ -615,15 +614,13 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { const opts = $.extend(true, {}, this.options); this.options = $.extend(true, {}, opts, args); - let arg; - for (arg in args) { + for (const arg in args) { if (args[arg] === undefined && this.options[arg] !== undefined) { delete this.options[arg]; } } - let attribute; - for (attribute in this.__attributes) { + for (const attribute in this.__attributes) { if (this.options[attribute] !== undefined) { const setter = this.__attributes[attribute].setter; this[setter](this.options[attribute]); @@ -645,12 +642,12 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { if (this.options.template) { $.ajax(this.options.template) .done( - $.proxy(function (res) { + $.proxy(function () { this.templateSuccess.apply(this, arguments); }, this) ) .fail( - $.proxy(function (res) { + $.proxy(function () { this.templateFailure.apply(this, arguments); }, this) ); @@ -662,10 +659,7 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { templateSuccess: function (templateString) { const template = Handlebars.compile(templateString); - const html = template(); - const res = template(this.templateContent()); - const $res = $.jqElem('span').append(res); this._rewireIds($res, this); @@ -727,7 +721,7 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { setValuesForKeys: function setValuesForKeys(obj) { const objCopy = $.extend({}, obj); - for (attribute in this.__attributes) { + for (const attribute in this.__attributes) { if (objCopy[attribute] !== undefined) { const setter = this.__attributes[attribute].setter; this[setter](objCopy[attribute]); @@ -769,7 +763,7 @@ define(['jquery', 'handlebars'], ($, Handlebars) => { $elem.removeAttr('id'); } - $.each($elem.find('[id]'), function (idx) { + $.each($elem.find('[id]'), function () { $target.data($(this).attr('id'), $(this)); $(this).attr('data-id', $(this).attr('id')); $(this).removeAttr('id'); diff --git a/kbase-extension/static/kbase/js/widgets/function_input/kbStandaloneListselect.js b/kbase-extension/static/kbase/js/widgets/function_input/kbStandaloneListselect.js index cf26054084..ec189ac8fa 100644 --- a/kbase-extension/static/kbase/js/widgets/function_input/kbStandaloneListselect.js +++ b/kbase-extension/static/kbase/js/widgets/function_input/kbStandaloneListselect.js @@ -1,4 +1,4 @@ -/* +/* Listselect Renderer Provides a select list that allows the selection of one or multiple data items that can be filtered by their attributes. The attribute to be filtered will be displayed as the label in the selection list. Filters can be chained by pressing the enter key in the filter box. @@ -140,7 +140,7 @@ render: function (index) { const renderer = rendererListselect[index]; - + let button_span, result_list; if (renderer.settings.navigation_url) { renderer.settings.navigation_callback = renderer.update_data; } @@ -231,14 +231,9 @@ renderer.settings.filter_attribute + ' '; const filter_list = document.createElement('ul'); filter_list.setAttribute('class', 'dropdown-menu'); - filter_list.setAttribute( - 'style', - renderer.settings.extra_wide - ? 'max-height: 200px; overflow: auto;' - : 'max-height: 200px; overflow: auto;' - ); + filter_list.setAttribute('style', 'max-height: 200px; overflow: auto;'); let filter_string = ''; - for (var i = 0; i < renderer.settings.filter.length; i++) { + for (let i = 0; i < renderer.settings.filter.length; i++) { filter_string += '
  • x'; - bc_button.addEventListener('click', function (event) { + bc_button.addEventListener('click', function () { rendererListselect[index].removeBreadcrumb(this, index); }); filter_breadcrumbs.appendChild(bc_button); @@ -285,7 +280,7 @@ // check for multi-select vs single select if (renderer.settings.multiple) { // create the result list - var result_list = document.createElement('select'); + const result_list = document.createElement('select'); result_list.setAttribute('multiple', ''); result_list.setAttribute('style', 'width: 415px'); result_list.setAttribute('size', renderer.settings.rows); @@ -294,7 +289,7 @@ renderer.redrawResultlist(result_list, index); // create the action buttons - var button_span = document.createElement('span'); + button_span = document.createElement('span'); button_span.setAttribute('style', 'position: relative; bottom: 100px;'); const button_left = document.createElement('a'); button_left.setAttribute('class', 'btn btn-small btn-default'); @@ -411,12 +406,12 @@ ? renderer.settings.button.icon : ''); if (typeof renderer.settings.callback == 'function') { - var index = renderer.index; + const index = renderer.index; if (renderer.settings.multiple) { submit_button.addEventListener('click', () => { const selection_result = []; if (renderer.settings.return_object) { - for (var x = 0; x < result_list.options.length; x++) { + for (let x = 0; x < result_list.options.length; x++) { for (let y = 0; y < renderer.settings.data.length; y++) { if ( result_list.options[x].value == @@ -428,7 +423,7 @@ } } } else { - for (var x = 0; x < result_list.options.length; x++) { + for (let x = 0; x < result_list.options.length; x++) { selection_result.push(result_list.options[x].value); } } @@ -550,7 +545,7 @@ redrawResultlist: function (result_list, index) { const renderer = rendererListselect[index]; const result_list_array = []; - for (var i = 0; i < renderer.settings.selection_data.length; i++) { + for (let i = 0; i < renderer.settings.selection_data.length; i++) { result_list_array.push([ renderer.settings.selection_data[i][renderer.settings.value], '