diff --git a/main/template/default/layout/footer.js.tpl b/main/template/default/layout/footer.js.tpl new file mode 100644 index 0000000000..24768bb5e7 --- /dev/null +++ b/main/template/default/layout/footer.js.tpl @@ -0,0 +1,111 @@ + diff --git a/main/template/default/layout/footer.tpl b/main/template/default/layout/footer.tpl index 89bb9fc1ed..c2a99fb83a 100755 --- a/main/template/default/layout/footer.tpl +++ b/main/template/default/layout/footer.tpl @@ -72,160 +72,6 @@ - +{% include template ~ '/layout/footer.js.tpl' %} {{ execution_stats }} diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index 8c1241774d..b04522d2c3 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -15,405 +15,19 @@ {{ social_meta }} {{ css_static_file_to_string }} {{ js_file_to_string }} - {{ extra_headers }} -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]; - } - } - } -} -$(document).ready(function(){ - $("#open-view-list").click(function(){ - $("#student-list-work").fadeIn(300); - }); - $("#closed-view-list").click(function(){ - $("#student-list-work").fadeOut(300); - }); -}); -function check_brand() { - if ($('.subnav').length) { - if ($(window).width() >= 969) { - $('.subnav .brand').hide(); - } else { - $('.subnav .brand').show(); - } - } -} - -$(window).resize(function() { - check_brand(); -}); - -$(document).scroll(function() { - - //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('subnav-fixed'); - fixed.css('width', '100%'); - } else { - fixed.removeClass('subnav-fixed'); - fixed.css('width', '200px'); - } - } - - // 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); - } - - if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop()) { - $('.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 showConfirmationPopup(obj, urlParam) -{ - if (urlParam) { - url = urlParam - } else { - url = obj.href; - } - - var dialog = $("#dialog"); - if ($("#dialog").length == 0) { - dialog = $('
').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' | get_lang }}', - click: function() { - window.location = url; - }, - icons:{ - primary:'ui-icon-locked' - } - }, - { - text: '{{ 'No' | get_lang }}', - click: function() { $(this).dialog("close"); }, - icons:{ - primary:'ui-icon-locked' - } - } - ] - }); - // prevent the browser to follow the link - return false; -} - -$(function() { - - check_brand(); - //if exists the toolbar admin - - if($('#toolbar').length){ - var heigthToolBar= $('#toolbar').height(); - $('header').css('margin-top', heigthToolBar+'px'); - $('#page-back').css('padding-top', heigthToolBar+20+'px'); - } - - // Removes the yellow input in Chrome - if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) { - $(window).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(' '); - } - - $('#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); - } - ); +{% include template ~ '/layout/header.js.tpl' %} - /* Make responsive image maps */ - $('map').imageMapResize(); -}); - {{ css_custom_file_to_string }} {{ css_style_print }} {# Extra header configured in admin section, only shown to non-admins #} diff --git a/main/template/default/layout/header.js.tpl b/main/template/default/layout/header.js.tpl new file mode 100644 index 0000000000..ac01fa0e9d --- /dev/null +++ b/main/template/default/layout/header.js.tpl @@ -0,0 +1,425 @@ +