forked from jikeytang/jikeytang.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathselect.js
93 lines (84 loc) · 2.86 KB
/
select.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
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
define(['drag'], function(drag){
$.pop = function(options){
var conf = this.conf = {
width : 200,
// height : 300,
title : '弹出层',
mask : 1,
content : '',
isDrag : 1,
container : document.body
}
$.extend(conf, options);
this.handler = {
container : $(conf.container),
wrap : null,
title : null,
content : null,
bottom : null,
z : 2014
}
this.init(conf);
}
$.pop.prototype = {
init : function(options){
var conf = this.conf;
this.create();
conf.mask && this.mask();
this.bindClose();
conf.callOpen && conf.callOpen.call(this);
return this;
},
create : function(){
var conf = this.conf,
handler = this.handler,
container = handler.container,
title = this.title(),
content = this.content(),
pop = null,
wrap = null;
this.z = $.pop.z;
pop = $('<div class="ui-pop"><div class="ui-pop-title ' + (conf.title == false ? 'none' : '') +'"><h1>' + title + '</h1><a class="ui-close" href="javascript:void(0)">×</a></div><div class="ui-pop-body">'+ content +'</div></div>').appendTo('body');
pop.css({ width : conf.width, height: conf.height, top : ($(window).height() - pop.height()) / 2, left : ($(window).width() - pop.width()) / 2, zIndex : ++$.pop.z });
if(conf.isDrag){
conf.title && drag(pop.find('.ui-pop-title'));
}
this.pop = pop;
},
mask : function(){
var m = null,
conf = this.conf,
handler = this.handler;
this.mask = m = $('<div class="ui-mask"></div>').appendTo('body');
m.css({ width :$(window).width(), height : $(document).height(), zIndex : this.z });
},
// 绑定事件
bindClose : function(){
var that = this,
conf = this.conf,
handler = this.handler,
mask = this.mask,
pop = this.pop,
btn = pop.find('.ui-close');
btn.on('click', function(){
that.close();
});
},
close : function(){
var conf = this.conf,
mask = this.mask,
pop = this.pop;
pop.hide();
mask.length && mask.hide();
conf.callClose && conf.callClose.call(this);
},
title : function(){
return this.conf.title || '消息';
},
content : function(d){
return this.conf.content || '内容';
}
}
$.pop.z = 2014;
return $.pop;
});