Mercurial > agora-palash
view templates/snippet/snippet_details.js @ 48:329a9d17be88
Implement/fix js for snippets and make whiteboxes all same width
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Mon, 02 Aug 2010 23:44:23 -0500 |
parents | 139e4b8ffb17 |
children | f872c643b056 |
line wrap: on
line source
jQuery(document).ready(function(){ curLine = document.location.hash; if(curLine.substring(0,2) == '#l'){ $('div.snippet div.line'+curLine).addClass('marked'); } $("div.accordion").accordion({ autoHeight: false, header: 'h3', animation: 'bounceslide', duration: 2000 }); /** * Diff Ajax Call */ $("form#diffform").submit(function() { $.get("{% url snippet_diff %}", { a: $("input[name=a]:checked").val(), b: $("input[name=b]:checked").val() }, function(data){ $('#diff').html(data).slideDown('fast'); }); return false; }); /** * Wordwrap */ $('#toggleWordwrap').toggle( function(){ $('div.snippet pre.code').css('white-space', 'pre-wrap'); return false; }, function(){ $('div.snippet pre.code').css('white-space', 'pre'); return false; } ); /** * Line Highlighting */ $('div.snippet th a').each(function(i){ $(this).click(function(){ var j = $(this).text(); $('div.snippet div.line.marked').removeClass('marked'); $('div.snippet div.line#l'+j).toggleClass('marked'); }); }); //{% if request.session.userprefs.display_all_lexer %} /** * Lexer Guessing */ $('#guess_lexer_btn').click(function(){ $.getJSON('{% url snippet_guess_lexer %}', {'codestring': $('#id_content').val()}, function(data){ if(data.lexer == "unknown"){ $('#guess_lexer_btn').css('color', 'red'); }else{ $('#id_lexer').val(data.lexer); $('#guess_lexer_btn').css('color', 'inherit'); } }); }); //{% endif %} });