-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathtips.js
54 lines (53 loc) · 1.07 KB
/
tips.js
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
/*
*Tip
*日期:2017-3-24
*config参数说明
*---------
*text:内容
*delay:延迟时间
*/
;(function($){
function Tip(config){
this.config = {
text:'出错了',
delay : 3000
};
//默认参数扩展
if(config && $.isPlainObject(config)){
$.extend(this.config , config);
};
this.wrap = $('<div class="ui-tips"></div>');
this.init();
};
Tip.prototype.init = function(){
var _this = this;
$('body').append(_this.wrap.html(_this.config.text));
_this.show();
};
Tip.prototype.show = function(){
var _this=this;
setTimeout(function(){
_this.wrap.css({
'-webkit-transform':'translateY(0)',
'transform':'translateY(0)'
});
},100);
_this.hide();
};
Tip.prototype.hide = function(){
var _this=this;
setTimeout(function(){
_this.wrap.css({
'-webkit-transform':'translateY(-100%)',
'transform':'translateY(-100%)'
});
},_this.config.delay);
setTimeout(function(){
_this.wrap.remove();
},_this.config.delay + 250);
};
window.Tip=Tip;
$.tip=function(config){
return new Tip(config);
}
})(window.jQuery || $);