Move MediaControlsView to precompiled Handlebars templates

In Nextcloud 15 the default Content Security Policy disallows unsafe
eval expressions, so Handlebars templates can no longer be compiled at
runtime.

For the time being that default Content Security Policy was lifted for
Talk so "Handlebars.compile" could still be used. However, this only
applies to Talk itself; when using Talk components in other apps they
must abide to the Content Security Policy of those apps. As
MediaControlsView is going to be used in the Files app it has been moved
to precompiled Handlebars templates (which are still compatible with the
regular Talk UI).

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2018-11-29 06:23:20 +01:00
Родитель c4c047a3c1
Коммит d6a0528bbc
3 изменённых файлов: 61 добавлений и 37 удалений

Просмотреть файл

@ -1,4 +1,4 @@
/* global Marionette, Handlebars, $ */
/* global Marionette, $ */
/**
*
@ -21,52 +21,26 @@
*
*/
(function(OC, OCA, Marionette, Handlebars, $) {
(function(OC, OCA, Marionette, $) {
'use strict';
OCA.SpreedMe = OCA.SpreedMe || {};
OCA.Talk = OCA.Talk || {};
OCA.SpreedMe.Views = OCA.SpreedMe.Views || {};
var TEMPLATE =
'<button id="mute" class="icon-audio icon-white icon-shadow" data-placement="top" data-toggle="tooltip" data-original-title="{{muteAudioButtonTitle}}"></button>' +
'<button id="hideVideo" class="icon-video icon-white icon-shadow" data-placement="top" data-toggle="tooltip" data-original-title="{{hideVideoButtonTitle}}"></button>' +
'<button id="screensharing-button" class="app-navigation-entry-utils-menu-button icon-screen-off icon-white icon-shadow screensharing-disabled" data-placement="top" data-toggle="tooltip" data-original-title="{{screensharingButtonTitle}}"></button>' +
'<div id="screensharing-menu" class="app-navigation-entry-menu">' +
' <ul>' +
' <li id="share-screen-entry">' +
' <button id="share-screen-button">' +
' <span class="icon-screen"></span>' +
' <span>{{shareScreenButtonTitle}}</span>' +
' </button>' +
' </li>' +
' <li id="share-window-entry">' +
' <button id="share-window-button">' +
' <span class="icon-share-window"></span>' +
' <span>{{shareWindowButtonTitle}}</span>' +
' </button>' +
' </li>' +
' <li id="show-screen-entry">' +
' <button id="show-screen-button">' +
' <span class="icon-screen"></span>' +
' <span>{{showScreenButtonTitle}}</span>' +
' </button>' +
' </li>' +
' <li id="stop-screen-entry">' +
' <button id="stop-screen-button">' +
' <span class="icon-screen-off"></span>' +
' <span>{{stopScreenButtonTitle}}</span>' +
' </button>' +
' </li>' +
' </ul>' +
'</div>';
OCA.Talk.Views = OCA.Talk.Views || {};
var MediaControlsView = Marionette.View.extend({
tagName: 'div',
className: 'nameIndicator',
template: Handlebars.compile(TEMPLATE),
template: function(context) {
// OCA.Talk.Views.Templates may not have been initialized when this
// view is initialized, so the template can not be directly
// assigned.
return OCA.Talk.Views.Templates['mediacontrolsview'](context);
},
templateContext: function() {
return {
@ -377,4 +351,4 @@
OCA.SpreedMe.Views.MediaControlsView = MediaControlsView;
})(OC, OCA, Marionette, Handlebars, $);
})(OC, OCA, Marionette, $);

Просмотреть файл

@ -113,6 +113,25 @@ templates['chatview_comment'] = template({"1":function(container,depth0,helpers,
+ ((stack1 = ((helper = (helper = helpers.formattedMessage || (depth0 != null ? depth0.formattedMessage : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"formattedMessage","hash":{},"data":data}) : helper))) != null ? stack1 : "")
+ "</div>\n</li>\n";
},"useData":true});
templates['mediacontrolsview'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;
return "<button id=\"mute\" class=\"icon-audio icon-white icon-shadow\" data-placement=\"top\" data-toggle=\"tooltip\" data-original-title=\""
+ alias4(((helper = (helper = helpers.muteAudioButtonTitle || (depth0 != null ? depth0.muteAudioButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"muteAudioButtonTitle","hash":{},"data":data}) : helper)))
+ "\"></button>\n<button id=\"hideVideo\" class=\"icon-video icon-white icon-shadow\" data-placement=\"top\" data-toggle=\"tooltip\" data-original-title=\""
+ alias4(((helper = (helper = helpers.hideVideoButtonTitle || (depth0 != null ? depth0.hideVideoButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hideVideoButtonTitle","hash":{},"data":data}) : helper)))
+ "\"></button>\n<button id=\"screensharing-button\" class=\"app-navigation-entry-utils-menu-button icon-screen-off icon-white icon-shadow screensharing-disabled\" data-placement=\"top\" data-toggle=\"tooltip\" data-original-title=\""
+ alias4(((helper = (helper = helpers.screensharingButtonTitle || (depth0 != null ? depth0.screensharingButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"screensharingButtonTitle","hash":{},"data":data}) : helper)))
+ "\"></button>\n<div id=\"screensharing-menu\" class=\"app-navigation-entry-menu\">\n <ul>\n <li id=\"share-screen-entry\">\n <button id=\"share-screen-button\">\n <span class=\"icon-screen\"></span>\n <span>"
+ alias4(((helper = (helper = helpers.shareScreenButtonTitle || (depth0 != null ? depth0.shareScreenButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareScreenButtonTitle","hash":{},"data":data}) : helper)))
+ "</span>\n </button>\n </li>\n <li id=\"share-window-entry\">\n <button id=\"share-window-button\">\n <span class=\"icon-share-window\"></span>\n <span>"
+ alias4(((helper = (helper = helpers.shareWindowButtonTitle || (depth0 != null ? depth0.shareWindowButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"shareWindowButtonTitle","hash":{},"data":data}) : helper)))
+ "</span>\n </button>\n </li>\n <li id=\"show-screen-entry\">\n <button id=\"show-screen-button\">\n <span class=\"icon-screen\"></span>\n <span>"
+ alias4(((helper = (helper = helpers.showScreenButtonTitle || (depth0 != null ? depth0.showScreenButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"showScreenButtonTitle","hash":{},"data":data}) : helper)))
+ "</span>\n </button>\n </li>\n <li id=\"stop-screen-entry\">\n <button id=\"stop-screen-button\">\n <span class=\"icon-screen-off\"></span>\n <span>"
+ alias4(((helper = (helper = helpers.stopScreenButtonTitle || (depth0 != null ? depth0.stopScreenButtonTitle : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"stopScreenButtonTitle","hash":{},"data":data}) : helper)))
+ "</span>\n </button>\n </li>\n </ul>\n</div>\n";
},"useData":true});
templates['richobjectstringparser_filepreview'] = template({"compiler":[7,">= 4.0.0"],"main":function(container,depth0,helpers,partials,data) {
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3="function", alias4=container.escapeExpression;

Просмотреть файл

@ -0,0 +1,31 @@
<button id="mute" class="icon-audio icon-white icon-shadow" data-placement="top" data-toggle="tooltip" data-original-title="{{muteAudioButtonTitle}}"></button>
<button id="hideVideo" class="icon-video icon-white icon-shadow" data-placement="top" data-toggle="tooltip" data-original-title="{{hideVideoButtonTitle}}"></button>
<button id="screensharing-button" class="app-navigation-entry-utils-menu-button icon-screen-off icon-white icon-shadow screensharing-disabled" data-placement="top" data-toggle="tooltip" data-original-title="{{screensharingButtonTitle}}"></button>
<div id="screensharing-menu" class="app-navigation-entry-menu">
<ul>
<li id="share-screen-entry">
<button id="share-screen-button">
<span class="icon-screen"></span>
<span>{{shareScreenButtonTitle}}</span>
</button>
</li>
<li id="share-window-entry">
<button id="share-window-button">
<span class="icon-share-window"></span>
<span>{{shareWindowButtonTitle}}</span>
</button>
</li>
<li id="show-screen-entry">
<button id="show-screen-button">
<span class="icon-screen"></span>
<span>{{showScreenButtonTitle}}</span>
</button>
</li>
<li id="stop-screen-entry">
<button id="stop-screen-button">
<span class="icon-screen-off"></span>
<span>{{stopScreenButtonTitle}}</span>
</button>
</li>
</ul>
</div>