Skip to content
This repository

Add AMD support to Tipsy architecutre #114

Open
wants to merge 2 commits into from

1 participant

Levi McCallum
Levi McCallum

I was unable to load Tipsy in my Require.js environment. I wrapped the plugin in a method provided by the UMD spec to optionally allow it to export its namespace in an AMD when available. More info about the code update here: https://github.com/umdjs/umd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  src/javascripts/jquery.tipsy.js
12  src/javascripts/jquery.tipsy.js
@@ -3,7 +3,15 @@
3 3
 // (c) 2008-2010 jason frame [jason@onehackoranother.com]
4 4
 // released under the MIT license
5 5
 
6  
-(function($) {
  6
+(function (factory) {
  7
+    if (typeof define === 'function' && define.amd) {
  8
+        // AMD. Register as an anonymous module.
  9
+        define(['jquery'], factory);
  10
+    } else {
  11
+        // Browser globals
  12
+        factory(jQuery);
  13
+    }
  14
+}(function($) {
7 15
     
8 16
     function maybeCall(thing, ctx) {
9 17
         return (typeof thing == 'function') ? (thing.call(ctx)) : thing;
@@ -255,4 +263,4 @@
255 263
 		}
256 264
 	};
257 265
     
258  
-})(jQuery);
  266
+}));
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.