-
-
Notifications
You must be signed in to change notification settings - Fork 552
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-21878: Various close button modals do not use intended icons #2888
Changes from 1 commit
883e07d
6af9611
b95e57d
0bfc237
505952d
b1e19f5
f6c9424
44e650d
217df8a
9546f19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,40 @@ define('modalTranslationKeys', [], [ | |
|
||
define('modal', ['jquery', 'l10n!modal', 'bootstrap'], function($, translations) { | ||
'use strict'; | ||
var modalTemplate = | ||
// Fetch the cross icon from the icon theme to fill up the modal template. | ||
let iconURL = `${XWiki.contextPath}/rest/wikis/${XWiki.currentWiki}/iconThemes/icons?name=cross`; | ||
let iconRequest = new XMLHttpRequest(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason to not use a jquery There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No specific reason. I don't have much experience with async javascript and API calls yet. I'll spend some time to try and use jquery instead 👍 |
||
let iconMetadata; | ||
// Default value taken until the fetch is fulfilled | ||
var closeIconTemplate = `<span aria-hidden="true">×</span>`; | ||
iconRequest.onreadystatechange = function() { | ||
if (iconRequest.readyState === 4 && iconRequest.status === 200 ) { | ||
let response = iconRequest.responseXML; | ||
iconMetadata = response.getElementsByTagName('icon')[0]; | ||
if (iconMetadata.getElementsByTagName('iconSetType')[0].textContent === 'IMAGE') { | ||
closeIconTemplate = '<img src="' + iconMetadata.getElementsByTagName('url')[0].textContent + | ||
'" alt="" />'; | ||
} | ||
else if (iconMetadata.getElementsByTagName('iconSetType')[0].textContent === 'FONT') { | ||
closeIconTemplate = '<span class="' + | ||
iconMetadata.getElementsByTagName('cssClass')[0].textContent + | ||
'" aria-hidden="true"></span>'; | ||
} | ||
console.log(closeIconTemplate); | ||
} | ||
// We update the places where the modalTemplate has already been instanced with the asynchronously retrieved value | ||
$('.modal').find('.close').html(closeIconTemplate); | ||
}; | ||
iconRequest.open('GET', iconURL); | ||
iconRequest.send(); | ||
|
||
let modalTemplate = | ||
'<div class="modal" tabindex="-1" role="dialog" data-backdrop="static">' + | ||
'<div class="modal-dialog" role="document">' + | ||
'<div class="modal-content">' + | ||
'<div class="modal-header">' + | ||
'<button type="button" class="close" data-dismiss="modal" aria-label="Close">' + | ||
'<span aria-hidden="true">×</span>' + | ||
closeIconTemplate + | ||
'</button>' + | ||
'<h4 class="modal-title"></h4>' + | ||
'</div>' + | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the wiki name should be URL-encoded to protect against wiki names with special characters (not sure if we allow them, though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/search?q=repo%3Axwiki%2Fxwiki-platform%20%24%7BXWiki.currentWiki%7D&type=code
It's already used a few times in the codebase.
I took the opportunity to fix those other uses in 4 files in 217df8a .
I rebuilt the ckeditor plugin with the change, and it didn't break anything when testing on the main wiki :)