Blame view

src/main/webapp/libs/jquery-easyui-1.4.1/plugins/jquery.tooltip.js 5.63 KB
caiyongsong committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
/**
 * jQuery EasyUI 1.4.1
 * 
 * Copyright (c) 2009-2014 www.jeasyui.com. All rights reserved.
 *
 * Licensed under the GPL license: http://www.gnu.org/licenses/gpl.txt
 * To use it on other terms please contact us at info@jeasyui.com
 *
 */
(function($){
function _1(_2){
$(_2).addClass("tooltip-f");
};
function _3(_4){
var _5=$.data(_4,"tooltip").options;
$(_4).unbind(".tooltip").bind(_5.showEvent+".tooltip",function(e){
$(_4).tooltip("show",e);
}).bind(_5.hideEvent+".tooltip",function(e){
$(_4).tooltip("hide",e);
}).bind("mousemove.tooltip",function(e){
if(_5.trackMouse){
_5.trackMouseX=e.pageX;
_5.trackMouseY=e.pageY;
$(_4).tooltip("reposition");
}
});
};
function _6(_7){
var _8=$.data(_7,"tooltip");
if(_8.showTimer){
clearTimeout(_8.showTimer);
_8.showTimer=null;
}
if(_8.hideTimer){
clearTimeout(_8.hideTimer);
_8.hideTimer=null;
}
};
function _9(_a){
var _b=$.data(_a,"tooltip");
if(!_b||!_b.tip){
return;
}
var _c=_b.options;
var _d=_b.tip;
var _e={left:-100000,top:-100000};
if($(_a).is(":visible")){
_e=_f(_c.position);
if(_c.position=="top"&&_e.top<0){
_e=_f("bottom");
}else{
if((_c.position=="bottom")&&(_e.top+_d._outerHeight()>$(window)._outerHeight()+$(document).scrollTop())){
_e=_f("top");
}
}
if(_e.left<0){
if(_c.position=="left"){
_e=_f("right");
}else{
$(_a).tooltip("arrow").css("left",_d._outerWidth()/2+_e.left);
_e.left=0;
}
}else{
if(_e.left+_d._outerWidth()>$(window)._outerWidth()+$(document)._scrollLeft()){
if(_c.position=="right"){
_e=_f("left");
}else{
var _10=_e.left;
_e.left=$(window)._outerWidth()+$(document)._scrollLeft()-_d._outerWidth();
$(_a).tooltip("arrow").css("left",_d._outerWidth()/2-(_e.left-_10));
}
}
}
}
_d.css({left:_e.left,top:_e.top,zIndex:(_c.zIndex!=undefined?_c.zIndex:($.fn.window?$.fn.window.defaults.zIndex++:""))});
_c.onPosition.call(_a,_e.left,_e.top);
function _f(_11){
_c.position=_11||"bottom";
_d.removeClass("tooltip-top tooltip-bottom tooltip-left tooltip-right").addClass("tooltip-"+_c.position);
var _12,top;
if(_c.trackMouse){
t=$();
_12=_c.trackMouseX+_c.deltaX;
top=_c.trackMouseY+_c.deltaY;
}else{
var t=$(_a);
_12=t.offset().left+_c.deltaX;
top=t.offset().top+_c.deltaY;
}
switch(_c.position){
case "right":
_12+=t._outerWidth()+12+(_c.trackMouse?12:0);
top-=(_d._outerHeight()-t._outerHeight())/2;
break;
case "left":
_12-=_d._outerWidth()+12+(_c.trackMouse?12:0);
top-=(_d._outerHeight()-t._outerHeight())/2;
break;
case "top":
_12-=(_d._outerWidth()-t._outerWidth())/2;
top-=_d._outerHeight()+12+(_c.trackMouse?12:0);
break;
case "bottom":
_12-=(_d._outerWidth()-t._outerWidth())/2;
top+=t._outerHeight()+12+(_c.trackMouse?12:0);
break;
}
return {left:_12,top:top};
};
};
function _13(_14,e){
var _15=$.data(_14,"tooltip");
var _16=_15.options;
var tip=_15.tip;
if(!tip){
tip=$("<div tabindex=\"-1\" class=\"tooltip\">"+"<div class=\"tooltip-content\"></div>"+"<div class=\"tooltip-arrow-outer\"></div>"+"<div class=\"tooltip-arrow\"></div>"+"</div>").appendTo("body");
_15.tip=tip;
_17(_14);
}
_6(_14);
_15.showTimer=setTimeout(function(){
$(_14).tooltip("reposition");
tip.show();
_16.onShow.call(_14,e);
var _18=tip.children(".tooltip-arrow-outer");
var _19=tip.children(".tooltip-arrow");
var bc="border-"+_16.position+"-color";
_18.add(_19).css({borderTopColor:"",borderBottomColor:"",borderLeftColor:"",borderRightColor:""});
_18.css(bc,tip.css(bc));
_19.css(bc,tip.css("backgroundColor"));
},_16.showDelay);
};
function _1a(_1b,e){
var _1c=$.data(_1b,"tooltip");
if(_1c&&_1c.tip){
_6(_1b);
_1c.hideTimer=setTimeout(function(){
_1c.tip.hide();
_1c.options.onHide.call(_1b,e);
},_1c.options.hideDelay);
}
};
function _17(_1d,_1e){
var _1f=$.data(_1d,"tooltip");
var _20=_1f.options;
if(_1e){
_20.content=_1e;
}
if(!_1f.tip){
return;
}
var cc=typeof _20.content=="function"?_20.content.call(_1d):_20.content;
_1f.tip.children(".tooltip-content").html(cc);
_20.onUpdate.call(_1d,cc);
};
function _21(_22){
var _23=$.data(_22,"tooltip");
if(_23){
_6(_22);
var _24=_23.options;
if(_23.tip){
_23.tip.remove();
}
if(_24._title){
$(_22).attr("title",_24._title);
}
$.removeData(_22,"tooltip");
$(_22).unbind(".tooltip").removeClass("tooltip-f");
_24.onDestroy.call(_22);
}
};
$.fn.tooltip=function(_25,_26){
if(typeof _25=="string"){
return $.fn.tooltip.methods[_25](this,_26);
}
_25=_25||{};
return this.each(function(){
var _27=$.data(this,"tooltip");
if(_27){
$.extend(_27.options,_25);
}else{
$.data(this,"tooltip",{options:$.extend({},$.fn.tooltip.defaults,$.fn.tooltip.parseOptions(this),_25)});
_1(this);
}
_3(this);
_17(this);
});
};
$.fn.tooltip.methods={options:function(jq){
return $.data(jq[0],"tooltip").options;
},tip:function(jq){
return $.data(jq[0],"tooltip").tip;
},arrow:function(jq){
return jq.tooltip("tip").children(".tooltip-arrow-outer,.tooltip-arrow");
},show:function(jq,e){
return jq.each(function(){
_13(this,e);
});
},hide:function(jq,e){
return jq.each(function(){
_1a(this,e);
});
},update:function(jq,_28){
return jq.each(function(){
_17(this,_28);
});
},reposition:function(jq){
return jq.each(function(){
_9(this);
});
},destroy:function(jq){
return jq.each(function(){
_21(this);
});
}};
$.fn.tooltip.parseOptions=function(_29){
var t=$(_29);
var _2a=$.extend({},$.parser.parseOptions(_29,["position","showEvent","hideEvent","content",{trackMouse:"boolean",deltaX:"number",deltaY:"number",showDelay:"number",hideDelay:"number"}]),{_title:t.attr("title")});
t.attr("title","");
if(!_2a.content){
_2a.content=_2a._title;
}
return _2a;
};
$.fn.tooltip.defaults={position:"bottom",content:null,trackMouse:false,deltaX:0,deltaY:0,showEvent:"mouseenter",hideEvent:"mouseleave",showDelay:200,hideDelay:100,onShow:function(e){
},onHide:function(e){
},onUpdate:function(_2b){
},onPosition:function(_2c,top){
},onDestroy:function(){
}};
})(jQuery);