divio/django-cms — pull request #1909 by gldnspud (2013-05-30 23:14:25+00:00)
Title: Ensure 'jQuery' is in the 'window' (global) namespace.

When running in DEBUG=False mode, a visit to `/admin/cms/page/add/` would load the following scripts in this order:

- ...
- `/static/admin/js/jquery.min.js` <-- creates window.jQuery
- `/static/admin/js/jquery.init.js` <-- replaces with django.jQuery
- ...
- `/static/cms/js/plugins/jquery.query.js` <-- cannot find window.jQuery
- ...

However in DEBUG=True mode, the following scripts would load:

- ...
- `/static/admin/js/jquery.js` <-- create window.jQuery
- `/static/admin/js/jquery.init.js` <-- replaces with django.jQuery
- ...
- `/static/admin/js/jquery.min.js` <-- creates window.jQuery again
- `/static/cms/js/plugins/jquery.query.js` <-- can find and use window.jQuery
- ...

From what I can tell this is a side-effect of having to support Django 1.3 through Django 1.5 as discussed in #1584

This patch introduces a `jquery.globaljquery.js` script in the three places in django-cms that load `jquery.min.js`; that way, if it's already loaded earlier and thus already moved to `django.jQuery`, it's available once again as `window.jQuery` for any plugins that are subsequently loaded.