mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2025-02-17 00:20:32 -05:00
Adds AMD wrapper
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.
This commit is contained in:
parent
47dc26620e
commit
0dda6d92a1
1 changed files with 11 additions and 2 deletions
|
@ -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));
|
||||
}));
|
||||
|
|
Loading…
Reference in a new issue