SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 0a2397b4 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add quick/dirty click-focus func on tex page

parent 46f02f17
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h3>Please process this code in your Tex Compiler:</h3> <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>
</div> </div>
...@@ -38,4 +38,36 @@ ...@@ -38,4 +38,36 @@
</form> </form>
</div> </div>
</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 %} {% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment