layer-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/layer/rails.rb +8 -0
- data/lib/layer/rails/version.rb +5 -0
- data/vendor/assets/images/icon-ext.png +0 -0
- data/vendor/assets/images/icon.png +0 -0
- data/vendor/assets/images/loading-0.gif +0 -0
- data/vendor/assets/images/loading-1.gif +0 -0
- data/vendor/assets/images/loading-2.gif +0 -0
- data/vendor/assets/javascript/layer.ext.js +256 -0
- data/vendor/assets/javascript/layer.js +792 -0
- data/vendor/assets/stylesheets/layer.css +719 -0
- data/vendor/assets/stylesheets/layer.ext.css +190 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a75bdbc8cd414c97b1ea98a38136a94deefefac
|
4
|
+
data.tar.gz: 47c0a57cbac2c59aaa84200b5ea02a445f3b6134
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f8e837a669d504d218f49f6a277fe1e8c766b86d31d93cf82f864d25caed9ce12cbaaaaf1c427bfcbd3cfc868d86c4b489d162f59a09e8316af19f9496a64cef
|
7
|
+
data.tar.gz: ff64607d7639ac755ba025f19b185d65e79b84141f5a7371eeedf67a0b29826316a7ec63cf821584f8209fdfe532486449ea179918b9ebb96bdd677b573639d3
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "layer/rails"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/layer/rails.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,256 @@
|
|
1
|
+
/*!
|
2
|
+
|
3
|
+
@Name: layer v1.9.x-ext
|
4
|
+
@Author: 贤心
|
5
|
+
@Api:http://sentsin.com/jquery/layer
|
6
|
+
|
7
|
+
*/
|
8
|
+
|
9
|
+
;!function(){
|
10
|
+
|
11
|
+
layer.use('skin/layer.ext.scss', function(){
|
12
|
+
layer.layui_layer_extendlayerextjs = true;
|
13
|
+
});
|
14
|
+
|
15
|
+
var cache = layer.cache||{}, skin = function(type){
|
16
|
+
return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : '');
|
17
|
+
}
|
18
|
+
|
19
|
+
//仿系统prompt
|
20
|
+
layer.prompt = function(options, yes){
|
21
|
+
options = options || {};
|
22
|
+
if(typeof options === 'function') yes = options;
|
23
|
+
var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input">'+ (options.value||'') +'</textarea>' : function(){
|
24
|
+
return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">';
|
25
|
+
}();
|
26
|
+
return layer.open($.extend({
|
27
|
+
btn: ['确定','取消'],
|
28
|
+
content: content,
|
29
|
+
skin: 'layui-layer-prompt' + skin('prompt'),
|
30
|
+
success: function(layero){
|
31
|
+
prompt = layero.find('.layui-layer-input');
|
32
|
+
prompt.focus();
|
33
|
+
}, yes: function(index){
|
34
|
+
var value = prompt.val();
|
35
|
+
if(value === ''){
|
36
|
+
prompt.focus();
|
37
|
+
} else if(value.length > (options.maxlength||500)) {
|
38
|
+
layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1});
|
39
|
+
} else {
|
40
|
+
yes && yes(value, index, prompt);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}, options));
|
44
|
+
};
|
45
|
+
|
46
|
+
//tab层
|
47
|
+
layer.tab = function(options){
|
48
|
+
options = options || {};
|
49
|
+
var tab = options.tab || {};
|
50
|
+
return layer.open($.extend({
|
51
|
+
type: 1,
|
52
|
+
skin: 'layui-layer-tab' + skin('tab'),
|
53
|
+
title: function(){
|
54
|
+
var len = tab.length, ii = 1, str = '';
|
55
|
+
if(len > 0){
|
56
|
+
str = '<span class="layui-layer-tabnow">'+ tab[0].title +'</span>';
|
57
|
+
for(; ii < len; ii++){
|
58
|
+
str += '<span>'+ tab[ii].title +'</span>';
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return str;
|
62
|
+
}(),
|
63
|
+
content: '<ul class="layui-layer-tabmain">'+ function(){
|
64
|
+
var len = tab.length, ii = 1, str = '';
|
65
|
+
if(len > 0){
|
66
|
+
str = '<li class="layui-layer-tabli xubox_tab_layer">'+ (tab[0].content || 'no content') +'</li>';
|
67
|
+
for(; ii < len; ii++){
|
68
|
+
str += '<li class="layui-layer-tabli">'+ (tab[ii].content || 'no content') +'</li>';
|
69
|
+
}
|
70
|
+
}
|
71
|
+
return str;
|
72
|
+
}() +'</ul>',
|
73
|
+
success: function(layero){
|
74
|
+
var btn = layero.find('.layui-layer-title').children();
|
75
|
+
var main = layero.find('.layui-layer-tabmain').children();
|
76
|
+
btn.on('mousedown', function(e){
|
77
|
+
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
|
78
|
+
var othis = $(this), index = othis.index();
|
79
|
+
othis.addClass('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow');
|
80
|
+
main.eq(index).show().siblings().hide();
|
81
|
+
});
|
82
|
+
}
|
83
|
+
}, options));
|
84
|
+
};
|
85
|
+
|
86
|
+
//相册层
|
87
|
+
layer.photos = function(options, loop, key){
|
88
|
+
var dict = {};
|
89
|
+
options = options || {};
|
90
|
+
if(!options.photos) return;
|
91
|
+
var type = options.photos.constructor === Object;
|
92
|
+
var photos = type ? options.photos : {}, data = photos.data || [];
|
93
|
+
var start = photos.start || 0;
|
94
|
+
dict.imgIndex = start + 1;
|
95
|
+
|
96
|
+
if(!type){ //页面直接获取
|
97
|
+
var parent = $(options.photos), img = parent.find(options.img||'img');
|
98
|
+
if (img.length === 0) return;
|
99
|
+
loop || parent.find(photos.img||'img').each(function(index){
|
100
|
+
var othis = $(this);
|
101
|
+
data.push({
|
102
|
+
alt: othis.attr('alt'),
|
103
|
+
pid: othis.attr('layer-pid'),
|
104
|
+
src: othis.attr('layer-src') || othis.attr('src'),
|
105
|
+
thumb: othis.attr('src')
|
106
|
+
});
|
107
|
+
othis.on('click', function(){
|
108
|
+
layer.photos($.extend(options, {
|
109
|
+
photos: {
|
110
|
+
start: index,
|
111
|
+
data: data,
|
112
|
+
tab: options.tab
|
113
|
+
},
|
114
|
+
full: options.full
|
115
|
+
}), true);
|
116
|
+
});
|
117
|
+
});
|
118
|
+
|
119
|
+
//不直接弹出
|
120
|
+
if(!loop) return;
|
121
|
+
|
122
|
+
} else if (data.length === 0){
|
123
|
+
layer.msg('没有图片');
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
|
127
|
+
//上一张
|
128
|
+
dict.imgprev = function(key){
|
129
|
+
dict.imgIndex--;
|
130
|
+
if(dict.imgIndex < 1){
|
131
|
+
dict.imgIndex = data.length;
|
132
|
+
}
|
133
|
+
dict.tabimg(key);
|
134
|
+
};
|
135
|
+
|
136
|
+
//下一张
|
137
|
+
dict.imgnext = function(key,errorMsg){
|
138
|
+
dict.imgIndex++;
|
139
|
+
if(dict.imgIndex > data.length){
|
140
|
+
dict.imgIndex = 1;
|
141
|
+
if (errorMsg) {return};
|
142
|
+
}
|
143
|
+
dict.tabimg(key)
|
144
|
+
};
|
145
|
+
|
146
|
+
//方向键
|
147
|
+
dict.keyup = function(event){
|
148
|
+
if(!dict.end){
|
149
|
+
var code = event.keyCode;
|
150
|
+
event.preventDefault();
|
151
|
+
if(code === 37){
|
152
|
+
dict.imgprev(true);
|
153
|
+
} else if(code === 39) {
|
154
|
+
dict.imgnext(true);
|
155
|
+
} else if(code === 27) {
|
156
|
+
layer.close(dict.index);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
//切换
|
162
|
+
dict.tabimg = function(key){
|
163
|
+
if(data.length <= 1) return;
|
164
|
+
photos.start = dict.imgIndex - 1;
|
165
|
+
layer.close(dict.index);
|
166
|
+
layer.photos(options, true, key);
|
167
|
+
}
|
168
|
+
|
169
|
+
//一些动作
|
170
|
+
dict.event = function(){
|
171
|
+
dict.bigimg.hover(function(){
|
172
|
+
dict.imgsee.show();
|
173
|
+
}, function(){
|
174
|
+
dict.imgsee.hide();
|
175
|
+
});
|
176
|
+
|
177
|
+
dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){
|
178
|
+
event.preventDefault();
|
179
|
+
dict.imgprev();
|
180
|
+
});
|
181
|
+
|
182
|
+
dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){
|
183
|
+
event.preventDefault();
|
184
|
+
dict.imgnext();
|
185
|
+
});
|
186
|
+
|
187
|
+
$(document).on('keyup', dict.keyup);
|
188
|
+
};
|
189
|
+
|
190
|
+
//图片预加载
|
191
|
+
function loadImage(url, callback, error) {
|
192
|
+
var img = new Image();
|
193
|
+
img.onload = function(){
|
194
|
+
img.onload = null;
|
195
|
+
callback(img);
|
196
|
+
};
|
197
|
+
img.onerror = function(e){
|
198
|
+
img.onerror = null;
|
199
|
+
error(e);
|
200
|
+
};
|
201
|
+
img.src = url;
|
202
|
+
};
|
203
|
+
|
204
|
+
dict.loadi = layer.load(1, {
|
205
|
+
shade: 'shade' in options ? false : 0.9,
|
206
|
+
scrollbar: false
|
207
|
+
});
|
208
|
+
loadImage(data[start].src, function(img){
|
209
|
+
layer.close(dict.loadi);
|
210
|
+
dict.index = layer.open($.extend({
|
211
|
+
type: 1,
|
212
|
+
area: function(){
|
213
|
+
var imgarea = [img.width, img.height];
|
214
|
+
var winarea = [$(window).width() - 100, $(window).height() - 100];
|
215
|
+
if(!options.full && imgarea[0] > winarea[0]){
|
216
|
+
imgarea[0] = winarea[0];
|
217
|
+
imgarea[1] = imgarea[0]*winarea[1]/imgarea[0];
|
218
|
+
}
|
219
|
+
return [imgarea[0]+'px', imgarea[1]+'px'];
|
220
|
+
}(),
|
221
|
+
title: false,
|
222
|
+
shade: 0.9,
|
223
|
+
shadeClose: true,
|
224
|
+
closeBtn: false,
|
225
|
+
move: '.layui-layer-phimg img',
|
226
|
+
moveType: 1,
|
227
|
+
scrollbar: false,
|
228
|
+
moveOut: true,
|
229
|
+
shift: Math.random()*5|0,
|
230
|
+
skin: 'layui-layer-photos' + skin('photos'),
|
231
|
+
content: '<div class="layui-layer-phimg">'
|
232
|
+
+'<img src="'+ data[start].src +'" alt="'+ (data[start].alt||'') +'" layer-pid="'+ data[start].pid +'">'
|
233
|
+
+'<div class="layui-layer-imgsee">'
|
234
|
+
+(data.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : '')
|
235
|
+
+'<div class="layui-layer-imgbar" style="display:'+ (key ? 'block' : '') +'"><span class="layui-layer-imgtit"><a href="javascript:;">'+ (data[start].alt||'') +'</a><em>'+ dict.imgIndex +'/'+ data.length +'</em></span></div>'
|
236
|
+
+'</div>'
|
237
|
+
+'</div>',
|
238
|
+
success: function(layero, index){
|
239
|
+
dict.bigimg = layero.find('.layui-layer-phimg');
|
240
|
+
dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar');
|
241
|
+
dict.event(layero);
|
242
|
+
options.tab && options.tab(data[start], layero);
|
243
|
+
}, end: function(){
|
244
|
+
dict.end = true;
|
245
|
+
$(document).off('keyup', dict.keyup);
|
246
|
+
}
|
247
|
+
}, options));
|
248
|
+
}, function(){
|
249
|
+
layer.close(dict.loadi);
|
250
|
+
layer.msg('当前图片地址异常', {time: 2000}, function(){
|
251
|
+
data.length > 1 && dict.imgnext(true,true);
|
252
|
+
});
|
253
|
+
});
|
254
|
+
};
|
255
|
+
|
256
|
+
}();
|
@@ -0,0 +1,792 @@
|
|
1
|
+
/*!
|
2
|
+
|
3
|
+
@Name:layer v2.0 弹层组件
|
4
|
+
@Author:贤心
|
5
|
+
@Site:http://layer.layui.com
|
6
|
+
@License:LGPL
|
7
|
+
|
8
|
+
*/
|
9
|
+
|
10
|
+
;!function(window, undefined){
|
11
|
+
"use strict";
|
12
|
+
|
13
|
+
var $, win, ready = {
|
14
|
+
getPath: function(){
|
15
|
+
var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
|
16
|
+
if(script.getAttribute('merge')) return;
|
17
|
+
return jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
|
18
|
+
}(),
|
19
|
+
|
20
|
+
//屏蔽Enter触发弹层
|
21
|
+
enter: function(e){
|
22
|
+
if(e.keyCode === 13) e.preventDefault();
|
23
|
+
},
|
24
|
+
config: {}, end: {},
|
25
|
+
btn: ['确定','取消'],
|
26
|
+
|
27
|
+
//五种原始层模式
|
28
|
+
type: ['dialog', 'page', 'iframe', 'loading', 'tips']
|
29
|
+
};
|
30
|
+
|
31
|
+
//默认内置方法。
|
32
|
+
var layer = {
|
33
|
+
v: '2.0',
|
34
|
+
ie6: !!window.ActiveXObject&&!window.XMLHttpRequest,
|
35
|
+
index: 0,
|
36
|
+
path: ready.getPath,
|
37
|
+
config: function(options, fn){
|
38
|
+
var item = 0;
|
39
|
+
options = options || {};
|
40
|
+
layer.cache = ready.config = $.extend(ready.config, options);
|
41
|
+
layer.path = ready.config.path || layer.path;
|
42
|
+
typeof options.extend === 'string' && (options.extend = [options.extend]);
|
43
|
+
layer.use('layer.css', (options.extend && options.extend.length > 0) ? (function loop(){
|
44
|
+
var ext = options.extend;
|
45
|
+
layer.use(ext[ext[item] ? item : item-1], item < ext.length ? function(){
|
46
|
+
++item;
|
47
|
+
return loop;
|
48
|
+
}() : fn);
|
49
|
+
}()) : fn);
|
50
|
+
return this;
|
51
|
+
},
|
52
|
+
|
53
|
+
//载入配件
|
54
|
+
use: function(module, fn, readyMethod){
|
55
|
+
var i = 0, head = $('head')[0];
|
56
|
+
var module = module.replace(/\s/g, '');
|
57
|
+
var iscss = /\.css$/.test(module);
|
58
|
+
var node = document.createElement(iscss ? 'link' : 'script');
|
59
|
+
var id = 'layui_layer_' + module.replace(/\.|\//g, '');
|
60
|
+
if(!layer.path) return;
|
61
|
+
if(iscss){
|
62
|
+
node.rel = 'stylesheet';
|
63
|
+
}
|
64
|
+
node[iscss ? 'href' : 'src'] = /^http:\/\//.test(module) ? module : layer.path + module;
|
65
|
+
node.id = id;
|
66
|
+
if(!$('#'+ id)[0]){
|
67
|
+
head.appendChild(node);
|
68
|
+
}
|
69
|
+
//轮询加载就绪
|
70
|
+
;(function poll() {
|
71
|
+
;(iscss ? parseInt($('#'+id).css('width')) === 1989 : layer[readyMethod||id]) ? function(){
|
72
|
+
fn && fn();
|
73
|
+
try { iscss || head.removeChild(node); } catch(e){};
|
74
|
+
}() : setTimeout(poll, 100);
|
75
|
+
}());
|
76
|
+
return this;
|
77
|
+
},
|
78
|
+
|
79
|
+
ready: function(path, fn){
|
80
|
+
var type = typeof path === 'function';
|
81
|
+
if(type) fn = path;
|
82
|
+
layer.config($.extend(ready.config, function(){
|
83
|
+
return type ? {} : {path: path};
|
84
|
+
}()), fn);
|
85
|
+
return this;
|
86
|
+
},
|
87
|
+
|
88
|
+
//各种快捷引用
|
89
|
+
alert: function(content, options, yes){
|
90
|
+
var type = typeof options === 'function';
|
91
|
+
if(type) yes = options;
|
92
|
+
return layer.open($.extend({
|
93
|
+
content: content,
|
94
|
+
yes: yes
|
95
|
+
}, type ? {} : options));
|
96
|
+
},
|
97
|
+
|
98
|
+
confirm: function(content, options, yes, cancel){
|
99
|
+
var type = typeof options === 'function';
|
100
|
+
if(type){
|
101
|
+
cancel = yes;
|
102
|
+
yes = options;
|
103
|
+
}
|
104
|
+
return layer.open($.extend({
|
105
|
+
content: content,
|
106
|
+
btn: ready.btn,
|
107
|
+
yes: yes,
|
108
|
+
cancel: cancel
|
109
|
+
}, type ? {} : options));
|
110
|
+
},
|
111
|
+
|
112
|
+
msg: function(content, options, end){ //最常用提示层
|
113
|
+
var type = typeof options === 'function', rskin = ready.config.skin;
|
114
|
+
var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg';
|
115
|
+
var shift = doms.anim.length - 1;
|
116
|
+
if(type) end = options;
|
117
|
+
return layer.open($.extend({
|
118
|
+
content: content,
|
119
|
+
time: 3000,
|
120
|
+
shade: false,
|
121
|
+
skin: skin,
|
122
|
+
title: false,
|
123
|
+
closeBtn: false,
|
124
|
+
btn: false,
|
125
|
+
end: end
|
126
|
+
}, (type && !ready.config.skin) ? {
|
127
|
+
skin: skin + ' layui-layer-hui',
|
128
|
+
shift: shift
|
129
|
+
} : function(){
|
130
|
+
options = options || {};
|
131
|
+
if(options.icon === -1 || options.icon === undefined && !ready.config.skin){
|
132
|
+
options.skin = skin + ' ' + (options.skin||'layui-layer-hui');
|
133
|
+
}
|
134
|
+
return options;
|
135
|
+
}()));
|
136
|
+
},
|
137
|
+
|
138
|
+
load: function(icon, options){
|
139
|
+
return layer.open($.extend({
|
140
|
+
type: 3,
|
141
|
+
icon: icon || 0,
|
142
|
+
shade: 0.01
|
143
|
+
}, options));
|
144
|
+
},
|
145
|
+
|
146
|
+
tips: function(content, follow, options){
|
147
|
+
return layer.open($.extend({
|
148
|
+
type: 4,
|
149
|
+
content: [content, follow],
|
150
|
+
closeBtn: false,
|
151
|
+
time: 3000,
|
152
|
+
maxWidth: 210
|
153
|
+
}, options));
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
var Class = function(setings){
|
158
|
+
var that = this;
|
159
|
+
that.index = ++layer.index;
|
160
|
+
that.config = $.extend({}, that.config, ready.config, setings);
|
161
|
+
that.creat();
|
162
|
+
};
|
163
|
+
|
164
|
+
Class.pt = Class.prototype;
|
165
|
+
|
166
|
+
//缓存常用字符
|
167
|
+
var doms = ['layui-layer', '.layui-layer-title', '.layui-layer-main', '.layui-layer-dialog', 'layui-layer-iframe', 'layui-layer-content', 'layui-layer-btn', 'layui-layer-close'];
|
168
|
+
doms.anim = ['layui-anim', 'layui-anim-01', 'layui-anim-02', 'layui-anim-03', 'layui-anim-04', 'layui-anim-05', 'layui-anim-06'];
|
169
|
+
|
170
|
+
//默认配置
|
171
|
+
Class.pt.config = {
|
172
|
+
type: 0,
|
173
|
+
shade: 0.3,
|
174
|
+
fix: true,
|
175
|
+
move: doms[1],
|
176
|
+
title: '信息',
|
177
|
+
offset: 'auto',
|
178
|
+
area: 'auto',
|
179
|
+
closeBtn: 1,
|
180
|
+
time: 0, //0表示不自动关闭
|
181
|
+
zIndex: 19891014,
|
182
|
+
maxWidth: 360,
|
183
|
+
shift: 0,
|
184
|
+
icon: -1,
|
185
|
+
scrollbar: true, //是否允许浏览器滚动条
|
186
|
+
tips: 2
|
187
|
+
};
|
188
|
+
|
189
|
+
//容器
|
190
|
+
Class.pt.vessel = function(conType, callback){
|
191
|
+
var that = this, times = that.index, config = that.config;
|
192
|
+
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
193
|
+
var ismax = config.maxmin && (config.type === 1 || config.type === 2);
|
194
|
+
var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">'
|
195
|
+
+ (titype ? config.title[0] : config.title)
|
196
|
+
+ '</div>' : '');
|
197
|
+
|
198
|
+
config.zIndex = zIndex;
|
199
|
+
callback([
|
200
|
+
//遮罩
|
201
|
+
config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '',
|
202
|
+
|
203
|
+
//主体
|
204
|
+
'<div class="'+ doms[0] +' '+ (doms.anim[config.shift]||'') + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fix ? '' : ';position:absolute;') +'">'
|
205
|
+
+ (conType && config.type != 2 ? '' : titleHTML)
|
206
|
+
+'<div class="layui-layer-content'+ ((config.type == 0 && config.icon !== -1) ? ' layui-layer-padding' :'') + (config.type == 3 ? ' layui-layer-loading'+config.icon : '') +'">'
|
207
|
+
+ (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico'+ config.icon +'"></i>' : '')
|
208
|
+
+ (config.type == 1 && conType ? '' : (config.content||''))
|
209
|
+
+'</div>'
|
210
|
+
+ '<span class="layui-layer-setwin">'+ function(){
|
211
|
+
var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : '';
|
212
|
+
config.closeBtn && (closebtn += '<a class="layui-layer-ico '+ doms[7] +' '+ doms[7] + (config.title ? config.closeBtn : (config.type == 4 ? '1' : '2')) +'" href="javascript:;"></a>');
|
213
|
+
return closebtn;
|
214
|
+
}() + '</span>'
|
215
|
+
+ (config.btn ? function(){
|
216
|
+
var button = '';
|
217
|
+
typeof config.btn === 'string' && (config.btn = [config.btn]);
|
218
|
+
for(var i = 0, len = config.btn.length; i < len; i++){
|
219
|
+
button += '<a class="'+ doms[6] +''+ i +'">'+ config.btn[i] +'</a>'
|
220
|
+
}
|
221
|
+
return '<div class="'+ doms[6] +'">'+ button +'</div>'
|
222
|
+
}() : '')
|
223
|
+
+'</div>'
|
224
|
+
], titleHTML);
|
225
|
+
return that;
|
226
|
+
};
|
227
|
+
|
228
|
+
//创建骨架
|
229
|
+
Class.pt.creat = function(){
|
230
|
+
var that = this, config = that.config, times = that.index, nodeIndex;
|
231
|
+
var content = config.content, conType = typeof content === 'object';
|
232
|
+
|
233
|
+
if(typeof config.area === 'string'){
|
234
|
+
config.area = config.area === 'auto' ? ['', ''] : [config.area, ''];
|
235
|
+
}
|
236
|
+
|
237
|
+
switch(config.type){
|
238
|
+
case 0:
|
239
|
+
config.btn = ('btn' in config) ? config.btn : ready.btn[0];
|
240
|
+
layer.closeAll('dialog');
|
241
|
+
break;
|
242
|
+
case 2:
|
243
|
+
var content = config.content = conType ? config.content : [config.content||'http://sentsin.com?from=layer', 'auto'];
|
244
|
+
config.content = '<iframe scrolling="'+ (config.content[1]||'auto') +'" allowtransparency="true" id="'+ doms[4] +''+ times +'" name="'+ doms[4] +''+ times +'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + config.content[0] + '"></iframe>';
|
245
|
+
break;
|
246
|
+
case 3:
|
247
|
+
config.title = false;
|
248
|
+
config.closeBtn = false;
|
249
|
+
config.icon === -1 && (config.icon === 0);
|
250
|
+
layer.closeAll('loading');
|
251
|
+
break;
|
252
|
+
case 4:
|
253
|
+
conType || (config.content = [config.content, 'body']);
|
254
|
+
config.follow = config.content[1];
|
255
|
+
config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>';
|
256
|
+
config.title = false;
|
257
|
+
config.shade = false;
|
258
|
+
config.fix = false;
|
259
|
+
config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true];
|
260
|
+
config.tipsMore || layer.closeAll('tips');
|
261
|
+
break;
|
262
|
+
}
|
263
|
+
|
264
|
+
//建立容器
|
265
|
+
that.vessel(conType, function(html, titleHTML){
|
266
|
+
$('body').append(html[0]);
|
267
|
+
conType ? function(){
|
268
|
+
(config.type == 2 || config.type == 4) ? function(){
|
269
|
+
$('body').append(html[1]);
|
270
|
+
}() : function(){
|
271
|
+
if(!content.parents('.'+doms[0])[0]){
|
272
|
+
content.show().addClass('layui-layer-wrap').wrap(html[1]);
|
273
|
+
$('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML);
|
274
|
+
}
|
275
|
+
}();
|
276
|
+
}() : $('body').append(html[1]);
|
277
|
+
that.layero = $('#'+ doms[0] + times);
|
278
|
+
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
279
|
+
}).auto(times);
|
280
|
+
|
281
|
+
config.type == 2 && layer.ie6 && that.layero.find('iframe').attr('src', content[0]);
|
282
|
+
$(document).off('keydown', ready.enter).on('keydown', ready.enter);
|
283
|
+
|
284
|
+
//坐标自适应浏览器窗口尺寸
|
285
|
+
config.type == 4 ? that.tips() : that.offset();
|
286
|
+
if(config.fix){
|
287
|
+
win.on('resize', function(){
|
288
|
+
that.offset();
|
289
|
+
(/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times);
|
290
|
+
config.type == 4 && that.tips();
|
291
|
+
});
|
292
|
+
}
|
293
|
+
|
294
|
+
config.time <= 0 || setTimeout(function(){
|
295
|
+
layer.close(that.index)
|
296
|
+
}, config.time);
|
297
|
+
that.move().callback();
|
298
|
+
};
|
299
|
+
|
300
|
+
//自适应
|
301
|
+
Class.pt.auto = function(index){
|
302
|
+
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
303
|
+
if(config.area[0] === '' && config.maxWidth > 0){
|
304
|
+
//为了修复IE7下一个让人难以理解的bug
|
305
|
+
if(/MSIE 7/.test(navigator.userAgent) && config.btn){
|
306
|
+
layero.width(layero.innerWidth());
|
307
|
+
}
|
308
|
+
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
309
|
+
}
|
310
|
+
var area = [layero.innerWidth(), layero.innerHeight()];
|
311
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
312
|
+
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
313
|
+
function setHeight(elem){
|
314
|
+
elem = layero.find(elem);
|
315
|
+
elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0));
|
316
|
+
}
|
317
|
+
switch(config.type){
|
318
|
+
case 2:
|
319
|
+
setHeight('iframe');
|
320
|
+
break;
|
321
|
+
default:
|
322
|
+
if(config.area[1] === ''){
|
323
|
+
if(config.fix && area[1] >= win.height()){
|
324
|
+
area[1] = win.height();
|
325
|
+
setHeight('.'+doms[5]);
|
326
|
+
}
|
327
|
+
} else {
|
328
|
+
setHeight('.'+doms[5]);
|
329
|
+
}
|
330
|
+
break;
|
331
|
+
}
|
332
|
+
return that;
|
333
|
+
};
|
334
|
+
|
335
|
+
//计算坐标
|
336
|
+
Class.pt.offset = function(){
|
337
|
+
var that = this, config = that.config, layero = that.layero;
|
338
|
+
var area = [layero.outerWidth(), layero.outerHeight()];
|
339
|
+
var type = typeof config.offset === 'object';
|
340
|
+
that.offsetTop = (win.height() - area[1])/2;
|
341
|
+
that.offsetLeft = (win.width() - area[0])/2;
|
342
|
+
if(type){
|
343
|
+
that.offsetTop = config.offset[0];
|
344
|
+
that.offsetLeft = config.offset[1]||that.offsetLeft;
|
345
|
+
} else if(config.offset !== 'auto'){
|
346
|
+
that.offsetTop = config.offset;
|
347
|
+
if(config.offset === 'rb'){ //右下角
|
348
|
+
that.offsetTop = win.height() - area[1];
|
349
|
+
that.offsetLeft = win.width() - area[0];
|
350
|
+
}
|
351
|
+
}
|
352
|
+
if(!config.fix){
|
353
|
+
that.offsetTop = /%$/.test(that.offsetTop) ?
|
354
|
+
win.height()*parseFloat(that.offsetTop)/100
|
355
|
+
: parseFloat(that.offsetTop);
|
356
|
+
that.offsetLeft = /%$/.test(that.offsetLeft) ?
|
357
|
+
win.width()*parseFloat(that.offsetLeft)/100
|
358
|
+
: parseFloat(that.offsetLeft);
|
359
|
+
that.offsetTop += win.scrollTop();
|
360
|
+
that.offsetLeft += win.scrollLeft();
|
361
|
+
}
|
362
|
+
layero.css({top: that.offsetTop, left: that.offsetLeft});
|
363
|
+
};
|
364
|
+
|
365
|
+
//Tips
|
366
|
+
Class.pt.tips = function(){
|
367
|
+
var that = this, config = that.config, layero = that.layero;
|
368
|
+
var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow);
|
369
|
+
if(!follow[0]) follow = $('body');
|
370
|
+
var goal = {
|
371
|
+
width: follow.outerWidth(),
|
372
|
+
height: follow.outerHeight(),
|
373
|
+
top: follow.offset().top,
|
374
|
+
left: follow.offset().left
|
375
|
+
}, tipsG = layero.find('.layui-layer-TipsG');
|
376
|
+
|
377
|
+
var guide = config.tips[0];
|
378
|
+
config.tips[1] || tipsG.remove();
|
379
|
+
|
380
|
+
goal.autoLeft = function(){
|
381
|
+
if(goal.left + layArea[0] - win.width() > 0){
|
382
|
+
goal.tipLeft = goal.left + goal.width - layArea[0];
|
383
|
+
tipsG.css({right: 12, left: 'auto'});
|
384
|
+
} else {
|
385
|
+
goal.tipLeft = goal.left;
|
386
|
+
};
|
387
|
+
};
|
388
|
+
|
389
|
+
//辨别tips的方位
|
390
|
+
goal.where = [function(){ //上
|
391
|
+
goal.autoLeft();
|
392
|
+
goal.tipTop = goal.top - layArea[1] - 10;
|
393
|
+
tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]);
|
394
|
+
}, function(){ //右
|
395
|
+
goal.tipLeft = goal.left + goal.width + 10;
|
396
|
+
goal.tipTop = goal.top;
|
397
|
+
tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]);
|
398
|
+
}, function(){ //下
|
399
|
+
goal.autoLeft();
|
400
|
+
goal.tipTop = goal.top + goal.height + 10;
|
401
|
+
tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]);
|
402
|
+
}, function(){ //左
|
403
|
+
goal.tipLeft = goal.left - layArea[0] - 10;
|
404
|
+
goal.tipTop = goal.top;
|
405
|
+
tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]);
|
406
|
+
}];
|
407
|
+
goal.where[guide-1]();
|
408
|
+
|
409
|
+
/* 8*2为小三角形占据的空间 */
|
410
|
+
if(guide === 1){
|
411
|
+
goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2]();
|
412
|
+
} else if(guide === 2){
|
413
|
+
win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]()
|
414
|
+
} else if(guide === 3){
|
415
|
+
(goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0]();
|
416
|
+
} else if(guide === 4){
|
417
|
+
layArea[0] + 8*2 - goal.left > 0 && goal.where[1]()
|
418
|
+
}
|
419
|
+
|
420
|
+
layero.find('.'+doms[5]).css({
|
421
|
+
'background-color': config.tips[1],
|
422
|
+
'padding-right': (config.closeBtn ? '30px' : '')
|
423
|
+
});
|
424
|
+
layero.css({left: goal.tipLeft, top: goal.tipTop});
|
425
|
+
}
|
426
|
+
|
427
|
+
//拖拽层
|
428
|
+
Class.pt.move = function(){
|
429
|
+
var that = this, config = that.config, conf = {
|
430
|
+
setY: 0,
|
431
|
+
moveLayer: function(){
|
432
|
+
var layero = conf.layero, mgleft = parseInt(layero.css('margin-left'));
|
433
|
+
var lefts = parseInt(conf.move.css('left'));
|
434
|
+
mgleft === 0 || (lefts = lefts - mgleft);
|
435
|
+
if(layero.css('position') !== 'fixed'){
|
436
|
+
lefts = lefts - layero.parent().offset().left;
|
437
|
+
conf.setY = 0;
|
438
|
+
}
|
439
|
+
layero.css({left: lefts, top: parseInt(conf.move.css('top')) - conf.setY});
|
440
|
+
}
|
441
|
+
};
|
442
|
+
|
443
|
+
var movedom = that.layero.find(config.move);
|
444
|
+
config.move && movedom.attr('move', 'ok');
|
445
|
+
movedom.css({cursor: config.move ? 'move' : 'auto'});
|
446
|
+
|
447
|
+
$(config.move).on('mousedown', function(M){
|
448
|
+
M.preventDefault();
|
449
|
+
if($(this).attr('move') === 'ok'){
|
450
|
+
conf.ismove = true;
|
451
|
+
conf.layero = $(this).parents('.'+ doms[0]);
|
452
|
+
var xx = conf.layero.offset().left, yy = conf.layero.offset().top, ww = conf.layero.outerWidth() - 6, hh = conf.layero.outerHeight() - 6;
|
453
|
+
if(!$('#layui-layer-moves')[0]){
|
454
|
+
$('body').append('<div id="layui-layer-moves" class="layui-layer-moves" style="left:'+ xx +'px; top:'+ yy +'px; width:'+ ww +'px; height:'+ hh +'px; z-index:2147483584"></div>');
|
455
|
+
}
|
456
|
+
conf.move = $('#layui-layer-moves');
|
457
|
+
config.moveType && conf.move.css({visibility: 'hidden'});
|
458
|
+
|
459
|
+
conf.moveX = M.pageX - conf.move.position().left;
|
460
|
+
conf.moveY = M.pageY - conf.move.position().top;
|
461
|
+
conf.layero.css('position') !== 'fixed' || (conf.setY = win.scrollTop());
|
462
|
+
}
|
463
|
+
});
|
464
|
+
|
465
|
+
$(document).mousemove(function(M){
|
466
|
+
if(conf.ismove){
|
467
|
+
var offsetX = M.pageX - conf.moveX, offsetY = M.pageY - conf.moveY;
|
468
|
+
M.preventDefault();
|
469
|
+
|
470
|
+
//控制元素不被拖出窗口外
|
471
|
+
if(!config.moveOut){
|
472
|
+
conf.setY = win.scrollTop();
|
473
|
+
var setRig = win.width() - conf.move.outerWidth(), setTop = conf.setY;
|
474
|
+
offsetX < 0 && (offsetX = 0);
|
475
|
+
offsetX > setRig && (offsetX = setRig);
|
476
|
+
offsetY < setTop && (offsetY = setTop);
|
477
|
+
offsetY > win.height() - conf.move.outerHeight() + conf.setY && (offsetY = win.height() - conf.move.outerHeight() + conf.setY);
|
478
|
+
}
|
479
|
+
|
480
|
+
conf.move.css({left: offsetX, top: offsetY});
|
481
|
+
config.moveType && conf.moveLayer();
|
482
|
+
|
483
|
+
offsetX = offsetY = setRig = setTop = null;
|
484
|
+
}
|
485
|
+
}).mouseup(function(){
|
486
|
+
try{
|
487
|
+
if(conf.ismove){
|
488
|
+
conf.moveLayer();
|
489
|
+
conf.move.remove();
|
490
|
+
config.moveEnd && config.moveEnd();
|
491
|
+
}
|
492
|
+
conf.ismove = false;
|
493
|
+
}catch(e){
|
494
|
+
conf.ismove = false;
|
495
|
+
}
|
496
|
+
});
|
497
|
+
return that;
|
498
|
+
};
|
499
|
+
|
500
|
+
Class.pt.callback = function(){
|
501
|
+
var that = this, layero = that.layero, config = that.config;
|
502
|
+
that.openLayer();
|
503
|
+
if(config.success){
|
504
|
+
if(config.type == 2){
|
505
|
+
layero.find('iframe')[0].onload = function(){
|
506
|
+
this.className = '';
|
507
|
+
config.success(layero, that.index);
|
508
|
+
};
|
509
|
+
} else {
|
510
|
+
config.success(layero, that.index);
|
511
|
+
}
|
512
|
+
}
|
513
|
+
layer.ie6 && that.IE6(layero);
|
514
|
+
|
515
|
+
//按钮
|
516
|
+
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
517
|
+
var index = $(this).index();
|
518
|
+
config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero);
|
519
|
+
if(index === 0){
|
520
|
+
config.yes ? config.yes(that.index, layero) : layer.close(that.index);
|
521
|
+
} else if(index === 1){
|
522
|
+
cancel();
|
523
|
+
} else {
|
524
|
+
config['btn'+(index+1)] || layer.close(that.index);
|
525
|
+
}
|
526
|
+
});
|
527
|
+
|
528
|
+
//取消
|
529
|
+
function cancel(){
|
530
|
+
var close = config.cancel && config.cancel(that.index);
|
531
|
+
close === false || layer.close(that.index);
|
532
|
+
}
|
533
|
+
|
534
|
+
//右上角关闭回调
|
535
|
+
layero.find('.'+ doms[7]).on('click', cancel);
|
536
|
+
|
537
|
+
//点遮罩关闭
|
538
|
+
if(config.shadeClose){
|
539
|
+
$('#layui-layer-shade'+ that.index).on('click', function(){
|
540
|
+
layer.close(that.index);
|
541
|
+
});
|
542
|
+
}
|
543
|
+
|
544
|
+
//最小化
|
545
|
+
layero.find('.layui-layer-min').on('click', function(){
|
546
|
+
layer.min(that.index, config);
|
547
|
+
config.min && config.min(layero);
|
548
|
+
});
|
549
|
+
|
550
|
+
//全屏/还原
|
551
|
+
layero.find('.layui-layer-max').on('click', function(){
|
552
|
+
if($(this).hasClass('layui-layer-maxmin')){
|
553
|
+
layer.restore(that.index);
|
554
|
+
config.restore && config.restore(layero);
|
555
|
+
} else {
|
556
|
+
layer.full(that.index, config);
|
557
|
+
config.full && config.full(layero);
|
558
|
+
}
|
559
|
+
});
|
560
|
+
|
561
|
+
config.end && (ready.end[that.index] = config.end);
|
562
|
+
};
|
563
|
+
|
564
|
+
//for ie6 恢复select
|
565
|
+
ready.reselect = function(){
|
566
|
+
$.each($('select'), function(index , value){
|
567
|
+
var sthis = $(this);
|
568
|
+
if(!sthis.parents('.'+doms[0])[0]){
|
569
|
+
(sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show();
|
570
|
+
}
|
571
|
+
sthis = null;
|
572
|
+
});
|
573
|
+
};
|
574
|
+
|
575
|
+
Class.pt.IE6 = function(layero){
|
576
|
+
var that = this, _ieTop = layero.offset().top;
|
577
|
+
|
578
|
+
//ie6的固定与相对定位
|
579
|
+
function ie6Fix(){
|
580
|
+
layero.css({top : _ieTop + (that.config.fix ? win.scrollTop() : 0)});
|
581
|
+
};
|
582
|
+
ie6Fix();
|
583
|
+
win.scroll(ie6Fix);
|
584
|
+
|
585
|
+
//隐藏select
|
586
|
+
$('select').each(function(index , value){
|
587
|
+
var sthis = $(this);
|
588
|
+
if(!sthis.parents('.'+doms[0])[0]){
|
589
|
+
sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide();
|
590
|
+
}
|
591
|
+
sthis = null;
|
592
|
+
});
|
593
|
+
};
|
594
|
+
|
595
|
+
//需依赖原型的对外方法
|
596
|
+
Class.pt.openLayer = function(){
|
597
|
+
var that = this;
|
598
|
+
|
599
|
+
//置顶当前窗口
|
600
|
+
layer.zIndex = that.config.zIndex;
|
601
|
+
layer.setTop = function(layero){
|
602
|
+
var setZindex = function(){
|
603
|
+
layer.zIndex++;
|
604
|
+
layero.css('z-index', layer.zIndex + 1);
|
605
|
+
};
|
606
|
+
layer.zIndex = parseInt(layero[0].style.zIndex);
|
607
|
+
layero.on('mousedown', setZindex);
|
608
|
+
return layer.zIndex;
|
609
|
+
};
|
610
|
+
};
|
611
|
+
|
612
|
+
ready.record = function(layero){
|
613
|
+
var area = [
|
614
|
+
layero.outerWidth(),
|
615
|
+
layero.outerHeight(),
|
616
|
+
layero.position().top,
|
617
|
+
layero.position().left + parseFloat(layero.css('margin-left'))
|
618
|
+
];
|
619
|
+
layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
|
620
|
+
layero.attr({area: area});
|
621
|
+
};
|
622
|
+
|
623
|
+
ready.rescollbar = function(index){
|
624
|
+
if(doms.html.attr('layer-full') == index){
|
625
|
+
if(doms.html[0].style.removeProperty){
|
626
|
+
doms.html[0].style.removeProperty('overflow');
|
627
|
+
} else {
|
628
|
+
doms.html[0].style.removeAttribute('overflow');
|
629
|
+
}
|
630
|
+
doms.html.removeAttr('layer-full');
|
631
|
+
}
|
632
|
+
};
|
633
|
+
|
634
|
+
/*! 内置成员 */
|
635
|
+
|
636
|
+
//获取子iframe的DOM
|
637
|
+
layer.getChildFrame = function(selector, index){
|
638
|
+
index = index || $('.'+doms[4]).attr('times');
|
639
|
+
return $('#'+ doms[0] + index).find('iframe').contents().find(selector);
|
640
|
+
};
|
641
|
+
|
642
|
+
//得到当前iframe层的索引,子iframe时使用
|
643
|
+
layer.getFrameIndex = function(name){
|
644
|
+
return $('#'+ name).parents('.'+doms[4]).attr('times');
|
645
|
+
};
|
646
|
+
|
647
|
+
//iframe层自适应宽高
|
648
|
+
layer.iframeAuto = function(index){
|
649
|
+
if(!index) return;
|
650
|
+
var heg = layer.getChildFrame('body', index).outerHeight();
|
651
|
+
var layero = $('#'+ doms[0] + index);
|
652
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
653
|
+
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
654
|
+
layero.css({height: heg + titHeight + btnHeight});
|
655
|
+
layero.find('iframe').css({height: heg});
|
656
|
+
};
|
657
|
+
|
658
|
+
//重置iframe url
|
659
|
+
layer.iframeSrc = function(index, url){
|
660
|
+
$('#'+ doms[0] + index).find('iframe').attr('src', url);
|
661
|
+
};
|
662
|
+
|
663
|
+
//设定层的样式
|
664
|
+
layer.style = function(index, options){
|
665
|
+
var layero = $('#'+ doms[0] + index), type = layero.attr('type');
|
666
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
667
|
+
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
668
|
+
if(type === ready.type[1] || type === ready.type[2]){
|
669
|
+
layero.css(options);
|
670
|
+
if(type === ready.type[2]){
|
671
|
+
layero.find('iframe').css({
|
672
|
+
height: parseFloat(options.height) - titHeight - btnHeight
|
673
|
+
});
|
674
|
+
}
|
675
|
+
}
|
676
|
+
};
|
677
|
+
|
678
|
+
//最小化
|
679
|
+
layer.min = function(index, options){
|
680
|
+
var layero = $('#'+ doms[0] + index);
|
681
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
682
|
+
ready.record(layero);
|
683
|
+
layer.style(index, {width: 180, height: titHeight, overflow: 'hidden'});
|
684
|
+
layero.find('.layui-layer-min').hide();
|
685
|
+
layero.attr('type') === 'page' && layero.find(doms[4]).hide();
|
686
|
+
ready.rescollbar(index);
|
687
|
+
};
|
688
|
+
|
689
|
+
//还原
|
690
|
+
layer.restore = function(index){
|
691
|
+
var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(',');
|
692
|
+
var type = layero.attr('type');
|
693
|
+
layer.style(index, {
|
694
|
+
width: parseFloat(area[0]),
|
695
|
+
height: parseFloat(area[1]),
|
696
|
+
top: parseFloat(area[2]),
|
697
|
+
left: parseFloat(area[3]),
|
698
|
+
overflow: 'visible'
|
699
|
+
});
|
700
|
+
layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
|
701
|
+
layero.find('.layui-layer-min').show();
|
702
|
+
layero.attr('type') === 'page' && layero.find(doms[4]).show();
|
703
|
+
ready.rescollbar(index);
|
704
|
+
};
|
705
|
+
|
706
|
+
//全屏
|
707
|
+
layer.full = function(index){
|
708
|
+
var layero = $('#'+ doms[0] + index), timer;
|
709
|
+
ready.record(layero);
|
710
|
+
if(!doms.html.attr('layer-full')){
|
711
|
+
doms.html.css('overflow','hidden').attr('layer-full', index);
|
712
|
+
}
|
713
|
+
clearTimeout(timer);
|
714
|
+
timer = setTimeout(function(){
|
715
|
+
var isfix = layero.css('position') === 'fixed';
|
716
|
+
layer.style(index, {
|
717
|
+
top: isfix ? 0 : win.scrollTop(),
|
718
|
+
left: isfix ? 0 : win.scrollLeft(),
|
719
|
+
width: win.width(),
|
720
|
+
height: win.height()
|
721
|
+
});
|
722
|
+
layero.find('.layui-layer-min').hide();
|
723
|
+
}, 100);
|
724
|
+
};
|
725
|
+
|
726
|
+
//改变title
|
727
|
+
layer.title = function(name, index){
|
728
|
+
var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]);
|
729
|
+
title.html(name);
|
730
|
+
};
|
731
|
+
|
732
|
+
//关闭layer总方法
|
733
|
+
layer.close = function(index){
|
734
|
+
var layero = $('#'+ doms[0] + index), type = layero.attr('type');
|
735
|
+
if(!layero[0]) return;
|
736
|
+
if(type === ready.type[1] && layero.attr('conType') === 'object'){
|
737
|
+
layero.children(':not(.'+ doms[5] +')').remove();
|
738
|
+
for(var i = 0; i < 2; i++){
|
739
|
+
layero.find('.layui-layer-wrap').unwrap().hide();
|
740
|
+
}
|
741
|
+
} else {
|
742
|
+
//低版本IE 回收 iframe
|
743
|
+
if(type === ready.type[2]){
|
744
|
+
try {
|
745
|
+
var iframe = $('#'+doms[4]+index)[0];
|
746
|
+
iframe.contentWindow.document.write('');
|
747
|
+
iframe.contentWindow.close();
|
748
|
+
layero.find('.'+doms[5])[0].removeChild(iframe);
|
749
|
+
} catch(e){}
|
750
|
+
}
|
751
|
+
layero[0].innerHTML = '';
|
752
|
+
layero.remove();
|
753
|
+
}
|
754
|
+
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
|
755
|
+
layer.ie6 && ready.reselect();
|
756
|
+
ready.rescollbar(index);
|
757
|
+
$(document).off('keydown', ready.enter);
|
758
|
+
typeof ready.end[index] === 'function' && ready.end[index]();
|
759
|
+
delete ready.end[index];
|
760
|
+
};
|
761
|
+
|
762
|
+
//关闭所有层
|
763
|
+
layer.closeAll = function(type){
|
764
|
+
$.each($('.'+doms[0]), function(){
|
765
|
+
var othis = $(this);
|
766
|
+
var is = type ? (othis.attr('type') === type) : 1;
|
767
|
+
is && layer.close(othis.attr('times'));
|
768
|
+
is = null;
|
769
|
+
});
|
770
|
+
};
|
771
|
+
|
772
|
+
//主入口
|
773
|
+
ready.run = function(){
|
774
|
+
$ = jQuery;
|
775
|
+
win = $(window);
|
776
|
+
doms.html = $('html');
|
777
|
+
layer.open = function(deliver){
|
778
|
+
var o = new Class(deliver);
|
779
|
+
return o.index;
|
780
|
+
};
|
781
|
+
};
|
782
|
+
|
783
|
+
'function' === typeof define ? define(function(){
|
784
|
+
ready.run();
|
785
|
+
return layer;
|
786
|
+
}) : function(){
|
787
|
+
window.layer = layer;
|
788
|
+
ready.run();
|
789
|
+
//layer.use('layer.css');
|
790
|
+
}();
|
791
|
+
|
792
|
+
}(window);
|