Use fos_js_routing to load URL in js file

- rename main.js to vendor.js (third party libs)
- create new app.js with the chamilo js code
pull/2635/head
Julio Montoya 7 years ago
parent 0281b37658
commit a29a50dd78
  1. 630
      assets/js/app.js
  2. 1
      assets/js/vendor.js
  3. 12
      config/packages/fos_js_routing.yaml
  4. 8
      config/routes/chamilo.yaml
  5. 4
      documentation/changelog.html
  6. 2
      src/CoreBundle/Controller/IndexController.php
  7. 7
      src/ThemeBundle/Resources/views/Layout/base-layout.html.twig
  8. 39
      src/ThemeBundle/Resources/views/Layout/head.html.twig
  9. 525
      src/ThemeBundle/Resources/views/Layout/header.js.twig
  10. 5
      webpack.config.js

@ -0,0 +1,630 @@
const routes = require('../../public/js/fos_js_routes.json');
import Routing from '../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.min.js';
Routing.setRoutingData(routes);
var homeUrl = Routing.generate('home');
var legacyIndex = Routing.generate('legacy_index');
var main = Routing.generate('legacy_main', {'name' : 'statusonline.png'});
var webAjax = Routing.generate('web.ajax');
/*console.log(homeUrl);
console.log(legacyIndex);
console.log(main);*/
var ajax_url = webAjax + 'chat.ajax.php';
var online_button = '<img src="' + homeUrl + 'public/img/statusonline.png">';
var offline_button = '<img src="' + homeUrl + 'public/img/statusoffline.png">';
/*var connect_lang = '{{ "ChatConnected"|get_lang }}';
var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}';*/
var connect_lang = 'ChatConnected';
var disconnect_lang = 'ChatDisconnected';
$(function() {
addMainEvent(window, 'unload', courseLogout ,false);
$("#open-view-list").click(function(){
$("#student-list-work").fadeIn(300);
});
$("#closed-view-list").click(function(){
$("#student-list-work").fadeOut(300);
});
checkBrand();
var id;
$(window).resize(function() {
clearTimeout(id);
id = setTimeout(doneResizing, 200);
});
// Removes the yellow input in Chrome
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).on("load", function () {
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
$(".accordion_jquery").accordion({
autoHeight: false,
active: false, // all items closed by default
collapsible: true,
header: ".accordion-heading"
});
// Start modals
// class='ajax' loads a page in a modal
$('body').on('click', 'a.ajax', function(e) {
e.preventDefault();
var contentUrl = this.href,
loadModalContent = $.get(contentUrl),
self = $(this);
$.when(loadModalContent).done(function(modalContent) {
var modalDialog = $('#global-modal').find('.modal-dialog'),
modalSize = self.data('size') || get_url_params(contentUrl, 'modal_size'),
modalWidth = self.data('width') || get_url_params(contentUrl, 'width'),
modalTitle = self.data('title') || ' ';
modalDialog.removeClass('modal-lg modal-sm').css('width', '');
if (modalSize && modalSize.length != 0) {
switch (modalSize) {
case 'lg':
modalDialog.addClass('modal-lg');
break;
case 'sm':
modalDialog.addClass('modal-sm');
break;
}
} else if (modalWidth) {
modalDialog.css('width', modalWidth + 'px');
}
$('#global-modal').find('.modal-title').text(modalTitle);
$('#global-modal').find('.modal-body').html(modalContent);
$('#global-modal').modal('show');
});
});
// Expands an image modal
$('a.expand-image').on('click', function(e) {
e.preventDefault();
var title = $(this).attr('title');
var image = new Image();
image.onload = function() {
if (title) {
$('#expand-image-modal').find('.modal-title').text(title);
} else {
$('#expand-image-modal').find('.modal-title').html('&nbsp;');
}
$('#expand-image-modal').find('.modal-body').html(image);
$('#expand-image-modal').modal({
show: true
});
};
image.src = this.href;
});
// Delete modal
$('#confirm-delete').on('show.bs.modal', function(e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
//var message = '{{ 'AreYouSureToDeleteJS' | get_lang }}: <strong>' + $(e.relatedTarget).data('item-title') + '</strong>';
var message = 'AreYouSureToDeleteJS : <strong>' + $(e.relatedTarget).data('item-title') + '</strong>';
if ($(e.relatedTarget).data('item-question')) {
message = $(e.relatedTarget).data('item-question');
}
$('.debug-url').html(message);
});
// End modals
// old jquery.menu.js
$('#navigation a').stop().animate({
'marginLeft':'50px'
},1000);
$('#navigation div').hover(
function () {
$('a',$(this)).stop().animate({
'marginLeft':'1px'
},200);
},
function () {
$('a',$(this)).stop().animate({
'marginLeft':'50px'
},200);
}
);
/* Make responsive image maps */
$('map').imageMapResize();
jQuery.fn.filterByText = function(textbox) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(textbox).bind('change keyup', function() {
var options = $(select).empty().data('options');
var search = $.trim($(this).val());
var regex = new RegExp(search,"gi");
$.each(options, function(i) {
var option = options[i];
if(option.text.match(regex) !== null) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
});
});
};
$(".black-shadow").mouseenter(function() {
$(this).addClass('hovered-course');
}).mouseleave(function() {
$(this).removeClass('hovered-course');
});
$("[data-toggle=popover]").each(function(i, obj) {
$(this).popover({
html: true,
content: function() {
var id = $(this).attr('id')
return $('#popover-content-' + id).html();
}
});
});
$('.scrollbar-inner').scrollbar();
var locale = $('html').attr('lang');
// Date time settings.
moment.locale(locale);
$.datepicker.setDefaults($.datepicker.regional[locale]);
$.datepicker.regional["local"] = $.datepicker.regional[locale];
// Fix old calls of "inc/lib/mediaplayer/player.swf" and convert to <audio> tag, then rendered by media element js
// see BT#13405
$('embed').each( function () {
var flashVars = $(this).attr('flashvars');
if (flashVars && flashVars.indexOf("file") == -1) {
var audioId = Math.floor( Math.random()*99999 );
flashVars = flashVars.replace('&autostart=false', '');
flashVars = flashVars.replace('&autostart=true', '');
var audioDiv = '<audio id="'+audioId+'" controls="controls" style="width:400px;" width:"400px;" src="'+flashVars+'" ><source src="'+flashVars+'" type="audio/mp3" ></source></audio>';
$(this).hide();
$(this).after(audioDiv);
}
});
// Chosen select
$(".chzn-select").chosen({
disable_search_threshold: 10,
/*no_results_text: '{{ 'SearchNoResultsFound' | get_lang | escape('js') }}',
placeholder_text_multiple: '{{ 'SelectSomeOptions' | get_lang | escape('js') }}',
placeholder_text_single: '{{ 'SelectAnOption' | get_lang | escape('js') }}',*/
width: "100%"
});
// Bootstrap tabs.
$('.tab-wrapper a').click(function (e) {
e.preventDefault();
$(this).tab('show');
//$('#tabs a:first').tab('show') // Select first tab
});
// Fixes bug when loading links inside a tab.
$('.tab-wrapper .tab-pane a').unbind();
/**
* Advanced options
* Usage
* <a id="link" href="url">Advanced</a>
* <div id="link_options">
* hidden content :)
* </div>
* */
$(".advanced_options").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#" + id).toggle();
});
/**
* <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
* <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
* <div id="div_id">Div content</div>
* */
$(".advanced_options_open").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).show();
});
$(".advanced_options_close").on("click", function (event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#" + id).hide();
});
// Adv multi-select search input.
$('.select_class_filter').each( function () {
var inputId = $(this).attr('id');
inputId = inputId.replace('-filter', '');
$("#" + inputId).filterByText($("#" + inputId + "-filter"));
});
// Mediaelement
//if ( {{ show_media_element }} == 1) {
$('video:not(.skip), audio:not(.skip)').mediaelementplayer({
pluginPath: _p.web + 'web/assets/mediaelement/build/',
//renderers: ['html5', 'flash_video', 'native_flv'],
features: ['{{ video_features }}'],
success: function(mediaElement, originalNode, instance) {
},
vrPath: _p.web + 'web/assets/vrview/build/vrview.js'
});
//}
// Table highlight.
$("form .data_table input:checkbox").click(function () {
if ($(this).is(":checked")) {
$(this).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(this).parentsUntil("tr").parent().removeClass("row_selected");
}
});
/* For non HTML5 browsers */
if ($("#formLogin".length > 1)) {
$("input[name=login]").focus();
}
// Tool tip (in exercises)
var tip_options = {
placement: 'right'
};
$('.boot-tooltip').tooltip(tip_options);
// var more = '{{ 'SeeMore' | get_lang | escape('js') }}';
// var close = '{{ 'Close' | get_lang | escape('js') }}';
var more = 'see more';
var close = 'close';
$('.list-teachers').readmore({
speed: 75,
moreLink: '<a href="#">' + more + '</a>',
lessLink: '<a href="#">' + close + '</a>',
collapsedHeight: 35,
blockCSS: 'display: block; width: 100%;'
});
$('.star-rating li a').on('click', function(event) {
var id = $(this).parents('ul').attr('id');
//$('#vote_label2_' + id).html("{{'Loading'|get_lang}}");
$('#vote_label2_' + id).html("loading");
$.ajax({
url: $(this).attr('data-link'),
success: function(data) {
$("#rating_wrapper_"+id).html(data);
if (data == 'added') {
//$('#vote_label2_' + id).html("{{'Saved'|get_lang}}");
}
if (data == 'updated') {
//$('#vote_label2_' + id).html("{{'Saved'|get_lang}}");
}
}
});
});
$("#notifications").load(_p.web_ajax + "online.ajax.php?a=get_users_online");
});
$(window).resize(function() {
checkBrand();
});
$(document).scroll(function() {
var valor = $('body').outerHeight() - 700;
if ($(this).scrollTop() > 100) {
$('.bottom_actions').addClass('bottom_actions_fixed');
} else {
$('.bottom_actions').removeClass('bottom_actions_fixed');
}
if ($(this).scrollTop() > valor) {
$('.bottom_actions').removeClass('bottom_actions_fixed');
} else {
$('.bottom_actions').addClass('bottom_actions_fixed');
}
//Exercise warning fixed at the top
var fixed = $("#exercise_clock_warning");
if (fixed.length) {
if (!fixed.attr('data-top')) {
// If already fixed, then do nothing
if (fixed.hasClass('subnav-fixed')) return;
// Remember top position
var offset = fixed.offset();
fixed.attr('data-top', offset.top);
fixed.css('width', '100%');
}
if (fixed.attr('data-top') - fixed.outerHeight() <= $(this).scrollTop()) {
fixed.addClass('navbar-fixed-top');
fixed.css('width', '100%');
} else {
fixed.removeClass('navbar-fixed-top');
fixed.css('width', '100%');
}
}
// Admin -> Settings toolbar.
if ($('body').width() > 959) {
if ($('.new_actions').length) {
if (!$('.new_actions').attr('data-top')) {
// If already fixed, then do nothing
if ($('.new_actions').hasClass('new_actions-fixed')) return;
// Remember top position
var offset = $('.new_actions').offset();
var more_top = 0;
if ($('.subnav').hasClass('new_actions-fixed')) {
more_top = 50;
}
$('.new_actions').attr('data-top', offset.top + more_top);
}
// Check if the height is enough before fixing the icons menu (or otherwise removing it)
// Added a 30px offset otherwise sometimes the menu plays ping-pong when scrolling to
// the bottom of the page on short pages.
if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop() + 30) {
$('.new_actions').addClass('new_actions-fixed');
} else {
$('.new_actions').removeClass('new_actions-fixed');
}
}
}
});
function get_url_params(q, attribute) {
var hash;
if (q != undefined) {
q = q.split('&');
for(var i = 0; i < q.length; i++){
hash = q[i].split('=');
if (hash[0] == attribute) {
return hash[1];
}
}
}
}
function checkBrand() {
if ($('.subnav').length) {
if ($(window).width() >= 969) {
$('.subnav .brand').hide();
} else {
$('.subnav .brand').show();
}
}
}
function setCheckbox(value, table_id) {
checkboxes = $("#"+table_id+" input:checkbox");
$.each(checkboxes, function(index, checkbox) {
checkbox.checked = value;
if (value) {
$(checkbox).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(checkbox).parentsUntil("tr").parent().removeClass("row_selected");
}
});
return false;
}
function action_click(element, table_id) {
d = $("#"+table_id);
if (!confirm('ConfirmYourChoice')) {
//if (!confirm('{{ "ConfirmYourChoice"|get_lang }}')) {
return false;
} else {
var action =$(element).attr("data-action");
$('#'+table_id+' input[name="action"] ').attr("value", action);
d.submit();
return false;
}
}
/**
* Generic function to replace the deprecated jQuery toggle function
* @param inId : id of block to hide / unhide
* @param inIdTxt : id of the button
* @param inTxtHide : text one of the button
* @param inTxtUnhide : text two of the button
* @todo : allow to detect if text is from a button or from a <a>
*/
function hideUnhide(inId, inIdTxt, inTxtHide, inTxtUnhide) {
if ($('#'+inId).css("display") == "none") {
$('#'+inId).show(400);
$('#'+inIdTxt).attr("value", inTxtUnhide);
} else {
$('#'+inId).hide(400);
$('#'+inIdTxt).attr("value", inTxtHide);
}
}
function expandColumnToogle(buttonSelector, col1Info, col2Info) {
$(buttonSelector).on('click', function (e) {
e.preventDefault();
col1Info = $.extend({
selector: '',
width: 4
}, col1Info);
col2Info = $.extend({
selector: '',
width: 8
}, col2Info);
if (!col1Info.selector || !col2Info.selector) {
return;
}
var col1 = $(col1Info.selector),
col2 = $(col2Info.selector);
$('#expand').toggleClass('hide');
$('#contract').toggleClass('hide');
if (col2.is('.col-md-' + col2Info.width)) {
col2.removeClass('col-md-' + col2Info.width).addClass('col-md-12');
col1.removeClass('col-md-' + col1Info.width).addClass('hide');
return;
}
col2.removeClass('col-md-12').addClass('col-md-' + col2Info.width);
col1.removeClass('hide').addClass('col-md-' + col1Info.width);
});
}
// Load ckeditor plugins
if (typeof CKEDITOR !== 'undefined') {
// External plugins not part of the default Ckeditor package.
var plugins = [
'asciimath',
'asciisvg',
'audio',
'ckeditor_wiris',
'dialogui',
'glossary',
'leaflet',
'mapping',
'maximize',
'mathjax',
'oembed',
'toolbar',
'toolbarswitch',
'video',
'wikilink',
'wordcount',
'youtube',
'flash',
'inserthtml',
'image2_chamilo'
];
plugins.forEach(function (plugin) {
CKEDITOR.plugins.addExternal(
plugin,
main + 'javascript/ckeditor/plugins/' + plugin + '/'
);
});
/**
* Function use to load templates in a div
**/
var showTemplates = function (ckeditorName) {
var editorName = 'content';
if (ckeditorName && ckeditorName.length > 0) {
editorName = ckeditorName;
}
CKEDITOR.editorConfig(CKEDITOR.config);
CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a) {
var templatesConfig = CKEDITOR.getTemplates("default");
var $templatesUL = $("<ul>");
if (templatesConfig) {
$.each(templatesConfig.templates, function () {
var template = this;
var $templateLi = $("<li>");
var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
templateHTML += "<b>" + template.title + "</b>";
if (template.description) {
templateHTML += "<div class=description>" + template.description + "</div>";
}
templateHTML += "</div>";
$("<a>", {
href: "#",
html: templateHTML,
click: function (e) {
e.preventDefault();
if (CKEDITOR.instances[editorName]) {
CKEDITOR.instances[editorName].setData(template.html, function () {
this.checkDirty();
});
}
}
}).appendTo($templateLi);
$templatesUL.append($templateLi);
});
}
$templatesUL.appendTo("#frmModel");
});
};
}
function doneResizing() {
var widthWindow = $(window).width();
if ((widthWindow>=1024) && (widthWindow>=768)) {
$("#profileCollapse").addClass("in");
$("#courseCollapse").addClass("in");
$("#skillsCollapse").addClass("in");
$("#sn-sidebar-collapse").addClass("in");
$("#user_image_block").removeClass("text-muted");
} else {
$("#profileCollapse").removeClass("in");
$("#courseCollapse").removeClass("in");
$("#skillsCollapse").removeClass("in");
$("#sn-avatar-one").removeClass("in");
$("#user_image_block").addClass("text-muted");
}
}
function addMainEvent(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
elm.attachEvent('on' + evType, fn);
} else {
elm['on'+evType] = fn;
}
}
function copyTextToClipBoard(elementId)
{
/* Get the text field */
var copyText = document.getElementById(elementId);
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("copy");
/* Alert the copied text */
//alert('Copied');
}

@ -31,6 +31,7 @@ require('flag-icon-css/css/flag-icon.css');
require("bootstrap-daterangepicker");
require("bootstrap-daterangepicker/daterangepicker.scss");
// doesn't work with webpack added directly in /public/libs folder
/*
require("fullcalendar");

@ -1,10 +1,2 @@
services:
# default configuration for services in *this* file
_defaults:
# automatically injects dependencies in your services
autowire: true
# automatically registers your services as commands, event subscribers, etc.
autoconfigure: true
# this means you cannot fetch services directly from the container via $container->get()
# if you need to do this, you can override this setting on individual services
public: true
fos_js_routing:
routes_to_expose: [home]

@ -1,16 +1,24 @@
chamilo_course:
resource: "@ChamiloCourseBundle/Resources/config/routing.yml"
prefix: /
options:
expose: true
chamilo_contact:
resource: "@ChamiloContactBundle/Resources/config/routing.yml"
prefix: /contact
#chamilo_installer:
# resource: "@ChamiloInstallerBundle/Resources/config/routing.yml"
# Always at the end
core_bundle:
resource: "@ChamiloCoreBundle/Resources/config/routing.yml"
options:
expose: true
page_bundle:
resource: "@ChamiloPageBundle/Resources/config/routing.yml"
faq:
resource: "@ChamiloFaqBundle/Resources/config/routing.yml"

@ -342,10 +342,10 @@
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/ddf3db2c1b0eab617bdd41e1e38bcb7dc1d4e849">ddf3db2c</a>) Optimization: CDN: Add CORS information to configuration.php in CDN feature block</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/5bfb14aa033c9318660db3d7fe75a93a3502d841">5bfb14aa</a>) Optimization: CDN: Implement missing CDN path feature for main JS and CSS files (was only working on custom CSS)</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/8839965e7fc93c1b664b1cbf4c65265c04d5df4b">8839965e</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2549">GH#2549</a>) Quiz: Improvement for responsive email template</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/ba8bb15e1311d3feea83d73403f53a96af843746">ba8bb15e</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2584">GH#2584</a>) Optimization: Make main.js file generation language-aware</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/ba8bb15e1311d3feea83d73403f53a96af843746">ba8bb15e</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2584">GH#2584</a>) Optimization: Make vendor.js file generation language-aware</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/5a80a12c58e3864cead851c43ad10d0048b7acd6">5a80a12c</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2549">GH#2549</a>) Quiz: Add tpl exercise_result_alert_body</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/de60f7ed3b16574896702a9df279ee6c4bd9022f">de60f7ed</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2584">GH#2584</a>) Global: Improve delete popup</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/0af3ddabe6e0cbd1699b64aa1f5ca6afde2dc44c">0af3ddab</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2584">GH#2584</a>) Optimization: Move js code into a file web/build/main.js #2584</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/0af3ddabe6e0cbd1699b64aa1f5ca6afde2dc44c">0af3ddab</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2584">GH#2584</a>) Optimization: Move js code into a file web/build/vendor.js #2584</li>
<li>[2018-07-20] (<a href="https://github.com/chamilo/chamilo-lms/commit/d7a4bceee6e2e1965061536ef95ae81c69ba0a6c">d7a4bcee</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2599">GH#2599</a>) Internal: Remove unused UserRepository file #2599, update references - Copy functions from old UserRepository to the new one. - Use shortcut UserManager::getRepository() instead of all path</li>
<li>[2018-07-19] (<a href="https://github.com/chamilo/chamilo-lms/commit/34aa5348b5be075650ef7b76da0bd73486252c15">34aa5348</a>) Display: Fix "delete" icon size</li>
<li>[2018-07-19] (<a href="https://github.com/chamilo/chamilo-lms/commit/7e884009f18514c85425446417aa2762bde6d0db">7e884009</a> - <a href="https://github.com/chamilo/chamilo-lms/issues/2598">GH#2598</a>) Display: Add "anonymous" icon</li>

@ -29,7 +29,7 @@ class IndexController extends BaseController
/**
* The Chamilo index home page.
*
* @Route("/", name="home")
* @Route("/", name="home", options={"expose"=true})
* @Method({"GET", "POST"})
*
* @param string $type courses|sessions|mycoursecategories

@ -4,12 +4,6 @@
{% import "ChamiloThemeBundle:Macros:image.html.twig" as macro_image %}
{% import 'ChamiloThemeBundle:Macros:headers.html.twig' as macro_headers %}
<!doctype html>
<!--[if lt IE 7 ]>
<html lang="{{ app.request.locale }}" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>
<html lang="{{ app.request.locale }}" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>
<html lang="{{ app.request.locale }}" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>
<html lang="{{ app.request.locale }}" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
@ -40,7 +34,6 @@
{% endblock %}
<div class="extra-header">{{ header_extra_content }}</div>
{% block chamilo_header %}
<header>
<div class="extra-header">

@ -10,7 +10,7 @@
{% endautoescape %}
<title>
{% block title %}
{{ chamilo_settings_get('platform.institution') }} - {{ chamilo_settings_get('platform.site_name') }}
{{ chamilo_settings_get('platform.institution') }} - {{ chamilo_settings_get('platform.site_name') }}
{% endblock %}
</title>
@ -37,27 +37,44 @@
{% set profile_link = '' %}
{% set message_link = '' %}
<link rel="stylesheet" href="{{ asset('build/chamilo.css') }}"/>
<link rel="stylesheet" href="{{ asset('build/vendor.css') }}"/>
<link rel="stylesheet" href="{{ asset('build/css/base.css') }}"/>
<link rel="stylesheet" href="{{ asset('build/css/themes/'~ theme ~'/default.css') }}"/>
<link rel="stylesheet" media="print" href="{{ asset('build/css/print.css') }}"/>
{# chamilo.js is generated using the file webpack.config.js and using yarn read /assets/README.md for more info #}
<script src="{{ asset('build/chamilo.js') }}"></script>
<script src="{{ asset('build/vendor.js') }}"></script>
<script src="{{ asset('libs/ckeditor/ckeditor.js') }}"></script>
<script src="{{ asset('libs/readmore-js/readmore.min.js') }}"></script>
<script src="{{ asset('libs/js-cookie/src/js.cookie.js') }}"></script>
{#<script src="{{ asset('assets/modernizr/modernizr.js') }}"></script>#}
{# Check chamilo_js key in assetic.yml #}
{% block javascripts %}
{#{%- javascripts '@chamilo_js' -%}#}
{#<script src="{{ asset_url }} "></script>#}
{#{% endjavascripts %}#}
{#<script src="{{ asset('bundles/ivoryckeditor/ckeditor.js') }}" type="text/javascript"></script>#}
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
{#<script src="{{ path('fos_js_routing_js', {"callback": "fos.Router.setData"}) }}"></script>#}
<script src="{{ asset('bundles/fosjsrouting/js/router.min.js') }}"></script>
{#<script src="{{ url('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>#}
<script src="{{ url('legacy_index') ~ 'public/js/routing?callback=fos.Router.setData' }}"></script>
{% if course %}
<script>
var logOutUrl = '{{ url('home') }}main/inc/ajax/course.ajax.php?a=course_logout&cidReq={{ course.code }}';
function courseLogout() {
$.ajax({
async : false,
url: logOutUrl,
success: function (data) {
return 1;
}
});
}
</script>
{% else %}
<script>
function courseLogout() {
}
</script>
{% endif %}
{% block chamilo_header_js %}
{# Loading legacy js using the $htmlHeadXtra array #}
@ -66,7 +83,7 @@
{{ js }}
{% endfor %}
{% endautoescape %}
{% include '@ChamiloTheme/Layout/header.js.twig' %}
{#{% include '@ChamiloTheme/Layout/header.js.twig' %}#}
{% endblock %}
{#'@MopaBootstrapBundle/Resources/public/js/eyecon-bootstrap-datepicker.js'#}
@ -77,4 +94,6 @@
{#%}#}
{#<script type="text/javascript" src="{{ asset_url | replace({'/app_dev.php': ''}) }}"></script>#}
{#{% endjavascripts %}#}
{% endblock %}
{% endblock %}
<script src="{{ asset('build/app.js') }}"></script>

@ -1,525 +0,0 @@
<script>
// External plugins not part of the default Ckeditor package.
var plugins = [
'asciimath',
'asciisvg',
'audio',
'ckeditor_wiris',
'image2_chamilo',
'dialogui',
'glossary',
'leaflet',
'mapping',
'maximize',
'mathjax',
'oembed',
'toolbar',
'toolbarswitch',
'video',
'wikilink',
'wordcount',
'youtube',
'inserthtml'
];
plugins.forEach(function (plugin) {
CKEDITOR.plugins.addExternal(plugin, '{{ asset('../main/inc/lib/javascript/ckeditor/plugins/') }}' + plugin + '/');
});
// basic plugins
plugins = [
'adobeair',
'ajax',
'docprops',
'iframedialog',
'lineutils',
'sourcedialog',
'stylesheetparser',
'sharedspace',
//'uicolor',
'widget',
'widgetselection',
'tableresize',
'xml'
];
plugins.forEach(function (plugin) {
CKEDITOR.plugins.addExternal(plugin, '{{ asset('libs/ckeditor/plugins/') }}' + plugin + '/');
});
/* Global chat variables */
var ajax_url = '{{ url('web.ajax') }}chat.ajax.php';
var online_button = '{{ asset('assets/img/statusonline.png') }}';
var offline_button = '{{ asset('assets/img/statusoffline.png') }}';
var connect_lang = '{{ "ChatConnected"|trans }}';
var disconnect_lang = '{{ "ChatDisconnected"|trans }}';
/**
* Function use to load templates in a div
**/
var showTemplates = function (ckeditorName) {
var editorName = 'content';
if (ckeditorName && ckeditorName.length > 0) {
editorName = ckeditorName;
}
CKEDITOR.editorConfig(CKEDITOR.config);
CKEDITOR.loadTemplates(CKEDITOR.config.templates_files, function (a){
var templatesConfig = CKEDITOR.getTemplates("default");
var $templatesUL = $("<ul>");
$.each(templatesConfig.templates, function () {
var template = this;
var $templateLi = $("<li>");
var templateHTML = "<img src=\"" + templatesConfig.imagesPath + template.image + "\" ><div>";
templateHTML += "<b>" + template.title + "</b>";
if (template.description) {
templateHTML += "<div class=description>" + template.description + "</div>";
}
templateHTML += "</div>";
$("<a>", {
href: "#",
html: templateHTML,
click: function (e) {
e.preventDefault();
if (CKEDITOR.instances[editorName]) {
CKEDITOR.instances[editorName].setData(template.html, function () {
this.checkDirty();
});
}
}
}).appendTo($templateLi);
$templatesUL.append($templateLi);
});
$templatesUL.appendTo("#frmModel");
});
};
function doneResizing() {
var widhtWindow = $(window).width();
if ((widhtWindow>=1024) && (widhtWindow>=768)) {
$("#profileCollapse").addClass("in");
$("#courseCollapse").addClass("in");
$("#skillsCollapse").addClass("in");
$("#sn-sidebar-collapse").addClass("in");
$("#user_image_block").removeClass("text-muted");
} else {
$("#profileCollapse").removeClass("in");
$("#courseCollapse").removeClass("in");
$("#skillsCollapse").removeClass("in");
$("#sn-avatar-one").removeClass("in");
$("#user_image_block").addClass("text-muted");
}
};
$(document).ready(function() {
$("#open-view-list").click(function(){
$("#student-list-work").fadeIn(300);
});
$("#closed-view-list").click(function(){
$("#student-list-work").fadeOut(300);
});
check_brand();
var id;
$(window).resize(function() {
clearTimeout(id);
id = setTimeout(doneResizing, 200);
});
// Removes the yellow input in Chrome
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).on('load', function() {
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
$(".accordion_jquery").accordion({
autoHeight: false,
active: false, // all items closed by default
collapsible: true,
header: ".accordion-heading"
});
// Global popup
$('body').on('click', 'a.ajax', function(e) {
e.preventDefault();
var contentUrl = this.href,
loadModalContent = $.get(contentUrl),
self = $(this);
$.when(loadModalContent).done(function(modalContent) {
var modalDialog = $('#global-modal').find('.modal-dialog'),
modalSize = self.data('size') || get_url_params(contentUrl, 'modal_size'),
modalWidth = self.data('width') || get_url_params(contentUrl, 'width'),
modalTitle = self.data('title') || ' ';
modalDialog.removeClass('modal-lg modal-sm').css('width', '');
if (modalSize) {
switch (modalSize) {
case 'lg':
modalDialog.addClass('modal-lg');
break;
case 'sm':
modalDialog.addClass('modal-sm');
break;
}
} else if (modalWidth) {
modalDialog.css('width', modalWidth + 'px');
}
$('#global-modal').find('.modal-title').text(modalTitle);
$('#global-modal').find('.modal-body').html(modalContent);
$('#global-modal').modal('show');
});
});
$('a.expand-image').on('click', function(e) {
e.preventDefault();
var title = $(this).attr('title');
var image = new Image();
image.onload = function() {
if (title) {
$('#expand-image-modal').find('.modal-title').text(title);
} else {
$('#expand-image-modal').find('.modal-title').html('&nbsp;');
}
$('#expand-image-modal').find('.modal-body').html(image);
$('#expand-image-modal').modal({
show: true
});
};
image.src = this.href;
});
// Global confirmation
$('.popup-confirmation').on('click', function() {
showConfirmationPopup(this);
return false;
});
// old jquery.menu.js
$('#navigation a').stop().animate({
'marginLeft':'50px'
},1000);
$('#navigation > li').hover(
function () {
$('a',$(this)).stop().animate({
'marginLeft':'1px'
},200);
},
function () {
$('a',$(this)).stop().animate({
'marginLeft':'50px'
},200);
}
);
/* Make responsive image maps */
//$('map').imageMapResize();
jQuery.fn.filterByText = function(textbox) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(textbox).bind('change keyup', function() {
var options = $(select).empty().data('options');
var search = $.trim($(this).val());
var regex = new RegExp(search,"gi");
$.each(options, function(i) {
var option = options[i];
if(option.text.match(regex) !== null) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
});
});
};
$(".black-shadow").mouseenter(function() {
$(this).addClass('hovered-course');
}).mouseleave(function() {
$(this).removeClass('hovered-course');
});
});
$(window).resize(function() {
check_brand();
});
$(document).scroll(function() {
var valor = $('body').outerHeight() - 700;
if ($(this).scrollTop() > 100) {
$('.bottom_actions').addClass('bottom_actions_fixed');
} else {
$('.bottom_actions').removeClass('bottom_actions_fixed');
}
if ($(this).scrollTop() > valor) {
$('.bottom_actions').removeClass('bottom_actions_fixed');
} else {
$('.bottom_actions').addClass('bottom_actions_fixed');
}
//Exercise warning fixed at the top
var fixed = $("#exercise_clock_warning");
if (fixed.length) {
if (!fixed.attr('data-top')) {
// If already fixed, then do nothing
if (fixed.hasClass('subnav-fixed')) return;
// Remember top position
var offset = fixed.offset();
fixed.attr('data-top', offset.top);
fixed.css('width', '100%');
}
if (fixed.attr('data-top') - fixed.outerHeight() <= $(this).scrollTop()) {
fixed.addClass('navbar-fixed-top');
fixed.css('width', '100%');
} else {
fixed.removeClass('navbar-fixed-top');
fixed.css('width', '100%');
}
}
// Admin -> Settings toolbar.
if ($('body').width() > 959) {
if ($('.new_actions').length) {
if (!$('.new_actions').attr('data-top')) {
// If already fixed, then do nothing
if ($('.new_actions').hasClass('new_actions-fixed')) return;
// Remember top position
var offset = $('.new_actions').offset();
var more_top = 0;
if ($('.subnav').hasClass('new_actions-fixed')) {
more_top = 50;
}
$('.new_actions').attr('data-top', offset.top + more_top);
}
// Check if the height is enough before fixing the icons menu (or otherwise removing it)
// Added a 30px offset otherwise sometimes the menu plays ping-pong when scrolling to
// the bottom of the page on short pages.
if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop() + 30) {
$('.new_actions').addClass('new_actions-fixed');
} else {
$('.new_actions').removeClass('new_actions-fixed');
}
}
}
// Bottom actions.
if ($('.bottom_actions').length) {
if (!$('.bottom_actions').attr('data-top')) {
// If already fixed, then do nothing
if ($('.bottom_actions').hasClass('bottom_actions_fixed')) return;
// Remember top position
var offset = $('.bottom_actions').offset();
$('.bottom_actions').attr('data-top', offset.top);
}
if ($('.bottom_actions').attr('data-top') > $('body').outerHeight()) {
if ( ($('.bottom_actions').attr('data-top') - $('body').outerHeight() - $('.bottom_actions').outerHeight()) >= $(this).scrollTop()) {
$('.bottom_actions').addClass('bottom_actions_fixed');
$('.bottom_actions').css("width", "100%");
} else {
$('.bottom_actions').css("width", "");
$('.bottom_actions').removeClass('bottom_actions_fixed');
}
} else {
if ( ($('.bottom_actions').attr('data-top') - $('.bottom_actions').outerHeight()) <= $(this).scrollTop()) {
$('.bottom_actions').addClass('bottom_actions_fixed');
$('.bottom_actions').css("width", "100%");
} else {
$('.bottom_actions').removeClass('bottom_actions_fixed');
$('.bottom_actions').css("width", "");
}
}
}
});
function get_url_params(q, attribute) {
var vars;
var hash;
if (q != undefined) {
q = q.split('&');
for(var i = 0; i < q.length; i++){
hash = q[i].split('=');
if (hash[0] == attribute) {
return hash[1];
}
}
}
}
function check_brand() {
if ($('.subnav').length) {
if ($(window).width() >= 969) {
$('.subnav .brand').hide();
} else {
$('.subnav .brand').show();
}
}
}
function showConfirmationPopup(obj, urlParam) {
if (urlParam) {
url = urlParam
} else {
url = obj.href;
}
var dialog = $("#dialog");
if ($("#dialog").length == 0) {
dialog = $('<div id="dialog" style="display:none">{{ "ConfirmYourChoice" | trans }} </div>').appendTo('body');
}
var width_value = 350;
var height_value = 150;
var resizable_value = true;
var new_param = get_url_params(url, 'width');
if (new_param) {
width_value = new_param;
}
var new_param = get_url_params(url, 'height')
if (new_param) {
height_value = new_param;
}
var new_param = get_url_params(url, 'resizable');
if (new_param) {
resizable_value = new_param;
}
// Show dialog
dialog.dialog({
modal : true,
width : width_value,
height : height_value,
resizable : resizable_value,
buttons: [
{
text: '{{ 'Yes' | trans }}',
click: function() {
window.location = url;
},
icons:{
primary:'ui-icon-locked'
}
},
{
text: '{{ 'No' | trans }}',
click: function() { $(this).dialog("close"); },
icons:{
primary:'ui-icon-locked'
}
}
]
});
// prevent the browser to follow the link
return false;
}
function setCheckbox(value, table_id) {
checkboxes = $("#"+table_id+" input:checkbox");
$.each(checkboxes, function(index, checkbox) {
checkbox.checked = value;
if (value) {
$(checkbox).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(checkbox).parentsUntil("tr").parent().removeClass("row_selected");
}
});
return false;
}
function action_click(element, table_id) {
d = $("#"+table_id);
if (!confirm('{{ "ConfirmYourChoice"|trans }}')) {
return false;
} else {
var action =$(element).attr("data-action");
$('#'+table_id+' input[name="action"] ').attr("value", action);
d.submit();
return false;
}
}
/**
* Generic function to replace the deprecated jQuery toggle function
* @param inId : id of block to hide / unhide
* @param inIdTxt : id of the button
* @param inTxtHide : text one of the button
* @param inTxtUnhide : text two of the button
* @todo : allow to detect if text is from a button or from a <a>
*/
function hideUnhide(inId, inIdTxt, inTxtHide, inTxtUnhide)
{
if ($('#'+inId).css("display") == "none") {
$('#'+inId).show(400);
$('#'+inIdTxt).attr("value", inTxtUnhide);
} else {
$('#'+inId).hide(400);
$('#'+inIdTxt).attr("value", inTxtHide);
}
}
function expandColumnToogle(buttonSelector, col1Info, col2Info)
{
$(buttonSelector).on('click', function (e) {
e.preventDefault();
col1Info = $.extend({
selector: '',
width: 4
}, col1Info);
col2Info = $.extend({
selector: '',
width: 8
}, col2Info);
if (!col1Info.selector || !col2Info.selector) {
return;
}
var col1 = $(col1Info.selector),
col2 = $(col2Info.selector);
$('#expand').toggleClass('hide');
$('#contract').toggleClass('hide');
if (col2.is('.col-md-' + col2Info.width)) {
col2.removeClass('col-md-' + col2Info.width).addClass('col-md-12');
col1.removeClass('col-md-' + col1Info.width).addClass('hide');
return;
}
col2.removeClass('col-md-12').addClass('col-md-' + col2Info.width);
col1.removeClass('hide').addClass('col-md-' + col1Info.width);
});
}
</script>

@ -15,8 +15,9 @@ Encore
})
.enableLessLoader()
.autoProvidejQuery()
// read main.js -> output as public/build/chamilo.js
.addEntry('chamilo', './assets/js/main.js')
// read main.js -> output as public/build/vendor.js
.addEntry('vendor', './assets/js/vendor.js')
.addEntry('app', './assets/js/app.js')
// read main.scss -> output as web/build/css/base.css
.addStyleEntry('css/base', './assets/css/main.scss')
.addStyleEntry('css/editor', './assets/css/editor.css')

Loading…
Cancel
Save