From 10e68d116a27c400e8d266b8767e34fee9f382de Mon Sep 17 00:00:00 2001 From: Christian Hammond Date: Sun, 4 Aug 2013 12:13:56 -0700 Subject: [PATCH] Add support for require.js and other AMD loaders. --- jquery.timesince.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jquery.timesince.js b/jquery.timesince.js index 493eb06..592bad3 100644 --- a/jquery.timesince.js +++ b/jquery.timesince.js @@ -14,14 +14,23 @@ * See https://github.com/chipx86/jquery-timesince for the latest. * * @name timesince - * @version 0.1 + * @version 0.2 * @requires jQuery v1.2.3+ * @author Christian Hammond * @license MIT License - http://www.opensource.org/licenses/mit-license.php * - * Copyright (c) 2012-2013 Beanbag, Inc. + * Copyright (c) 2012, Christian Hammond (chipx86@chipx86.com) + * Copyright (c) 2013, Beanbag, Inc. */ -(function($) { +(function(factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as anonymous module. + define(['jquery'], factory); + } else { + // Browser globals. + factory(jQuery); + } +}(function($) { $.timesince = function(timestamp) { if (timestamp instanceof Date) { return timeSince(timestamp); @@ -186,4 +195,4 @@ // IE6 doesn't understand the