diff options
| -rw-r--r-- | debug_toolbar/settings.py | 1 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.js | 13 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js | 11 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.sql.js | 10 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.template.js | 10 | ||||
| -rw-r--r-- | debug_toolbar/static/debug_toolbar/js/toolbar.timer.js | 10 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/base.html | 9 | ||||
| -rw-r--r-- | docs/changes.rst | 21 | ||||
| -rw-r--r-- | docs/configuration.rst | 10 | ||||
| -rw-r--r-- | docs/panels.rst | 3 | ||||
| -rw-r--r-- | docs/tips.rst | 7 |
11 files changed, 50 insertions, 55 deletions
diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 5c2919c..7ba7012 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -18,6 +18,7 @@ CONFIG_DEFAULTS = { # Toolbar options 'DISABLE_PANELS': set(['debug_toolbar.panels.redirects.RedirectsPanel']), 'INSERT_BEFORE': '</body>', + 'JQUERY_URL': '//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js', 'RENDER_PANELS': None, 'RESULTS_STORE_SIZE': 10, 'ROOT_TAG_EXTRA_ATTRS': '', diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.js b/debug_toolbar/static/debug_toolbar/js/toolbar.js index 4bbd162..771bdda 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.js @@ -1,12 +1,4 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); - } else { - // Browser globals. - window.djdt = factory(jQuery); - } -}(function ($) { +(function ($) { var djdt = { handleDragged: false, events: { @@ -289,5 +281,4 @@ } }; $(document).ready(djdt.init); - return djdt; -})); +})(djdt.jQuery); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js index 172c2a6..1018e9b 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js @@ -1,10 +1,4 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(jQuery); - } -}(function ($) { +(function ($) { function getSubcalls(row) { var id = row.attr('id'); return $('.djDebugProfileRow[id^="'+id+'_"]'); @@ -23,5 +17,4 @@ subcalls.hide(); } }); - -})); +})(djdt.jQuery); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js index c554bce..e470ac8 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.sql.js @@ -1,13 +1,7 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(jQuery); - } -}(function ($) { +(function ($) { $('#djDebug a.djDebugToggle').on('click', function(e) { e.preventDefault(); $(this).parent().find('.djDebugCollapsed').toggle(); $(this).parent().find('.djDebugUncollapsed').toggle(); }); -})); +})(djdt.jQuery); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js index 6240898..01ac8a4 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js @@ -1,10 +1,4 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(jQuery); - } -}(function ($) { +(function ($) { var uarr = String.fromCharCode(0x25b6), darr = String.fromCharCode(0x25bc); @@ -14,4 +8,4 @@ $(this).parent().next().toggle(); return false; }); -})); +})(djdt.jQuery); diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js index 514fda7..cc9d6ae 100644 --- a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js +++ b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js @@ -1,10 +1,4 @@ -(function (factory) { - if (typeof define === 'function' && define.amd) { - define(['jquery'], factory); - } else { - factory(jQuery); - } -}(function ($) { +(function ($) { // Browser timing remains hidden unless we can successfully access the performance object var perf = window.performance || window.msPerformance || window.webkitPerformance || window.mozPerformance; @@ -51,4 +45,4 @@ addRow('domContentLoadedEventStart', 'domContentLoadedEventEnd'); addRow('loadEventStart', 'loadEventEnd'); $('#djDebugBrowserTiming').css("display", "block"); -})); +})(djdt.jQuery); diff --git a/debug_toolbar/templates/debug_toolbar/base.html b/debug_toolbar/templates/debug_toolbar/base.html index 8ce7a0e..6bc017a 100644 --- a/debug_toolbar/templates/debug_toolbar/base.html +++ b/debug_toolbar/templates/debug_toolbar/base.html @@ -3,9 +3,12 @@ @media print { #djDebug {display:none;}} </style> <link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" /> -<script>//<![CDATA[ -if(!window.jQuery) document.write('<scr'+'ipt src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></scr'+'ipt>'); -//]]></script> +{% if toolbar.config.JQUERY_URL %} +<script src="{{ toolbar.config.JQUERY_URL }}"></script> +<script>var djdt = {jQuery: jQuery.noConflict(true)};</script> +{% else %} +<script>var djdt = {jQuery: jQuery};</script> +{% endif %} <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script> <div id="djDebug" style="display:none;" dir="ltr" data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}" diff --git a/docs/changes.rst b/docs/changes.rst index 5020466..ca31fb9 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -1,6 +1,23 @@ Change log ========== +1.2 +--- + +New features +~~~~~~~~~~~~ + +* The ``JQUERY_URL`` setting defines where the toolbar loads jQuery from. + +Bugfixes +~~~~~~~~ + +* The toolbar now always loads a private copy of jQuery in order to avoid + using an incompatible version. It no longer attemps to integrate with AMD. + + This private copy is available in ``djdt.jQuery``. Third-party panels are + encouraged to use it because it should be as stable as the toolbar itself. + 1.1 --- @@ -24,8 +41,8 @@ Bugfixes Deprecated features ~~~~~~~~~~~~~~~~~~~ -* The `INTERCEPT_REDIRECT` setting is superseded by the more generic - `DISABLE_PANELS`. +* The ``INTERCEPT_REDIRECTS`` setting is superseded by the more generic + ``DISABLE_PANELS``. 1.0 --- diff --git a/docs/configuration.rst b/docs/configuration.rst index ff4ece7..0905be5 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -71,6 +71,14 @@ Toolbar options The toolbar searches for this string in the HTML and inserts itself just before. +* ``JQUERY_URL`` + + Default: ``'//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js'`` + + URL of the copy of jQuery that will be used by the toolbar. Set it to a + locally-hosted version of jQuery for offline development. Make it empty to + rely on a version of jQuery that already exists on every page of your site. + * ``RENDER_PANELS`` Default: ``None`` @@ -113,7 +121,7 @@ Toolbar options This is the dotted path to a function used for determining whether the toolbar should show or not. The default checks are that ``DEBUG`` must be set to ``True``, the IP of the request must be in ``INTERNAL_IPS``, and the - request must no be an AJAX request. You can provide your own function + request must no be an AJAX request. You can provide your own function ``callback(request)`` which returns ``True`` or ``False``. Panel options diff --git a/docs/panels.rst b/docs/panels.rst index 58713b4..8941ed2 100644 --- a/docs/panels.rst +++ b/docs/panels.rst @@ -240,7 +240,8 @@ according to the public API described below. Unless noted otherwise, all methods are optional. Panels can ship their own templates, static files and views. They're no public -CSS or JavaScript API at this time, but they can assume jQuery is available. +CSS or JavaScript API at this time, but they can assume jQuery is available in +``djdt.jQuery``. .. autoclass:: debug_toolbar.panels.Panel(*args, **kwargs) diff --git a/docs/tips.rst b/docs/tips.rst index 5e3ea40..b65c3d6 100644 --- a/docs/tips.rst +++ b/docs/tips.rst @@ -16,14 +16,13 @@ flatpages. Using the toolbar offline ------------------------- -The Debug Toolbar depends on the jQuery_ library. If jQuery isn't already -loaded in your page, the toolbar loads it from the Google Hosted Libraries +The Debug Toolbar loads the jQuery_ library from the Google Hosted Libraries CDN. Your browser will keep it in cache, allowing you to use the toolbar even if you disconnect from the Internet temporarily. If you want to use the Debug Toolbar without an Internet connection at all, or -if you refuse to depend on Google's services, you should include your own copy -of jQuery on every page. +if you refuse to depend on Google's services, look at the ``JQUERY_URL`` +configuration option. .. _jQuery: http://jquery.com/ |
