This repository has been archived by the owner on Feb 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for github repo. License, readme, example and source i…
…ncluded.
- Loading branch information
Showing
4 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2009 Jonas Arnklint ( http://arnklint.com ) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Simple Tooltip for jQuery | ||
==================================== | ||
|
||
Simple Tooltip is a tiny plugin for making simple tooltips, when hovering over an element. It is written by Jonas Arnklint ( http://arnklint.com ). The goal is to keep it simple, tiny and agile as I'm a fan of KISS. Its functionality includes displaying generic tooltip messages as well as individual messages based on the title attribute of an element. The source was originally extracted from our easy to use CMS Venio at http://venio.se | ||
|
||
Usage | ||
==================================== | ||
1. Include it along with jQuery (i'm including jQuery from G All Mighty in this example): | ||
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
<script src="path/to/jquery.simple-tooltip.js" type="text/javascript" charset="utf-8"></script> | ||
|
||
2. Declare an element that you want to display a tooltip when hovering over: | ||
<script type="text/javascript" charset="utf-8"> | ||
jQuery(document).ready(function(){ | ||
$('#my-link, p span').simpleTooltip({ | ||
title: 'me is a tooltip' | ||
}); | ||
}); | ||
</script> | ||
Look at $.fn.simpleTooltip.defaults in source for more options. | ||
|
||
3. Style it! The tooltip gets the "v-tooltip" id so that you can style it however you want with CSS. | ||
<style type="text/css" media="screen"> | ||
#v-tooltip { | ||
position:absolute; | ||
background:#000; | ||
padding:3px 5px; | ||
color:#fff; | ||
font-size: 11px; | ||
font-family: Arial, Verdana, sans-serif; | ||
display:none; | ||
-moz-border-radius: 3px; | ||
-webkit-border-radius: 3px; | ||
} | ||
</style> | ||
|
||
4. Done! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | ||
<title>Simple Tooltip for jQuery</title> | ||
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
<script src="../jquery.simple-tooltip.js" type="text/javascript" charset="utf-8"></script> | ||
<script type="text/javascript" charset="utf-8"> | ||
jQuery(document).ready(function(){ | ||
$('#my-link, p span').simpleTooltip({ | ||
title: 'me is a tooltip' | ||
}); | ||
}); | ||
</script> | ||
<style type="text/css" media="screen"> | ||
#v-tooltip { | ||
position:absolute; | ||
background:#000; | ||
padding:3px 5px; | ||
color:#fff; | ||
font-size: 11px; | ||
font-family: Arial, Verdana, sans-serif; | ||
display:none; | ||
-moz-border-radius: 3px; | ||
-webkit-border-radius: 3px; | ||
} | ||
p span { | ||
font-style: italic; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Simple tooltip for jQuery</h1> | ||
<p> | ||
This example shows how you can use the Simple Tooltip plugin for jQuery to display tooltips when <span>hovering over</span> elements in DOM. Simple, tiny and agile! | ||
</p> | ||
<p> | ||
This plugin is made by <a href="http://arnklint.com" id="my-link" title="Web developer from Umeå in Sweden">Jonas Arnklint</a> | ||
</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Made by web ninja Jonas Arnklint. Use it, modify it and... | ||
An MIT license is distributed with this plugins original source. | ||
Originally extracted from the easy to use CMS Venio at http://venio.se. | ||
*/ | ||
(function($) { | ||
$.fn.simpleTooltip = function(options){ | ||
var opts = $.extend({}, $.fn.simpleTooltip.defaults, options); | ||
|
||
return this.each(function(){ | ||
var me = $(this); | ||
me.hover(function(e){ | ||
var title = me.attr('title') && !opts.overrideElementTitle ? me.attr('title') : opts.title; | ||
$("body").append("<p id='v-tooltip'>"+title+"</p>"); | ||
$("#v-tooltip") | ||
.css("top",(e.pageY - opts.xOffset) + "px") | ||
.css("left",(e.pageX + opts.yOffset) + "px") | ||
.fadeIn("fast"); | ||
},function(){ | ||
$("#v-tooltip").remove(); | ||
}); | ||
me.mousemove(function(e){ | ||
$("#v-tooltip") | ||
.css("top",(e.pageY - opts.xOffset) + "px") | ||
.css("left",(e.pageX + opts.yOffset) + "px"); | ||
}); | ||
}); | ||
} | ||
|
||
$.fn.simpleTooltip.defaults = { | ||
title: null, | ||
xOffset: 10, | ||
yOffset: 20, | ||
overrideElementTitle: false | ||
} | ||
})(jQuery); |