diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2024-06-28 09:23:03 +0200 |
---|---|---|
committer | Szymon Kłos <eszkadev@gmail.com> | 2024-06-28 11:29:52 +0200 |
commit | 201cc5c2497ac3cf914464510dd4d4a391933212 (patch) | |
tree | ed86c8eea1df87726c76ebc4cc1a5d53a11f4e93 | |
parent | jsdialog: support generic rendered_entry action (diff) | |
download | online-201cc5c2497ac3cf914464510dd4d4a391933212.tar.gz online-201cc5c2497ac3cf914464510dd4d4a391933212.zip |
iconview: use const
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I895e5d1166c6463df33b1ba68c6717c342a8c1be
-rw-r--r-- | browser/src/control/jsdialog/Widget.IconView.ts | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/browser/src/control/jsdialog/Widget.IconView.ts b/browser/src/control/jsdialog/Widget.IconView.ts index 01ed2b0040..d9109d0c6f 100644 --- a/browser/src/control/jsdialog/Widget.IconView.ts +++ b/browser/src/control/jsdialog/Widget.IconView.ts @@ -31,7 +31,7 @@ function _iconViewEntry( entry: IconViewEntry, builder: any, ) { - var disabled = parentData.enabled === false; + const disabled = parentData.enabled === false; if (entry.separator && entry.separator === true) { L.DomUtil.create( @@ -42,7 +42,7 @@ function _iconViewEntry( return; } - var entryContainer = L.DomUtil.create( + const entryContainer = L.DomUtil.create( 'div', builder.options.cssClass + ' ui-iconview-entry', parentContainer, @@ -50,14 +50,18 @@ function _iconViewEntry( if (entry.selected && entry.selected === true) $(entryContainer).addClass('selected'); - var icon = L.DomUtil.create( + const icon = L.DomUtil.create( 'div', builder.options.cssClass + ' ui-iconview-icon', entryContainer, ); if (entry.ondemand) { - var placeholder = L.DomUtil.create('span', builder.options.cssClass, icon); + const placeholder = L.DomUtil.create( + 'span', + builder.options.cssClass, + icon, + ); placeholder.innerText = entry.text; if (entry.tooltip) placeholder.title = entry.tooltip; else placeholder.title = entry.text; @@ -71,7 +75,7 @@ function _iconViewEntry( entry.text, ); } else { - var img = L.DomUtil.create('img', builder.options.cssClass, icon); + const img = L.DomUtil.create('img', builder.options.cssClass, icon); if (entry.image) img.src = entry.image; img.alt = entry.text; if (entry.tooltip) img.title = entry.tooltip; @@ -79,7 +83,7 @@ function _iconViewEntry( } if (!disabled) { - var singleClick = parentData.singleclickactivate === true; + const singleClick = parentData.singleclickactivate === true; $(entryContainer).click(function () { $('#' + parentData.id + ' .ui-treeview-entry').removeClass('selected'); builder.callback('iconview', 'select', parentData, entry.row, builder); @@ -114,22 +118,22 @@ JSDialog.iconView = function ( data: IconViewJSON, builder: any, ) { - var container = L.DomUtil.create( + const container = L.DomUtil.create( 'div', builder.options.cssClass + ' ui-iconview', parentContainer, ); container.id = data.id; - var disabled = data.enabled === false; + const disabled = data.enabled === false; if (disabled) L.DomUtil.addClass(container, 'disabled'); - for (var i in data.entries) { + for (const i in data.entries) { _iconViewEntry(container, data, data.entries[i], builder); } - var firstSelected = $(container).children('.selected').get(0); - var blockOption = JSDialog._scrollIntoViewBlockOption('nearest'); + const firstSelected = $(container).children('.selected').get(0); + const blockOption = JSDialog._scrollIntoViewBlockOption('nearest'); if (firstSelected) firstSelected.scrollIntoView({ behavior: 'smooth', @@ -140,14 +144,14 @@ JSDialog.iconView = function ( container.onSelect = (position: number) => { $(container).children('.selected').removeClass('selected'); - var entry = + const entry = container.children.length > position ? container.children[position] : null; if (entry) { L.DomUtil.addClass(entry, 'selected'); - var blockOption = JSDialog._scrollIntoViewBlockOption('nearest'); + const blockOption = JSDialog._scrollIntoViewBlockOption('nearest'); entry.scrollIntoView({ behavior: 'smooth', block: blockOption, @@ -160,10 +164,10 @@ JSDialog.iconView = function ( }; container.updateRenders = (pos: number) => { - var dropdown = container.querySelectorAll('.ui-iconview-entry'); + const dropdown = container.querySelectorAll('.ui-iconview-entry'); if (dropdown[pos]) { dropdown[pos].innerHTML = ''; - var img = L.DomUtil.create('img', '', dropdown[pos]); + const img = L.DomUtil.create('img', '', dropdown[pos]); img.src = builder.rendersCache[data.id].images[pos]; const entry = data.entries[pos]; |