From 1974fc07173e08cdf7a39f015904b520c2087539 Mon Sep 17 00:00:00 2001 From: Matt Patterson Date: Tue, 6 May 2014 17:55:14 +0200 Subject: [PATCH] Add UMD declaration In order to require this plugin using Require JS or another AMD system both this plugin and JQuery itself must be AMD-compatible. This PR adds the Universal Module Defintion pattern from https://github.com/umdjs/umd so it works as expected with AMD and with traditional methods of inclusion. --- js/jquery.knob.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/js/jquery.knob.js b/js/jquery.knob.js index d7e2e96..4c927f7 100755 --- a/js/jquery.knob.js +++ b/js/jquery.knob.js @@ -10,7 +10,15 @@ * * Thanks to vor, eskimoblood, spiffistan, FabrizioC */ -(function($) { +(function (factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else { + // Browser globals + factory(jQuery); + } +}(function ($) { /** * Kontrol library @@ -788,4 +796,5 @@ ).parent(); }; -})(jQuery); +})); +