# HG changeset patch # User dellsystem # Date 1348956215 14400 # Node ID 4d358e1e301473229ebdd937f0887b193c88cc71 # Parent 00c71a6192ded3ab84f1c595f23de5863beea15b Add "highlight code" link, to easily select code diff -r 00c71a6192de -r 4d358e1e3014 static/js/agora.js --- a/static/js/agora.js Sat Sep 29 18:03:07 2012 -0400 +++ b/static/js/agora.js Sat Sep 29 18:03:35 2012 -0400 @@ -19,6 +19,24 @@ } }; + // jQuery plugin for selecting text + $.fn.selectText = function () { + var element = this[0]; + var range, selection; + + if (document.body.createTextRange) { + range = document.body.createTextRange(); + range.moveToElementText(element); + range.select(); + } else if (window.getSelection) { + selection = window.getSelection(); + range = document.createRange(); + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); + } + }; + $(document).ready(function () { handleLoginLink(); @@ -34,5 +52,10 @@ $('.line-counters').append(div); }); } + + // Highlight the code when the link is clicked + $('.highlight-code-lines').click(function () { + $('.code-lines').selectText(); + }); }); })(jQuery); diff -r 00c71a6192de -r 4d358e1e3014 templates/snippet/snippet_details.djhtml --- a/templates/snippet/snippet_details.djhtml Sat Sep 29 18:03:07 2012 -0400 +++ b/templates/snippet/snippet_details.djhtml Sat Sep 29 18:03:35 2012 -0400 @@ -72,6 +72,8 @@ {% endfor %} + — + Highlight code
Author: {% if snippet.author %}