Created
December 18, 2011 17:18
-
-
Save sebastien-p/1493961 to your computer and use it in GitHub Desktop.
jQuery (or Zepto) plugin AMD adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;!function(a,b,c){typeof(c=this.define)=="function"&&c.amd?c(a,b):b(this[(c=/(^|[/!,])(jquery|zepto)(,|!|$)/.exec(a))&&(c[2]=="zepto"?"Zepto":"jQuery")])}(["jquery"],function($){return $}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on https://github.com/umdjs/umd | |
;!function (a, b, c) { | |
typeof (c = this.define) == "function" && c.amd ? | |
c(a, b) // Define call | |
: | |
// Globals fallback (dep. path can be something like "lib/dom/jquery"). | |
// Search for the first jquery or zepto str. in the dep. array, | |
// if found, try to get the proper ref. from the global obj. | |
b(this[(c = /(^|[/!,])(jquery|zepto)(,|!|$)/.exec(a)) && (c[2] == "zepto" ? "Zepto" : "jQuery")]) | |
} ( | |
["jquery"], function ($) { | |
// Plugin stuff... | |
return $ | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment