Skip to content

Commit

Permalink
Feature #12713 fixing sonar feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverYoCha committed Mar 1, 2022
1 parent 832b792 commit 94c9c98
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 18 deletions.
Expand Up @@ -188,6 +188,7 @@
});
},
close : function(props) {
// Nothing to do here
}
},
},
Expand Down
Expand Up @@ -75,7 +75,10 @@
width : '600px',
height : '400px',
playerParameters : undefined,
messageEventHandler : undefined
messageEventHandlerConfig : {
origin : undefined,
handler : undefined
}
};
const config = $.extend({}, defaultParams);
$.extend(config, options);
Expand Down Expand Up @@ -117,11 +120,21 @@
$iframe.setAttribute('mozallowfullscreen', 'true');
$iframe.setAttribute('allowfullscreen', 'true');
$container.append(jQuery($iframe));
if (typeof config.messageEventHandler === 'function') {
$iframe.contentWindow.addEventListener("message", function (event) {
event.$iframe = $iframe;
config.messageEventHandler(event);
}, false);
const messageEventHandlerConfig = config.messageEventHandlerConfig;
if (typeof messageEventHandlerConfig === 'object') {
if (StringUtil.isNotDefined(messageEventHandlerConfig.origin)) {
const errorMsg = "silverpeas-embed-player - config.messageEventHandlerConfig.origin MUST be defined";
sp.log.error(errorMsg);
throw new Error(errorMsg);
}
if (typeof messageEventHandlerConfig.handler === 'function') {
$iframe.contentWindow.addEventListener("message", function(event) {
if (event.origin === messageEventHandlerConfig.origin) {
event.$iframe = $iframe;
messageEventHandlerConfig.handler(event);
}
}, false);
}
}
}, 0)
}
Expand Down
Expand Up @@ -26,10 +26,6 @@
width: 60px;
}

.image-selector-container .thumbnail {
width: 60px;
}

.image-url {
display: flex;
gap: 10px;
Expand Down
Expand Up @@ -68,14 +68,14 @@ public void init() {
add(IFRAMEAJAXTRANSPORT, (x, l) -> includeIFrameAjaxTransport(x));
add(PREVIEW, (x, l) -> includePreview(x));
add(FPVIEWER, (x, l) -> includeFlexPaperViewer(x));
add(PDFVIEWER, (x, l) -> JavascriptPluginInclusion.includePdfViewer(x));
add(PDFVIEWER, (x, l) -> includePdfViewer(x));
add(NOTIFIER, (x, l) -> includeNotifier(x));
add(PASSWORD, (x, l) -> includePassword(x));
add(GAUGE, (x, l) -> includeGauge(x));
add(JQUERY, (x, l) -> includeJQuery(x));
add(TAGS, (x, l) -> includeTags(x));
add(PDC, (x, l) -> JavascriptPluginInclusion.includePdc(x, l, false));
add(PDCDYNAMICALLY, (x, l) -> JavascriptPluginInclusion.includePdc(x, l, true));
add(PDC, (x, l) -> includePdc(x, l, false));
add(PDCDYNAMICALLY, (x, l) -> includePdc(x, l, true));
add(TKN, (x, l) -> includeSecurityTokenizing(x));
add(RATING, (x, l) -> includeRating(x));
add(TOGGLE, (x, l) -> includeToggle(x));
Expand All @@ -85,10 +85,10 @@ public void init() {
add(LANG, (x, l) -> includeLang(x));
add(TICKER, JavascriptPluginInclusion::includeTicker);
add(SUBSCRIPTION, JavascriptPluginInclusion::includeDynamicallySubscription);
add(CONTRIBUTIONMODICTX, (x, l) -> JavascriptPluginInclusion.includeContributionModificationContext(x));
add(CONTRIBUTIONMODICTX, (x, l) -> includeContributionModificationContext(x));
add(DRAGANDDROPUPLOAD, JavascriptPluginInclusion::includeDragAndDropUpload);
add(IMAGESELECTOR, JavascriptPluginInclusion::includeImageSelector);
add(BASKETSELECTION, JavascriptPluginInclusion::includeBasketSelection);
add(BASKETSELECTION, (x, l) -> includeBasketSelection(x));
add(CHART, JavascriptPluginInclusion::includeChart);
add(CHAT, (x, l) -> includeChat(x));
add(SELECTIZE, (x, l) -> includeSelectize(x));
Expand Down
Expand Up @@ -699,7 +699,7 @@ static ElementContainer includeCalendar(final ElementContainer xhtml, final Stri
includeDragAndDropUpload(xhtml, language);
includeWysiwygEditor(xhtml, language);
includeContributionReminder(xhtml, language);
includeBasketSelection(xhtml, language);
includeBasketSelection(xhtml);

SettingBundle calendarSettings = ResourceLocator
.getSettingBundle("org.silverpeas.calendar.settings.calendar");
Expand Down Expand Up @@ -1018,8 +1018,7 @@ static ElementContainer includeImageSelector(final ElementContainer xhtml,
* Includes the Silverpeas basket selection VueJS Plugins.
* @return the completed parent container.
*/
static ElementContainer includeBasketSelection(final ElementContainer xhtml,
final String language) {
static ElementContainer includeBasketSelection(final ElementContainer xhtml) {
xhtml.addElement(script(SERVICE_PATH + "contribution/silverpeas-basket-service.js"));
xhtml.addElement(link(VUEJS_COMPONENT_PATH + "contribution/silverpeas-basket-selection.css"));
xhtml.addElement(script(VUEJS_COMPONENT_PATH + "contribution/silverpeas-basket-selection.js"));
Expand Down

0 comments on commit 94c9c98

Please sign in to comment.