pull/8/head
sentsin 2015-04-29 00:39:13 +08:00
parent 5bfc1ec84b
commit eb7433363d
19 changed files with 43 additions and 26 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/*! /*!
@Namelayer v1.9.0 弹层组件 @Namelayer v1.9.1 弹层组件
@Author贤心 @Author贤心
@Sitehttp://sentsin.com/jquery/layer @Sitehttp://sentsin.com/jquery/layer
@LicenseLGPL @LicenseLGPL
@ -12,7 +12,8 @@
var $, win, ready = { var $, win, ready = {
getPath: function(){ getPath: function(){
var js = document.scripts, jsPath = js[js.length - 1].src; var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
if(script.getAttribute('merge')) return;
return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); return jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
}(), }(),
config: {}, end: {}, config: {}, end: {},
@ -24,7 +25,7 @@ var $, win, ready = {
//默认内置方法。 //默认内置方法。
window.layer = { window.layer = {
v: '1.9.0', v: '1.9.1',
ie6: !!window.ActiveXObject&&!window.XMLHttpRequest, ie6: !!window.ActiveXObject&&!window.XMLHttpRequest,
index: 0, index: 0,
path: ready.getPath, path: ready.getPath,
@ -51,6 +52,7 @@ window.layer = {
var iscss = /\.css$/.test(module); var iscss = /\.css$/.test(module);
var node = document.createElement(iscss ? 'link' : 'script'); var node = document.createElement(iscss ? 'link' : 'script');
var id = 'layui_layer_' + module.replace(/\.|\//g, ''); var id = 'layui_layer_' + module.replace(/\.|\//g, '');
if(!layer.path) return;
if(iscss){ if(iscss){
node.rel = 'stylesheet'; node.rel = 'stylesheet';
} }
@ -149,7 +151,7 @@ window.layer = {
var Class = function(setings){ var Class = function(setings){
var that = this; var that = this;
that.index = ++layer.index; that.index = ++layer.index;
that.config = $.extend({}, that.config, setings, ready.config); that.config = $.extend({}, that.config, ready.config, setings);
that.creat(); that.creat();
}; };
@ -182,7 +184,7 @@ 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) && (!/^\d+%$/.test(config.area[0]) || !/^\d+%$/.test(config.area[1])); var ismax = config.maxmin && (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>' : '');
@ -332,7 +334,7 @@ Class.pt.offset = function(){
that.offsetLeft = (win.width() - area[0])/2; that.offsetLeft = (win.width() - area[0])/2;
if(type){ if(type){
that.offsetTop = config.offset[0]; that.offsetTop = config.offset[0];
that.offsetLeft = config.offset[1]; that.offsetLeft = config.offset[1]||that.offsetLeft;
} else if(config.offset !== 'auto'){ } else if(config.offset !== 'auto'){
that.offsetTop = config.offset; that.offsetTop = config.offset;
if(config.offset === 'rb'){ //右下角 if(config.offset === 'rb'){ //右下角
@ -341,6 +343,12 @@ Class.pt.offset = function(){
} }
} }
if(!config.fix){ if(!config.fix){
that.offsetTop = /%$/.test(that.offsetTop) ?
win.height()*parseFloat(that.offsetTop)/100
: parseFloat(that.offsetTop);
that.offsetLeft = /%$/.test(that.offsetLeft) ?
win.width()*parseFloat(that.offsetLeft)/100
: parseFloat(that.offsetLeft);
that.offsetTop += win.scrollTop(); that.offsetTop += win.scrollTop();
that.offsetLeft += win.scrollLeft(); that.offsetLeft += win.scrollLeft();
} }
@ -497,16 +505,26 @@ Class.pt.callback = function(){
} }
layer.ie6 && that.IE6(layero); layer.ie6 && that.IE6(layero);
//确认 //按钮
layero.find('.'+ doms[6] +'0').on('click',function(){ layero.find('.'+ doms[6]).children('a').on('click', function(){
config.yes ? config.yes(that.index) : layer.close(that.index); var index = $(this).index();
if(index === 0){
config.yes ? config.yes(that.index, layero) : layer.close(that.index);
} else if(index === 1){
cancel();
} else {
config['btn'+(index+1)] ? config['btn'+(index+1)](that.index, layero) : layer.close(that.index);
}
}); });
//取消 //取消
layero.find('.'+ doms[7] +',.'+ doms[6] +'1').on('click', function(){ function cancel(){
config.cancel && config.cancel(that.index); var close = config.cancel && config.cancel(that.index);
layer.close(that.index); close === false || layer.close(that.index);
}); }
//右上角关闭回调
layero.find('.'+ doms[7]).on('click', cancel);
//点遮罩关闭 //点遮罩关闭
if(config.shadeClose){ if(config.shadeClose){
@ -654,7 +672,7 @@ layer.min = function(index, options){
var layero = $('#'+ doms[0] + index); var layero = $('#'+ doms[0] + index);
var titHeight = layero.find(doms[1]).outerHeight() || 0; var titHeight = layero.find(doms[1]).outerHeight() || 0;
ready.record(layero); ready.record(layero);
layer.style(index, {width: 180, height: titHeight}); layer.style(index, {width: 180, height: titHeight, overflow: 'hidden'});
layero.find('.layui-layer-min').hide(); layero.find('.layui-layer-min').hide();
layero.attr('type') === 'page' && layero.find(doms[4]).hide(); layero.attr('type') === 'page' && layero.find(doms[4]).hide();
ready.rescollbar(index); ready.rescollbar(index);
@ -668,7 +686,8 @@ layer.restore = function(index){
width: parseFloat(area[0]), width: parseFloat(area[0]),
height: parseFloat(area[1]), height: parseFloat(area[1]),
top: parseFloat(area[2]), top: parseFloat(area[2]),
left: parseFloat(area[3]) left: parseFloat(area[3]),
overflow: 'visible'
}); });
layero.find('.layui-layer-max').removeClass('layui-layer-maxmin'); layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
layero.find('.layui-layer-min').show(); layero.find('.layui-layer-min').show();
@ -736,9 +755,7 @@ layer.closeAll = function(type){
$.each($('.'+doms[0]), function(){ $.each($('.'+doms[0]), function(){
var othis = $(this); var othis = $(this);
var is = type ? (othis.attr('type') === type) : 1; var is = type ? (othis.attr('type') === type) : 1;
if(is){ is && layer.close(othis.attr('times'));
layer.close(othis.attr('times'));
}
is = null; is = null;
}); });
}; };

View File

@ -57,8 +57,8 @@ html #layui_layer_skinlayercss{display:none; position: absolute; width:1989px;}
/* 按钮栏 */ /* 按钮栏 */
.layui-layer-btn{text-align:center; padding:10px 30px; pointer-events: auto;} .layui-layer-btn{text-align:center; padding:10px 30px; pointer-events: auto;}
.layui-layer-btn a{height:30px; line-height:30px; margin:0 8px; padding:0 20px; background:#5FBFE7; color:#fff; font-size:14px; font-weight:bold; cursor:pointer;} .layui-layer-btn a{height:30px; line-height:30px; margin:0 8px; padding:0 20px; background:#5FBFE7; color:#fff; font-size:14px; font-weight:bold; cursor:pointer; text-decoration: none;}
.layui-layer-btn a:hover{opacity:0.9;} .layui-layer-btn a:hover{opacity:0.9; text-decoration: none;}
.layui-layer-btn a:active{opacity:0.7;} .layui-layer-btn a:active{opacity:0.7;}
.layui-layer-btn .layui-layer-btn1{background:#A6BBCE;} .layui-layer-btn .layui-layer-btn1{background:#A6BBCE;}
@ -112,8 +112,8 @@ html #layui_layer_skinlayercss{display:none; position: absolute; width:1989px;}
.layui-layer-lan .layui-layer-btn{border-top:1px solid #E9E7E7} .layui-layer-lan .layui-layer-btn{border-top:1px solid #E9E7E7}
.layui-layer-lan .layui-layer-btn a{background:#BBB5B5;} .layui-layer-lan .layui-layer-btn a{background:#BBB5B5;}
.layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;} .layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;}
.layui-layer-molv .layui-layer-title{background:#60B979; color:#fff; border: none;} .layui-layer-molv .layui-layer-title{background:#009f95; color:#fff; border: none;}
.layui-layer-molv .layui-layer-btn a{background:#659D94;} .layui-layer-molv .layui-layer-btn a{background:#009f95;}
.layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;} .layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -31,6 +31,6 @@ body .layer-ext-seaning .layui-layer-ico11{background:url(default.png) no-repeat
body .layer-ext-seaning .layui-layer-ico12{background:url(default.png) no-repeat -576px 0;} body .layer-ext-seaning .layui-layer-ico12{background:url(default.png) no-repeat -576px 0;}
body .layer-ext-seaning .layui-layer-ico13{background:url(default.png) no-repeat -624px 0;} body .layer-ext-seaning .layui-layer-ico13{background:url(default.png) no-repeat -624px 0;}
body .layer-ext-seaning .layui-layer-setwin .layui-layer-close1 {width: 14px; height: 14px; background:url(close.png) no-repeat;} body .layer-ext-seaning .layui-layer-setwin .layui-layer-close1 {width: 14px; height: 14px; background:url(close.png) no-repeat;}
body .layer-ext-seaning .layui-layer-content{border-bottom:1px #e9e9e9 solid;padding:30px;} body .layer-ext-seaning .layui-layer-btn{border-top:1px #e9e9e9 solid;}
body .layer-ext-seaning .layui-layer-padding{padding-top:28px;padding-left:74px;} body .layer-ext-seaning .layui-layer-padding{padding-top:28px;padding-left:74px;padding-bottom: 30px;}
body .layer-ext-seaning .layui-layer-btn{padding:5px 0;text-align:right;} body .layer-ext-seaning .layui-layer-btn{padding:5px 0;text-align:right;}