forked from geokrety/geokrety-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajaxtooltip.min.js
1 lines (1 loc) · 3.01 KB
/
ajaxtooltip.min.js
1
var ajaxtooltip={useroffset:[15,5],loadingHTML:'<div style="font-style:italic;text-align:center"><img src="templates/ajax-loader.gif" /><br />Please wait ...</div>',positiontip:function(f,h){var j=f.get(0).x,i=f.get(0).y,m=this.useroffset[0],l=this.useroffset[1],b=f.outerHeight(),g=f.outerWidth(),d=$(window).width(),a=$(window).height(),c=$(window).scrollLeft(),k=$(window).scrollTop();if(g+m+m>(d-(j-c))){f.children().css("width",d-(j-c)-m-m-10+"px");g=f.outerWidth()}if(b+l+l>a){f.children().css("height",a-l-l-10+"px");b=f.outerHeight()}if(j+g+m>d+c){f.css("left",j-g-m)}else{f.css("left",j+m)}if(b>400){f.css("top",k+a/2-b/2)}else{if(i-k<=a-b-l){f.css("top",i+l)}else{f.css("top",i-b-l)}}}};jQuery(document).ready(function(){ajaxtooltip.iebody=(document.compatMode&&document.compatMode!="BackCompat")?document.documentElement:document.body;var a=[];$(".att_js").each(function(c){if(this.getAttribute("title").substr(0,5)=="ajax|"){this.doajax=true;this.datatype=parseInt(jQuery.trim(this.getAttribute("title").split("|")[1]),10);if(this.datatype===0){this.titleurl=jQuery.trim(this.getAttribute("title").split("|")[2]);a.push($('<div class="ajaxttip"></div>').appendTo("body"))}if(this.datatype==1){this.picurl=jQuery.trim(this.getAttribute("title").split("|")[2]);a.push($('<div class="ajaxttip"></div>').appendTo("body"))}if(this.datatype==2){this.picurl=jQuery.trim(this.getAttribute("title").split("|")[2]);this.bigpicurl=jQuery.trim(this.getAttribute("title").split("|")[3]);a.push($('<div class="ajaxttippic"></div>').appendTo("body"))}}else{this.doajax=false;this.datatype=0;this.titleurl=jQuery.trim(this.getAttribute("title"));a.push($('<div class="ttip"></div>').appendTo("body"))}this.titleposition=c;var b=$(this);b.removeAttr("title");b.hover(function(f){var d=a[this.titleposition];d.get(0).hovering=true;d.get(0).x=f.pageX;d.get(0).y=f.pageY;if(!d.get(0).loadsuccess){if(this.doajax){ajaxtooltip.positiontip(d,f);d.html(ajaxtooltip.loadingHTML).show();if(this.datatype===0){d.load(this.titleurl,"",function(){ajaxtooltip.positiontip(d,f);d.get(0).loadsuccess=true})}if(this.datatype==1||this.datatype==2){$("<img />").bind("load",function(g){d.empty().append(this);d.get(0).loadsuccess=true;if(d.get(0).hovering){d.show();ajaxtooltip.positiontip(d,g)}}).attr("src",this.picurl)}}else{d.html(this.titleurl);ajaxtooltip.positiontip(d,f);d.show();d.get(0).loadsuccess=true}}else{if(this.datatype===0||this.datatype==1||this.datatype==2){ajaxtooltip.positiontip(d,f)}d.show()}},function(f){var d=a[this.titleposition];d.get(0).hovering=false;d.hide()});b.bind("mousemove",function(f){var d=a[this.titleposition];d.get(0).x=f.pageX;d.get(0).y=f.pageY;if(this.datatype===0||this.datatype==1||this.datatype==2){ajaxtooltip.positiontip(d,f)}});if(this.datatype==2){b.bind("click",function(f){var d=a[this.titleposition];ajaxtooltip.positiontip(d,f);d.empty().html(ajaxtooltip.loadingHTML);$("<img />").bind("load",function(e){d.empty().append(this);if(d.get(0).hovering){ajaxtooltip.positiontip(d,f);d.show()}}).attr("src",this.bigpicurl);b.unbind("mousemove")})}})});