Mercurial > agora-palash
view static/js/agora.js @ 137:00c71a6192de
Make line numbers work for real
This commit has a very long and tragic backstory. For details:
http://dellsystem.me/posts/line-numbering/
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Sat, 29 Sep 2012 18:03:07 -0400 |
parents | 2bca07be6e51 |
children | 4d358e1e3014 |
line wrap: on
line source
(function ($) { // Handle showing the login popup var handleLoginLink = function () { var loginLink = $('.login-link'); if (loginLink.length) { loginLink.click(function () { $('#login-popup').show(); return false; }); $('#login-popup').click(function (event) { // Only catch events in the outer, overlay div if (event.target === this) { $(this).hide(); } }); } }; $(document).ready(function () { handleLoginLink(); // Add in the line numbers (no JS fallback unfortunately) if ($('.snippet').length) { var counter = 1; $('.code-lines').children().each(function () { // Set the top offset to be the same as that of the line var div = '<p style="top: ' + this.offsetTop + 'px">' + '<a href="#l' + counter + '">' + counter + '</a></p>'; counter++; $('.line-counters').append(div); }); } }); })(jQuery);