Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions lib/jquery.sizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,36 @@
* All rights reserved.
*/
/*global jQuery*/
(function ($) {

// https://github.com/umdjs/umd/blob/master/templates/jqueryPlugin.js
// Uses CommonJS, AMD or browser globals to create a jQuery plugin.
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function( root, jQuery ) {
if ( jQuery === undefined ) {
// require('jQuery') returns a factory that requires window to
// build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop
// if it's defined (how jquery works)
if ( typeof window !== 'undefined' ) {
jQuery = require('jquery');
}
else {
jQuery = require('jquery')(root);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
'use strict';
var num = function (value) {
return parseInt(value, 10) || 0;
Expand Down Expand Up @@ -73,4 +102,4 @@
return this;
};
});
}(jQuery));
}));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "jquery-sizes",
"version": "0.33.0",
"description": "jQuery extension plugin for CSS properties",
"main": "lib/jquery.sizes.js",
"keywords": [
"jQuery sizes jsizes"
],
Expand Down Expand Up @@ -34,4 +35,4 @@
"env": "env",
"echo": "echo \"\""
}
}
}