{% load i18n %} {% if not err %} {% if filetype == 'Text' %} {% ifnotequal file_content None %} var editor = CodeMirror.fromTextArea($('#docu-view')[0], { {% include 'snippets/editor_set_mode.html' %} theme: 'default', indentUnit: 4, {% if fileext != 'txt' and fileext != 'text' %} lineNumbers: true, {% endif %} lineWrapping: true, readOnly: true }); {% endifnotequal %} {% endif %} {% if filetype == 'Image' %} window.onload = function () { var img = $('#image-view'); var img_h = img.outerHeight(); var file_view_h = parseInt($('#file-view').css('min-height')); {% if img_prev or img_next %} var prev_next_h = $('#img-prev-next').outerHeight(true); {% else %} var prev_next_h = 0; {% endif %} if (img_h < file_view_h - prev_next_h) { img.css({'margin-top':(file_view_h - img_h - prev_next_h)/2}); } if (img.width() > 946) { img.width(946); } img.removeClass('vh'); } {% if img_prev or img_next %} var input_focus = false; $('input, textarea').focus(function() { input_focus = true; }).blur(function() { input_focus = false; }); $('body').bind('keydown', function(e) { if (!input_focus) { // so cursor move in form input element can work normally {% if img_prev %} if (e.keyCode == 37) { // press '<-' location.href = $('#img-prev').attr('href'); } {% endif %} {% if img_next %} if (e.keyCode == 39) { // press '->' location.href = $('#img-next').attr('href'); } {% endif %} } }) {% endif %} {% endif %} {% if filetype == 'SVG' %} if (!$.browser.mozilla && !$.browser.safari && !($.browser.msie && parseInt($.browser.version) > 8)) { $('#file-view').html('
' + "{% trans "To view it online, you can use firefox, chrome or IE 9." %}" + '
{% trans "You can use IE 10 or other browsers, for example, Firefox, to view it online." %}