From ea1f9430ddb58f28b50cc702f9eb2612f19e308d Mon Sep 17 00:00:00 2001 From: Rob Hudson Date: Sun, 22 Mar 2009 23:41:15 -0700 Subject: Add fix so jQuery doesn't conflict with other Javascript libraries. I think I finally got this one working. The saving of the temporary variable has to happen *before* jQuery loads, or else jQuery has already stomped on the '$' variable that another library might have used. This patch moves the temporary saving of this variable the HTML template so it tucks it aside before jQuery loads and puts it back after we're done. Tested and works with jQuery, mootools, and prototype.--- debug_toolbar/media/toolbar.js | 7 ++----- debug_toolbar/media/toolbar.min.js | 2 +- debug_toolbar/templates/debug_toolbar/base.html | 7 +++++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/debug_toolbar/media/toolbar.js b/debug_toolbar/media/toolbar.js index 3ada44a..40e1a58 100644 --- a/debug_toolbar/media/toolbar.js +++ b/debug_toolbar/media/toolbar.js @@ -1,6 +1,5 @@ -var _$ = window.$; -$j = jQuery.noConflict(); -jQuery(function() { +jQuery.noConflict(); +jQuery(function($j) { var COOKIE_NAME = 'dj_debug_panel'; $j.djDebug = function(data, klass) { $j.djDebug.init(); @@ -104,5 +103,3 @@ jQuery(function() { jQuery(function() { jQuery.djDebug(); }); -$ = _$; - diff --git a/debug_toolbar/media/toolbar.min.js b/debug_toolbar/media/toolbar.min.js index 4c967f8..7f8658f 100644 --- a/debug_toolbar/media/toolbar.min.js +++ b/debug_toolbar/media/toolbar.min.js @@ -1 +1 @@ -var _$=window.$;$j=jQuery.noConflict();jQuery(function(){var a="dj_debug_panel";$j.djDebug=function(c,b){$j.djDebug.init()};$j.extend($j.djDebug,{init:function(){var b=null;$j("#djDebugPanelList li a").click(function(){if(!this.className){return false}b=$j("#djDebug #"+this.className);if(b.is(":visible")){$j(document).trigger("close.djDebug")}else{$j(".panelContent").hide();b.show();$j.djDebug.open()}return false});$j("#djDebug a.close").click(function(){$j(document).trigger("close.djDebug");return false});$j("#djDebug a.remoteCall").click(function(){$j("#djDebugWindow").load(this.href,{},function(){$j("#djDebugWindow a.back").click(function(){$j(this).parent().hide();return false})});$j("#djDebugWindow").show();return false});$j("#djDebugTemplatePanel a.djTemplateShowContext").click(function(){$j.djDebug.toggle_content($j(this).parent().next());return false});$j("#djDebugSQLPanel a.djSQLShowStacktrace").click(function(){$j.djDebug.toggle_content($j(this).parent().next());return false});$j("#djHideToolBarButton").click(function(){$j.djDebug.hide_toolbar(true);return false});$j("#djShowToolBarButton").click(function(){$j.djDebug.show_toolbar();return false});if($j.cookie(a)){$j.djDebug.hide_toolbar(false)}else{$j("#djDebugToolbar").show()}},open:function(){$j(document).bind("keydown.djDebug",function(b){if(b.keyCode==27){$j.djDebug.close()}})},toggle_content:function(b){if(b.is(":visible")){b.hide()}else{b.show()}},close:function(){$j(document).trigger("close.djDebug");return false},hide_toolbar:function(b){$j("#djDebugToolbar").hide("fast");$j("#djDebugToolbarHandle").show();if(b){$j.cookie(a,"hide",{path:"/",expires:10})}},show_toolbar:function(){$j("#djDebugToolbarHandle").hide();$j("#djDebugToolbar").show("fast");$j.cookie(a,null,{path:"/",expires:-1})}});$j(document).bind("close.djDebug",function(){$j(document).unbind("keydown.djDebug");$j(".panelContent").hide()})});jQuery(function(){jQuery.djDebug()});$=_$;jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h + // When jQuery is sourced, it's going to overwrite whatever might be in the + // '$' variable, so store a reference of it in a temporary variable... + var _$ = window.$; if (typeof jQuery == 'undefined') { var jquery_url = '{{ BASE_URL }}/__debug__/m/jquery.js'; document.write(unescape('%3Cscript src="' + jquery_url + '" type="text/javascript"%3E%3C/script%3E')); } + -- cgit v1.2.3