Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compatibility with jQuery 1.6.4, minify with yuicompressor #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
TipTip

*******
small modification to work with jQuery 1.6.4
(works also with jQuery 1.7b1)
*******

Copyright 2010 Drew Wilson

http://www.drewwilson.com
Expand All @@ -11,7 +16,7 @@ This Plug-In will create a custom tooltip to replace the default
browser tooltip. It is extremely lightweight and very smart in
that it detects the edges of the browser window and will make sure
the tooltip stays within the current window size. As a result the
tooltip will adjust itself to be displayed above, below, to the left
tooltip will adjust itself to be displayed above, below, to the left
or to the right depending on what is necessary to stay within the
browser window. It is completely customizable as well via CSS.

Expand Down
44 changes: 22 additions & 22 deletions jquery.tipTip.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*!
* TipTip
* Copyright 2010 Drew Wilson
* www.drewwilson.com
Expand All @@ -10,7 +10,7 @@
* browser tooltip. It is extremely lightweight and very smart in
* that it detects the edges of the browser window and will make sure
* the tooltip stays within the current window size. As a result the
* tooltip will adjust itself to be displayed above, below, to the left
* tooltip will adjust itself to be displayed above, below, to the left
* or to the right depending on what is necessary to stay within the
* browser window. It is completely customizable as well via CSS.
*
Expand All @@ -21,7 +21,7 @@

(function($){
$.fn.tipTip = function(options) {
var defaults = {
var defaults = {
activation: "hover",
keepAlive: false,
maxWidth: "200px",
Expand All @@ -36,7 +36,7 @@
exit: function(){}
};
var opts = $.extend(defaults, options);

// Setup tip tip elements and render them to the DOM
if($("#tiptip_holder").length <= 0){
var tiptip_holder = $('<div id="tiptip_holder" style="max-width:'+ opts.maxWidth +';"></div>');
Expand All @@ -48,20 +48,20 @@
var tiptip_content = $("#tiptip_content");
var tiptip_arrow = $("#tiptip_arrow");
}

return this.each(function(){
var org_elem = $(this);
if(opts.content){
var org_title = opts.content;
} else {
var org_title = org_elem.attr(opts.attribute);
}
if(org_title != ""){
if(org_title && org_title != ""){
if(!opts.content){
org_elem.removeAttr(opts.attribute); //remove original Attribute
}
var timeout = false;

if(opts.activation == "hover"){
org_elem.hover(function(){
active_tiptip();
Expand Down Expand Up @@ -96,13 +96,13 @@
});
}
}

function active_tiptip(){
opts.enter.call(this);
tiptip_content.html(org_title);
tiptip_holder.hide().removeAttr("class").css("margin","0");
tiptip_arrow.removeAttr("style");

var top = parseInt(org_elem.offset()['top']);
var left = parseInt(org_elem.offset()['left']);
var org_width = parseInt(org_elem.outerWidth());
Expand All @@ -119,17 +119,17 @@

if(opts.defaultPosition == "bottom"){
t_class = "_bottom";
} else if(opts.defaultPosition == "top"){
} else if(opts.defaultPosition == "top"){
t_class = "_top";
} else if(opts.defaultPosition == "left"){
t_class = "_left";
} else if(opts.defaultPosition == "right"){
t_class = "_right";
}

var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
var left_compare = (tip_w + left) > parseInt($(window).width());

if((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))){
t_class = "_right";
arrow_top = Math.round(tip_h - 13) / 2;
Expand All @@ -146,7 +146,7 @@

var top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
var bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;

if(top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)){
if(t_class == "_top" || t_class == "_bottom"){
t_class = "_top";
Expand All @@ -161,31 +161,31 @@
} else {
t_class = t_class+"_bottom";
}
arrow_top = -12;
arrow_top = -12;
marg_top = Math.round(top + org_height + opts.edgeOffset);
}

if(t_class == "_right_top" || t_class == "_left_top"){
marg_top = marg_top + 5;
} else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
} else if(t_class == "_right_bottom" || t_class == "_left_bottom"){
marg_top = marg_top - 5;
}
if(t_class == "_left_top" || t_class == "_left_bottom"){
if(t_class == "_left_top" || t_class == "_left_bottom"){
marg_left = marg_left + 5;
}
tiptip_arrow.css({"margin-left": arrow_left+"px", "margin-top": arrow_top+"px"});
tiptip_holder.css({"margin-left": marg_left+"px", "margin-top": marg_top+"px"}).attr("class","tip"+t_class);

if (timeout){ clearTimeout(timeout); }
timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay);
}

function deactive_tiptip(){
opts.exit.call(this);
if (timeout){ clearTimeout(timeout); }
tiptip_holder.fadeOut(opts.fadeOut);
}
}
}
});
}
})(jQuery);
})(jQuery);
6 changes: 3 additions & 3 deletions jquery.tipTip.minified.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.