Documents: Add document.js BT#18893

pull/3959/head
Julio 4 years ago
parent f72976c7d4
commit b29e4ec815
  1. 3
      assets/js/document.js
  2. 14
      src/CoreBundle/Controller/ResourceController.php
  3. 5
      src/CoreBundle/Resources/views/Layout/document.html.twig
  4. 10
      src/CoreBundle/Resources/views/Layout/vue_js_setup.html.twig
  5. 11
      src/CoreBundle/Resources/views/Layout/vue_setup.html.twig

@ -0,0 +1,3 @@
/** This JS will be included when loading an HTML in the Document tool */
require('./translatehtml.js');

@ -628,14 +628,12 @@ class ResourceController extends AbstractResourceController implements CourseCon
if ('true' === $this->getSettingsManager()->getSetting('editor.translate_html')) {
$user = $this->getUser();
if (null !== $user) {
$user = json_encode(['locale' => $user->getLocale()]);
$js = '
<script>
window.user = '.$user.'
</script>
<style src="/build/css/document.css"></style>
<script src="/build/runtime.js"></script>
<script src="/build/translatehtml.js"></script>';
// Overwrite user_json, otherwise it will be loaded by the TwigListener.php
$userJson = json_encode(['locale' => $user->getLocale()]);
$js = $this->renderView(
'@ChamiloCore/Layout/document.html.twig',
['breadcrumb' => '', 'user_json' => $userJson]
);
$content = str_replace('</html>', $js.'</html>', $content);
}
}

@ -0,0 +1,5 @@
{% include 'vue_js_setup.html.twig' %}
<link href="/build/css/document.css" rel="stylesheet">
<script src="/build/runtime.js"></script>
<script src="/build/document.js"></script>

@ -0,0 +1,10 @@
<script>
window.config = {{ config_json | raw }};
window.user = {{ user_json | raw }};
window.languages = {{ languages_json | raw }};
{% if legacy_breadcrumb is defined %}
window.breadcrumb = {{ legacy_breadcrumb | raw }};
{% else %}
window.breadcrumb = '';
{% endif %}
</script>

@ -1,13 +1,4 @@
<script>
window.config = {{ config_json | raw }};
window.user = {{ user_json | raw }};
window.languages = {{ languages_json | raw }};
{% if legacy_breadcrumb is defined %}
window.breadcrumb = {{ legacy_breadcrumb | raw }};
{% else %}
window.breadcrumb = '';
{% endif %}
</script>
{% include 'vue_js_setup.html.twig' %}
<div id="app" data-flashes="{{ app.flashes()|json_encode }}">
</div>

Loading…
Cancel
Save