Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XWIKI-22540: Slow loading time when changing the icons theme to Silk in the Icon picker #3537

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ define('xwiki-iconService', [
return;
}

$.getJSON(getResourceURL('data_icons', {iconTheme}), function (dataIcons) {
$.getJSON(getResourceURL('data_icons', {iconTheme, 'metadata': 'true'}), function (dataIcons) {
cachedIcons[iconTheme] = dataIcons;
resolve(dataIcons);
}).fail(reject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
#set($icon = {})
#set($discard = $icon.put('name', $xwikiIcon))
#set($discard = $icon.put('render', $services.icon.renderHTML($xwikiIcon, $iconTheme)))
#set($discard = $icon.put('metadata', $services.icon.getMetaData($xwikiIcon, $iconTheme)))
#if($request.metadata == 'true')
#set($discard = $icon.put('metadata', $services.icon.getMetaData($xwikiIcon, $iconTheme)))
#end
#set($discard = $icons.add($icon))
#end
#jsonResponse($icons)
Expand Down Expand Up @@ -230,24 +232,25 @@ require(['jquery', 'xwiki-icon-picker'], function($) {
/**
* Display the list of icons
*/
var displayList = function(iconTheme) {
var displayList = function(iconList) {
// Filter the icons we display based on the value of the input field.
let selectedIconName = '';
if (currentInput.data('xwikiIconPickerSettings') !== '') {
selectedIconName = currentInput[0].value.replace(currentInput.data('xwikiIconPickerSettings').prefix, '');
}
// For each icon
for (var i=0; i < iconTheme.length; ++i) {
for (var i=0; i < iconList.length; ++i) {
let icon = iconList[i];
// Display the icon
if (selectedIconName === '' || iconTheme[i].name.includes(selectedIconName)) {
if (selectedIconName === '' || icon.name.includes(selectedIconName)) {
var displayer = $(document.createElement('div'));
iconListSection.append(displayer);
displayer.addClass('xwikiIconPickerIcon');
var imageDiv = $(document.createElement('div'));
imageDiv.addClass('xwikiIconPickerIconImage').html(iconTheme[i].render);
imageDiv.addClass('xwikiIconPickerIconImage').html(icon.render);
displayer.append(imageDiv);
var iconNameSpan = $(document.createElement('span'));
iconNameSpan.addClass('xwikiIconPickerIconName').text(iconTheme[i].name);
iconNameSpan.addClass('xwikiIconPickerIconName').text(icon.name);
displayer.append(iconNameSpan);
// Change the input value when the icon is clicked
displayer.on('click', function(event) {
Expand Down