Browse Source

! Minor additional flexibility for tip displays

Signed-off-by: Spuds <spuds@simplemachines.org>
Spuds 12 years ago
parent
commit
d4f192c6b3
1 changed files with 16 additions and 10 deletions
  1. 16 10
      Themes/default/scripts/smf_jquery_plugins.js

+ 16 - 10
Themes/default/scripts/smf_jquery_plugins.js

@@ -25,9 +25,11 @@
 			hoverIntent: {sensitivity: 10, interval: 300, timeout: 50},
 			positionTop: 12,
 			positionLeft: 12,
-			tooltipID: 'smf_tooltip',
-			tooltipClass: 'tooltip',
-			tooltipTextID: 'smf_tooltipText'
+			tooltipID: 'smf_tooltip', // ID used on the outer div
+			tooltipTextID: 'smf_tooltipText', // as above but on the inner div holding the text
+			tooltipClass: 'tooltip', // The class applied to the outer div (that displays on hover), use this in your css
+			tooltipSwapClass: 'smf_swaptip', // a class only used internally, change only if you have a conflict
+			tooltipContent: 'html' // display captured title text as html or text
 		};
 		
 		// account for any user options
@@ -36,7 +38,7 @@
 		// move passed selector titles to a hidden span, then remove the selector title to prevent any default browser actions
 		$(this).each(function()
 		{
-			var sTitle = $('<span class="' + oSettings.tooltipClass + '">' + this.title + '</span>').hide();
+			var sTitle = $('<span class="' + oSettings.tooltipSwapClass + '">' + this.title + '</span>').hide();
 			$(this).append(sTitle).attr('title', '');
 		});
 		
@@ -128,8 +130,8 @@
 			// create the on tip action
 			function smf_tooltip_on(event)
 			{
-				// Grab the text from the hidden span element we created on page load
-				if ($(this).children('.' + oSettings.tooltipClass).text())
+				// If we have text in the hidden span element we created on page load
+				if ($(this).children('.' + oSettings.tooltipSwapClass).text())
 				{
 					// create a ID'ed div with our style class that holds the tooltip info, hidden for now
 					$('body').append('<div id="' + oSettings.tooltipID + '" class="' + oSettings.tooltipClass + '"><div id="' + oSettings.tooltipTextID + '" style="display:none;"></div></div>');
@@ -137,12 +139,16 @@
 					// load information in to our newly created div
 					var $tt = $('#' + oSettings.tooltipID);
 					var $ttContent = $('#' + oSettings.tooltipID + ' #' + oSettings.tooltipTextID);
-				
-					// set the text in the div
-					$ttContent.text($(this).children('.' + oSettings.tooltipClass).text());
-					$tt.show();
+					
+					if (oSettings.tooltipContent == 'html')
+						$ttContent.html($(this).children('.' + oSettings.tooltipSwapClass).html());
+					else
+						$ttContent.text($(this).children('.' + oSettings.tooltipSwapClass).text());
+					
+					oSettings.tooltipContent
 					
 					// show then position or it may postion off screen
+					$tt.show();
 					showTooltip();
 					positionTooltip(event);
 				}