/**************************************************************
@name: layer v1.7.0 弹层组件开发版
@author: 贤心
@date: 2013-12-16
@blog: http://sentsin.com
@微博:http://weibo.com/sentsinxu
@qq群:176047238(一群)、218604143(若一群已满,可加此群)
@copyright: sentsin xu(贤心)
@官网说明:http://sentsin.com/jquery/layer
@赞助layer: https://me.alipay.com/sentsin
*************************************************************/
;!function(window, undefined){
"use strict";
var pathtype = true, //是否采用自动获取绝对路径。false:将采用下述变量中的配置
pathurl = 'lily/lib/layer/', //上述变量为false才有效,当前layerjs所在目录(不用填写host,相对站点的根目录即可)。
$, win, ready = {
hosts: (function(){
var dk = location.href.match(/\:\d+/);
dk = dk ? dk[0] : '';
return 'http://' + document.domain + dk + '/';
}()),
getpath: function(){
var js = document.scripts || $('script'), jspath = js[js.length - 1].src;
if(pathtype){
return jspath.substring(0, jspath.lastindexof("/") + 1);
} else {
return this.hosts + pathurl;
}
}
};
//默认内置方法。
window.layer = {
v : '1.7.0', //版本号
ie6: !-[1,] && !window.xmlhttprequest,
index: 0,
path: ready.getpath(),
//载入模块
use: function(module, callback){
var i = 0, head = $('head')[0];
var module = module.replace(/\s/g, '');
var iscss = /\.css$/.test(module);
var node = document.createelement(iscss ? 'link' : 'script');
var id = module.replace(/\.|\//g, '');
if(iscss){
node.setattribute('type', 'text/css');
node.setattribute('rel', 'stylesheet');
}
node.setattribute((iscss ? 'href' : 'src'), layer.path + module);
node.setattribute('id', id);
if(!$('#'+ id)[0]){
head.appendchild(node);
}
$(node).ready(function(){
callback && callback();
});
},
ready: function(callback){
return layer.use('skin/layer.css', callback);
},
//普通对话框,类似系统默认的alert()
alert: function(alertmsg, alerttype, alerttit, alertyes){
return $.layer({
dialog : {msg : alertmsg, type : alerttype, yes : alertyes},
title : alerttit,
area: ['auto', 'auto']
});
},
//询问框,类似系统默认的confirm()
confirm: function(conmsg, conyes, contit, conno){
return $.layer({
dialog : {msg : conmsg, type : 4, btns : 2, yes : conyes, no : conno},
title : contit
});
},
//普通消息框,一般用于行为成功后的提醒,默认两秒自动关闭
msg: function(msgtext, msgtime, parme, callback){
var icon, conf = {title: false, closebtn: false};
(msgtext == '' || msgtext == undefined) && (msgtext = ' ');
msgtime === undefined && (msgtime = 2);
if(typeof parme === 'number'){
icon = parme;
} else {
parme = parme || {};
icon = parme.type;
conf.success = function(){layer.shift(parme.rate)};
conf.shade = parme.shade;
}
conf.time = msgtime;
conf.dialog = {msg: msgtext, type: icon};
conf.end = typeof parme === 'function' ? parme : callback;
return $.layer(conf);
},
//加载层快捷引用
load: function(parme, loadicon){
if(typeof parme === 'string'){
return this.msg(parme, 0, 16);
} else {
return $.layer({
time: parme,
loading: {type : loadicon},
bgcolor: !loadicon ? '' : '#fff',
shade: [0.1, '#000', !loadicon ? false : true],
border :[7,0.3, '#000', (loadicon === 3 || !loadicon) ? false : true],
type : 3,
title : ['',false],
closebtn : [0 , false]
});
}
},
//tips层快捷引用
tips: function(html, follow, parme, maxwidth, guide, style){
var conf = {type: 4, shade: false, success: function(layere){
if(!this.closebtn){
layere.find('.xubox_tips').css({'padding-right': 10});
}
}, bgcolor:'', tips:{msg: html, follow: follow}};
parme = parme || {};
conf.time = parme.time || parme;
conf.closebtn = parme.closebtn || false
conf.maxwidth = parme.maxwidth || maxwidth;
conf.tips.guide = parme.guide || guide;
conf.tips.style = parme.style || style;
return $.layer(conf);
}
};
var class = function(setings){
var config = this.config;
layer.index++;
this.index = layer.index;
this.config = $.extend({} , config , setings);
this.config.dialog = $.extend({}, config.dialog , setings.dialog);
this.config.page = $.extend({}, config.page , setings.page);
this.config.iframe = $.extend({}, config.iframe , setings.iframe);
this.config.loading = $.extend({}, config.loading , setings.loading);
this.config.tips = $.extend({}, config.tips , setings.tips);
this.creat();
};
class.pt = class.prototype;
//默认配置
class.pt.config = {
type: 0,
shade: [0.3 , '#000' , true],
shadeclose: false,
fix: true,
move: ['.xubox_title' , true],
moveout: false,
title: ['信息' , true],
offset: ['200px' , '50%'],
area: ['310px' , 'auto'],
closebtn: [0 , true],
time: 0,
bgcolor: '#fff',
border: [8 , 0.3 , '#000', true],
zindex: 19891014,
maxwidth: 400,
dialog: {btns : 1, btn : ['确定','取消'], type : 3, msg : '', yes : function(index){ layer.close(index);}, no : function(index){ layer.close(index);}
},
page: {dom: '#xulayer', html: '', url: ''},
iframe: {src: 'http://sentsin.com'},
loading: {type: 0},
tips: {msg: '', follow: '', guide: 0, isguide: true, style: ['background-color:#ff9900; color:#fff;', '#ff9900']},
success: function(layer){}, //创建成功后的回调
close: function(index){ layer.close(index);}, //右上角关闭回调
end: function(){} //终极销毁回调
};
class.pt.type = ['dialog', 'page', 'iframe', 'loading', 'tips'];
//容器
class.pt.space = function(html){
var html = html || '', times = this.index, config = this.config, dialog = config.dialog, dom = this.dom,
ico = dialog.type === -1 ? '' : '',
frame = [
'
'+ ico +'' + dialog.msg + '
',
''+ html +'
',
'',
'',
''
],
shade = '' , border = '', zindex = config.zindex + times,
shadestyle = 'z-index:'+ zindex +'; background-color:'+ config.shade[1] +'; opacity:'+ config.shade[0] +'; filter:alpha(opacity='+ config.shade[0]*100 +');';
config.shade[2] && (shade = '');
config.zindex = zindex;
var title = '', closebtn = '', borderstyle = "z-index:"+ (zindex-1) +"; background-color: "+ config.border[2] +"; opacity:"+ config.border[1] +"; filter:alpha(opacity="+ config.border[1]*100 +"); top:-"+ config.border[0] +"px; left:-"+ config.border[0] +"px;";
config.border[3] && (border = '');
config.closebtn[1] && (closebtn = '');
config.title[1] && (title = '' + config.title[0] + '
')
var boxhtml = ''
+ '
'
+ frame[config.type]
+ title
+ closebtn
+ ''
+ '
'+ border + '
';
return [shade , boxhtml];
};
//缓存字符
class.pt.dom = {
lay: 'xubox_layer',
ifr: 'xubox_iframe'
};
//创建骨架
class.pt.creat = function(){
var that = this , space = '', config = this.config, dialog = config.dialog, title = that.config.title, dom = that.dom, times = that.index;;
title.constructor === array || (that.config.title = [title, true]);
title === false && (that.config.title = [title, false]);
var page = config.page, body = $("body"), setspace = function(html){
var html = html || ''
space = that.space(html);
body.append(space[0]);
};
switch(config.type){
case 1:
if(page.html !== ''){
setspace(''+ page.html +'
');
body.append(space[1]);
}else if(page.url !== ''){
setspace(''+ page.html +'
');
body.append(space[1]);
$.get(page.url, function(datas){
$('#xuboxpagehtml'+ times).html(datas);
page.ok && page.ok(datas);
});
}else{
if($(page.dom).parents('.xubox_page').length == 0){
setspace();
$(page.dom).show().wrap(space[1]);
}else{
return;
}
}
break;
case 2:
setspace();
body.append(space[1]);
break;
case 3:
config.title = ['', false];
config.area = ['auto', 'auto'];
config.closebtn = ['', false];
$('.xubox_loading')[0] && layer.close($('.xubox_loading').parents('.'+dom.lay).attr('times'));
setspace();
body.append(space[1]);
break;
case 4:
config.title = ['', false];
config.area = ['auto', 'auto'];
config.fix = false;
config.border = false;
$('.xubox_tips')[0] && layer.close($('.xubox_tips').parents('.'+dom.lay).attr('times'));
setspace();
body.append(space[1]);
$('#'+ dom.lay + times).find('.xubox_close').css({top: 6, right: 7});
break;
default:
config.title[1] || (config.area = ['auto','auto']);
$('.xubox_dialog')[0] && layer.close($('.xubox_dialog').parents('.'+dom.lay).attr('times'));
setspace();
body.append(space[1]);
break;
};
this.layers = $('#xubox_shade' + times);
this.layerb = $('#xubox_border' + times);
this.layere = $('#'+ dom.lay + times);
var layere = this.layere;
this.layermian = layere.find('.xubox_main');
this.layertitle = layere.find('.xubox_title');
this.layertext = layere.find('.xubox_text');
this.layerpage = layere.find('.xubox_page');
this.layerbtn = layere.find('.xubox_botton');
//设置layer面积坐标等数据
if(config.offset[1].indexof("px") != -1){
var _left = parseint(config.offset[1]);
}else{
if(config.offset[1] == '50%'){
var _left = config.offset[1];
}else{
var _left = parseint(config.offset[1])/100 * win.width();
}
};
layere.css({left: _left + config.border[0], width: config.area[0], height: config.area[1]});
config.fix ? layere.css({top: parseint(config.offset[0]) + config.border[0]}) : layere.css({top: parseint(config.offset[0]) + win.scrolltop() + config.border[0], position: 'absolute'});
//配置按钮 对话层形式专有
if(config.type == 0 && config.title[1]){
switch(dialog.btns){
case 0:
that.layerbtn.html('').hide();
break;
case 2:
that.layerbtn.html(''+ dialog.btn[0] +'' + ''+ dialog.btn[1] + '');
break;
default:
that.layerbtn.html(''+ dialog.btn[0] +'');
}
};
if(layere.css('left') === 'auto'){
layere.hide();
settimeout(function(){
layere.show();
that.set(times);
}, 500);
}else{
that.set(times);
}
config.time <= 0 || that.autoclose();
this.callback();
};
//初始化骨架
class.pt.set = function(times){
var that = this, layere = that.layere, config = that.config, dialog = config.dialog, page = config.page, loading = config.loading, dom = that.dom;
that.autoarea(times);
if(config.title[1]){
layer.ie6 && that.layertitle.css({width : layere.outerwidth()});
}else{
config.type != 4 && layere.find('.xubox_close').addclass('xubox_close1');
};
layere.attr({'type' : that.type[config.type]});
switch(config.type){
case 1:
layere.find(page.dom).addclass('layer_pagecontent');
config.shade[2] && layere.css({zindex: config.zindex + 1});
config.title[1] && that.layerpage.css({top: that.layertitle.outerheight()});
break;
case 2:
var iframe = layere.find('.'+ dom.ifr), heg = layere.height();
iframe.addclass('xubox_load').css({width: layere.width()});
config.title[1] ? iframe.css({top: that.layertitle.height(), height: heg - that.layertitle.height()}) : iframe.css({top: 0, height : heg});
layer.ie6 && iframe.attr('src', config.iframe.src);
break;
case 3:
break;
case 4 :
var layarea = [0, layere.outerheight()], fow = $(config.tips.follow), fowo = {
width: fow.outerwidth(),
height: fow.outerheight(),
top: fow.offset().top,
left: fow.offset().left
}, tipsg = layere.find('.layertipsg');
config.tips.isguide || tipsg.remove();
layere.outerwidth() > config.maxwidth && layere.width(config.maxwidth);
fowo.tipcolor = config.tips.style[1];
layarea[0] = layere.outerwidth();
//辨别tips的方位
fowo.where = [function(){ //上
fowo.tipleft = fowo.left;
fowo.tiptop = fowo.top - layarea[1] - 10;
tipsg.removeclass('layertipsb').addclass('layertipst').css({'border-right-color': fowo.tipcolor});
}, function(){ //右
fowo.tipleft = fowo.left + fowo.width + 10;
fowo.tiptop = fowo.top;
tipsg.removeclass('layertipsl').addclass('layertipsr').css({'border-bottom-color': fowo.tipcolor});
}, function(){ //下
fowo.tipleft = fowo.left;
fowo.tiptop = fowo.top + fowo.height + 10;
tipsg.removeclass('layertipst').addclass('layertipsb').css({'border-right-color': fowo.tipcolor});
}, function(){ //左
fowo.tipleft = fowo.left - layarea[0] + 10;
fowo.tiptop = fowo.top;
tipsg.removeclass('layertipsr').addclass('layertipsl').css({'border-bottom-color': fowo.tipcolor});
}];
fowo.where[config.tips.guide]();
/* 8*2为小三角形占据的空间 */
if(config.tips.guide === 0){
fowo.top - (win.scrolltop() + layarea[1] + 8*2) < 0 && fowo.where[2]();
} else if (config.tips.guide === 1){
win.width() - (fowo.left + fowo.width + layarea[0] + 8*2) > 0 || fowo.where[3]()
} else if (config.tips.guide === 2){
(fowo.top - win.scrolltop() + fowo.height + layarea[1] + 8*2) - win.height() > 0 && fowo.where[0]();
} else if (config.tips.guide === 3){
layarea[0] + 8*2 - fowo.left > 0 && fowo.where[1]()
}
layere.css({left: fowo.tipleft, top: fowo.tiptop});
break;
default:
that.layermian.css({'background-color': '#fff'});
if(config.title[1]){
that.layertext.css({paddingtop: 18 + that.layertitle.outerheight()});
}else{
layere.find('.xubox_msgico').css({top: 8});
that.layertext.css({margintop : 11});
}
break;
};
config.fadein && layere.css({opacity: 0}).animate({opacity: 1}, config.fadein);
that.move();
};
//自适应宽高
class.pt.autoarea = function(times){
var that = this, layere = that.layere, config = that.config, page = config.page,
layermian = that.layermian, layerbtn = that.layerbtn, layertext = that.layertext,
layerpage = that.layerpage, layerb = that.layerb, titheight, outheight, btnheight = 0,
load = $(".xubox_loading");
if(config.area[0] === 'auto' && layermian.outerwidth() >= config.maxwidth){
layere.css({width : config.maxwidth});
}
config.title[1] ? titheight = that.layertitle.innerheight() : titheight = 0;
switch(config.type){
case 0:
var abtn = layerbtn.find('a');
outheight = layertext.outerheight() + 20;
if(abtn.length > 0){
btnheight = abtn.outerheight() + 20;
}
break;
case 1:
outheight = $(page.dom).outerheight();
config.area[0] === 'auto' && layere.css({width : layerpage.outerwidth()});
if(page.html !== '' || page.url !== ''){
outheight = layerpage.outerheight();
}
break;
case 3:
outheight = load.outerheight();
layermian.css({width: load.width()});
break;
};
(config.area[1] === 'auto') && layermian.css({height: titheight + outheight + btnheight});
layerb.css({width: layere.outerwidth() + 2*config.border[0] , height: layere.outerheight() + 2*config.border[0]});
(layer.ie6 && config.area[0] != 'auto') && layermian.css({width : layere.outerwidth()});
(config.offset[1] === '50%' || config.offset[1] == '') && (config.type !== 4) ? layere.css({marginleft : -layere.outerwidth()/2}) : layere.css({marginleft : 0});
};
//拖拽层
class.pt.move = function(){
var that = this, config = this.config, dom = that.dom, conf = {
sety: 0,
movelayer: function(){
if(parseint(conf.layere.css('margin-left')) == 0){
var lefts = parseint(conf.move.css('left'));
}else{
var lefts = parseint(conf.move.css('left')) + (-parseint(conf.layere.css('margin-left')))
}
if(conf.layere.css('position') !== 'fixed'){
lefts = lefts - conf.layere.parent().offset().left;
conf.sety = 0
}
conf.layere.css({left: lefts, top: parseint(conf.move.css('top')) - conf.sety});
}
};
config.move[1] && that.layere.find(config.move[0]).attr('move','ok');
config.move[1] ? that.layere.find(config.move[0]).css({cursor: 'move'}) : that.layere.find(config.move[0]).css({cursor: 'auto'});
$(config.move[0]).on('mousedown', function(m){
m.preventdefault();
if($(this).attr('move') === 'ok'){
conf.ismove = true;
conf.layere = $(this).parents('.'+ dom.lay);
var xx = conf.layere.offset().left, yy = conf.layere.offset().top, ww = conf.layere.width() - 6, hh = conf.layere.height() - 6;
if(!$('#xubox_moves')[0]){
$('body').append('');
}
conf.move = $('#xubox_moves');
config.movetype && conf.move.css({opacity: 0});
conf.movex = m.pagex - conf.move.position().left;
conf.movey = m.pagey - conf.move.position().top;
conf.layere.css('position') !== 'fixed' || (conf.sety = win.scrolltop());
}
});
$(document).mousemove(function(m){
if(conf.ismove){
var offsetx = m.pagex - conf.movex, offsety = m.pagey - conf.movey;
m.preventdefault();
//控制元素不被拖出窗口外
if(!config.moveout){
conf.sety = win.scrolltop();
var setrig = win.width() - conf.move.outerwidth() - config.border[0], settop = config.border[0] + conf.sety;
offsetx < config.border[0] && (offsetx = config.border[0]);
offsetx > setrig && (offsetx = setrig);
offsety < settop && (offsety = settop);
offsety > win.height() - conf.move.outerheight() - config.border[0] + conf.sety && (offsety = win.height() - conf.move.outerheight() - config.border[0] + conf.sety);
}
conf.move.css({left: offsetx, top: offsety});
config.movetype && conf.movelayer();
offsetx = null;
offsety = null;
setrig = null;
settop = null
}
}).mouseup(function(){
try{
if(conf.ismove){
conf.movelayer();
conf.move.remove();
}
conf.ismove = false;
}catch(e){
conf.ismove = false;
}
config.moveend && config.moveend();
});
};
//自动关闭layer
class.pt.autoclose = function(){
var that = this, time = this.config.time, maxload = function(){
time--;
if(time === 0){
layer.close(that.index);
clearinterval(that.autotime);
}
};
this.autotime = setinterval(maxload , 1000);
};
ready.config = {
end : {}
};
class.pt.callback = function(){
var that = this, layere = that.layere, config = that.config, dialog = config.dialog;
that.openlayer();
that.config.success(layere);
layer.ie6 && that.ie6();
layere.find('.xubox_close').off('click').on('click', function(e){
e.preventdefault();
config.close(that.index);
});
layere.find('.xubox_yes').off('click').on('click',function(e){
e.preventdefault();
dialog.yes(that.index);
});
layere.find('.xubox_no').off('click').on('click',function(e){
e.preventdefault();
dialog.no(that.index);
});
this.layers.off('click').on('click', function(e){
e.preventdefault();
that.config.shadeclose && layer.close(that.index);
});
ready.config.end[that.index] = config.end;
};
class.pt.ie6 = function(){
var that = this, layere = that.layere, select = $('select'), dom = that.dom;
var _ietop = layere.offset().top;
//ie6的固定与相对定位
if(that.config.fix){
var ie6fix = function(){
layere.css({top : $(document).scrolltop() + _ietop});
};
}else{
var ie6fix = function(){
layere.css({top : _ietop});
};
}
ie6fix();
win.scroll(ie6fix);
//隐藏select
$.each(select, function(index , value){
var sthis = $(this);
if(!sthis.parents('.'+dom.lay)[0]){
sthis.css('display') == 'none' || sthis.attr({'layer' : '1'}).hide();
}
sthis = null;
});
//恢复select
that.reselect = function(){
$.each(select, function(index , value){
var sthis = $(this);
if(!sthis.parents('.'+dom.lay)[0]){
(sthis.attr('layer') == 1 && $('.'+dom.lay).length < 1) && sthis.removeattr('layer').show();
}
sthis = null;
});
};
};
//给layer对象拓展方法
class.pt.openlayer = function(){
var that = this, dom = that.dom;
//自适应宽高
layer.autoarea = function(index){
return that.autoarea(index);
};
//获取layer当前索引
layer.getindex = function(selector){
return $(selector).parents('.'+dom.lay).attr('times');
};
//获取子iframe的dom
layer.getchildframe = function(selector, index){
index = index || $('.'+ dom.ifr).parents('.'+dom.lay).attr('times');
return $('#'+ dom.lay + index).find('.'+ dom.ifr).contents().find(selector);
};
//得到当前iframe层的索引,子iframe时使用
layer.getframeindex = function(name){
return $(name ? '#'+ name : '.'+ dom.ifr).parents('.'+dom.lay).attr('times');
};
//iframe层自适应宽高
layer.iframeauto = function(index){
index = index || $('.'+ dom.ifr).parents('.'+dom.lay).attr('times');
var heg = this.getchildframe('body', index).outerheight(),
lbox = $('#'+ dom.lay + index), tit = lbox.find('.xubox_title'), titht = 0;
!tit || (titht = tit.height());
lbox.css({height: heg + titht});
var bs = -parseint($('#xubox_border'+ index).css('top'));
$('#xubox_border'+ index).css({height: heg + 2*bs + titht});
$('#'+ dom.ifr + index).css({height: heg});
};
//关闭layer
layer.close = function(index){
var layernow = $('#'+ dom.lay + index), shadenow = $('#xubox_moves, #xubox_shade' + index);
if(layernow.attr('type') == that.type[1]){
if(layernow.find('.xuboxpagehtml')[0]){
layernow.remove();
}else{
layernow.find('.xubox_close,.xubox_botton,.xubox_title,.xubox_border').remove();
for(var i = 0 ; i < 3 ; i++){
layernow.find('.layer_pagecontent').unwrap().hide();
}
}
}else{
document.all && layernow.find('#'+ dom.ifr + index).remove();
layernow.remove();
}
shadenow.remove();
layer.ie6 && that.reselect();
typeof ready.config.end[index] === 'function' && ready.config.end[index]();
delete ready.config.end[index];
};
//关闭加载层
layer.loadclose = function(){
var parent = $('.xubox_loading').parents('.'+dom.lay),
index = parent.attr('times');
layer.close(index);
};
//出场内置动画
layer.shift = function(type, rate){
var config = that.config, ie6 = layer.ie6, layere = that.layere, cutwth = 0, ww = win.width(), wh = win.height();
(config.offset[1] == '50%' || config.offset[1] == '') ? cutwth = layere.outerwidth()/2 : cutwth = layere.outerwidth();
var anim = {
t: {top : config.border[0]},
b: {top : wh - layere.outerheight() - config.border[0]},
cl: cutwth + config.border[0],
ct: -layere.outerheight(),
cr: ww - cutwth - config.border[0],
fn: function(){
ie6 && that.ie6();
}
};
switch(type){
case 'left-top':
layere.css({left: anim.cl, top: anim.ct}).animate(anim.t, rate, anim.fn);
break;
case 'top':
layere.css({top: anim.ct}).animate(anim.t, rate, anim.fn);
break;
case 'right-top':
layere.css({left: anim.cr, top: anim.ct}).animate(anim.t, rate, anim.fn);
break;
case 'right-bottom':
layere.css({left: anim.cr, top: wh}).animate(anim.b, rate, anim.fn);
break;
case 'bottom':
layere.css({top: wh}).animate(anim.b, rate, anim.fn);
break;
case 'left-bottom':
layere.css({left: anim.cl, top: wh}).animate(anim.b, rate, anim.fn);
break;
case 'left':
layere.css({left: -layere.outerwidth(), marginleft:0}).animate({left:anim.t.top}, rate, anim.fn);
break;
};
};
//初始化拖拽元素
layer.setmove = function(){
return that.move();
};
//给指定层重置属性
layer.area = function(index, options){
var nowobect = [$('#'+ dom.lay + index), $('#xubox_border'+ index)],
type = nowobect[0].attr('type'), main = nowobect[0].find('.xubox_main'),
title = nowobect[0].find('.xubox_title');
if(type === that.type[1] || type === that.type[2]){
nowobect[0].css(options);
if(nowobect[1][0]){
nowobect[1].css({
width: options.width - 2*parseint(nowobect[1].css('left')),
height: options.height - 2*parseint(nowobect[1].css('top'))
});
}
main.css({height: options.height});
if(type === that.type[2]){
var iframe = nowobect[0].find('iframe');
iframe.css({width: options.width, height: title ? options.height - title.outerheight() : options.height});
}
if(nowobect[0].css('margin-left') !== '0px') {
options.hasownproperty('top') && nowobect[0].css({top: options.top - (nowobect[1][0] && parseint(nowobect[1].css('top')))});
options.hasownproperty('left') && nowobect[0].css({left: options.left + nowobect[0].outerwidth()/2 - (nowobect[1][0] && parseint(nowobect[1].css('left')))})
nowobect[0].css({marginleft : -nowobect[0].outerwidth()/2});
}
}
};
//关闭所有层
layer.closeall = function(){
var layerobj = $('.'+dom.lay);
$.each(layerobj, function(){
var i = $(this).attr('times');
layer.close(i);
});
};
//置顶当前窗口
layer.zindex = that.config.zindex;
layer.settop = function(layernow){
var setzindex = function(){
layer.zindex++;
layernow.css('z-index', layer.zindex + 1);
};
layer.zindex = parseint(layernow[0].style.zindex);
layernow.on('mousedown', setzindex);
return layer.zindex;
};
};
//主入口
ready.run = function(){
$ = jquery;
win = $(window);
layer.use('skin/layer.css');
$.layer = function(deliver){
var o = new class(deliver);
return o.index;
};
};
//为支持cmd规范的模块加载器
var require = '../../init/jquery'; //若采用seajs,需正确配置jquery的相对路径。未用可无视此处。
if(window.seajs){
define([require], function(require, exports, module){
ready.run();
exports.layer = [window.layer, window['$'].layer];
});
}else{
ready.run();
}
}(window);