Skip to content

Commit

Permalink
添加两个功能项
Browse files Browse the repository at this point in the history
一,添加一个恢复到offset设置位置的方法layer.autoOffset(index);
主要是可以方便的进行居中或恢复到原来位置
二,更改配置项maxmin为max,min
用于选择是否需要同时显示max和min两个按钮
同时保留maxmin选项
  • Loading branch information
Feelop committed Jun 9, 2015
1 parent 935eed0 commit eaba17b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ Class.pt.config = {
Class.pt.vessel = function(conType, callback){
var that = this, times = that.index, config = that.config;
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] : '') +'">'
+ (titype ? config.title[0] : config.title)
+ '</div>' : '');
Expand All @@ -203,7 +204,9 @@ Class.pt.vessel = function(conType, callback){
+ (config.type == 1 && conType ? '' : (config.content||''))
+'</div>'
+ '<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>');
return closebtn;
}() + '</span>'
Expand Down Expand Up @@ -327,8 +330,8 @@ Class.pt.auto = function(index){
};

//计算坐标
Class.pt.offset = function(){
var that = this, config = that.config, layero = that.layero;
Class.pt.offset = function (times) {
var that = this, times = times || that.index, config = that.config, layero = $('#' + doms[0] + times);
var area = [layero.outerWidth(), layero.outerHeight()];
var type = typeof config.offset === 'object';
that.offsetTop = (win.height() - area[1])/2;
Expand Down Expand Up @@ -601,6 +604,9 @@ Class.pt.openLayer = function(){
layero.on('mousedown', setZindex);
return layer.zIndex;
};
layer.autoOffset = function (index) {
return that.offset(index);
};
};

ready.record = function(layero){
Expand Down Expand Up @@ -781,4 +787,4 @@ ready.run = function(){
layer.use('skin/layer.css');
}();

}(window);
}(window);

0 comments on commit eaba17b

Please sign in to comment.