';
var offline_button = '
';
var connect_lang = '{{ "ChatConnected"|get_lang | escape('js')}}';
var disconnect_lang = '{{ "ChatDisconnected"|get_lang | escape('js')}}';
var chatLang = '{{ "GlobalChat"|get_lang | escape('js')}}';
var sessionRemainingSeconds = 0;
var sessionCounterInterval;
var sessionClosing = false;
{% if 'hide_chat_video'|api_get_configuration_value %}
var hide_chat_video = true;
{% else %}
var hide_chat_video = false;
{% endif %}
$(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 globalModal = $('#global-modal');
if ($(this).hasClass('no-close-button')) {
globalModal.find('.close').hide();
}
if ($(this).hasClass('no-header')) {
globalModal.find('.modal-header').hide();
}
var blockDiv = $(this).attr('data-block-closing');
if (blockDiv != '') {
globalModal.attr('data-backdrop', 'static');
globalModal.attr('data-keyboard', 'false');
}
var contentUrl = this.href;
var self = $(this);
if (contentUrl == 'javascript:void(0);') {
var
modalSize = self.data('size'),
modalWidth = self.data('width'),
modalTitle = self.data('title');
modalContent = self.data('content');
globalModal.find('.modal-title').text(modalTitle);
globalModal.find('.modal-body').html(modalContent);
globalModal.modal('show');
return true;
}
if (contentUrl) {
var loadModalContent = $.get(contentUrl);
$.when(loadModalContent).done(function (modalContent) {
var modalDialog = globalModal.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');
}
globalModal.find('.modal-title').text(modalTitle);
globalModal.find('.modal-body').html(modalContent);
globalModal.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(' ');
}
$('#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 | escape('js')}} ' + $(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(
$('