Skip to content

Commit

Permalink
Merge pull request #5528 from AngelFQC/BT21588
Browse files Browse the repository at this point in the history
LP: Refactoring viewer styles
  • Loading branch information
NicoDucou authored Jun 21, 2024
2 parents 6f23b6f + d0de8c2 commit 6a22d3f
Show file tree
Hide file tree
Showing 13 changed files with 719 additions and 819 deletions.
774 changes: 372 additions & 402 deletions assets/css/scorm.scss

Large diffs are not rendered by default.

445 changes: 221 additions & 224 deletions assets/js/legacy/annotation.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions assets/js/legacy/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import "./main"
import moment from "moment"
import Sortable from "sortablejs"
import Swal from "sweetalert2"
import "./vendor"

// Gets HTML content from tinymce
window.getContentFromEditor = function (id) {
Expand Down Expand Up @@ -53,8 +54,6 @@ window.setContentFromEditor = function (id, content) {
// global.frameReady = frameReady;
// window.frameReady = frameReady;

import "./vendor"

global.moment = moment
moment.locale(locale)
//$.datepicker.setDefaults($.datepicker.regional[locale]);
Expand Down Expand Up @@ -544,7 +543,7 @@ function addMainEvent(elm, evType, fn, useCapture) {
}
}

window.copyTextToClipBoard = function(elementId) {
window.copyTextToClipBoard = function (elementId) {
var copyText = document.getElementById(elementId)

if (copyText) {
Expand Down
8 changes: 4 additions & 4 deletions assets/js/legacy/document.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createPinia, setActivePinia } from 'pinia'
import { createPinia, setActivePinia } from "pinia"
import translateHtml from "./../translatehtml.js"

const pinia = createPinia()
setActivePinia(pinia)

import translateHtml from './../translatehtml.js'
document.addEventListener('DOMContentLoaded', function () {
document.addEventListener("DOMContentLoaded", function () {
translateHtml()
});
})
58 changes: 29 additions & 29 deletions assets/js/legacy/exercise.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// Script to be added in the exercises tool.
import 'jsplumb';
import 'jquery-ui-touch-punch';
import 'signature_pad';
import '../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.dateformat.min.js';
import '../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.epiclock.js';
import '../../../public/main/inc/lib/javascript/epiclock/renderers/minute/epiclock.minute.js';
import './annotation'
import '../../../public/main/inc/lib/javascript/hotspot/js/hotspot.js';
import '../../../public/main/inc/lib/javascript/d3/jquery.xcolor.js';
import "jsplumb"
import "jquery-ui-touch-punch"
import "signature_pad"
import "../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.dateformat.min.js"
import "../../../public/main/inc/lib/javascript/epiclock/javascript/jquery.epiclock.js"
import "../../../public/main/inc/lib/javascript/epiclock/renderers/minute/epiclock.minute.js"
import "./annotation"
import "../../../public/main/inc/lib/javascript/hotspot/js/hotspot.js"
import "../../../public/main/inc/lib/javascript/d3/jquery.xcolor.js"

document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMContentLoaded", function () {
// Mapping French paths to their English equivalents
var routeMapping = {
"enregistrement-audio": "audio-recording-help"
};
"enregistrement-audio": "audio-recording-help",
}

var currentUrlParams = new URLSearchParams(window.location.search);
var cid = currentUrlParams.get('cid') || '0';
var sid = currentUrlParams.get('sid') || '0';
var gid = currentUrlParams.get('gid') || '0';
var currentUrlParams = new URLSearchParams(window.location.search)
var cid = currentUrlParams.get("cid") || "0"
var sid = currentUrlParams.get("sid") || "0"
var gid = currentUrlParams.get("gid") || "0"

var links = document.querySelectorAll('a[href*="web"]');
links.forEach(function(link) {
var href = link.getAttribute("href");
var pathSegments = href.split("/");
var lastSegmentIndex = pathSegments.length - (pathSegments[pathSegments.length - 1] === '' ? 2 : 1);
var lastPathSegment = pathSegments[lastSegmentIndex];
var links = document.querySelectorAll('a[href*="web"]')
links.forEach(function (link) {
var href = link.getAttribute("href")
var pathSegments = href.split("/")
var lastSegmentIndex = pathSegments.length - (pathSegments[pathSegments.length - 1] === "" ? 2 : 1)
var lastPathSegment = pathSegments[lastSegmentIndex]

if (lastPathSegment && routeMapping[lastPathSegment]) {
var englishEquivalent = routeMapping[lastPathSegment];
var newHref = `/main/inc/ajax/exercise.ajax.php?a=${englishEquivalent}&cid=${cid}&sid=${sid}&gid=${gid}`;
link.setAttribute("href", newHref);
link.setAttribute("data-title", link.textContent.trim());
link.classList.add("ajax");
var englishEquivalent = routeMapping[lastPathSegment]
var newHref = `/main/inc/ajax/exercise.ajax.php?a=${englishEquivalent}&cid=${cid}&sid=${sid}&gid=${gid}`
link.setAttribute("href", newHref)
link.setAttribute("data-title", link.textContent.trim())
link.classList.add("ajax")
}
});
});
})
})
60 changes: 31 additions & 29 deletions assets/js/legacy/lp.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@

/* For licensing terms, see /license.txt */

import $ from 'jquery';

window.jQuery = $;
window.$ = $;
global.jQuery = $;
import $ from "jquery"
import "jquery-ui-dist/jquery-ui.js"

import 'jquery-ui-dist/jquery-ui.js';
window.jQuery = $
window.$ = $
global.jQuery = $

const frameReady = require('/public/main/inc/lib/javascript/jquery.frameready.js');
const frameReady = require("/public/main/inc/lib/javascript/jquery.frameready.js")

global.frameReady = frameReady;
window.frameReady = frameReady;
global.frameReady = frameReady
window.frameReady = frameReady

var hljs = require('highlight.js');
global.hljs = hljs;
var hljs = require("highlight.js")
global.hljs = hljs

document.addEventListener('DOMContentLoaded', (event) => {
var tabLinks = document.querySelectorAll('.nav-item.nav-link');
document.addEventListener("DOMContentLoaded", (event) => {
var tabLinks = document.querySelectorAll(".nav-item.nav-link")

function removeActiveClasses() {
tabLinks.forEach(function(link) {
link.classList.remove('active');
var tabPanel = document.getElementById(link.getAttribute('aria-controls'));
tabLinks.forEach(function (link) {
link.classList.remove("active")
var tabPanel = document.getElementById(link.getAttribute("aria-controls"))
if (tabPanel) {
tabPanel.classList.remove('active');
tabPanel.classList.remove("active")
}
});
})
}

tabLinks.forEach(function(link) {
link.addEventListener('click', function() {
removeActiveClasses();
this.classList.add('active');
var tabContentId = this.getAttribute('aria-controls');
var tabContent = document.getElementById(tabContentId);
tabLinks.forEach(function (link) {
link.addEventListener("click", function () {
removeActiveClasses()
this.classList.add("active")
var tabContentId = this.getAttribute("aria-controls")
var tabContent = document.getElementById(tabContentId)
if (tabContent) {
tabContent.classList.add('active');
tabContent.classList.add("active")
}
});
});
});
})
})

document
.querySelectorAll(".accordion")
.forEach((accordion) => accordion.addEventListener("click", () => accordion.classList.toggle("active")))
})
55 changes: 30 additions & 25 deletions assets/js/legacy/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,40 @@ $(function () {
// Elevator Scroll
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('.app-elevator').fadeIn();
$(".app-elevator").fadeIn()
} else {
$('.app-elevator').fadeOut();
$(".app-elevator").fadeOut()
}
});
})

// scroll body to 0px on click
$('#back-to-top').click(function () {
$('#back-to-top').tooltip('hide');
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
$("#back-to-top").click(function () {
$("#back-to-top").tooltip("hide")
$("body,html").animate(
{
scrollTop: 0,
},
800,
)
return false
})

var $inputTitle = $("#add_course_title");
$inputTitle.keyup(function () {
var value = $(this).val();
var titleDefault = "Course Title";
if (value.length > 0) {
$("#title_course_card").text(value);
} else {
$("#title_course_card").text(titleDefault);
}
}).keyup();
var $inputTitle = $("#add_course_title")
$inputTitle
.keyup(function () {
var value = $(this).val()
var titleDefault = "Course Title"
if (value.length > 0) {
$("#title_course_card").text(value)
} else {
$("#title_course_card").text(titleDefault)
}
})
.keyup()

$("select[name=category_code]").change(function () {
$(".category").show();
var $category = $('select[name=category_code] option:selected').html();
$(".category").text($category);
});
});
$(".category").show()
var $category = $("select[name=category_code] option:selected").html()
$(".category").text($category)
})
})
14 changes: 7 additions & 7 deletions public/main/lp/learnpath.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1357,17 +1357,17 @@ public function get_navigation_bar($barId = '')
if (false === $hideArrows) {
$icon = Display::getMdiIcon('chevron-left');
$previousIcon = '
<a class="icon-toolbar" id="scorm-previous" href="#"
<button class="icon-toolbar" id="scorm-previous" type="button"
onclick="switch_item('.$mycurrentitemid.',\'previous\');return false;" title="'.$previousText.'">
'.$icon.'<span class="sr-only">'.$previousText.'</span>
</a>';
</button>';

$icon = Display::getMdiIcon('chevron-right');
$nextIcon = '
<a class="icon-toolbar" id="scorm-next" href="#"
<button class="icon-toolbar" id="scorm-next" type="button"
onclick="switch_item('.$mycurrentitemid.',\'next\');return false;" title="'.$nextText.'">
'.$icon.'<span class="sr-only">'.$nextText.'</span>
</a>';
</button>';
}

if ('fullscreen' === $this->mode) {
Expand Down Expand Up @@ -2660,14 +2660,14 @@ public function get_teacher_toc_buttons()
if ($isAllow && false == $hideIcons) {
if ($this->get_lp_session_id() == api_get_session_id()) {
$html .= '<div id="actions_lp" class="actions_lp"><hr>';
$html .= '<div class="flex flex-row justify-center mb-2">';
$html .= '<div class="flex flex-wrap gap-1 justify-center">';
$html .= "<a
class='btn btn-sm btn--plain mx-1'
class='btn btn-sm btn--plain'
href='lp_controller.php?".api_get_cidreq()."&action=add_item&type=step&lp_id=".$this->lp_id."&isStudentView=false'
target='_parent'>".
Display::getMdiIcon('pencil').get_lang('Edit')."</a>";
$html .= '<a
class="btn btn-sm btn--plain mx-1"
class="btn btn-sm btn--plain"
href="lp_controller.php?'.api_get_cidreq()."&action=edit&lp_id=".$this->lp_id.'&isStudentView=false">'.
Display::getMdiIcon('hammer-wrench').get_lang('Settings').'</a>';
$html .= '</div>';
Expand Down
2 changes: 0 additions & 2 deletions public/main/lp/scorm_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -1709,8 +1709,6 @@ function switch_item(current_item, next_item)
if ($("#lp_media_file").length != 0) {
$("#lp_media_file").html(result);
}

LPViewUtils.setHeightLPToc();
}
});*/

Expand Down
4 changes: 4 additions & 0 deletions src/CoreBundle/Resources/views/Layout/head.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
{{ encore_entry_link_tags('vue') }}
{{ encore_entry_link_tags('app') }}

{% if lp_view is defined %}
{{ encore_entry_link_tags('css/scorm') }}
{% endif %}

{% if color_theme_link is defined %}
{{ color_theme_link|raw }}
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions src/CoreBundle/Resources/views/LearnPath/menubar.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
{% set label = "Expand" | trans %}
{% set icon_expand = "arrow-expand-horizontal" %}
{% endif %}
<a href="#"
<button type="button"
id="lp-view-expand-toggle"
class="icon-toolbar expand"
role="button"
title="{{ label }}"
>
<i class="mdi-{{ icon_expand }} mdi" aria-hidden="true"></i>
</a>
</button>
{% endif %}
<a id="home-course"
title="{{ 'Home'|trans }}"
Expand All @@ -36,8 +36,8 @@
</a>
{{ navigation_bar }}
</div>
<a title="{{ 'Options'|trans }}" class="menu-button icons" href="#">
<button title="{{ 'Options'|trans }}" class="menu-button icons" type="button">
<i class="mdi-menu mdi" aria-hidden="true"></i>
</a>
</button>
</nav>
{% endautoescape %}
42 changes: 4 additions & 38 deletions src/CoreBundle/Resources/views/LearnPath/scorm_list.html.twig
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{% autoescape false %}
{% macro processItem(item, lp_current_item_id, status_list) %}
{% import _self as self %}
{% set itemClass = '' %}
{% set itemClass = ' ' %}
{% if 'dir' == item.itemType %}
{% set itemClass = 'scorm_item_section' %}
{% set itemClass = itemClass ~ 'scorm_item_section ' %}
{% endif %}

{% if lp_current_item_id == item.iid %}
{% set itemClass = 'scorm_highlight' %}
{% set itemClass = itemClass ~ 'scorm_highlight ' %}
{% endif %}

{% set itemLevel = 'level_' ~ (item.lvl - 1) %}
{% set itemStatusClass = status_list[item.iid] %}
{% set accordionClass = '' %}
{% if item.itemType == 'dir' %}
{% set accordionClass = 'accordion' %}
{% endif %}
{% set accordionClass = item.itemType == 'dir' and 'true' == chamilo_settings_get('lp.lp_view_accordion') ? 'accordion' : '' %}
<div id="toc_{{ item.iid }}"
class=" scorm_item_normal {{ itemStatusClass }} {{ itemClass }} item-{{ item.itemType }} {{ accordionClass }}">
{% if item.itemType == 'dir' %}
Expand Down Expand Up @@ -119,34 +116,3 @@
</div>
{% endif %}
{% endautoescape %}
<script>
document.addEventListener("DOMContentLoaded", function() {
setTimeout(function() {
var lpCurrentItemId = '{{ lp_current_item_id }}'
var currentElement = document.getElementById("toc_" + lpCurrentItemId)
if (currentElement) {
var parentContainer = currentElement.closest(".item-children")
var previousSibling
if (parentContainer) {
previousSibling = parentContainer.previousElementSibling
}
if (previousSibling) {
previousSibling.click()
var parentContainer2 = previousSibling.closest(".item-children")
var previousSibling2
if (parentContainer2) {
previousSibling2 = parentContainer2.previousElementSibling
}
if (previousSibling2) {
previousSibling2.click()
}
}
}
}, 1000)
})
</script>
Loading

0 comments on commit 6a22d3f

Please sign in to comment.