Author: jacob
Date: 2010-04-19 13:37:12 -0500 (Mon, 19 Apr 2010)
New Revision: 13002
Modified:
django/trunk/django/contrib/admin/media/js/admin/DateTimeShortcuts.js
django/trunk/django/contrib/admin/templates/admin/base.html
Log:
Fixed #11967: use a different technique to get `ADMIN_MEDIA_PREFIX` in admin JS.
We now store ADMIN_MEDIA_PREFIX on the window object and let JS files read it
from there. The old technique -- looking a <script> tags and trying to deduce
the prefix -- broke with libraries like TineMCE that dynamically add <script>
tags to the <head>.
This is potentially backwards-incompatible for folks who've overridden
`admin/base.html`; they'll need to add the proper <script> line to
their new `admin/base.html`. For that reason, this changeset shouldn't
be backported to 1.1.X.
Modified: django/trunk/django/contrib/admin/media/js/admin/DateTimeShortcuts.js
===================================================================
--- django/trunk/django/contrib/admin/media/js/admin/DateTimeShortcuts.js
2010-04-19 14:18:14 UTC (rev 13001)
+++ django/trunk/django/contrib/admin/media/js/admin/DateTimeShortcuts.js
2010-04-19 18:37:12 UTC (rev 13002)
@@ -14,15 +14,14 @@
shortCutsClass: 'datetimeshortcuts', // class of the clock and cal
shortcuts
admin_media_prefix: '',
init: function() {
- // Deduce admin_media_prefix by looking at the <script>s in the
- // current document and finding the URL of *this* module.
- var scripts = document.getElementsByTagName('script');
- for (var i=0; i<scripts.length; i++) {
- if (scripts[i].src.match(/DateTimeShortcuts/)) {
- var idx = scripts[i].src.indexOf('js/admin/DateTimeShortcuts');
- DateTimeShortcuts.admin_media_prefix =
scripts[i].src.substring(0, idx);
- break;
- }
+ // Get admin_media_prefix by grabbing it off the window object. It's
+ // set in the admin/base.html template, so if it's not there, someone's
+ // overridden the template. In that case, we'll set a clearly-invalid
+ // value in the hopes that someone will examine HTTP requests and see
it.
+ if (window.__admin_media_prefix__ != undefined) {
+ DateTimeShortcuts.admin_media_prefix =
window.__admin_media_prefix__;
+ } else {
+ DateTimeShortcuts.admin_media_prefix =
'/missing-admin-media-prefix/';
}
var inputs = document.getElementsByTagName('input');
Modified: django/trunk/django/contrib/admin/templates/admin/base.html
===================================================================
--- django/trunk/django/contrib/admin/templates/admin/base.html 2010-04-19
14:18:14 UTC (rev 13001)
+++ django/trunk/django/contrib/admin/templates/admin/base.html 2010-04-19
18:37:12 UTC (rev 13002)
@@ -6,6 +6,7 @@
{% block extrastyle %}{% endblock %}
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block
stylesheet_ie %}{% load adminmedia %}{% admin_media_prefix %}css/ie.css{%
endblock %}" /><![endif]-->
{% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block
stylesheet_rtl %}{% admin_media_prefix %}css/rtl.css{% endblock %}" />{% endif
%}
+<script type="text/javascript">window.__admin_media_prefix__ = "{% filter
escapejs %}{% admin_media_prefix %}{% endfilter %}";</script>
{% block extrahead %}{% endblock %}
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{%
endblock %}
</head>
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.