]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Made the noConflict() check more robust. Now works when Zepto is in noConflict-like... 1844/head
authormmikitka <matt@mikitka.net>
Wed, 13 Mar 2013 13:24:25 +0000 (09:24 -0400)
committermmikitka <matt@mikitka.net>
Wed, 13 Mar 2013 13:24:25 +0000 (09:24 -0400)
js/foundation/foundation.js

index 5f6f8c1aadaca3c0815c185eef9488c53eae1525..d4246f58a94fe715dd764289a2b05485e715ec2e 100644 (file)
@@ -8,11 +8,21 @@
 
 /*jslint unparam: true, browser: true, indent: 2 */
 
-// Accommodate running jQuery in noConflict() mode by
-// using an anonymous function to redefine the jQuery $
-// shorthand name. See http://docs.jquery.com/Using_jQuery_with_Other_Libraries
-if (jQuery == null) {
-    var jQuery = $;
+// Accommodate running jQuery or Zepto in noConflict() mode by
+// using an anonymous function to redefine the $ shorthand name.
+// See http://docs.jquery.com/Using_jQuery_with_Other_Libraries
+// and http://zeptojs.com/
+var libFuncName = null;
+if (typeof jQuery === "undefined" &&
+    typeof Zepto === "undefined" &&
+    typeof $ === "function") {
+    libFuncName = $;
+} else if (typeof jQuery === "function") {
+    libFuncName = jQuery;
+} else if (typeof Zepto === "function") {
+    libFuncName = Zepto;
+} else {
+    throw new TypeError();
 }
 
 (function ($) {
@@ -339,4 +349,4 @@ if (jQuery == null) {
 
 }(this, this.document));
 
-})(jQuery);
+})(libFuncName);