Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed two click event bugs and better minification with UglifyJS

  • Loading branch information...
commit 96b7a5e955db2198d82421939b74eeaa52de05e0 1 parent 0b59939
James Simpson authored
7 README.md
View
@@ -1,4 +1,4 @@
-jQuery miniTip Plugin (v1.5.0)
+jQuery miniTip Plugin (v1.5.1)
---------------------
License
@@ -67,6 +67,11 @@ Requirements
Changelog
============
+### Version 1.5.1 (June 30, 2012) ###
+* Switched to UglifyJS for minified version.
+* Fixed issue that added multiple click events to the html element.
+* Call the hide custom function on the correct tooltip when multiple miniTips are used on the same page.
+
### Version 1.5.0 (December 9, 2011) ###
* Fix image map compatibility for Firefox and Opera.
* Allow show() callback to access options and element context for dynamically overriding content (Wolfram Arnold).
16 jquery.miniTip.js
View
@@ -1,7 +1,7 @@
/*!
- * miniTip v1.5.0
+ * miniTip v1.5.1
*
- * Updated: December 9, 2011
+ * Updated: June 30, 2012
* Requires: jQuery v1.3+
*
* (c) 2011, James Simpson
@@ -14,7 +14,7 @@
*/
(function($){
- $.fn.miniTip = function(opts) {
+ $.fn.miniTip = function(opts) {
// declare the default option values
var d = {
title: '', // if left blank, no title bar will show
@@ -118,13 +118,13 @@
tt_w.data('last_target', el);
+ // clear the tooltip if anywhere but the tooltip itself is clicked
+ $('html').unbind('click').click(function(e){
+ if (tt_w.css('display') == 'block' && !$(e.target).closest('#miniTip').length) hide();
+ });
+
return false;
});
-
- // clear the tooltip if anywhere but the tooltip itself is clicked
- $('html').click(function(e){
- if (tt_w.css('display') == 'block' && !$(e.target).closest('#miniTip').length) hide();
- });
}
// show the tooltip
6 jquery.miniTip.min.js
View
@@ -1,7 +1,7 @@
/*!
- * miniTip v1.5.0
+ * miniTip v1.5.1
*
- * Updated: December 9, 2011
+ * Updated: June 30, 2012
* Requires: jQuery v1.3+
*
* (c) 2011, James Simpson
@@ -12,4 +12,4 @@
* Documentation found at:
* http://goldfirestudios.com/blog/81/miniTip-jQuery-Plugin
*/
-(function(a){a.fn.miniTip=function(f){var i={title:"",content:false,delay:300,anchor:"n",event:"hover",fadeIn:200,fadeOut:200,aHide:true,maxW:"250px",offset:5,doHide:false},h=a.extend(i,f);if(!a("#miniTip")[0]){a("body").append('<div id="miniTip"><div id="miniTip_t"></div><div id="miniTip_c"></div><div id="miniTip_a"></div></div>')}var e=a("#miniTip"),g=a("#miniTip_t"),b=a("#miniTip_c"),c=a("#miniTip_a");if(h.doHide){e.stop(true,true).fadeOut(h.fadeOut);return false}return this.each(function(){var m=a(this);var d=h.content?h.content:m.attr("title");if(d!=""&&typeof d!="undefined"){window.delay=false;var n=false,o=true;if(!h.content){m.removeAttr("title")}if(h.event=="hover"){m.hover(function(){e.removeAttr("click");o=true;j.call(this)},function(){o=false;k()});if(!h.aHide){e.hover(function(){n=true},function(){n=false;setTimeout(function(){if(!o&&!e.attr("click")){k()}},20)})}}else{if(h.event=="click"){h.aHide=true;m.click(function(){e.attr("click","t");if(e.data("last_target")!==m){j.call(this)}else{if(e.css("display")=="none"){j.call(this)}else{k()}}e.data("last_target",m);return false});a("html").click(function(p){if(e.css("display")=="block"&&!a(p.target).closest("#miniTip").length){k()}})}}var j=function(){if(h.show){h.show.call(this,h)}if(h.content&&h.content!=""){d=h.content}b.html(d);if(h.title!=""){g.html(h.title).show()}else{g.hide()}if(h.render){h.render(e)}c.removeAttr("class");e.hide().width("").width(e.width()).css("max-width",h.maxW);var K=m.is("area");if(K){var H,D=[],B=[],L=m.attr("coords").split(",");function A(y,x){return y-x}for(H=0;H<L.length;H++){D.push(L[H++]);B.push(L[H])}var u=m.parent().attr("name"),s=a("img[usemap=\\#"+u+"]").offset(),v=parseInt(s.left,10)+parseInt((parseInt(D.sort(A)[0],10)+parseInt(D.sort(A)[D.length-1],10))/2,10),E=parseInt(s.top,10)+parseInt((parseInt(B.sort(A)[0],10)+parseInt(B.sort(A)[B.length-1],10))/2,10)}else{var E=parseInt(m.offset().top,10),v=parseInt(m.offset().left,10)}var J=K?0:parseInt(m.outerWidth(),10),r=K?0:parseInt(m.outerHeight(),10),F=e.outerWidth(),M=e.outerHeight(),G=Math.round(v+Math.round((J-F)/2)),q=Math.round(E+r+h.offset+8),w=(Math.round(F-16)/2)-parseInt(e.css("borderLeftWidth"),10),z=0,p=(v+J+F+h.offset+8)>parseInt(a(window).width(),10),I=(F+h.offset+8)>v,C=(M+h.offset+8)>E-a(window).scrollTop(),t=(E+r+M+h.offset+8)>parseInt(a(window).height()+a(window).scrollTop(),10),N=h.anchor;if(I||h.anchor=="e"&&!p){if(h.anchor=="w"||h.anchor=="e"){N="e";z=Math.round((M/2)-8-parseInt(e.css("borderRightWidth"),10));w=-8-parseInt(e.css("borderRightWidth"),10);G=v+J+h.offset+8;q=Math.round((E+r/2)-(M/2))}}else{if(p||h.anchor=="w"&&!I){if(h.anchor=="w"||h.anchor=="e"){N="w";z=Math.round((M/2)-8-parseInt(e.css("borderLeftWidth"),10));w=F-parseInt(e.css("borderLeftWidth"),10);G=v-F-h.offset-8;q=Math.round((E+r/2)-(M/2))}}}if(t||h.anchor=="n"&&!C){if(h.anchor=="n"||h.anchor=="s"){N="n";z=M-parseInt(e.css("borderTopWidth"),10);q=E-(M+h.offset+8)}}else{if(C||h.anchor=="s"&&!t){if(h.anchor=="n"||h.anchor=="s"){N="s";z=-8-parseInt(e.css("borderBottomWidth"),10);q=E+r+h.offset+8}}}if(h.anchor=="n"||h.anchor=="s"){if((F/2)>v){G=G<0?w+G:w;w=0}else{if((v+F/2)>parseInt(a(window).width(),10)){G-=w;w*=2}}}else{if(C){q=q+z;z=0}else{if(t){q-=z;z*=2}}}c.css({"margin-left":w+"px","margin-top":z+"px"}).attr("class",N);if(delay){clearTimeout(delay)}delay=setTimeout(function(){e.css({"margin-left":G+"px","margin-top":q+"px"}).stop(true,true).fadeIn(h.fadeIn)},h.delay)};var k=function(){if(!h.aHide&&!n||h.aHide){if(delay){clearTimeout(delay)}delay=setTimeout(function(){l()},h.delay)}};var l=function(){if(!h.aHide&&!n||h.aHide){e.stop(true,true).fadeOut(h.fadeOut);if(h.hide){h.hide.call(this)}}else{setTimeout(function(){k()},200)}}}})}})(jQuery);
+(function(e){e.fn.miniTip=function(t){var n={title:"",content:!1,delay:300,anchor:"n",event:"hover",fadeIn:200,fadeOut:200,aHide:!0,maxW:"250px",offset:5,doHide:!1},r=e.extend(n,t);e("#miniTip")[0]||e("body").append('<div id="miniTip"><div id="miniTip_t"></div><div id="miniTip_c"></div><div id="miniTip_a"></div></div>');var i=e("#miniTip"),s=e("#miniTip_t"),o=e("#miniTip_c"),u=e("#miniTip_a");return r.doHide?(i.stop(!0,!0).fadeOut(r.fadeOut),!1):this.each(function(){var t=e(this),n=r.content?r.content:t.attr("title");if(n!=""&&typeof n!="undefined"){window.delay=!1;var a=!1,f=!0;r.content||t.removeAttr("title"),r.event=="hover"?(t.hover(function(){i.removeAttr("click"),f=!0,l.call(this)},function(){f=!1,c()}),r.aHide||i.hover(function(){a=!0},function(){a=!1,setTimeout(function(){!f&&!i.attr("click")&&c()},20)})):r.event=="click"&&(r.aHide=!0,t.click(function(){return i.attr("click","t"),i.data("last_target")!==t?l.call(this):i.css("display")=="none"?l.call(this):c(),i.data("last_target",t),e("html").unbind("click").click(function(t){i.css("display")=="block"&&!e(t.target).closest("#miniTip").length&&c()}),!1}));var l=function(){r.show&&r.show.call(this,r),r.content&&r.content!=""&&(n=r.content),o.html(n),r.title!=""?s.html(r.title).show():s.hide(),r.render&&r.render(i),u.removeAttr("class"),i.hide().width("").width(i.width()).css("max-width",r.maxW);var a=t.is("area");if(a){var f,l=[],c=[],h=t.attr("coords").split(",");function p(e,t){return e-t}for(f=0;f<h.length;f++)l.push(h[f++]),c.push(h[f]);var d=t.parent().attr("name"),v=e("img[usemap=\\#"+d+"]").offset(),m=parseInt(v.left,10)+parseInt((parseInt(l.sort(p)[0],10)+parseInt(l.sort(p)[l.length-1],10))/2,10),g=parseInt(v.top,10)+parseInt((parseInt(c.sort(p)[0],10)+parseInt(c.sort(p)[c.length-1],10))/2,10)}else var g=parseInt(t.offset().top,10),m=parseInt(t.offset().left,10);var y=a?0:parseInt(t.outerWidth(),10),b=a?0:parseInt(t.outerHeight(),10),w=i.outerWidth(),E=i.outerHeight(),S=Math.round(m+Math.round((y-w)/2)),x=Math.round(g+b+r.offset+8),T=Math.round(w-16)/2-parseInt(i.css("borderLeftWidth"),10),N=0,C=m+y+w+r.offset+8>parseInt(e(window).width(),10),k=w+r.offset+8>m,L=E+r.offset+8>g-e(window).scrollTop(),A=g+b+E+r.offset+8>parseInt(e(window).height()+e(window).scrollTop(),10),O=r.anchor;if(k||r.anchor=="e"&&!C){if(r.anchor=="w"||r.anchor=="e")O="e",N=Math.round(E/2-8-parseInt(i.css("borderRightWidth"),10)),T=-8-parseInt(i.css("borderRightWidth"),10),S=m+y+r.offset+8,x=Math.round(g+b/2-E/2)}else if(C||r.anchor=="w"&&!k)if(r.anchor=="w"||r.anchor=="e")O="w",N=Math.round(E/2-8-parseInt(i.css("borderLeftWidth"),10)),T=w-parseInt(i.css("borderLeftWidth"),10),S=m-w-r.offset-8,x=Math.round(g+b/2-E/2);if(A||r.anchor=="n"&&!L){if(r.anchor=="n"||r.anchor=="s")O="n",N=E-parseInt(i.css("borderTopWidth"),10),x=g-(E+r.offset+8)}else if(L||r.anchor=="s"&&!A)if(r.anchor=="n"||r.anchor=="s")O="s",N=-8-parseInt(i.css("borderBottomWidth"),10),x=g+b+r.offset+8;r.anchor=="n"||r.anchor=="s"?w/2>m?(S=S<0?T+S:T,T=0):m+w/2>parseInt(e(window).width(),10)&&(S-=T,T*=2):L?(x+=N,N=0):A&&(x-=N,N*=2),u.css({"margin-left":T+"px","margin-top":N+"px"}).attr("class",O),delay&&clearTimeout(delay),delay=setTimeout(function(){i.css({"margin-left":S+"px","margin-top":x+"px"}).stop(!0,!0).fadeIn(r.fadeIn)},r.delay)},c=function(){if(!r.aHide&&!a||r.aHide)delay&&clearTimeout(delay),delay=setTimeout(function(){h()},r.delay)},h=function(){!r.aHide&&!a||r.aHide?(i.stop(!0,!0).fadeOut(r.fadeOut),r.hide&&r.hide.call(this)):setTimeout(function(){c()},200)}}})}})(jQuery)
2  miniTip.css
View
@@ -1,4 +1,4 @@
-/*! miniTip CSS - v1.5.0 */
+/*! miniTip CSS - v1.5.1 */
#miniTip {
/* main styles for tooltip */
2  miniTip.min.css
View
@@ -1,2 +1,2 @@
-/*! miniTip CSS - v1.5.0 */
+/*! miniTip CSS - v1.5.1 */
#miniTip{background-color:#f8f5ca;border:4px solid #eae4b4;color:#927847;font-size:.9em;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;display:none;position:absolute;top:0;left:0;z-index:99999}#miniTip_t{background-color:#f5edc2;font-weight:700;padding:4px 6px}#miniTip_c{padding:4px 8px}#miniTip_a{width:0;height:0;position:absolute;top:0;left:0}#miniTip .n{border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid #eae4b4;border-bottom:0}#miniTip .s{border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid #eae4b4;border-top:0}#miniTip .e{border-bottom:8px solid transparent;border-top:8px solid transparent;border-right:8px solid #eae4b4;border-left:0}#miniTip .w{border-bottom:8px solid transparent;border-top:8px solid transparent;border-left:8px solid #eae4b4;border-right:0}
Please sign in to comment.
Something went wrong with that request. Please try again.