Skip to content

Commit 727b4e0

Browse files
committed
Make the pain go away.
Fix #581, #544, #541, #535 and a few others.
1 parent 6ce52b2 commit 727b4e0

File tree

11 files changed

+50
-55
lines changed

11 files changed

+50
-55
lines changed

debug_toolbar/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
# Toolbar options
1919
'DISABLE_PANELS': set(['debug_toolbar.panels.redirects.RedirectsPanel']),
2020
'INSERT_BEFORE': '</body>',
21+
'JQUERY_URL': '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js',
2122
'RENDER_PANELS': None,
2223
'RESULTS_STORE_SIZE': 10,
2324
'ROOT_TAG_EXTRA_ATTRS': '',

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
// AMD. Register as anonymous module.
4-
define(['jquery'], factory);
5-
} else {
6-
// Browser globals.
7-
window.djdt = factory(jQuery);
8-
}
9-
}(function ($) {
1+
(function ($) {
102
var djdt = {
113
handleDragged: false,
124
events: {
@@ -283,5 +275,4 @@
283275
}
284276
};
285277
$(document).ready(djdt.init);
286-
return djdt;
287-
}));
278+
})(djdt.jQuery);

debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
define(['jquery'], factory);
4-
} else {
5-
factory(jQuery);
6-
}
7-
}(function ($) {
1+
(function ($) {
82
function getSubcalls(row) {
93
var id = row.attr('id');
104
return $('.djDebugProfileRow[id^="'+id+'_"]');
@@ -23,5 +17,4 @@
2317
subcalls.hide();
2418
}
2519
});
26-
27-
}));
20+
})(djdt.jQuery);
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
define(['jquery'], factory);
4-
} else {
5-
factory(jQuery);
6-
}
7-
}(function ($) {
1+
(function ($) {
82
$('#djDebug a.djDebugToggle').on('click', function(e) {
93
e.preventDefault();
104
$(this).parent().find('.djDebugCollapsed').toggle();
115
$(this).parent().find('.djDebugUncollapsed').toggle();
126
});
13-
}));
7+
})(djdt.jQuery);
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
define(['jquery'], factory);
4-
} else {
5-
factory(jQuery);
6-
}
7-
}(function ($) {
1+
(function ($) {
82
var uarr = String.fromCharCode(0x25b6),
93
darr = String.fromCharCode(0x25bc);
104

@@ -14,4 +8,4 @@
148
$(this).parent().next().toggle();
159
return false;
1610
});
17-
}));
11+
})(djdt.jQuery);

debug_toolbar/static/debug_toolbar/js/toolbar.timer.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
(function (factory) {
2-
if (typeof define === 'function' && define.amd) {
3-
define(['jquery'], factory);
4-
} else {
5-
factory(jQuery);
6-
}
7-
}(function ($) {
1+
(function ($) {
82
// Browser timing remains hidden unless we can successfully access the performance object
93
var perf = window.performance || window.msPerformance ||
104
window.webkitPerformance || window.mozPerformance;
@@ -51,4 +45,4 @@
5145
addRow('domContentLoadedEventStart', 'domContentLoadedEventEnd');
5246
addRow('loadEventStart', 'loadEventEnd');
5347
$('#djDebugBrowserTiming').css("display", "block");
54-
}));
48+
})(djdt.jQuery);

debug_toolbar/templates/debug_toolbar/base.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
@media print { #djDebug {display:none;}}
44
</style>
55
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" />
6-
<script>//<![CDATA[
7-
if(!window.jQuery) document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></scr'+'ipt>');
8-
//]]></script>
6+
{% if toolbar.config.JQUERY_URL %}
7+
<script src="{{ toolbar.config.JQUERY_URL }}"></script>
8+
<script>var djdt = {jQuery: jQuery.noConflict(true)};</script>
9+
{% else %}
10+
<script>var djdt = {jQuery: jQuery};</script>
11+
{% endif %}
912
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script>
1013
<div id="djDebug" style="display:none;" dir="ltr"
1114
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}"

docs/changes.rst

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
Change log
22
==========
33

4+
1.2
5+
---
6+
7+
New features
8+
~~~~~~~~~~~~
9+
10+
* The ``JQUERY_URL`` setting defines where the toolbar loads jQuery from.
11+
12+
Bugfixes
13+
~~~~~~~~
14+
15+
* The toolbar now always loads a private copy of jQuery in order to avoid
16+
using an incompatible version. It no longer attemps to integrate with AMD.
17+
18+
This private copy is available in ``djdt.jQuery``. Third-party panels are
19+
encouraged to use it because it should be as stable as the toolbar itself.
20+
421
1.1
522
---
623

@@ -24,8 +41,8 @@ Bugfixes
2441
Deprecated features
2542
~~~~~~~~~~~~~~~~~~~
2643

27-
* The `INTERCEPT_REDIRECT` setting is superseded by the more generic
28-
`DISABLE_PANELS`.
44+
* The ``INTERCEPT_REDIRECTS`` setting is superseded by the more generic
45+
``DISABLE_PANELS``.
2946

3047
1.0
3148
---

docs/configuration.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ Toolbar options
7171
The toolbar searches for this string in the HTML and inserts itself just
7272
before.
7373

74+
* ``JQUERY_URL``
75+
76+
Default: ``'//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js'``
77+
78+
URL of the copy of jQuery that will be used by the toolbar. Set it to a
79+
locally-hosted version of jQuery for offline development. Make it empty to
80+
rely on a version of jQuery that already exists on every page of your site.
81+
7482
* ``RENDER_PANELS``
7583

7684
Default: ``None``
@@ -113,7 +121,7 @@ Toolbar options
113121
This is the dotted path to a function used for determining whether the
114122
toolbar should show or not. The default checks are that ``DEBUG`` must be
115123
set to ``True``, the IP of the request must be in ``INTERNAL_IPS``, and the
116-
request must no be an AJAX request. You can provide your own function
124+
request must no be an AJAX request. You can provide your own function
117125
``callback(request)`` which returns ``True`` or ``False``.
118126

119127
Panel options

docs/panels.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ according to the public API described below. Unless noted otherwise, all
240240
methods are optional.
241241

242242
Panels can ship their own templates, static files and views. They're no public
243-
CSS or JavaScript API at this time, but they can assume jQuery is available.
243+
CSS or JavaScript API at this time, but they can assume jQuery is available in
244+
``djdt.jQuery``.
244245

245246
.. autoclass:: debug_toolbar.panels.Panel(*args, **kwargs)
246247

0 commit comments

Comments
 (0)