From 0a2397b46bd2ca16a81330535289dfd1208e0bc2 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Thu, 6 Jul 2017 10:32:34 +0200 Subject: [PATCH] Add quick/dirty click-focus func on tex page --- .../submissions/reports_pdf_compile.html | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/submissions/templates/submissions/reports_pdf_compile.html b/submissions/templates/submissions/reports_pdf_compile.html index 4caf7ba1d..ec589e304 100644 --- a/submissions/templates/submissions/reports_pdf_compile.html +++ b/submissions/templates/submissions/reports_pdf_compile.html @@ -24,7 +24,7 @@ <div class="row"> <div class="col-12"> <h3>Please process this code in your Tex Compiler:</h3> - <pre><code>{% include 'submissions/_report_tex_template.html' with report=report %}</code></pre> + <pre class="clickfocus"><code>{% include 'submissions/_report_tex_template.html' with report=report %}</code></pre> </div> </div> @@ -38,4 +38,36 @@ </form> </div> </div> + +<script> + jQuery.fn.selectText = function(){ + this.find('input').each(function() { + if($(this).prev().length == 0 || !$(this).prev().hasClass('p_copy')) { + $('<p class="p_copy" style="position: absolute; z-index: -1;"></p>').insertBefore($(this)); + } + $(this).prev().html($(this).val()); + }); + var doc = document; + var element = this[0]; + + if (doc.body.createTextRange) { + var range = document.body.createTextRange(); + range.moveToElementText(element); + range.select(); + } else if (window.getSelection) { + var selection = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); + } + }; + + $(function() { + $('.clickfocus').on('click', function() { + $(this).find('code').selectText(); + }); + }); +</script> + {% endblock %} -- GitLab