From af4f7a99dc346bb6b844564370fd6d479d6c36e7 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 20 Sep 2008 20:18:41 +0100 Subject: Use $ shortcut for jQuery without conflicting with other libraries --- debug_toolbar/media/toolbar.js | 43 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/media/toolbar.js b/debug_toolbar/media/toolbar.js index 3da65d2..b163000 100644 --- a/debug_toolbar/media/toolbar.js +++ b/debug_toolbar/media/toolbar.js @@ -1,34 +1,36 @@ jQuery.noConflict(); -jQuery(function() { - jQuery.djDebug = function(data, klass) { - jQuery.djDebug.init(); +jQuery(function($) { + $.djDebug = function(data, klass) { + $.djDebug.init(); } - jQuery.extend(jQuery.djDebug, { + $.extend($.djDebug, { init: function() { var current = null; - jQuery('#djDebugPanelList li a').click(function() { - current = jQuery('#djDebug #' + this.className); + $('#djDebugPanelList li a').click(function() { + current = $('#djDebug #' + this.className); if (current.is(':visible')) { - jQuery(document).trigger('close.djDebug'); + $(document).trigger('close.djDebug'); } else { - jQuery('.panelContent').hide(); + $('.panelContent').hide(); current.show(); - jQuery.djDebug.open(); + $.djDebug.open(); } return false; }); - jQuery('#djDebugTemplatePanel a.djTemplateShowContext').click(function() { - jQuery.djDebug.toggle_content(jQuery(this).parent().next()); - }); - jQuery('#djDebug a.close').click(function() { - jQuery(document).trigger('close.djDebug'); + $('#djDebugTemplatePanel a.djTemplateShowContext').click( + function() { + $.djDebug.toggle_content($(this).parent().next()); + } + ); + $('#djDebug a.close').click(function() { + $(document).trigger('close.djDebug'); return false; }); }, open: function() { - jQuery(document).bind('keydown.djDebug', function(e) { + $(document).bind('keydown.djDebug', function(e) { if (e.keyCode == 27) { - jQuery.djDebug.close(); + $.djDebug.close(); } }); }, @@ -40,16 +42,15 @@ jQuery(function() { } }, close: function() { - jQuery(document).trigger('close.djDebug'); + $(document).trigger('close.djDebug'); return false; } }); - jQuery(document).bind('close.djDebug', function() { - jQuery(document).unbind('keydown.djDebug'); - jQuery('.panelContent').hide(); + $(document).bind('close.djDebug', function() { + $(document).unbind('keydown.djDebug'); + $('.panelContent').hide(); }); }); - jQuery(function() { jQuery.djDebug(); }); -- cgit v1.2.3 From 8e124b0a129ab351ec6cae30d8358709d4c1430b Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sat, 20 Sep 2008 20:30:45 +0100 Subject: Use pformat for template contexts, which makes it more readable --- debug_toolbar/panels/template.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/panels/template.py b/debug_toolbar/panels/template.py index bda6630..e08f220 100644 --- a/debug_toolbar/panels/template.py +++ b/debug_toolbar/panels/template.py @@ -5,6 +5,8 @@ from django.template.loader import render_to_string from django.test.signals import template_rendered from debug_toolbar.panels import DebugPanel +from pprint import pformat + # Code taken and adapted from Simon Willison and Django Snippets: # http://www.djangosnippets.org/snippets/766/ @@ -60,7 +62,7 @@ class TemplateDebugPanel(DebugPanel): info['template'] = t # Clean up context for better readability c = d.get('context', None) - info['context'] = '\n'.join([_d.__repr__() for _d in c.dicts]) + info['context'] = '\n'.join([pformat(_d) for _d in c.dicts]) template_context.append(info) context = { 'templates': template_context, -- cgit v1.2.3