|
@ -1,28 +1,18 @@
|
1
|
1
|
/*引入util对应的js文件*/
|
2
|
2
|
|
3
|
|
define(['util'], function(){
|
|
3
|
define(["jcl","wmWebUI"], function($,WmWebUI){
|
4
|
4
|
/*WmToolTip对象定义*/
|
5
|
|
function WmToolTip(id){
|
|
5
|
var WmToolTip = function(id){
|
6
|
6
|
this.listeners = new Array(); //存储监听事件
|
7
|
7
|
this.id = id;
|
8
|
8
|
/*常用对象*/
|
9
|
|
this.tip = (function(obj){
|
10
|
|
if(typeof(obj)=="object"){
|
11
|
|
obj = $(obj);
|
12
|
|
}else if(typeof(obj)=="string"){
|
13
|
|
obj = $("#"+obj);
|
14
|
|
}else{
|
15
|
|
alert("没有匹配类型");
|
16
|
|
return null;
|
17
|
|
}
|
18
|
|
return obj;
|
19
|
|
})(id);
|
|
9
|
this.tip = WmWebUI.getElement(id);
|
20
|
10
|
this.baseSize = parseInt($(document.getElementsByTagName("html")[0]).css("font-size"));
|
21
|
11
|
}
|
22
|
12
|
/*关闭按钮事件*/
|
23
|
13
|
WmToolTip.prototype.setCloseAction = function(action){
|
24
|
|
var closeAction = function(e){
|
25
|
|
$($(e.target).parents("div.c_toolTip-view")[0]).removeClass("c_toolTip-view");
|
|
14
|
var closeAction = function(that){
|
|
15
|
that.hide();
|
26
|
16
|
if(action){
|
27
|
17
|
if(typeof action =="function"){
|
28
|
18
|
action();
|
|
@ -32,7 +22,7 @@ define(['util'], function(){
|
32
|
22
|
}
|
33
|
23
|
};
|
34
|
24
|
var btn = this.tip.find("span.e_button");
|
35
|
|
$(btn[0]).tap(closeAction);
|
|
25
|
$(btn[0]).tap(closeAction,this);
|
36
|
26
|
};
|
37
|
27
|
/*设置位置参照元素*/
|
38
|
28
|
WmToolTip.prototype.setBaseElement = function(ele){
|
|
@ -91,16 +81,21 @@ define(['util'], function(){
|
91
|
81
|
};
|
92
|
82
|
/*设置图标*/
|
93
|
83
|
WmToolTip.prototype.setIcon = function(icon){
|
94
|
|
var e = this.tip.find('div.ico');
|
95
|
|
if(e.length){
|
96
|
|
$(e[0]).html('<span class="e_ico '+icon+'"></span>');
|
|
84
|
var elem = this.tip.find('div.ico');
|
|
85
|
if(elem.length){
|
|
86
|
$(elem[0]).html('<span class="e_ico '+icon+'"></span>');
|
97
|
87
|
}else{
|
98
|
88
|
$(this.tip.find("div.content")[0]).prepend('<div class="ico"><span class="e_ico '+icon+'"></span></div>');
|
99
|
89
|
}
|
100
|
90
|
};
|
101
|
91
|
/*设置提示内容*/
|
102
|
92
|
WmToolTip.prototype.setContent = function(text){
|
103
|
|
$(this.tip.find("div.detail")[0]).text(text);
|
|
93
|
var elem = this.tip.find("div.detail");
|
|
94
|
if(elem.length){
|
|
95
|
$(elem[0]).text(text);
|
|
96
|
}else{
|
|
97
|
$(this.tip.find("div.content")[0]).prepend('<div class="detail">'+text+'</div>');
|
|
98
|
}
|
104
|
99
|
};
|
105
|
100
|
/*导出WmToolTip*/
|
106
|
101
|
return WmToolTip;
|