Skip to content
This repository
Browse code

Simplify jQuery.noConflict mode to fix #16

  • Loading branch information...
commit 002dea199eef9edeebd32b0ec65b0f0187ba0d5e 1 parent bb99b48
Matt Good authored February 18, 2012
19  flask_debugtoolbar/static/js/toolbar.js
... ...
@@ -1,19 +1,4 @@
1  
-(function(window, document, version, callback) {
2  
-	var j, d;
3  
-	var loaded = false;
4  
-	if (!(j = window.jQuery) || version > j.fn.jquery || callback(j)) {
5  
-		var script = document.createElement("script");
6  
-		script.type = "text/javascript";
7  
-		script.src = DEBUG_TOOLBAR_STATIC_PATH + "js/jquery.js";
8  
-		script.onload = script.onreadystatechange = function() {
9  
-			if (!loaded && (!(d = this.readyState) || d == "loaded" || d == "complete")) {
10  
-				callback((j = window.jQuery).noConflict(1), loaded = true);
11  
-				j(script).remove();
12  
-			}
13  
-		};
14  
-		document.documentElement.childNodes[0].appendChild(script)
15  
-	}
16  
-})(window, document, "1.3", function($, jquery_loaded) {
  1
+(function($) {
17 2
     $.cookie = function(name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = $.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } };
18 3
     $('head').append('<link rel="stylesheet" href="'+DEBUG_TOOLBAR_STATIC_PATH+'css/toolbar.css?'+ Math.random() +'" type="text/css" />');
19 4
 	var COOKIE_NAME = 'fldt';
@@ -181,4 +166,4 @@
181 166
 		fldt.init();
182 167
 	});
183 168
 
184  
-});
  169
+})(jQuery.noConflict(true));
1  flask_debugtoolbar/templates/base.html
... ...
@@ -1,5 +1,6 @@
1 1
 <div id="flDebug" style="display:none;">
2 2
     <script type="text/javascript">var DEBUG_TOOLBAR_STATIC_PATH = '{{ static_path }}'</script>
  3
+    <script type="text/javascript" src="{{ static_path }}js/jquery.js"></script>
3 4
     <script type="text/javascript" src="{{ static_path }}js/toolbar.js"></script>
4 5
 
5 6
     <div style="display: none;" id="flDebugToolbar">

0 notes on commit 002dea1

Please sign in to comment.
Something went wrong with that request. Please try again.