From e5cb2d23f43d7ad4f607a74ed53493ee33f26c63 Mon Sep 17 00:00:00 2001 From: Jonas Arnklint Date: Sun, 19 Jul 2009 12:59:02 +0200 Subject: [PATCH] Initial commit for github repo. License, readme, example and source included. --- LICENSE | 20 ++++++++++++++++++++ README | 37 ++++++++++++++++++++++++++++++++++++ example/index.html | 41 ++++++++++++++++++++++++++++++++++++++++ jquery.simple-tooltip.js | 36 +++++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 LICENSE create mode 100644 example/index.html create mode 100644 jquery.simple-tooltip.js diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..736fca3 --- /dev/null +++ b/LICENSE @@ -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. \ No newline at end of file diff --git a/README b/README index e69de29..5fbe690 100644 --- a/README +++ b/README @@ -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): + + + +2. Declare an element that you want to display a tooltip when hovering over: + +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. + + +4. Done! \ No newline at end of file diff --git a/example/index.html b/example/index.html new file mode 100644 index 0000000..6430fc2 --- /dev/null +++ b/example/index.html @@ -0,0 +1,41 @@ + + + + + Simple Tooltip for jQuery + + + + + + +

Simple tooltip for jQuery

+

+ This example shows how you can use the Simple Tooltip plugin for jQuery to display tooltips when hovering over elements in DOM. Simple, tiny and agile! +

+

+ This plugin is made by Jonas Arnklint +

+ + \ No newline at end of file diff --git a/jquery.simple-tooltip.js b/jquery.simple-tooltip.js new file mode 100644 index 0000000..ec72260 --- /dev/null +++ b/jquery.simple-tooltip.js @@ -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("

"+title+"

"); + $("#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);