huangbo vor 9 Jahren
Ursprung
Commit
0328c96ef5
1 geänderte Dateien mit 80 neuen und 0 gelöschten Zeilen
  1. 80 0
      multiple-server/web/res/js/ui/wm-dialog2.js

+ 80 - 0
multiple-server/web/res/js/ui/wm-dialog2.js

@ -0,0 +1,80 @@
1
/*引入util对应的js文件*/
2
define(['util'], function(){
3
	var isClose = true;
4
	/*WmNavBar对象定义*/
5
	function WmDialog2(id){
6
		this.listeners = new Array(); //存储监听事件
7
		this.id = id;
8
		/*常用对象*/
9
		this.box = (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);
20
		this.negativeButton = this.box.find(".s-dialog-cancle");
21
		this.positiveButton = this.box.find(".s-dialog-ok");
22
		this.title = this.box.find('.s-dialog-title');
23
		this.mainView = this.box.find('.s-dialog-mainview');
24
		
25
		var that = this;
26
		this.negativeButton.tap(function(){
27
			that.hide();
28
		});
29
	}
30
	
31
	WmDialog2.prototype.show = function(){
32
		this.box.addClass('s-dialog-show');
33
	}
34
	
35
	WmDialog2.prototype.hide = function(){
36
		this.box.removeClass('s-dialog-show');
37
	}
38
	
39
	WmDialog2.prototype.setPositiveAction = function(action,isHide){
40
		var that = this;
41
		if(this.positiveButton.length != 0){
42
			this.positiveButton.tap(function(){
43
				if(typeof(action) == "function") {
44
					action();
45
				}
46
				if(isHide){
47
					that.hide();
48
				}
49
			});
50
		}
51
	}
52
	
53
	WmDialog2.prototype.setNegativeAction = function(action,isHide){
54
		var that = this;
55
		if(this.negativeButton.length != 0){
56
			this.negativeButton.tap(function(){
57
				if(typeof(action) == "function") {
58
					action();
59
				}
60
				if(isHide){
61
					that.hide();
62
				}
63
			});
64
		}
65
	}
66
	
67
	WmDialog2.prototype.setTitle = function(title){
68
		this.title.text(title);
69
	}
70
	/*设置内容*/
71
	WmDialog2.prototype.setContentView = function(str,setBy) {
72
		if (setBy == "html") {
73
			this.mainView.html($("#" + str).html());
74
		} else {
75
			this.mainView.html("<div>" + str + "</div>");
76
		}
77
	}
78
	
79
	return WmDialog2;
80
});