Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from fernandogmar/master

Added AMD and CommonJS modules support
  • Loading branch information...
commit f9a3347956c7c97e8a960359af5767fac8b0dda3 2 parents ce83f1f + c9cbbb8
@jpjoyal authored
Showing with 16 additions and 3 deletions.
  1. +1 −0  README.markdown
  2. +15 −3 jquery.jsperanto.js
View
1  README.markdown
@@ -9,6 +9,7 @@ Simple translation for your javascripts, yummy with your favorite templates engi
* similar to Rails's i18n but sans backend needed
* No global pollution (hides under jQuery.jsperanto)
* Works with : IE6+, Firefox 3+, Safari 3+, Chrome, Opera 9+
+ * AMD, CommonJS modules supported
Depends on jQuery 1.3.2+ (uses $.ajax, $.each, $.extend)
View
18 jquery.jsperanto.js
@@ -1,8 +1,19 @@
//jquery 1.3.2 dependencies : $.each, $.extend, $.ajax
-(function($) {
+// Uses CommonJS, AMD or browser globals to create a jQuery extension.
+(function (factory) {
+ if (typeof exports === 'object') {
+ // Node/CommonJS
+ factory(require('jquery'));
+ } else if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define(['jquery'], factory);
+ } else {
+ // Browser globals
+ factory(jQuery);
+ }
+}(function($) {
-
var o = {};
var dictionary = false; //not yet loaded
var currentLang = false;
@@ -150,4 +161,5 @@
detectLanguage : detectLanguage,
lang : lang
};
-})(jQuery);
+}));
+
Please sign in to comment.
Something went wrong with that request. Please try again.