mirror of https://github.com/layui/layer
添加两个功能项
一,添加一个恢复到offset设置位置的方法layer.autoOffset(index); 主要是可以方便的进行居中或恢复到原来位置 二,更改配置项maxmin为max,min 用于选择是否需要同时显示max和min两个按钮 同时保留maxmin选项pull/9/head
parent
935eed0344
commit
eaba17bf9e
16
src/layer.js
16
src/layer.js
|
@ -185,7 +185,8 @@ Class.pt.config = {
|
||||||
Class.pt.vessel = function(conType, callback){
|
Class.pt.vessel = function(conType, callback){
|
||||||
var that = this, times = that.index, config = that.config;
|
var that = this, times = that.index, config = that.config;
|
||||||
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
||||||
var ismax = config.maxmin && (config.type === 1 || config.type === 2);
|
var ismax = (config.maxmin || config.max) && (config.type === 1 || config.type === 2);
|
||||||
|
var ismin = (config.maxmin || config.min) && (config.type === 1 || config.type === 2);
|
||||||
var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">'
|
var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">'
|
||||||
+ (titype ? config.title[0] : config.title)
|
+ (titype ? config.title[0] : config.title)
|
||||||
+ '</div>' : '');
|
+ '</div>' : '');
|
||||||
|
@ -203,7 +204,9 @@ Class.pt.vessel = function(conType, callback){
|
||||||
+ (config.type == 1 && conType ? '' : (config.content||''))
|
+ (config.type == 1 && conType ? '' : (config.content||''))
|
||||||
+'</div>'
|
+'</div>'
|
||||||
+ '<span class="layui-layer-setwin">'+ function(){
|
+ '<span class="layui-layer-setwin">'+ function(){
|
||||||
var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : '';
|
var closebtn = '';
|
||||||
|
closebtn += ismin ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a>' : '';
|
||||||
|
closebtn += ismax ? '<a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : '';
|
||||||
config.closeBtn && (closebtn += '<a class="layui-layer-ico '+ doms[7] +' '+ doms[7] + (config.title ? config.closeBtn : (config.type == 4 ? '1' : '2')) +'" href="javascript:;"></a>');
|
config.closeBtn && (closebtn += '<a class="layui-layer-ico '+ doms[7] +' '+ doms[7] + (config.title ? config.closeBtn : (config.type == 4 ? '1' : '2')) +'" href="javascript:;"></a>');
|
||||||
return closebtn;
|
return closebtn;
|
||||||
}() + '</span>'
|
}() + '</span>'
|
||||||
|
@ -327,8 +330,8 @@ Class.pt.auto = function(index){
|
||||||
};
|
};
|
||||||
|
|
||||||
//计算坐标
|
//计算坐标
|
||||||
Class.pt.offset = function(){
|
Class.pt.offset = function (times) {
|
||||||
var that = this, config = that.config, layero = that.layero;
|
var that = this, times = times || that.index, config = that.config, layero = $('#' + doms[0] + times);
|
||||||
var area = [layero.outerWidth(), layero.outerHeight()];
|
var area = [layero.outerWidth(), layero.outerHeight()];
|
||||||
var type = typeof config.offset === 'object';
|
var type = typeof config.offset === 'object';
|
||||||
that.offsetTop = (win.height() - area[1])/2;
|
that.offsetTop = (win.height() - area[1])/2;
|
||||||
|
@ -601,6 +604,9 @@ Class.pt.openLayer = function(){
|
||||||
layero.on('mousedown', setZindex);
|
layero.on('mousedown', setZindex);
|
||||||
return layer.zIndex;
|
return layer.zIndex;
|
||||||
};
|
};
|
||||||
|
layer.autoOffset = function (index) {
|
||||||
|
return that.offset(index);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
ready.record = function(layero){
|
ready.record = function(layero){
|
||||||
|
@ -781,4 +787,4 @@ ready.run = function(){
|
||||||
layer.use('skin/layer.css');
|
layer.use('skin/layer.css');
|
||||||
}();
|
}();
|
||||||
|
|
||||||
}(window);
|
}(window);
|
||||||
|
|
Loading…
Reference in New Issue