jquery功能强大的提示信息特效代码

版权:原创 更新时间:1年以上
[该文章底部包含文件资源,可根据自己情况,决定是否下载资源使用,时间>金钱,如有需要,立即查看资源]

以下是 jquery功能强大的提示信息特效代码 的示例演示效果:

当前平台(PC电脑)
  • 平台:

部分效果截图:

jquery功能强大的提示信息特效代码

HTML代码(index.html):

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>功能强大的jquery提示信息特效</title>

	<!-- Tooltip classes -->
	<link rel="stylesheet" href="src/tip-yellow/tip-yellow.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-violet/tip-violet.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-darkgray/tip-darkgray.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-skyblue/tip-skyblue.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-yellowsimple/tip-yellowsimple.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-twitter/tip-twitter.css" type="text/css" />
	<link rel="stylesheet" href="src/tip-green/tip-green.css" type="text/css" />

	<!-- jQuery and the Poshy Tip plugin files -->
	<script type="text/javascript" src="includes/jquery-1.4.min.js"></script>
	<script type="text/javascript" src="src/jquery.poshytip.js"></script>

	<!-- Setup examples on this page -->
	<script type="text/javascript">
		$(function(){

			$('#demo-basic').poshytip();
			$('#demo-tip-yellow').poshytip();
			$('#demo-tip-violet').poshytip({
				className: 'tip-violet',
				bgImageFrameSize: 9
			});
			$('#demo-tip-darkgray').poshytip({
				className: 'tip-darkgray',
				bgImageFrameSize: 11,
				offsetX: -25
			});
			$('#demo-tip-skyblue').poshytip({
				className: 'tip-skyblue',
				bgImageFrameSize: 9,
				offsetX: 0,
				offsetY: 20
			});
			$('#demo-tip-yellowsimple').poshytip({
				className: 'tip-yellowsimple',
				showTimeout: 1,
				alignTo: 'target',
				alignX: 'center',
				offsetY: 5,
				allowTipHover: false
			});
			$('#demo-tip-twitter').poshytip({
				className: 'tip-twitter',
				showTimeout: 1,
				alignTo: 'target',
				alignX: 'center',
				offsetY: 5,
				allowTipHover: false,
				fade: false,
				slide: false
			});
			$('#demo-tip-green').poshytip({
				className: 'tip-green',
				offsetX: -7,
				offsetY: 16,
				allowTipHover: false
			});
			$('#demo-form-name').poshytip({
				className: 'tip-yellowsimple',
				showOn: 'focus',
				alignTo: 'target',
				alignX: 'right',
				alignY: 'center',
				offsetX: 5
			});
			$('#demo-form-email').poshytip({
				className: 'tip-yellowsimple',
				showOn: 'focus',
				alignTo: 'target',
				alignX: 'left',
				alignY: 'center',
				offsetX: 5
			});
			$('#demo-form-site').poshytip({
				className: 'tip-yellowsimple',
				showOn: 'focus',
				alignTo: 'target',
				alignX: 'inner-left',
				offsetX: 0,
				offsetY: 5
			});
			$('#demo-form-subject').poshytip({
				className: 'tip-yellowsimple',
				showOn: 'focus',
				alignTo: 'target',
				alignX: 'center',
				alignY: 'bottom',
				offsetX: 0,
				offsetY: 5
			});
			$('#demo-async-timeout').poshytip({
				content: function(updateCallback) {
					window.setTimeout(function() {
						updateCallback('Tooltip content updated!');
					}, 1000);
					return 'Loading...';
				}
			});

			var flickrFeedsCache = {};
			$('#demo-async-flickr > a').poshytip({
				className: 'tip-darkgray',
				bgImageFrameSize: 11,
				alignY: 'bottom',
				content: function(updateCallback) {
					var rel = $(this).attr('rel');
					if (flickrFeedsCache[rel] && flickrFeedsCache[rel].container)
						return flickrFeedsCache[rel].container;
					if (!flickrFeedsCache[rel]) {
						flickrFeedsCache[rel] = { container: null };
						var tagsComma = rel.substring(4).replace('-', ',');
						$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=' + tagsComma + '&tagmode=all&format=json&jsoncallback=?',
							function(data) {
								var container = $('<div/>').addClass('flickr-thumbs');
								$.each(data.items, function(i, item) {
									$('<a/>')
										.attr('href', item.link)
										.append($('<img/>').attr('src', item.media.m))
										.appendTo(container)
										.data('tip', '<strong>' + (item.title || '(no title)') + '</strong><br />by: ' + item.author.match(/\((.*)\)/)[1]);
									if (i == 4)
										return false;
								});
								// add tips for the images inside the main tip
								container.find('a').poshytip({
									content: function(){return $(this).data('tip');},
									className: 'tip-yellowsimple',
									showTimeout: 100,
									alignTo: 'target',
									alignX: 'center',
									alignY: 'bottom',
									offsetY: 5,
									allowTipHover: false,
									hideAniDuration: 0
								});
								// call the updateCallback function to update the content in the main tooltip
								// and also store the content in the cache
								updateCallback(flickrFeedsCache[rel].container = container);
							}
						);
					}
					return 'Loading images...';
				}
			});
			$('#demo-follow-cursor').poshytip({
				followCursor: true,
				slide: false
			});
			$('#demo-manual-trigger').poshytip({
				content: 'Hey, there! This is a tooltip.',
				showOn: 'none',
				alignTo: 'target',
				alignX: 'inner-left',
				offsetX: 0,
				offsetY: 5
			});
			$('#button-show').click(function() { $('#demo-manual-trigger').poshytip('show'); });
			$('#button-hide').click(function() { $('#demo-manual-trigger').poshytip('hide'); });
			$('#button-disable').click(function() { $('#demo-manual-trigger').poshytip('disable'); });
			$('#button-enable').click(function() { $('#demo-manual-trigger').poshytip('enable'); });
			$('#button-destroy').click(function() { $('#demo-manual-trigger').poshytip('destroy'); });

		});
	</script>
	<style type="text/css">
		.flickr-thumbs {
			overflow:hidden;
		}
		.flickr-thumbs a {
			float:left;
			display:block;
			margin:0 3px;
			border:1px solid #333;
		}
		.flickr-thumbs a:hover {
			border-color:#eee;
		}
		.flickr-thumbs img {
			display:block;
			width:60px;
			height:60px;
		}
	</style>


	<!-- Neglect these files - they are used just to make the demo page prettier -->
	<link rel="stylesheet" href="includes/demos.css" type="text/css" />
	<script type="text/javascript" src="includes/sh_main.min.js"></script>
	<script type="text/javascript" src="includes/demos.js"></script>
</head>

<body>

	<div id="holder">

		<div id="nav">
			<h2>Demo Page Navigation</h2>
			<ul>
				<li class="first"><a href="#examples">Usage Examples</a>
					<ul>
						<li><a href="#styles">Styles (Classes)</a></li>
						<li><a href="#form-tooltips">Form Tooltips (with varying positioning)</a></li>
						<li><a href="#async-content">Asynchronous Loading of the Content</a>
							<ul>
								<li><a href="#async-simple">Simple Example</a></li>
								<li><a href="#async-flickr-feeds">Loading Flickr Feeds</a></li>
							</ul>
						</li>
						<li><a href="#follow-cursor">Following the Mouse Cursor</a></li>
						<li><a href="#manual-trigger">Triggering the Tooltip Manually</a></li>
					</ul>
				</li>
				<li><a href="#options">Options</a></li>
				<li><a href="#methods">Methods</a></li>
				<li><a href="#notes">Notes</a></li>
				<li><a href="#license">License</a></li>
				<li><a href="#download">Download</a></li>
				<li><a href="#support">Support</a></li>
				<li class="last"><a href="#donate">Donate</a></li>
			</ul>
			<h2>Next?</h2>
			<ul>
				<li class="first"><a href="http://13141618.taobao.com/">&laquo; Back to the Poshy Tip Page</a></li>
				<li class="last"><a href="http://13141618.taobao.com/">&laquo; Back to Vadikom.com</a></li>
			</ul>
		</div>

		<div id="content">
			<h1>Poshy Tip jQuery Plugin <span>Demo Page</span></h1>

			<h2 id="examples">Usage Examples</h2>

			<p>The default browser tooltip that displays the value of the <code>title</code> attribute is replaced with a "poshier" version:</p>

			<!-- #demo-basic -->
			<p><a id="demo-basic" title="Hey, there! This is a tooltip." href="#">Hover for a tooltip</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-basic').poshytip();</pre>
			</div>

			<h3 id="styles">Styles (Classes)</h3>

			<p>Using different tooltip classes is easy. Here are some examples that are included in the download package (in the "src" folder).</p>

			<!-- #demo-tip-yellow -->
			<p><a id="demo-tip-yellow" title="Hey, there! This is a tooltip." href="#">.tip-yellow</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-yellow').poshytip();</pre>
			</div>

			<!-- #demo-tip-violet -->
			<p><a id="demo-tip-violet" title="Hey, there! This is a tooltip." href="#">.tip-violet</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-violet').poshytip({
	className: 'tip-violet',
	bgImageFrameSize: 9
});</pre>
			</div>

			<!-- #demo-tip-darkgray -->
			<p><a id="demo-tip-darkgray" title="Hey, there! This is a tooltip." href="#">.tip-darkgray</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-darkgray').poshytip({
	className: 'tip-darkgray',
	bgImageFrameSize: 11,
	offsetX: -25
});</pre>
			</div>

			<!-- #demo-tip-skyblue -->
			<p><a id="demo-tip-skyblue" title="Hey, there! This is a tooltip." href="#">.tip-skyblue</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-skyblue').poshytip({
	className: 'tip-skyblue',
	bgImageFrameSize: 9,
	offsetX: 0,
	offsetY: 20
});</pre>
			</div>

			<!-- #demo-tip-yellowsquare -->
			<p><a id="demo-tip-yellowsimple" title="Hey, there! This is a tooltip." href="#">.tip-yellowsimple</a> (no background-image used for the tooltip body)</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-yellowsimple').poshytip({
	className: 'tip-yellowsimple',
	showTimeout: 1,
	alignTo: 'target',
	alignX: 'center',
	offsetY: 5,
	allowTipHover: false
});</pre>
			</div>

			<!-- #demo-tip-twitter -->
			<p><a id="demo-tip-twitter" title="Follow vadikom" href="#">.tip-twitter</a> (ala Twitter)</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-twitter').poshytip({
	className: 'tip-twitter',
	showTimeout: 1,
	alignTo: 'target',
	alignX: 'center',
	offsetY: 5,
	allowTipHover: false,
	fade: false,
	slide: false
});</pre>
			</div>

			<!-- #demo-tip-green -->
			<p><a id="demo-tip-green" title="Hey, there! This is a tooltip." href="#">.tip-green</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-tip-green').poshytip({
	className: 'tip-green',
	offsetX: -7,
	offsetY: 16,
	allowTipHover: false
});</pre>
			</div>

			<h3 id="form-tooltips">Form Tooltips (with varying positioning)</h3>

			<p>Adding form input field tooltips is simple. You just have to make sure they are triggered on focus/blur (i.e. <code>showOn: 'focus'</code>) and positioned relatively to the target element (i.e. <code>alignTo: 'target'</code>). The script also updates the position of such tooltips if the window is resized (e.g. show some of the tips below and resize your browser window for a demo).</p>

			<!-- #demo-form-name -->
			<p>
				<label for="demo-form-name">Name:</label><br />
				<input id="demo-form-name" type="text" size="30" title="Enter your name" />
			</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-form-name').poshytip({
	className: 'tip-yellowsimple',
	showOn: 'focus',
	alignTo: 'target',
	alignX: 'right',
	alignY: 'center',
	offsetX: 5
});</pre>
			</div>

			<!-- #demo-form-email -->
			<p>
				<label for="demo-form-email">Email:</label><br />
				<input id="demo-form-email" type="text" size="30" title="Enter a valid email" />
			</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-form-email').poshytip({
	className: 'tip-yellowsimple',
	showOn: 'focus',
	alignTo: 'target',
	alignX: 'left',
	alignY: 'center',
	offsetX: 5
});</pre>
			</div>

			<!-- #demo-form-site -->
			<p>
				<label for="demo-form-site">Site:</label><br />
				<input id="demo-form-site" type="text" size="30" title="Enter your website URL" />
			</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-form-site').poshytip({
	className: 'tip-yellowsimple',
	showOn: 'focus',
	alignTo: 'target',
	alignX: 'inner-left',
	offsetX: 0,
	offsetY: 5
});</pre>
			</div>

			<!-- #demo-form-subject -->
			<p>
				<label for="demo-form-subject">Subject:</label><br />
				<input id="demo-form-subject" type="text" size="30" title="Enter a subject" />
			</p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-form-subject').poshytip({
	className: 'tip-yellowsimple',
	showOn: 'focus',
	alignTo: 'target',
	alignX: 'center',
	alignY: 'bottom',
	offsetX: 0,
	offsetY: 5
});</pre>
			</div>

			<h3 id="async-content">Asynchronous Loading of the Content</h3>

			<p>Poshy Tip supports using a function for returning the tooltip content and the script also passes an update callback function as an argument to this function. By using this callback, you can easily update asynchronously the content of the tooltip after it has been displayed. The script also recalculates and updates the position of the tooltip when its content is updated.</p>

			<h4 id="async-simple">Simple Example</h4>

			<!-- #demo-async-timeout -->
			<p><a id="demo-async-timeout" href="#">Update content after 1 second</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-async-timeout').poshytip({
	content: function(updateCallback) {
		window.setTimeout(function() {
			updateCallback('Tooltip content updated!');
		}, 1000);
		return 'Loading...';
	}
});</pre>
			</div>

			<h4 id="async-flickr-feeds">Loading Flickr Feeds</h4>

			<p>A more complicated example of loading some Flickr images by tags:</p>

			<!-- #demo-async-flickr -->
			<p id="demo-async-flickr"><a rel="tag-flowers-closeup" href="#">flowers, closeup</a>, <a rel="tag-sunset" href="#">sunset</a>, <a rel="tag-architecture" href="#">architecture</a>, <a rel="tag-Plovdiv-old-town" href="#">Plovdiv, old, town</a>, <a rel="tag-Nesebar" href="#">Nesebar</a>, <a rel="tag-depeche" href="#">depeche</a></p>


			<div class="code-block">
			<pre class="sh_javascript">var flickrFeedsCache = {};

$('#demo-async-flickr &gt; a').poshytip({
	className: 'tip-darkgray',
	bgImageFrameSize: 11,
	alignY: 'bottom',
	content: function(updateCallback) {
		var rel = $(this).attr('rel');
		if (flickrFeedsCache[rel] && flickrFeedsCache[rel].container)
			return flickrFeedsCache[rel].container;
		if (!flickrFeedsCache[rel]) {
			flickrFeedsCache[rel] = { container: null };
			var tagsComma = rel.substring(4).replace('-', ',');
			$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=' + tagsComma + '&tagmode=all&format=json&jsoncallback=?',
				function(data) {
					var container = $('&lt;div/&gt;').addClass('flickr-thumbs');
					$.each(data.items, function(i, item) {
						$('&lt;a/&gt;')
							.attr('href', item.link)
							.append($('&lt;img/&gt;').attr('src', item.media.m))
							.appendTo(container)
							.data('tip', '&lt;strong&gt;' + (item.title || '(no title)') + '&lt;/strong&gt;&lt;br /&gt;by: ' + item.author.match(/\((.*)\)/)[1]);
						if (i == 4)
							return false;
					});
					// add tips for the images inside the main tip
					container.find('a').poshytip({
						content: function(){return $(this).data('tip');},
						className: 'tip-yellowsimple',
						showTimeout: 100,
						alignTo: 'target',
						alignX: 'center',
						alignY: 'bottom',
						offsetY: 5,
						allowTipHover: false,
						hideAniDuration: 0
					});
					// store the content in the cache
					// and call updateCallback() to update the content in the main tooltip
					updateCallback(flickrFeedsCache[rel].container = container);
				}
			);
		}
		return 'Loading images...';
	}
});</pre>
			</div>

			<h3 id="follow-cursor">Following the Mouse Cursor</h3>

			<p>If using the <code>followCursor: true</code> option, it's better to make sure the the slide animation effect is disabled (i.e. <code>slide: false</code>) so that it doesn't conflict with the code that moves the tooltip with the cursor.</p>

			<!-- #demo-follow-cursor -->
			<p><a id="demo-follow-cursor" title="Hey, there! This is a tooltip." href="#">Hover for a tooltip that follows the cursor</a></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-follow-cursor').poshytip({
	followCursor: true,
	slide: false
});</pre>
			</div>

			<h3 id="manual-trigger">Triggering the Tooltip Manually</h3>

			<p>If you like, you can add a tooltip to some element(s) and configure it to not be triggered automatically on hover or focus/blur by using the <code>showOn: 'none'</code> option. You can then control the tooltip manually via the available methods.</p>

			<!-- #demo-manual-trigger -->
			<p><a id="demo-manual-trigger" href="#">This link has a tooltip that is not triggered automatically</a></p>
			<p><button id="button-show">Show</button> <button id="button-hide">Hide</button> <button id="button-disable">Disable</button> <button id="button-enable">Enable</button> <button id="button-destroy">Destroy</button></p>
			<div class="code-block">
			<pre class="sh_javascript">$('#demo-manual-trigger').poshytip({
	content: 'Hey, there! This is a tooltip.',
	showOn: 'none',
	alignTo: 'target',
	alignX: 'inner-left',
	offsetX: 0,
	offsetY: 5
});
$('#button-show').click(function() { $('#demo-manual-trigger').poshytip('show'); });
$('#button-hide').click(function() { $('#demo-manual-trigger').poshytip('hide'); });
$('#button-disable').click(function() { $('#demo-manual-trigger').poshytip('disable'); });
$('#button-enable').click(function() { $('#demo-manual-trigger').poshytip('enable'); });
$('#button-destroy').click(function() { $('#demo-manual-trigger').poshytip('destroy'); });</pre>
			</div>

			<h2 id="options">Options</h2>

			<dl class="options">
				<dt><strong>content</strong> <i>String, DOM element, Function, jQuery</i></dt>
				<dd><div class="possible-values">Possible Values: <span>'[title]', 'string', element, function(updateCallback){...}, jQuery</span></div>Content to display.</dd>

				<dt><strong>className</strong> <i>String</i></dt>
				<dd>Class for the tips.</dd>

				<dt><strong>bgImageFrameSize</strong> <i>Number</i></dt>
				<dd>Size in pixels for the background-image (if set in CSS) frame around the inner content of the tip.</dd>

				<dt><strong>showTimeout</strong> <i>Number</i></dt>
				<dd>Timeout before showing the tip (in milliseconds 1000 == 1 second).</dd>

				<dt><strong>hideTimeout</strong> <i>Number</i></dt>
				<dd>Timeout before hiding the tip.</dd>

				<dt><strong>showOn</strong> <i>String</i></dt>
				<dd><div class="possible-values">Possible Values: <span>'hover', 'focus', 'none'</span></div>Handler for showing the tip. Use <code>'none'</code> if you would like to trigger the tooltip just manually (i.e. by calling the <code>'show'</code> and <code>'hide'</code> methods).</dd>

				<dt><strong>alignTo</strong> <i>String</i></dt>
				<dd><div class="possible-values">Possible Values: <span>'cursor', 'target'</span></div>Align/position the tip relative to</dd>

				<dt><strong>alignX</strong> <i>String</i></dt>
				<dd><div class="possible-values">Possible Values: <span>'right', 'center', 'left', 'inner-left', 'inner-right'</span></div>Horizontal alignment for the tip relative to the mouse cursor or the target element - values 'inner-*' matter if <code>alignTo:'target'</code></dd>

				<dt><strong>alignY</strong> <i>String</i></dt>
				<dd><div class="possible-values">Possible Values: <span>'bottom', 'center', 'top', 'inner-bottom', 'inner-top'</span></div>Vertical alignment for the tip relative to the mouse cursor or the target element - values 'inner-*' matter if <code>alignTo:'target'</code></dd>

				<dt><strong>offsetX</strong> <i>Number</i></dt>
				<dd>Offset X pixels from the default position - doesn't matter if <code>alignX:'center'</code></dd>

				<dt><strong>offsetY</strong> <i>Number</i></dt>
				<dd>Offset Y pixels from the default position - doesn't matter if <code>alignY:'center'</code></dd>

				<dt><strong>allowTipHover</strong> <i>Boolean</i></dt>
				<dd>Allow hovering the tip without hiding it onmouseout of the target - matters only if <code>showOn:'hover'</code></dd>

				<dt><strong>followCursor</strong> <i>Boolean</i></dt>
				<dd>If the tip should follow the cursor - matters only if showOn:'hover' and alignTo:'cursor'</dd>

				<dt><strong>fade</strong> <i>Boolean</i></dt>
				<dd>Use fade animation.</dd>

				<dt><strong>slide</strong> <i>Boolean</i></dt>
				<dd>Use slide animation.</dd>

				<dt><strong>slideOffset</strong> <i>Number</i></dt>
				<dd>Slide animation offset.</dd>

				<dt><strong>showAniDuration</strong> <i>Number</i></dt>
				<dd>Show animation duration.</dd>

				<dt><strong>hideAniDuration</strong> <i>Number</i></dt>
				<dd>Hide animation duration.</dd>
			</dl>

			<h2 id="methods">Methods</h2>

			<dl class="options">
				<dt><strong>show</strong></dt>
				<dd><div class="signature">.poshytip('show')</div>Manually show the tooltip. Make sure the <code>alignTo</code> option is set to <code>'target'</code> in order the tooltip to be properly positioned when you trigger it.</dd>

				<dt><strong>hide</strong></dt>
				<dd><div class="signature">.poshytip('hide')</div>Manually hide the tooltip.</dd>

				<dt><strong>disable</strong></dt>
				<dd><div class="signature">.poshytip('disable')</div>Disable the tooltip.</dd>

				<dt><strong>enable</strong></dt>
				<dd><div class="signature">.poshytip('enable')</div>Enable the tooltip.</dd>

				<dt><strong>destroy</strong></dt>
				<dd><div class="signature">.poshytip('destroy')</div>Destroy completely the tooltip functionality.</dd>
			</dl>

			<h2 id="notes">Notes</h2>

			<ul>
				<li>Requires jQuery 1.4+</li>
				<li>Works in IE6+, FF 2+, Opera 9+, Safari 3+, Chrome</li>
				<li>In IE6 min/max-width are supported (only px values) for the tooltip container DIV so you can use them in your CSS without worrying for IE6 (if you still care about it)</li>
				<li>When a background-image is set for the tooltip container DIV, the script will neglect the background-color/padding/border declarations set for it and will use the background image to create a scalable frame around the tooltip inner DIV (for an explanation how this works, please take a look at the <a href="http://13141618.taobao.com/">Poshy Tip Page</a>)</li>
				<li>In IE6 PNG background images are not supported (only GIF). If a PNG is set as a background-image for the tooltip container, in IE6 the script will fallback and use the background-color/padding/border declarations instead.</li>
			</ul>

			<h2 id="license">License</h2>

			<p>Like jQuery, Poshy Tip is dual licensed under the <a href="http://github.com/vadikom/poshytip/raw/master/MIT-LICENSE.txt">MIT</a> and <a href="http://github.com/vadikom/poshytip/raw/master/GPL-LICENSE.txt">GPL</a> licenses.</p>

			<h3>Git</h3>

			<p>The Poshy Tip source code is also available at GitHub:</p>
			<div class="code-block">
			<pre class="sh_html">git clone git://github.com/vadikom/poshytip.git</pre>
			</div>

			<h2 id="support">Support</h2>

			<p>Post your questions/suggestions in the <a href="http://13141618.taobao.com/">support forums</a>.</p>

			<h2 id="donate">Donate</h2>

			<p>If you appreciate this script, you can support me by <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=paypal@vadikom.com&no_shipping=1&currency_code=USD&item_name=Poshy+Tip+jQuery+Plugin+Development" rel="nofollow">donating a small amount</a> through PayPal or just by <a href="http://www.addtoany.com/share_save?linkname=Poshy%20Tip%20-%20Tooltip%20Plugin%20for%20jQuery%20-%20Vadikom&linkurl=http://vadikom.com/tools/poshy-tip-jquery-plugin-for-stylish-tooltips/" rel="nofollow">spreading the word</a> about it. Your support is highly appreciated!</p>
		</div>
	</div>
</body>
</html>





JS代码(demos.js):

$(function(){
	// =================================// init SHJS (syntax highlither)// =================================window.sh_highlightDocument();
	$('pre.sh_sourceCode').parent().hover(function(){
	var $div = $(this);
	if ($div.data('hideTimeout')){
	clearTimeout($div.data('hideTimeout'));
	$div.data('hideTimeout',0);
}
if (!$div.data('active')){
	$div.data('showTimeout',setTimeout(function(){
	var $pre = $div.children().eq(-1),scrollBarFix = 30,width = $pre[0].scrollWidth > $pre.outerWidth() ?Math.min($pre[0].scrollWidth + scrollBarFix,$(window).width() - scrollBarFix - $div.offset().left):$pre.outerWidth(),height = $div.height();
	$div.wrap('<div class="code-placeholder" style="position:relative;
	height:' + $div.outerHeight() + 'px;
	margin:' + $div.css('margin-top') + ' ' + $div.css('margin-right') + ' ' + $div.css('margin-bottom') + ' ' + $div.css('margin-left') + ';
	"></div>').css({
	position:'absolute',width:width,height:height}
).data('active',true).find('> a').fadeIn(500);
}
,500));
}
}
,function(){
	var $div = $(this);
	if ($div.data('showTimeout')){
	clearTimeout($div.data('showTimeout'));
	$div.data('showTimeout',0);
}
if ($div.data('active') && !$div.data('plainView')){
	$div.data('hideTimeout',setTimeout(function(){
	$div.unwrap().css({
	position:'relative',width:'auto',height:'auto'}
).data('active',false).find('> a').hide();
}
,500));
}
}
).prepend('<a/>').find('> a').addClass('view-plain').attr('href','#').html('<span>View plain code</span>').click(function(){
	var $link = $(this),$div = $link.parent(),$pre = $link.next(),$window = $(window),scrollPos = [$window.scrollLeft(),$window.scrollTop()],value = $pre.text(),height = $pre.outerHeight() + (window.opera && window.opera.version && window.opera.version() < 10.5 ? $pre[0].scrollHeight / ((value.replace(/\r\n/g,'\n').match(/\n/g) || '').length + 1):0);
	$('<textarea wrap="off"/>').css({
	width:$div.width(),height:height,'-moz-box-shadow':'0 5px 15px #888','-webkit-box-shadow':'0 5px 15px #888','box-shadow':'0 5px 15px #888'}
).attr({
	value:value,readonly:'readonly'}
).insertBefore($pre).blur(function(){
	$(this).next()/* pre */
.css('visibility','inherit').prev()/* textarea */
.remove();
	$div.data('plainView',false).mouseleave();
}
);
	$link.hide().next().next()/* pre */
.css('visibility','hidden').prev()/* textarea */
.focus();
	// some browsers (like IE < 8) may mess up the scroll position when the textarea is focusedif (window.scrollTo)window.scrollTo(scrollPos[0],scrollPos[1]);
	$div.data('plainView',true);
	return false;
}
);
}
);
	

JS代码(jquery.poshytip.min.js):

/* * Poshy Tip jQuery plugin v1.0 * http://vadikom.com/tools/poshy-tip-jquery-plugin-for-stylish-tooltips/ * Copyright 2010,Vasil Dinkov,http://vadikom.com/ */
(function(e){
	var a=[],d=/^url\(["']?([^"'\)]*)["']?\);
	?$/i,c=/\.png$/i,b=e.browser.msie&&e.browser.version==6;
	function f(){
	e.each(a,function(){
	this.refresh(true)}
)}
e(window).resize(f);
	e.Poshytip=function(h,g){
	this.$elm=e(h);
	this.opts=e.extend({
}
,e.fn.poshytip.defaults,g);
	this.$tip=e(['<div class="',this.opts.className,'">','<div class="tip-inner tip-bg-image"></div>','<div class="tip-arrow tip-arrow-top tip-arrow-right tip-arrow-bottom tip-arrow-left"></div>',"</div>"].join(""));
	this.$arrow=this.$tip.find("div.tip-arrow");
	this.$inner=this.$tip.find("div.tip-inner");
	this.disabled=false;
	this.init()}
;
	e.Poshytip.prototype={
	init:function(){
	a.push(this);
	this.$elm.data("title.poshytip",this.$elm.attr("title")).data("poshytip",this);
	switch(this.opts.showOn){
	case"hover":this.$elm.bind({
	"mouseenter.poshytip":e.proxy(this.mouseenter,this),"mouseleave.poshytip":e.proxy(this.mouseleave,this)}
);
	if(this.opts.alignTo=="cursor"){
	this.$elm.bind("mousemove.poshytip",e.proxy(this.mousemove,this))}
if(this.opts.allowTipHover){
	this.$tip.hover(e.proxy(this.clearTimeouts,this),e.proxy(this.hide,this))}
break;
	case"focus":this.$elm.bind({
	"focus.poshytip":e.proxy(this.show,this),"blur.poshytip":e.proxy(this.hide,this)}
);
	break}
}
,mouseenter:function(g){
	if(this.disabled){
	return true}
this.clearTimeouts();
	this.$elm.attr("title","");
	this.showTimeout=setTimeout(e.proxy(this.show,this),this.opts.showTimeout)}
,mouseleave:function(){
	if(this.disabled){
	return true}
this.clearTimeouts();
	this.$elm.attr("title",this.$elm.data("title.poshytip"));
	this.hideTimeout=setTimeout(e.proxy(this.hide,this),this.opts.hideTimeout)}
,mousemove:function(g){
	if(this.disabled){
	return true}
this.eventX=g.pageX;
	this.eventY=g.pageY;
	if(this.opts.followCursor&&this.$tip.data("active")){
	this.calcPos();
	this.$tip.css({
	left:this.pos.l,top:this.pos.t}
);
	if(this.pos.arrow){
	this.$arrow[0].className="tip-arrow tip-arrow-"+this.pos.arrow}
}
}
,show:function(){
	if(this.disabled||this.$tip.data("active")){
	return}
this.reset();
	this.update();
	this.display()}
,hide:function(){
	if(this.disabled||!this.$tip.data("active")){
	return}
this.display(true)}
,reset:function(){
	this.$tip.queue([]).detach().css("visibility","hidden").data("active",false);
	this.$inner.find("*").poshytip("hide");
	if(this.opts.fade){
	this.$tip.css("opacity",this.opacity)}
this.$arrow[0].className="tip-arrow tip-arrow-top tip-arrow-right tip-arrow-bottom tip-arrow-left"}
,update:function(i){
	if(this.disabled){
	return}
var h=i!==undefined;
	if(h){
	if(!this.$tip.data("active")){
	return}
}
else{
	i=this.opts.content}
this.$inner.contents().detach();
	var g=this;
	this.$inner.append(typeof i=="function"?i.call(this.$elm[0],function(j){
	g.update(j)}
):i=="[title]"?this.$elm.data("title.poshytip"):i);
	this.refresh(h)}
,refresh:function(h){
	if(this.disabled){
	return}
if(h){
	if(!this.$tip.data("active")){
	return}
var k={
	left:this.$tip.css("left"),top:this.$tip.css("top")}
}
this.$tip.css({
	left:0,top:0}
).appendTo(document.body);
	if(this.opacity===undefined){
	this.opacity=this.$tip.css("opacity")}
var l=this.$tip.css("background-image").match(d),m=this.$arrow.css("background-image").match(d);
	if(l){
	var i=c.test(l[1]);
	if(b&&i){
	this.$tip.css("background-image","none");
	this.$inner.css({
	margin:0,border:0,padding:0}
);
	l=i=false}
else{
	this.$tip.prepend('<table border="0" cellpadding="0" cellspacing="0"><tr><td class="tip-top tip-bg-image" colspan="2"><span></span></td><td class="tip-right tip-bg-image" rowspan="2"><span></span></td></tr><tr><td class="tip-left tip-bg-image" rowspan="2"><span></span></td><td></td></tr><tr><td class="tip-bottom tip-bg-image" colspan="2"><span></span></td></tr></table>').css({
	border:0,padding:0,"background-image":"none","background-color":"transparent"}
).find(".tip-bg-image").css("background-image",'url("'+l[1]+'")').end().find("td").eq(3).append(this.$inner)}
if(i&&!e.support.opacity){
	this.opts.fade=false}
}
if(m&&!e.support.opacity){
	if(b&&c.test(m[1])){
	m=false;
	this.$arrow.css("background-image","none")}
this.opts.fade=false}
var o=this.$tip.find("table");
	if(b){
	this.$tip[0].style.width="";
	o.width("auto").find("td").eq(3).width("auto");
	var n=this.$tip.width(),j=parseInt(this.$tip.css("min-width")),g=parseInt(this.$tip.css("max-width"));
	if(!isNaN(j)&&n<j){
	n=j}
else{
	if(!isNaN(g)&&n>g){
	n=g}
}
this.$tip.add(o).width(n).eq(0).find("td").eq(3).width("100%")}
else{
	if(o[0]){
	o.width("auto").find("td").eq(3).width("auto").end().end().width(this.$tip.width()).find("td").eq(3).width("100%")}
}
this.tipOuterW=this.$tip.outerWidth();
	this.tipOuterH=this.$tip.outerHeight();
	this.calcPos();
	if(m&&this.pos.arrow){
	this.$arrow[0].className="tip-arrow tip-arrow-"+this.pos.arrow;
	this.$arrow.css("visibility","inherit")}
if(h){
	this.$tip.css(k).animate({
	left:this.pos.l,top:this.pos.t}
,200)}
else{
	this.$tip.css({
	left:this.pos.l,top:this.pos.t}
)}
}
,display:function(h){
	var i=this.$tip.data("active");
	if(i&&!h||!i&&h){
	return}
this.$tip.stop();
	if((this.opts.slide&&this.pos.arrow||this.opts.fade)&&(h&&this.opts.hideAniDuration||!h&&this.opts.showAniDuration)){
	var m={
}
,l={
}
;
	if(this.opts.slide&&this.pos.arrow){
	var k,g;
	if(this.pos.arrow=="bottom"||this.pos.arrow=="top"){
	k="top";
	g="bottom"}
else{
	k="left";
	g="right"}
var j=parseInt(this.$tip.css(k));
	m[k]=j+(h?0:this.opts.slideOffset*(this.pos.arrow==g?-1:1));
	l[k]=j+(h?this.opts.slideOffset*(this.pos.arrow==g?1:-1):0)}
if(this.opts.fade){
	m.opacity=h?this.$tip.css("opacity"):0;
	l.opacity=h?0:this.opacity}
this.$tip.css(m).animate(l,this.opts[h?"hideAniDuration":"showAniDuration"])}
h?this.$tip.queue(e.proxy(this.reset,this)):this.$tip.css("visibility","inherit");
	this.$tip.data("active",!i)}
,disable:function(){
	this.reset();
	this.disabled=true}
,enable:function(){
	this.disabled=false}
,destroy:function(){
	this.reset();
	this.$tip.remove();
	this.$elm.unbind("poshytip").removeData("title.poshytip").removeData("poshytip");
	a.splice(e.inArray(this,a),1)}
,clearTimeouts:function(){
	if(this.showTimeout){
	clearTimeout(this.showTimeout);
	this.showTimeout=0}
if(this.hideTimeout){
	clearTimeout(this.hideTimeout);
	this.hideTimeout=0}
}
,calcPos:function(){
	var n={
	l:0,t:0,arrow:""}
,h=e(window),k={
	l:h.scrollLeft(),t:h.scrollTop(),w:h.width(),h:h.height()}
,p,j,m,i,q,g;
	if(this.opts.alignTo=="cursor"){
	p=j=m=this.eventX;
	i=q=g=this.eventY}
else{
	var o=this.$elm.offset(),l={
	l:o.left,t:o.top,w:this.$elm.outerWidth(),h:this.$elm.outerHeight()}
;
	p=l.l+(this.opts.alignX!="inner-right"?0:l.w);
	j=p+Math.floor(l.w/2);
	m=p+(this.opts.alignX!="inner-left"?l.w:0);
	i=l.t+(this.opts.alignY!="inner-bottom"?0:l.h);
	q=i+Math.floor(l.h/2);
	g=i+(this.opts.alignY!="inner-top"?l.h:0)}
switch(this.opts.alignX){
	case"right":case"inner-left":n.l=m+this.opts.offsetX;
	if(n.l+this.tipOuterW>k.l+k.w){
	n.l=k.l+k.w-this.tipOuterW}
if(this.opts.alignX=="right"||this.opts.alignY=="center"){
	n.arrow="left"}
break;
	case"center":n.l=j-Math.floor(this.tipOuterW/2);
	if(n.l+this.tipOuterW>k.l+k.w){
	n.l=k.l+k.w-this.tipOuterW}
else{
	if(n.l<k.l){
	n.l=k.l}
}
break;
	default:n.l=p-this.tipOuterW-this.opts.offsetX;
	if(n.l<k.l){
	n.l=k.l}
if(this.opts.alignX=="left"||this.opts.alignY=="center"){
	n.arrow="right"}
}
switch(this.opts.alignY){
	case"bottom":case"inner-top":n.t=g+this.opts.offsetY;
	if(!n.arrow||this.opts.alignTo=="cursor"){
	n.arrow="top"}
if(n.t+this.tipOuterH>k.t+k.h){
	n.t=i-this.tipOuterH-this.opts.offsetY;
	if(n.arrow=="top"){
	n.arrow="bottom"}
}
break;
	case"center":n.t=q-Math.floor(this.tipOuterH/2);
	if(n.t+this.tipOuterH>k.t+k.h){
	n.t=k.t+k.h-this.tipOuterH}
else{
	if(n.t<k.t){
	n.t=k.t}
}
break;
	default:n.t=i-this.tipOuterH-this.opts.offsetY;
	if(!n.arrow||this.opts.alignTo=="cursor"){
	n.arrow="bottom"}
if(n.t<k.t){
	n.t=g+this.opts.offsetY;
	if(n.arrow=="bottom"){
	n.arrow="top"}
}
}
this.pos=n}
}
;
	e.fn.poshytip=function(g){
	if(typeof g=="string"){
	return this.each(function(){
	var i=e(this).data("poshytip");
	if(i&&i[g]){
	i[g]()}
}
)}
var h=e.extend({
}
,e.fn.poshytip.defaults,g);
	if(!e("#poshytip-css-"+h.className)[0]){
	e(['<style id="poshytip-css-',h.className,'" type="text/css">',"div.",h.className,"{
	visibility:hidden;
	position:absolute;
	top:0;
	left:0;
}
","div.",h.className," table,div.",h.className," td{
	margin:0;
	font-family:inherit;
	font-size:inherit;
	font-weight:inherit;
	font-style:inherit;
	font-variant:inherit;
}
","div.",h.className," td.tip-bg-image span{
	display:block;
	font:1px/1px sans-serif;
	height:",h.bgImageFrameSize,"px;
	width:",h.bgImageFrameSize,"px;
	overflow:hidden;
}
","div.",h.className," td.tip-right{
	background-position:100% 0;
}
","div.",h.className," td.tip-bottom{
	background-position:100% 100%;
}
","div.",h.className," td.tip-left{
	background-position:0 100%;
}
","div.",h.className," div.tip-inner{
	background-position:-",h.bgImageFrameSize,"px -",h.bgImageFrameSize,"px;
}
","div.",h.className," div.tip-arrow{
	visibility:hidden;
	position:absolute;
	overflow:hidden;
	font:1px/1px sans-serif;
}
","</style>"].join("")).appendTo("head")}
return this.each(function(){
	new e.Poshytip(this,h)}
)}
;
	e.fn.poshytip.defaults={
	content:"[title]",className:"tip-yellow",bgImageFrameSize:10,showTimeout:500,hideTimeout:100,showOn:"hover",alignTo:"cursor",alignX:"right",alignY:"top",offsetX:-22,offsetY:18,allowTipHover:true,followCursor:false,fade:true,slide:true,slideOffset:8,showAniDuration:300,hideAniDuration:300}
}
)(jQuery);
	
附件:下载该文件资源,减少时间成本(增值服务)
留言
该资源可下载
File Source
.rar
173.53 KB
Html Js 图片切换触摸3
最新结算
股权转让协议意向书模板
类型: .docx 金额: CNY 2.23¥ 状态: 待结算 详细>
股权转让协议意向书模板
类型: .docx 金额: CNY 0.28¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 0.29¥ 状态: 待结算 详细>
CSS3图片向上3D翻转渐隐消失特效
类型: .rar 金额: CNY 2.31¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 2.39¥ 状态: 待结算 详细>
.net c# 将金额转人名币大写金额
类型: .rar 金额: CNY 0.3¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 2.23¥ 状态: 待结算 详细>
合伙退伙协议书范本模板
类型: .doc 金额: CNY 0.28¥ 状态: 待结算 详细>
我们力求给您提供有用的文章,再此基础上,会附加营收资源,不做任何广告,让平台可以更好发展 若您发现您的权利被侵害,或使用了您的版权,请发邮件联系 sunlifel@foxmail.com ggbig觉得 : 不提供源码的文章不是好文章
合作伙伴
联系我们
  • QQ:21499807
  • 邮箱:sunlifel@foxmail.com
  • QQ扫一扫加QQ
    QQ扫一扫
Copyright 2023-2024 ggbig.com·皖ICP备2023004211号-1
打赏文章