Update qtip to get AMD loader support
[gitphp.git] / js / modules / tooltip.snapshot.js
blob:a/js/modules/tooltip.snapshot.js -> blob:b/js/modules/tooltip.snapshot.js
--- a/js/modules/tooltip.snapshot.js
+++ b/js/modules/tooltip.snapshot.js
@@ -9,13 +9,12 @@
  * @subpackage Javascript
  */
 
-define(["jquery", "ext/jquery.qtip.min"],
-	function($) {
+define(["jquery", 'modules/snapshotformats'],
+	function($, formats) {
 		
 		function buildTipContent(href) {
 			var content = '<div>' + GitPHP.Resources.Snapshot + ': ';
 			var first = true;
-			var formats = GitPHP.Snapshot.Formats
 			var cleanurl = href.indexOf('/snapshot') != -1;
 			for (var type in formats) {
 				if (formats.hasOwnProperty(type)) {
@@ -57,14 +56,18 @@
 		}
 
 		return function(elements) {
-			elements.each(function(){
-				var jThis = $(this);
-				var href = jThis.attr('href');
-				var content = buildTipContent(href);
-				var config = buildTipConfig(content);
-				jThis.qtip(config);
-				jThis.click(function() { return false; });
-			});
+			if (elements && (elements.size() > 0)) {
+				require(['qtip'], function() {
+					elements.each(function(){
+						var jThis = $(this);
+						var href = jThis.attr('href');
+						var content = buildTipContent(href);
+						var config = buildTipConfig(content);
+						jThis.qtip(config);
+						jThis.click(function() { return false; });
+					});
+				});
+			}
 		}
 	}
 );

comments