|
|
7 |
(function(t){t.cluetip={version:"1.2.9",template:["<div>",'<div class="cluetip-outer">','<h3 class="cluetip-title ui-widget-header ui-cluetip-header"></h3>','<div class="cluetip-inner ui-widget-content ui-cluetip-content"></div>',"</div>",'<div class="cluetip-extra"></div>',"</div>"].join(""),setup:{insertionType:"appendTo",insertionElement:"body"},defaults:{multiple:!1,width:275,height:"auto",cluezIndex:97,positionBy:"auto",topOffset:15,leftOffset:15,snapToEdge:!1,local:!1,localPrefix:null,localIdSuffix:null,hideLocal:!0,attribute:"rel",titleAttribute:"title",splitTitle:"",escapeTitle:!1,showTitle:!0,cluetipClass:"default",hoverClass:"",waitImage:!0,cursor:"help",arrows:!1,dropShadow:!0,dropShadowSteps:6,sticky:!1,mouseOutClose:!1,delayedClose:50,activation:"hover",clickThrough:!0,tracking:!1,closePosition:"top",closeText:"Close",truncate:0,fx:{open:"show",openSpeed:""},hoverIntent:{sensitivity:3,interval:50,timeout:0},onActivate:function(){return!0},onShow:function(){},onHide:function(){},ajaxCache:!0,ajaxProcess:function(t){return t=t.replace(/<(script|style|title)[^<]+<\/(script|style|title)>/gm,"").replace(/<(link|meta)[^>]+>/g,"")},ajaxSettings:{dataType:"html"},debug:!1}};var e,i="cluetip ui-widget ui-widget-content ui-cluetip",o={},a=0,l=0;t.fn.attrProp=t.fn.prop||t.fn.attr,t.fn.cluetip=function(s,n){function c(e,i){var o=e||"";return i=i||"","object"==typeof i?t.each(i,function(t,e){o+="-"+t+"-"+e}):"string"==typeof i&&(o+=i),o}function u(e,i,o){var a="",l=i.dropShadow&&i.dropShadowSteps?+i.dropShadowSteps:0;if(t.support.boxShadow)return l&&(a="1px 1px "+l+"px rgba(0,0,0,0.5)"),e.css(t.support.boxShadow,a),!1;var s=e.find(".cluetip-drop-shadow");if(l==s.length)return s;s.remove();for(var n=[],c=0;l>c;)n[c++]='<div style="top:'+c+"px;left:"+c+'px;"></div>';return o=t(n.join("")).css({position:"absolute",backgroundColor:"#000",zIndex:v-1,opacity:.1}).addClass("cluetip-drop-shadow").prependTo(e)}var r,p,d,f,h,m;if("object"==typeof s&&(n=s,s=null),"destroy"==s)return this.each(function(){var e=t(this),i=e.data("cluetip");i&&(t(i.selector).remove(),t.removeData(this,"title"),t.removeData(this,"cluetip")),i.title&&e.attrProp("title",i.title),e.unbind(".cluetip").unbind("cluetipMoc")}),t('[id^="cluetip"]').length||t(document).unbind(".cluetip"),this;n=t.extend(!0,{},t.cluetip.defaults,n||{}),a++;var v,g=t.cluetip.backCompat||!n.multiple?"cluetip":"cluetip-"+a,b="#"+g,x=t.cluetip.backCompat?"#":".",w=t.cluetip.setup.insertionType,y=t.cluetip.setup.insertionElement||"body";w=/appendTo|prependTo|insertBefore|insertAfter/.test(w)?w:"appendTo",r=t(b),r.length||(r=t(t.cluetip.template)[w](y).attr("id",g).css({position:"absolute",display:"none"}),v=+n.cluezIndex,d=r.find(x+"cluetip-outer").css({position:"relative",zIndex:v}),p=r.find(x+"cluetip-inner"),f=r.find(x+"cluetip-title"),r.bind("mouseenter mouseleave",function(e){t(this).data("entered","mouseenter"===e.type)})),e=t("#cluetip-waitimage"),!e.length&&n.waitImage&&(e=t("<div></div>").attr("id","cluetip-waitimage").css({position:"absolute"}),e.insertBefore(r).hide());var C=(parseInt(r.css("paddingLeft"),10)||0)+(parseInt(r.css("paddingRight"),10)||0);return this.each(function(a){function g(){return!1}function w(t,e){var i=t.status;e.beforeSend(t.xhr,e),"error"==i?e[i](t.xhr,t.textStatus):"success"==i&&e[i](t.data,t.textStatus,t.xhr),e.complete(t.xhr,e.textStatus)}var S=this,I=t(this),T=t.extend(!0,{},n,t.metadata?I.metadata():t.meta?I.data():I.data("cluetip")||{}),k=!1,j=!1,z=null,B=T[T.attribute]||("href"==T.attribute?I.attr(T.attribute):I.attrProp(T.attribute)||I.attr(T.attribute)),P=T.cluetipClass;if(v=+T.cluezIndex,I.data("cluetip",{title:S.title,zIndex:v,selector:b,cursor:S.style.cursor||""}),T.arrows&&!r.find(".cluetip-arrows").length&&r.append('<div class="cluetip-arrows ui-state-default"></div>'),!B&&!T.splitTitle&&!s)return!0;T.local&&T.localPrefix&&(B=T.localPrefix+B),T.local&&T.hideLocal&&B&&t(B+":first").hide();var O,M,A,L,N,E,Y,H,D,R,X,W,$,q,Q=parseInt(T.topOffset,10),U=parseInt(T.leftOffset,10),F=isNaN(parseInt(T.height,10))?"auto":/\D/g.test(T.height)?T.height:T.height+"px",G=parseInt(T.width,10)||275,J=G+C+T.dropShadowSteps,K=this.offsetWidth,V="title"!=T.attribute?I.attr(T.titleAttribute)||"":"";T.splitTitle&&(q=V.split(T.splitTitle),V=T.showTitle||""===q[0]?q.shift():""),T.escapeTitle&&(V=V.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<")),I.bind("mouseenter mouseleave",function(t){var e=I.data("cluetip");e.entered="entered"===t.type,I.data("cluetip",e)});var Z=function(i){var u,m,v,g=T.onActivate.call(S,i);if(g===!1)return!1;if(j=!0,r=t(b).css({position:"absolute"}),d=r.find(x+"cluetip-outer"),p=r.find(x+"cluetip-inner"),f=r.find(x+"cluetip-title"),h=r.find(x+"cluetip-arrows"),r.removeClass().css({width:G}),B==I.attr("href")&&I.css("cursor",T.cursor),T.hoverClass&&I.addClass(T.hoverClass),L=E=I.offset().top,N=L+I.innerHeight(),R=I.offset().left,"relative"===t(y).css("position")&&(R-=t(y)[0].getBoundingClientRect().left),K=I.innerWidth(),i.type==focus?(W=R+K/2+U,r.css({left:X}),H=E+Q):(W=i.pageX,H=i.pageY),"area"!=S.tagName.toLowerCase()&&(A=t(document).scrollTop(),$=t(window).width()),"fixed"==T.positionBy?(X=K+R+U,r.css({left:X})):(X=K>R&&R>J||R+K+J+U>$?R-J-U:K+R+U,("area"==S.tagName.toLowerCase()||"mouse"==T.positionBy||K+J>$)&&(W+20+J>$?(r.addClass("cluetip-"+P),X=W-J-U>=0?W-J-U-parseInt(r.css("marginLeft"),10)+parseInt(p.css("marginRight"),10):W-J/2):X=W+U),u=0>X?i.pageY+Q:i.pageY,(0>X||"bottomTop"==T.positionBy||"topBottom"==T.positionBy)&&(X=W+J/2>$?$/2-J/2:Math.max(W-J/2,0))),h.css({zIndex:I.data("cluetip").zIndex+1}),r.css({left:X,zIndex:I.data("cluetip").zIndex}),M=t(window).height(),s)"function"==typeof s&&(s=s.call(S)),p.html(s),_(u);else if(q){var C=q.length;if(p.html(C?q[0]:""),C>1)for(var z=1;C>z;z++)p.append('<div class="split-body">'+q[z]+"</div>");_(u)}else if(T.local||0===B.indexOf("#")){if(T.local){var O=t(B+(/^#\S+$/.test(B)?"":":eq("+a+")")).clone(!0).show();T.localIdSuffix&&O.attr("id",O[0].id+T.localIdSuffix),p.html(O),_(u)}}else if(/\.(jpe?g|tiff?|gif|png)(?:\?.*)?$/i.test(B))p.html('<img src="'+B+'" alt="'+V+'" />'),_(u);else{var Y=T.ajaxSettings.beforeSend,D=T.ajaxSettings.error,F=T.ajaxSettings.success,Z=T.ajaxSettings.complete;v=c(B,T.ajaxSettings.data);var te={cache:T.ajaxCache,url:B,beforeSend:function(t,i){Y&&Y.call(S,t,r,p,i),d.children().empty(),T.waitImage&&e.css({top:H+20,left:W+20,zIndex:I.data("cluetip").zIndex-1}).show()},error:function(t,e){n.ajaxCache&&!o[v]&&(o[v]={status:"error",textStatus:e,xhr:t}),j&&(D?D.call(S,t,e,r,p):p.html("<i>sorry, the contents could not be loaded</i>"))},success:function(t,e,i){n.ajaxCache&&!o[v]&&(o[v]={status:"success",data:t,textStatus:e,xhr:i}),k=T.ajaxProcess.call(S,t),"object"==typeof k&&null!==k&&(V=k.title,k=k.content),j&&(F&&F.call(S,t,e,r,p),p.html(k))},complete:function(i,o){Z&&Z.call(S,i,o,r,p);var a=p[0].getElementsByTagName("img");l=a.length;for(var s=0,n=a.length;n>s;s++)a[s].complete&&l--;l?t(a).bind("load.ct error.ct",function(){l--,0===l&&(e.hide(),t(a).unbind(".ct"),j&&_(u))}):(e.hide(),j&&_(u))}};m=t.extend(!0,{},T.ajaxSettings,te),o[v]?w(o[v],m):t.ajax(m)}},_=function(e){var o,a,l,s=V||T.showTitle&&" ",n="",c="",v=!1,g={bottom:function(t){t.appendTo(p)},top:function(t){t.prependTo(p)},title:function(t){t.prependTo(f)}};if(r.addClass("cluetip-"+P),T.truncate){var b=p.text().slice(0,T.truncate)+"...";p.html(b)}s?f.show().html(s):f.hide(),T.sticky&&(g[T.closePosition]&&(o=t('<div class="cluetip-close"><a href="#">'+T.closeText+"</a></div>"),g[T.closePosition](o),o.bind("click.cluetip",function(){return ee(),!1})),T.mouseOutClose&&(I.unbind("mouseleave.cluetipMoc"),r.unbind("mouseleave.cluetipMoc"),("both"==T.mouseOutClose||"cluetip"==T.mouseOutClose||T.mouseOutClose===!0)&&r.bind("mouseleave.cluetipMoc",ie),("both"==T.mouseOutClose||"link"==T.mouseOutClose)&&I.bind("mouseleave.cluetipMoc",ie))),d.css({zIndex:I.data("cluetip").zIndex,overflow:"auto"==F?"visible":"auto",height:F}),O="auto"==F?Math.max(r.outerHeight(),r.height()):parseInt(F,10),Y=E,D=A+M,v=W>X&&Math.max(X,0)+J>W,"fixed"==T.positionBy?Y=E-T.dropShadowSteps+Q:"topBottom"==T.positionBy||"bottomTop"==T.positionBy||v?("topBottom"==T.positionBy?c=D>E+O+Q&&O+Q>H-A?"bottom":"top":("bottomTop"==T.positionBy||v)&&(c=E+O+Q>D&&H-A>O+Q?"top":"bottom"),T.snapToEdge?"top"==c?Y=L-O-Q:"bottom"==c&&(Y=N+Q):"top"==c?Y=H-O-Q:"bottom"==c&&(Y=H+Q)):Y=E+O+Q>D?O>=M?A:D-O-Q:"block"==I.css("display")||"area"==S.tagName.toLowerCase()||"mouse"==T.positionBy?e-Q:E-T.dropShadowSteps,""===c&&(c=R>X?"left":"right"),a=" clue-"+c+"-"+P+" cluetip-"+P,"rounded"==P&&(a+=" ui-corner-all"),r.css({top:Y+"px"}).attrProp({className:i+a}),T.arrows?(/(left|right)/.test(c)&&(l=r.height()-h.height(),n=X>=0&&e>0?E-Y-T.dropShadowSteps:0,n=l>n?n:l,n+="px"),h.css({top:n}).show()):h.hide(),m=u(r,T),m&&m.length&&m.hide().css({height:O,width:G,zIndex:I.data("cluetip").zIndex-1}).show(),z||r.hide(),clearTimeout(z),z=null,r[T.fx.open](T.fx.openSpeed||0),t.fn.bgiframe&&r.bgiframe(),T.onShow.call(S,r,p)},te=function(){j=!1,e.hide(),(!T.sticky||/click|toggle/.test(T.activation))&&(T.delayedClose>0?(clearTimeout(z),z=null,z=setTimeout(ee,T.delayedClose)):(ee(),clearTimeout(z))),T.hoverClass&&I.removeClass(T.hoverClass)},ee=function(e){var i=e&&e.data("cluetip")?e:I,o=i.data("cluetip")&&i.data("cluetip").selector,a=o||"div.cluetip",l=t(a),s=l.find(x+"cluetip-inner"),n=l.find(x+"cluetip-arrows");l.hide().removeClass(),T.onHide.call(i[0],l,s),o&&(i.removeClass("cluetip-clicked"),I.css("cursor",I.data("cluetip").cursor)),o&&V&&i.attrProp(T.titleAttribute,V),T.arrows&&n.css({top:""}),m&&m.hide()},ie=function(){var t=this;clearTimeout(z),z=setTimeout(function(){var e=I.data("cluetip").entered,i=r.data("entered"),o=!1;"both"==T.mouseOutClose&&(e||i)?o=!0:T.mouseOutClose!==!0&&"cluetip"!=T.mouseOutClose||!i?"link"==T.mouseOutClose&&e&&(o=!0):o=!0,o||ee.call(t)},T.delayedClose)};if(t(document).unbind("hideCluetip.cluetip").bind("hideCluetip.cluetip",function(e){ee(t(e.target))}),/click|toggle/.test(T.activation))I.bind("click.cluetip",function(e){return r.is(":hidden")||!I.is(".cluetip-clicked")?(Z(e),t(".cluetip-clicked").removeClass("cluetip-clicked"),I.addClass("cluetip-clicked")):te(e),!1});else if("focus"==T.activation)I.bind("focus.cluetip",function(t){I.attrProp("title",""),Z(t)}),I.bind("blur.cluetip",function(t){I.attrProp("title",I.data("cluetip").title),te(t)});else{I[T.clickThrough?"unbind":"bind"]("click.cluetip",g);var oe=function(t){if(T.tracking){var e=X-t.pageX,i=Y?Y-t.pageY:E-t.pageY;I.bind("mousemove.cluetip",function(t){r.css({left:t.pageX+e,top:t.pageY+i})})}};t.fn.hoverIntent&&T.hoverIntent?I.hoverIntent({sensitivity:T.hoverIntent.sensitivity,interval:T.hoverIntent.interval,over:function(t){Z(t),oe(t)},timeout:T.hoverIntent.timeout,out:function(t){te(t),I.unbind("mousemove.cluetip")}}):I.bind("mouseenter.cluetip",function(t){Z(t),oe(t)}).bind("mouseleave.cluetip",function(t){te(t),I.unbind("mousemove.cluetip")}),I.bind("mouseover.cluetip",function(){I.attrProp("title","")}).bind("mouseleave.cluetip",function(){I.attrProp("title",I.data("cluetip").title)})}}),this},function(){t.support=t.support||{};for(var e=document.createElement("div"),i=e.style,o=["boxShadow"],a=["moz","Moz","webkit","o"],l=0,s=o.length;s>l;l++){var n=o[l],c=n.charAt(0).toUpperCase()+n.slice(1);if(i[n]!==void 0)t.support[n]=n;else for(var u=0,r=a.length;r>u;u++)if(i[a[u]+c]!==void 0){t.support[n]=a[u]+c;break}}e=null}(),t.fn.cluetip.defaults=t.cluetip.defaults})(jQuery);
|