From 0dda6d92a185403ca98c0dde961193514bd7b1ff Mon Sep 17 00:00:00 2001 From: Brian Corrigan Date: Fri, 18 Jan 2013 22:26:07 -0500 Subject: [PATCH] Adds AMD wrapper MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is handy for working with RequireJS setups that use jQuery in noConflict mode.  Without it this plugin continually tries to access the global object.  --- jquery.timeago.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/jquery.timeago.js b/jquery.timeago.js index 1d0fe7e..51a5a2a 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -13,7 +13,16 @@ * * Copyright (c) 2008-2012, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org) */ -(function($) { + + (function(factory) { + // Add jQuery via AMD registration or browser globals + if (typeof define === 'function' && define.amd) { + define([ 'jquery' ], factory); + } + else { + factory(jQuery); + } +}(function($) { $.timeago = function(timestamp) { if (timestamp instanceof Date) { return inWords(timestamp); @@ -150,4 +159,4 @@ // fix for IE6 suckage document.createElement("abbr"); document.createElement("time"); -}(jQuery)); +}));