Skip to content

Commit

Permalink
Merge pull request #20 from websdotcom/wrap-in-umd
Browse files Browse the repository at this point in the history
Wrap in UMD (so that it supports AMD)
  • Loading branch information
jackocnr committed Jan 20, 2014
2 parents c9a68b1 + 9b7c9d3 commit ed1e5eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
13 changes: 10 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,17 @@ module.exports = function(grunt) {
'license: <%= pkg.license %>\n'+
'author: <%= pkg.author %>\n'+
'*/\n'+
// wrap in self-executing anonymous function
'(function($, window, document, undefined) {\n'+
'(function (factory) {\n'+
' if (typeof define === \'function\' && define.amd) {\n'+
' // AMD. Register as an anonymous module.\n'+
' define([\'jquery\'], function($){factory($, window, document);});\n'+
' } else {\n'+
' // Browser globals\n'+
' factory(jQuery, window, document);\n'+
' }\n'+
'}(function ($, window, document, undefined) {\n'+
'"use strict";\n\n',
footer: "\n\n})(jQuery, window, document);\n"
footer: '\n\n}));\n'
},
dev: {
options: {
Expand Down
12 changes: 10 additions & 2 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ repository: https://github.com/Bluefieldscom/intl-tel-input.git
license: MIT
author: Jack O'Connor (http://jackocnr.com)
*/
(function($, window, document, undefined) {
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], function($){factory($, window, document);});
} else {
// Browser globals
factory(jQuery, window, document);
}
}(function ($, window, document, undefined) {
"use strict";

var pluginName = "intlTelInput", id = 1, // give each instance it's own id for namespaced event handling
Expand Down Expand Up @@ -1744,4 +1752,4 @@ var intlDataFull = {
}
};

})(jQuery, window, document);
}));
Loading

0 comments on commit ed1e5eb

Please sign in to comment.