/* For licensing terms, see /license.txt */ // Load symfony routes in order to use it in a js const routes = require('../../public/js/fos_js_routes.json'); import Routing from '../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.min.js'; // Import Vue and Components import Vue from 'vue'; import {VueConfig} from './VueConfig'; import Example from './components/Example'; import $ from 'jquery'; window.jQuery = $; window.$ = $; Routing.setRoutingData(routes); const locale = document.querySelector('html').lang; require('./vendor'); require('./main'); require('webpack-jquery-ui'); require('webpack-jquery-ui/css'); // @todo rework url naming const homePublicUrl = Routing.generate('home'); const mainUrl = homePublicUrl + 'main/'; const webAjax = homePublicUrl + 'main/inc/ajax/'; console.log(webAjax); var ajax_url = webAjax + 'chat.ajax.php'; var online_button = ''; var offline_button = ''; /*var connect_lang = '{{ "ChatConnected"|get_lang }}'; var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}';*/ var connect_lang = 'ChatConnected'; var disconnect_lang = 'ChatDisconnected'; $(function () { if (document.getElementById('app_header')) { // Create Vue Application new Vue( Object.assign(VueConfig, { el: '#app_header', components: {Example}, data() { return { chamilo: '' } }, methods: { getConsole() { console.log("Hello Vuejs"); } }, created() { this.chamilo = "Hello Chamilo"; this.getConsole(); console.log(this.chamilo); } }) ); } var webCidReq = '&cidReq=' + $('body').attr('data-course-code'); window.webCidReq = webCidReq; $("#menu_courses").click(function(){ return false; }); $("#menu_social").click(function(){ return false; }); $("#menu_administrator").click(function(){ return false; }); var isInCourse = $("body").data("in-course"); if (isInCourse == true) { var courseCode = $("body").data("course-code"); var logOutUrl = webAjax + 'course.ajax.php?a=course_logout&cidReq=' + courseCode; function courseLogout() { $.ajax({ async: false, url: logOutUrl, success: function (data) { return 1; } }); } 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); }); // 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); }); }); } // 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'); }); }); $('#global-modal').on('hidden.bs.modal', function () { jQuery(".embed-responsive").find('iframe').remove(); }); // 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(' '); } $('#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 }}: ' + $(e.relatedTarget).data('item-title') + ''; var message = 'AreYouSureToDeleteJS : ' + $(e.relatedTarget).data('item-title') + ''; 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( $('