diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..18924b82 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +1.8.5/ +*.iml +.idea/ +.ipr +.iws +*~ +~* +*.diff +*.patch +*.bak +.DS_Store +Thumbs.db +.svn/ +*.swp +.nojekyll +.project +.settings/ +node_modules/ +_site/ +.npmignore +release/ +skin/moon/ +src/skin/moon/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..be179b1a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 layui + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index a0bab7d7..ba7c599f 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,18 @@ -## 前言 -实在是有点迟到,最近才把layer托管到github,目的是收集更优秀的代码,以让其"易用和实用性"具备更强大的技术支撑。因此我们强烈呼吁有缘人加入进来,共同完善这位最懂你的精灵。 - -## 愿景 -致力于打造国内最盛行的弹层组件,为web开发提供强劲动力。 +## 📣 提示 +**layer 组件已完全集成到 Layui 中,不再做单独维护。建议直接使用 layui 中 layer。** -## 简要 -layer遵循于LGPL开源协议,她是一枚可以让你想到即可做到的新生代web弹窗/层js组件。layer侧重于用户灵活的自定义,为不同人的使用习惯提供全方位设计,您的页面会因此拥有更丰富、友好的操作体验,而您只需在调用时简单地配置相关参数,即可轻松实现各类交互。 +> layer 文档:https://layui.dev/docs/layer/ -与同类弹出层组件相比,layer的优势明显,她尽可能地在以更少的代码展现出更强健的功能。layer格外注重性能的提升、易用和实用性,正因如此,越来越多的开发者将媚眼投上了小小的layer。当你问及她的兼容时,layer必须告诉你,她兼容了一切浏览器,包括古老的ie6。layer公开了如此多的接口,这使得您可以DIY太多您需要的风格,尤其是页面层模式,意味着必要时您可以完全抛弃layer的现有皮肤,并用你的思维去勾勒她的衣着。而问题在于,我必须中止"王婆卖瓜"的陈述。因为一切的不足或友好,都需要您在使用过程中去发现。 -## 现状 -从两年前初出茅庐,到后来成为小众组件,再发展到今天,已为数以万计的人所熟知。 -据不完全统计,截至到2014年5月13号,layer已服务于15万多家web平台。 -其中包括: -* [中国联通](http://app.10010.com/) -* [蚂蚁短租](http://www.mayi.com/) -* [phpyun](http://www.phpyun.com/) -* [卡牌网](http://www.kapai.com/) -* [八圆包](http://www.bayuanbao.com/) +## 概要 +layer 是一款历来都备受青睐的 Web 弹出层组件,具备全方位的解决方案,面向的是各个水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验。在与同类组件的比较中,layer 会更能被开发者所选择。这不仅是凭「脸」取胜,而是它尽可能地在以更少的代码展现更强健的功能,且格外注重性能的提升、易用和实用性,layer 甚至还兼容了包括 IE6 在内的所有主流浏览器。其数量可观的基础属性和方法,使得您可以自定义太多您需要的风格,每一种弹层模式各具特色,广受欢迎。当然,这种「王婆卖瓜」的陈述听起来总是有点难受,因此你需要进一步了解她是否真的如你所愿。 +[文档与演示](http://layui.dev/docs/2/layer/) -事实上我们无法获取到更多案例,所以如果您有大型项目也在使用layer,您可以联系作者,以便在layer官网展现,也为您的品牌推广尽一些绵薄之力。 +## 愿景 +成为网页弹出层的首先交互方案 +## 影响 +因着数年的坚持维护,layer 已被运用在不计其数 Web 平台,几乎所处可见,其中还不乏众多知名大型网站。layer 已被国内乃至全世界至少数十万的开发者所使用过。 -## 备注 -[官网](http://sentsin.com/jquery/layer/)、[更新日志](https://github.com/sentsin/layer/blob/master/Update%20Notes.txt)、[Say交流](http://say.sentsin.com/home-48.html)、[商业支持](http://url.cn/RAejZY) \ No newline at end of file diff --git a/Update Notes.txt b/Update Notes.txt deleted file mode 100644 index 908adc19..00000000 --- a/Update Notes.txt +++ /dev/null @@ -1,57 +0,0 @@ -【1.8.3更新日志】2014年6月4日 -1、新增遮罩层fadeIn淡入。 -2、修复设置border:[0]时,最大/小化的小bug -3、修复layer.area潜在的一个非常小的bug -4、优化代码结构 - -【1.8.2更新日志】2014年5月27日 -1、优化核心代码 -2、修复了两个潜在的小小小bug - -【1.8.1更新日志】2014年5月16日 -1、紧急修复ie7下无法显示关闭按钮的bug -2、紧急修复ie6最小化按钮高度稍微溢出的bug -3、去掉layer.css的reset,以避免可能存在的样式冲突 - -【1.8.0更新日志】2014年5月15日 - -01、新增窗口最小化/全屏/还原功能,通过配置参数 maxmin:true,不开启不用配置。本功能只针对普通页面层(type:1)和iframe层(type:2)有效。另外还需注意一点,参数area一旦配置%,将不会输出此项图标。 -02、新增窗口最小化回调函数min: function(index){} -03、新增窗口全屏回调函数full: function(index){} -04、新增窗口还原回调函数restore: function(index){} -05、新增方法layer.min(index, options)/layer.full(index, options)/layer.restore(index),分别用于外部设置新增窗口最小化/全屏/还原 -06、iframe层新增一个scrolling参数,用于控制是否显示滚动条。默认自动,如果想不显示,配置 iframe: {scrolling: 'no'} 即可 -07、layer.shift方法增加一个stop参数,用于设置是否动画到最顶部。如layer.shift('bottom', 500, 1)则表示从最顶部动画到指定坐标。 - -08、优化IE6-8下拖动iframe层一卡一卡的问题 -09、优化在IE低版本下的内存占用问题。 -10、优化内部代码。 - -11、修复layer.load('文字',time)第二个参数不能倒计时关闭的小bug -12、修复ie个别版本的低级浏览器,第二次弹出iframe层时,无法获取焦点的bug -13、修改弹出动画到offset设定好的位置,不再只是在边缘。 -14、修复layer.autoArea(index)的重大bug -15、修复当fix设为false时,layer.shift动画弹出的bug。 -16、修复layer.use无法正确执行回调的bug - -17、layer.shift不再对ie6提供支持。 -18、为了规范统一性,关闭loading加载层的方法:layer.loadClose()改成layer.closeLoad() -19、对layer所需要的icon做了预先加载 -20、layer.use支持加载外部的css/js - -【拓展模块】 -提示:相册支持左右方向键切换,以及ESC键关闭。 -21、新增layer.photos(options),以实现图片的相册模式浏览。支持获取页面指定区域所有图片、支持异步请求过来的json数据 -22、新增layer.photosPage(options),用于相册模式查看页面指定区域的所有图片。 -23、新增layer.ext = function(){}回调方法,用于首次加载layer.ext.js时立即执行拓展层。 -24、layer.prompt方法新增title和length参数,title用于自定义标题,length用于文本框的字数。如:layer.prompt({title:'helllo prompt', title: 300}); -25、layer.tab方法新增offset参数,用于控制坐标 - - - -【小提示:如果亲们觉得layer对你有所帮助,可以去layer官网适当点击下广告支持一下。】 -官网: http://sentsin.com/jquery/layer/ -日志:http://say.sentsin.com/say-706.html - - - diff --git a/demo.html b/demo.html deleted file mode 100644 index 34aebe0f..00000000 --- a/demo.html +++ /dev/null @@ -1,100 +0,0 @@ - - - -layer-更懂你的web弹窗解决方案 - - - - - -
-
-
- @Name:layer-v 弹层组件说明
- @Author:贤心
- @Blog:http://sentsin.com
- @官网:http://sentsin.com/jquery/layer
- @授权:http://url.cn/RAejZY
-
-
-【注意事项】
-一、使用时,请把文件夹layer整个放置在您站点的任何一个目录,只需引入layer.min.js即可,除jQuery外,其它文件无需再引入。
-二、如果您的js引入是通过合并处理或者您不想采用layer自动获取的绝对路径,您需要打开layer.min.js 去配置相对路径url。(默认采用自动获取layer所在的路径)
-三、jquery必须为1.8或1.8以上版本(原因,更小,性能更好,且新版layer使用了部分jq1.8+的特性),下载包里doc文件里有jquery1.9下载地址
-四、更多使用说明与演示(demo),请参见layer官网。
-五、layer使用免费,可应用于任何类型的web平台(违法站除外),使用时请务必保留来源。
-六、如果您用于商业平台,您须经过授权。
-七、您也可申请VIP技术服务。版权最终解释权:贤心。
-
-
- -
-

layer1.8相册模块,点击下述图片试试

-
- - - - -
-
- - -
- 使用文档 - 更新日志 - 交流反馈 -
- - -

AltStyle によって変換されたページ (->オリジナル) /

- \ No newline at end of file diff --git a/dist/layer.js b/dist/layer.js new file mode 100644 index 00000000..c6bc68b8 --- /dev/null +++ b/dist/layer.js @@ -0,0 +1,2 @@ +/*! layer-v3.5.1 Web 通用弹出层组件 MIT License */ + ;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var t=document.currentScript?document.currentScript.src:function(){for(var e,t=document.scripts,i=t.length-1,n=i;n>0;n--)if("interactive"===t[n].readyState){e=t[n].src;break}return e||t[i].src}(),i=e.LAYUI_GLOBAL||{};return i.layer_dir||t.substring(0,t.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["确定","取消"],type:["dialog","page","iframe","loading","tips"],getStyle:function(t,i){var n=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](i)},link:function(t,i,n){if(r.path){var a=document.getElementsByTagName("head")[0],s=document.createElement("link");"string"==typeof i&&(n=i);var l=(n||t).replace(/\.|\//g,""),f="layuicss-"+l,c="creating",u=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,document.getElementById(f)||a.appendChild(s),"function"==typeof i&&!function d(t){var n=100,a=document.getElementById(f);return++u>1e4/n?e.console&&console.error(l+".css: Invalid"):void(1989===parseInt(o.getStyle(a,"width"))?(t===c&&a.removeAttribute("lay-status"),a.getAttribute("lay-status")===c?setTimeout(d,n):i()):(a.setAttribute("lay-status",c),setTimeout(function(){d(c)},n)))}()}}},r={v:"3.5.1",ie:function(){var t=navigator.userAgent.toLowerCase();return!!(e.ActiveXObject||"ActiveXObject"in e)&&((t.match(/msie\s(\d+)/)||[])[1]||"11")}(),index:e.layer&&e.layer.v?1e5:0,path:o.getPath,config:function(e,t){return e=e||{},r.cache=o.config=i.extend({},o.config,e),r.path=o.config.path||r.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.config.path&&r.ready(),e.extend?(a?layui.addcss("modules/layer/"+e.extend):o.link("theme/"+e.extend),this):this},ready:function(e){var t="layer",i="",n=(a?"modules/layer/":"theme/")+"default/layer.css?v="+r.v+i;return a?layui.addcss(n,e,t):o.link(n,e,t),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),r.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,a){var s="function"==typeof t;return s&&(a=n,n=t),r.open(i.extend({content:e,btn:o.btn,yes:n,btn2:a},s?{}:t))},msg:function(e,n,a){var s="function"==typeof n,f=o.config.skin,c=(f?f+" "+f+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(a=n),r.open(i.extend({content:e,time:3e3,shade:!1,skin:c,title:!1,closeBtn:!1,btn:!1,resize:!1,end:a},s&&!o.config.skin?{skin:c+" layui-layer-hui",anim:u}:function(){return n=n||{},(n.icon===-1||n.icon===t&&!o.config.skin)&&(n.skin=c+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return r.open(i.extend({type:3,icon:e||0,resize:!1,shade:.01},t))},tips:function(e,t,n){return r.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,resize:!1,fixed:!1,maxWidth:260},n))}},s=function(e){var t=this,a=function(){t.creat()};t.index=++r.index,t.config.maxWidth=i(n).width()-30,t.config=i.extend({},t.config,o.config,e),document.body?a():setTimeout(function(){a()},30)};s.pt=s.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim-00","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],l.SHADE="layui-layer-shade",l.MOVE="layui-layer-move",s.pt.config={type:0,shade:.3,fixed:!0,move:l[1],title:"信息",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,anim:0,isOutAnim:!0,minStack:!0,icon:-1,moveType:1,resize:!0,scrollbar:!0,tips:2},s.pt.vessel=function(e,t){var n=this,a=n.index,r=n.config,s=r.zIndex+a,f="object"==typeof r.title,c=r.maxmin&&(1===r.type||2===r.type),u=r.title?'
'+(f?r.title[0]:r.title)+"
":"";return r.zIndex=s,t([r.shade?'
':"",'
'+(e&&2!=r.type?"":u)+'
'+(0==r.type&&r.icon!==-1?'':"")+(1==r.type&&e?"":r.content||"")+'
'+function(){var e=c?'':"";return r.closeBtn&&(e+=''),e}()+""+(r.btn?function(){var e="";"string"==typeof r.btn&&(r.btn=[r.btn]);for(var t=0,i=r.btn.length;t'+r.btn[t]+"";return'
'+e+"
"}():"")+(r.resize?'':"")+"
"],u,i('
')),n},s.pt.creat=function(){var e=this,t=e.config,a=e.index,s=t.content,f="object"==typeof s,c=i("body");if(!t.id||!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.shift&&(t.anim=t.shift),6==r.ie&&(t.fixed=!1),t.type){case 0:t.btn="btn"in t?t.btn:o.btn[0],r.closeAll("dialog");break;case 2:var s=t.content=f?t.content:[t.content||"","auto"];t.content='[フレーム]';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}if(e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i("#"+l.MOVE)[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),e.shadeo=i("#"+l.SHADE+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),e.shadeo.css({"background-color":t.shade[1]||"#000",opacity:t.shade[0]||t.shade}),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():function(){e.offset(),parseInt(o.getStyle(document.getElementById(l.MOVE),"z-index"))||function(){e.layero.css("visibility","hidden"),r.ready(function(){e.offset(),e.layero.css("visibility","visible")})}()}(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||settimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]){var u="layer-anim "+l.anim[t.anim];e.layero.addClass(u).one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){i(this).removeClass(u)})}t.isOutAnim&&e.layero.data("isOutAnim",!0)}},s.pt.auto=function(e){var t=this,a=t.config,o=i("#"+l[0]+e);""===a.area[0]&&a.maxWidth>0&&(r.ie&&r.ie<8&&a.btn&&o.width(o.innerwidth()),o.outerwidth()>a.maxWidth&&o.width(a.maxWidth));var s=[o.innerWidth(),o.innerHeight()],f=o.find(l[1]).outerHeight()||0,c=o.find("."+l[6]).outerHeight()||0,u=function(e){e=o.find(e),e.height(s[1]-f-c-2*(0|parseFloat(e.css("padding-top"))))};switch(a.type){case 2:u("iframe");break;default:""===a.area[1]?a.maxHeight>0&&o.outerHeight()>a.maxHeight?(s[1]=a.maxHeight,u("."+l[5])):a.fixed&&s[1]>=n.height()&&(s[1]=n.height(),u("."+l[5])):u("."+l[5])}return t},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;af&&(a=f),ou&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),n.find("."+l[7]).on("click",e),a.shadeClose&&t.shadeo.on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n,t.index);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n,t.index)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n,t.index)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeattr("layer").show(),n=null})},s.pt.ie6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc="function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var" a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");s!==o.type[3]&&s!==o.type[4]&&(n||(parseFloat(t.width)<=260&&(t.."+l[6]).outerheight(),s===o.type[2]?a.find("iframe").css({height:parsefloat(t.height)-f-c}):r.css({height:parsefloat(t.height)-f-c-parsefloat(r.css("padding-top"))-parsefloat(r.css("padding-bottom"))}))},r.min=function(e,t){t=t||{};var" a=i("#"+l[0]+e),s=i("#"+l.SHADE+e),f=a.find(l[1]).outerHeight()||0,c=a.attr("minLeft")||181*o.minIndex+"px",u=a.css("position"),d={width:180,height:f,position:"fixed",overflow:"hidden"};o.record(a),o.minLeft[0]&&(c=o.minLeft[0],o.minLeft.shift()),t.minStack&&(d.left=c,d.top=n.height()-f,a.attr("minLeft")||o.minIndex++,a.attr("minLeft",c)),a.attr("position",u),r.style(e,d,!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),s.hide()},r.restore=function(e){var t=i("#"+l[0]+e),n=i("#"+l.SHADE+e),a=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(a[0]),height:parseFloat(a[1]),top:parseFloat(a[2]),left:parseFloat(a[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e),n.show()},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e,t){var n=i("#"+l[0]+e),a=n.attr("type"),s="layer-anim-close";if(n[0]){var f="layui-layer-wrap",c=function(){if(a===o.type[1]&&"object"===n.attr("conType")){n.children(":not(."+l[5]+")").remove();for(var r=n.find("."+f),s=0;s<2;s++)r.unwrap();r.css("display",r.data("display")).removeclass(f)}else{if(a===o.type[2])try{var c=i("#"+l[4]+e)[0];c.contentWindow.document.write(""),c.contentWindow.close(),n.find("."+l[5])[0].removeChild(c)}catch(u){}n[0].innerHTML="",n.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e],"function"==typeof t&&t()};n.data("isOutAnim")&&n.addClass("layer-anim "+s),i("#layui-layer-moves, #"+l.SHADE+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),n.attr("minLeft")&&(o.minIndex--,o.minLeft.push(n.attr("minLeft"))),r.ie&&r.ie<10||!n.data("isoutanim")?c():settimeout(function(){c()},200)}},r.closeall=function(e,t){"function"==typeof e&&(t=e,e=null);var n=i("."+l[0]);i.each(n,function(a){var o=i(this),s=e?o.attr("type")===e:1;s&&r.close(o.attr("times"),a===n.length-1?t:null),s=null}),0===n.length&&"function"==typeof t&&t()};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'":function(){return''}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["确定","取消"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(t){s=t.find(".layui-layer-input"),s.val(e.value||"").focus(),"function"==typeof f&&f(t)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("最多输入"+(e.maxlength||500)+"个字数",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n="layui-this",a=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,a="";if(e>0)for(a=''+t[0].title+"";i"+t[i].title+"";return a}(),content:'
    '+function(){var e=t.length,i=1,a="";if(e>0)for(a='
  • '+(t[0].content||"no content")+"
  • ";i'+(t[i].content||"no content")+"";return a}()+"
",success:function(t){var o=t.find(".layui-layer-title").children(),r=t.find(".layui-layer-tabmain").children();o.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var a=i(this),o=a.index();a.addClass(n).siblings().removeClass(n),r.eq(o).show().siblings().hide(),"function"==typeof e.change&&e.change(o)}),"function"==typeof a&&a(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){var l=!("string"==typeof t.photos||t.photos instanceof i),f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("没有图片")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){h();var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0)}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgindex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgindex++,s.imgindex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){if(!(u.length<=1))return f.start=s.imgIndex-1,r.close(s.index),r.photos(t,!0,e)},s.event=function(){s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev(!0)}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext(!0)}),i(document).on("keyup",s.keyup)},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),a&&(t.anim=-1),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]'+function(){return u.length>1?'
"+s.imgIndex+" / "+u.length+"
":""}()+"",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("当前图片地址异常
是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.$),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define(["jquery"],function(){return o.run(e.jQuery),r}):function(){r.ready(),o.run(e.jQuery)}()}(window); \ No newline at end of file diff --git a/dist/mobile/layer.js b/dist/mobile/layer.js new file mode 100644 index 00000000..46d22550 --- /dev/null +++ b/dist/mobile/layer.js @@ -0,0 +1,2 @@ +/*! layer mobile-v2.0.0 Web 通用弹出层组件 MIT License */ + ;!function(e){"use strict";var t=document,n="querySelectorAll",i="getElementsByClassName",a=function(e){return t[n](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var n in e)t[n]=e[n];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var r=0,o=["layui-m-layer"],c=function(e){var t=this;t.config=l.extend(e),t.view()};c.prototype.view=function(){var e=this,n=e.config,s=t.createElement("div");e.id=s.id=o[0]+r,s.setAttribute("class",o[0]+" "+o[0]+(n.type||0)),s.setAttribute("index",r);var l=function(){var e="object"==typeof n.title;return n.title?'

'+(e?n.title[0]:n.title)+"

":""}(),c=function(){"string"==typeof n.btn&&(n.btn=[n.btn]);var e,t=(n.btn||[]).length;return 0!==t&&n.btn?(e=''+n.btn[0]+"",2===t&&(e=''+n.btn[1]+""+e),'
'+e+"
"):""}();if(n.fixed||(n.top=n.hasOwnProperty("top")?n.top:100,n.style=n.style||"",n.style+=" top:"+(t.body.scrollTop+n.top)+"px"),2===n.type&&(n.content='

'+(n.content||"")+"

"),n.skin&&(n.anim="up"),"msg"===n.skin&&(n.shade=!1),s.innerHTML=(n.shade?"
':"")+'
"+l+'
'+n.content+"
"+c+"
",!n.type||2===n.type){var d=t[i](o[0]+n.type),y=d.length;y>=1&&layer.close(d[0].getAttribute("index"))}document.body.appendChild(s);var u=e.elem=a("#"+e.id)[0];n.success&&n.success(u),e.index=r++,e.action(n,u)},c.prototype.action=function(e,t){var n=this;e.time&&(l.timer[n.index]=setTimeout(function(){layer.close(n.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),layer.close(n.index)):e.yes?e.yes(n.index):layer.close(n.index)};if(e.btn)for(var s=t[i]("layui-m-layerbtn")[0].children,r=s.length,o=0;odiv{line-height:22px;padding-top:7px;margin-bottom:20px;font-size:14px}.layui-m-layerbtn{display:box;display:-moz-box;display:-webkit-box;width:100%;height:50px;line-height:50px;font-size:0;border-top:1px solid #D0D0D0;background-color:#F2F2F2}.layui-m-layerbtn span{display:block;-moz-box-flex:1;box-flex:1;-webkit-box-flex:1;font-size:14px;cursor:pointer}.layui-m-layerbtn span[yes]{color:#40AFFE}.layui-m-layerbtn span[no]{border-right:1px solid #D0D0D0;border-radius:0 0 0 5px}.layui-m-layerbtn span:active{background-color:#F6F6F6}.layui-m-layerend{position:absolute;right:7px;top:10px;width:30px;height:30px;border:0;font-weight:400;background:0 0;cursor:pointer;-webkit-appearance:none;font-size:30px}.layui-m-layerend::after,.layui-m-layerend::before{position:absolute;left:5px;top:15px;content:'';width:18px;height:1px;background-color:#999;transform:rotate(45deg);-webkit-transform:rotate(45deg);border-radius:3px}.layui-m-layerend::after{transform:rotate(-45deg);-webkit-transform:rotate(-45deg)}body .layui-m-layer .layui-m-layer-footer{position:fixed;width:95%;max-width:100%;margin:0 auto;left:0;right:0;bottom:10px;background:0 0}.layui-m-layer-footer .layui-m-layercont{padding:20px;border-radius:5px 5px 0 0;background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn{display:block;height:auto;background:0 0;border-top:none}.layui-m-layer-footer .layui-m-layerbtn span{background-color:rgba(255,255,255,.8)}.layui-m-layer-footer .layui-m-layerbtn span[no]{color:#FD482C;border-top:1px solid #c2c2c2;border-radius:0 0 5px 5px}.layui-m-layer-footer .layui-m-layerbtn span[yes]{margin-top:10px;border-radius:5px}body .layui-m-layer .layui-m-layer-msg{width:auto;max-width:90%;margin:0 auto;bottom:-150px;background-color:rgba(0,0,0,.7);color:#fff}.layui-m-layer-msg .layui-m-layercont{padding:10px 20px} \ No newline at end of file diff --git a/dist/theme/default/icon-ext.png b/dist/theme/default/icon-ext.png new file mode 100644 index 00000000..bbbb669b Binary files /dev/null and b/dist/theme/default/icon-ext.png differ diff --git a/dist/theme/default/icon.png b/dist/theme/default/icon.png new file mode 100644 index 00000000..3e17da8b Binary files /dev/null and b/dist/theme/default/icon.png differ diff --git a/dist/theme/default/layer.css b/dist/theme/default/layer.css new file mode 100644 index 00000000..db51f318 --- /dev/null +++ b/dist/theme/default/layer.css @@ -0,0 +1 @@ +.layui-layer-imgbar,.layui-layer-imgtit a,.layui-layer-tab .layui-layer-title span,.layui-layer-title{text-overflow:ellipsis;white-space:nowrap}html #layuicss-layer{display:none;position:absolute;width:1989px}.layui-layer,.layui-layer-shade{position:fixed;_position:absolute;pointer-events:auto}.layui-layer-shade{top:0;left:0;width:100%;height:100%;_height:expression(document.body.offsetHeight+"px")}.layui-layer{-webkit-overflow-scrolling:touch;top:150px;left:0;margin:0;padding:0;background-color:#fff;-webkit-background-clip:content;border-radius:2px;box-shadow:1px 1px 50px rgba(0,0,0,.3)}.layui-layer-close{position:absolute}.layui-layer-content{position:relative}.layui-layer-border{border:1px solid #B2B2B2;border:1px solid rgba(0,0,0,.1);box-shadow:1px 1px 5px rgba(0,0,0,.2)}.layui-layer-load{background:url(loading-1.gif) center center no-repeat #eee}.layui-layer-ico{background:url(icon.png) no-repeat}.layui-layer-btn a,.layui-layer-dialog .layui-layer-ico,.layui-layer-setwin a{display:inline-block;*display:inline;*zoom:1;vertical-align:top}.layui-layer-move{display:none;position:fixed;*position:absolute;left:0;top:0;width:100%;height:100%;cursor:move;opacity:0;filter:alpha(opacity=0);background-color:#fff;z-index:2147483647}.layui-layer-resize{position:absolute;width:15px;height:15px;right:0;bottom:0;cursor:se-resize}.layer-anim{-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.3s;animation-duration:.3s}@-webkit-keyframes layer-bounceIn{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes layer-bounceIn{0%{opacity:0;-webkit-transform:scale(.5);-ms-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.layer-anim-00{-webkit-animation-name:layer-bounceIn;animation-name:layer-bounceIn}@-webkit-keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);-ms-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);-ms-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-01{-webkit-animation-name:layer-zoomInDown;animation-name:layer-zoomInDown}@-webkit-keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.layer-anim-02{-webkit-animation-name:layer-fadeInUpBig;animation-name:layer-fadeInUpBig}@-webkit-keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);-ms-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);-ms-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-03{-webkit-animation-name:layer-zoomInLeft;animation-name:layer-zoomInLeft}@-webkit-keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0) rotate(0);transform:translateX(0) rotate(0)}}@keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);-ms-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0) rotate(0);-ms-transform:translateX(0) rotate(0);transform:translateX(0) rotate(0)}}.layer-anim-04{-webkit-animation-name:layer-rollIn;animation-name:layer-rollIn}@keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn}@-webkit-keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);transform:translateX(10px)}}@keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);-ms-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);-ms-transform:translateX(10px);transform:translateX(10px)}}.layer-anim-06{-webkit-animation-name:layer-shake;animation-name:layer-shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.layui-layer-title{padding:0 80px 0 20px;height:50px;line-height:50px;border-bottom:1px solid #F0F0F0;font-size:14px;color:#333;overflow:hidden;border-radius:2px 2px 0 0}.layui-layer-setwin{position:absolute;right:15px;*right:0;top:17px;font-size:0;line-height:initial}.layui-layer-setwin a{position:relative;width:16px;height:16px;margin-left:10px;font-size:12px;_overflow:hidden}.layui-layer-setwin .layui-layer-min cite{position:absolute;width:14px;height:2px;left:0;top:50%;margin-top:-1px;background-color:#2E2D3C;cursor:pointer;_overflow:hidden}.layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA}.layui-layer-setwin .layui-layer-max{background-position:-32px -40px}.layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px}.layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px}.layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px}.layui-layer-setwin .layui-layer-close1{background-position:1px -40px;cursor:pointer}.layui-layer-setwin .layui-layer-close1:hover{opacity:.7}.layui-layer-setwin .layui-layer-close2{position:absolute;right:-28px;top:-28px;width:30px;height:30px;margin-left:0;background-position:-149px -31px;*right:-18px;_display:none}.layui-layer-setwin .layui-layer-close2:hover{background-position:-180px -31px}.layui-layer-btn{text-align:right;padding:0 15px 12px;pointer-events:auto;user-select:none;-webkit-user-select:none}.layui-layer-btn a{height:28px;line-height:28px;margin:5px 5px 0;padding:0 15px;border:1px solid #dedede;background-color:#fff;color:#333;border-radius:2px;font-weight:400;cursor:pointer;text-decoration:none}.layui-layer-btn a:hover{opacity:.9;text-decoration:none}.layui-layer-btn a:active{opacity:.8}.layui-layer-btn .layui-layer-btn0{border-color:#1E9FFF;background-color:#1E9FFF;color:#fff}.layui-layer-btn-l{text-align:left}.layui-layer-btn-c{text-align:center}.layui-layer-dialog{min-width:300px}.layui-layer-dialog .layui-layer-content{position:relative;padding:20px;line-height:24px;word-break:break-all;overflow:hidden;font-size:14px;overflow-x:hidden;overflow-y:auto}.layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute;top:16px;left:15px;_left:-40px;width:30px;height:30px}.layui-layer-ico1{background-position:-30px 0}.layui-layer-ico2{background-position:-60px 0}.layui-layer-ico3{background-position:-90px 0}.layui-layer-ico4{background-position:-120px 0}.layui-layer-ico5{background-position:-150px 0}.layui-layer-ico6{background-position:-180px 0}.layui-layer-rim{border:6px solid #8D8D8D;border:6px solid rgba(0,0,0,.3);border-radius:5px;box-shadow:none}.layui-layer-msg{min-width:180px;border:1px solid #D3D4D3;box-shadow:none}.layui-layer-hui{min-width:100px;background-color:#000;filter:alpha(opacity=60);background-color:rgba(0,0,0,.6);color:#fff;border:none}.layui-layer-hui .layui-layer-content{padding:12px 25px;text-align:center}.layui-layer-dialog .layui-layer-padding{padding:20px 20px 20px 55px;text-align:left}.layui-layer-page .layui-layer-content{position:relative;overflow:auto}.layui-layer-iframe .layui-layer-btn,.layui-layer-page .layui-layer-btn{padding-top:10px}.layui-layer-nobg{background:0 0}.layui-layer-iframe iframe{display:block;width:100%}.layui-layer-loading{border-radius:100%;background:0 0;box-shadow:none;border:none}.layui-layer-loading .layui-layer-content{width:60px;height:24px;background:url(loading-0.gif) no-repeat}.layui-layer-loading .layui-layer-loading1{width:37px;height:37px;background:url(loading-1.gif) no-repeat}.layui-layer-ico16,.layui-layer-loading .layui-layer-loading2{width:32px;height:32px;background:url(loading-2.gif) no-repeat}.layui-layer-tips{background:0 0;box-shadow:none;border:none}.layui-layer-tips .layui-layer-content{position:relative;line-height:22px;min-width:12px;padding:8px 15px;font-size:12px;_float:left;border-radius:2px;box-shadow:1px 1px 3px rgba(0,0,0,.2);background-color:#000;color:#fff}.layui-layer-tips .layui-layer-close{right:-2px;top:-1px}.layui-layer-tips i.layui-layer-TipsG{position:absolute;width:0;height:0;border-width:8px;border-color:transparent;border-style:dashed;*overflow:hidden}.layui-layer-tips i.layui-layer-TipsB,.layui-layer-tips i.layui-layer-TipsT{left:5px;border-right-style:solid;border-right-color:#000}.layui-layer-tips i.layui-layer-TipsT{bottom:-8px}.layui-layer-tips i.layui-layer-TipsB{top:-8px}.layui-layer-tips i.layui-layer-TipsL,.layui-layer-tips i.layui-layer-TipsR{top:5px;border-bottom-style:solid;border-bottom-color:#000}.layui-layer-tips i.layui-layer-TipsR{left:-8px}.layui-layer-tips i.layui-layer-TipsL{right:-8px}.layui-layer-lan[type=dialog]{min-width:280px}.layui-layer-lan .layui-layer-title{background:#4476A7;color:#fff;border:none}.layui-layer-lan .layui-layer-btn{padding:5px 10px 10px;text-align:right;border-top:1px solid #E9E7E7}.layui-layer-lan .layui-layer-btn a{background:#fff;border-color:#E9E7E7;color:#333}.layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5}.layui-layer-molv .layui-layer-title{background:#009f95;color:#fff;border:none}.layui-layer-molv .layui-layer-btn a{background:#009f95;border-color:#009f95}.layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1}.layui-layer-iconext{background:url(icon-ext.png) no-repeat}.layui-layer-prompt .layui-layer-input{display:block;width:260px;height:36px;margin:0 auto;line-height:30px;padding-left:10px;border:1px solid #e6e6e6;color:#333}.layui-layer-prompt textarea.layui-layer-input{width:300px;height:100px;line-height:20px;padding:6px 10px}.layui-layer-prompt .layui-layer-content{padding:20px}.layui-layer-prompt .layui-layer-btn{padding-top:0}.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4)}.layui-layer-tab .layui-layer-title{padding-left:0;overflow:visible}.layui-layer-tab .layui-layer-title span{position:relative;float:left;min-width:80px;max-width:300px;padding:0 20px;text-align:center;overflow:hidden;cursor:pointer}.layui-layer-tab .layui-layer-title span.layui-this{height:51px;border-left:1px solid #eee;border-right:1px solid #eee;background-color:#fff;z-index:10}.layui-layer-tab .layui-layer-title span:first-child{border-left:none}.layui-layer-tabmain{line-height:24px;clear:both}.layui-layer-tabmain .layui-layer-tabli{display:none}.layui-layer-tabmain .layui-layer-tabli.layui-this{display:block}.layui-layer-photos{background:0 0;box-shadow:none}.layui-layer-photos .layui-layer-content{overflow:hidden;text-align:center}.layui-layer-photos .layui-layer-phimg img{position:relative;width:100%;display:inline-block;*display:inline;*zoom:1;vertical-align:top}.layui-layer-imgnext,.layui-layer-imgprev{position:fixed;top:50%;width:27px;_width:44px;height:44px;margin-top:-22px;outline:0;blr:expression(this.onFocus=this.blur())}.layui-layer-imgprev{left:30px;background-position:-5px -5px;_background-position:-70px -5px}.layui-layer-imgprev:hover{background-position:-33px -5px;_background-position:-120px -5px}.layui-layer-imgnext{right:30px;_right:8px;background-position:-5px -50px;_background-position:-70px -50px}.layui-layer-imgnext:hover{background-position:-33px -50px;_background-position:-120px -50px}.layui-layer-imgbar{position:fixed;left:0;right:0;bottom:0;width:100%;height:40px;line-height:40px;background-color:#0009円;filter:Alpha(opacity=60);background-color:rgba(2,0,0,.35);color:#fff;overflow:hidden;font-size:0}.layui-layer-imgtit *{display:inline-block;*display:inline;*zoom:1;vertical-align:top;font-size:12px}.layui-layer-imgtit a{max-width:65%;overflow:hidden;color:#fff}.layui-layer-imgtit a:hover{color:#fff;text-decoration:underline}.layui-layer-imgtit em{padding-left:10px;font-style:normal}@-webkit-keyframes layer-bounceOut{100%{opacity:0;-webkit-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.05);transform:scale(1.05)}0%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes layer-bounceOut{100%{opacity:0;-webkit-transform:scale(.7);-ms-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.05);-ms-transform:scale(1.05);transform:scale(1.05)}0%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.layer-anim-close{-webkit-animation-name:layer-bounceOut;animation-name:layer-bounceOut;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.2s;animation-duration:.2s}@media screen and (max-width:1100px){.layui-layer-iframe{overflow-y:auto;-webkit-overflow-scrolling:touch}} \ No newline at end of file diff --git a/layer/skin/default/xubox_loading0.gif b/dist/theme/default/loading-0.gif similarity index 100% rename from layer/skin/default/xubox_loading0.gif rename to dist/theme/default/loading-0.gif diff --git a/layer/skin/default/xubox_loading1.gif b/dist/theme/default/loading-1.gif similarity index 100% rename from layer/skin/default/xubox_loading1.gif rename to dist/theme/default/loading-1.gif diff --git a/layer/skin/default/xubox_loading2.gif b/dist/theme/default/loading-2.gif similarity index 100% rename from layer/skin/default/xubox_loading2.gif rename to dist/theme/default/loading-2.gif diff --git a/dist/theme/moon/default.png b/dist/theme/moon/default.png new file mode 100644 index 00000000..77dfaf30 Binary files /dev/null and b/dist/theme/moon/default.png differ diff --git a/dist/theme/moon/style.css b/dist/theme/moon/style.css new file mode 100644 index 00000000..027dd1e0 --- /dev/null +++ b/dist/theme/moon/style.css @@ -0,0 +1 @@ +html #layui_layer_skinmoonstylecss{display:none;position:absolute;width:1989px}body .layer-ext-moon[type=dialog]{min-width:320px}body .layer-ext-moon-msg[type=dialog]{min-width:200px}body .layer-ext-moon .layui-layer-title{background:#f6f6f6;color:#212a31;font-size:16px;font-weight:700;height:46px;line-height:46px;border-bottom:1px solid #D5D5D5}body .layer-ext-moon .layui-layer-content .layui-layer-ico{height:32px;width:32px;top:18.5px}body .layer-ext-moon .layui-layer-ico0{background:url(default.png) -96px 0 no-repeat}body .layer-ext-moon .layui-layer-ico1{background:url(default.png) -224px 0 no-repeat}body .layer-ext-moon .layui-layer-ico2{background:url(default.png) -192px 0 no-repeat}body .layer-ext-moon .layui-layer-ico3{background:url(default.png) -160px 0 no-repeat}body .layer-ext-moon .layui-layer-ico4{background:url(default.png) -320px 0 no-repeat}body .layer-ext-moon .layui-layer-ico5{background:url(default.png) -288px 0 no-repeat}body .layer-ext-moon .layui-layer-ico6{background:url(default.png) -256px 0}body .layer-ext-moon .layui-layer-ico7{background:url(default.png) -128px 0 no-repeat}body .layer-ext-moon .layui-layer-setwin{top:15px;right:15px}body .layer-ext-moon .layui-layer-setwin a{width:16px;height:16px}body .layer-ext-moon .layui-layer-setwin .layui-layer-min cite:hover{background-color:#56abe4}body .layer-ext-moon .layui-layer-setwin .layui-layer-max{background:url(default.png) -80px 0 no-repeat}body .layer-ext-moon .layui-layer-setwin .layui-layer-max:hover{background:url(default.png) -64px 0 no-repeat}body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin{background:url(default.png) -32px 0 no-repeat}body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin:hover{background:url(default.png) -16px 0 no-repeat}body .layer-ext-moon .layui-layer-setwin .layui-layer-close1,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2{background:url(default.png)}body .layer-ext-moon .layui-layer-setwin .layui-layer-close1:hover,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2:hover{background:url(default.png) -48px 0}body .layer-ext-moon .layui-layer-padding{padding-top:24px}body .layer-ext-moon .layui-layer-btn{text-align:center;padding-top:15px;padding-bottom:15px;background:#f0f4f7;border-top:1px #c7c7c7 solid}body .layer-ext-moon .layui-layer-btn a{font-size:12px;font-weight:400;margin:0 7px;padding:6px 20px;color:#fff;border:1px solid #0064b6;background:no-repeat #0071ce;border-radius:3px;display:inline-block;height:20px;line-height:20px;text-align:center;vertical-align:middle;text-decoration:none;outline:0}body .layer-ext-moon .layui-layer-btn .layui-layer-btn0{background:#0071ce}body .layer-ext-moon .layui-layer-btn .layui-layer-btn1{background:#fff;color:#404a58;border:1px solid #c0c4cd;border-radius:3px}body .layer-ext-moon .layui-layer-btn .layui-layer-btn2{background:#f60;color:#fff;border:1px solid #f60;border-radius:3px}body .layer-ext-moon .layui-layer-btn .layui-layer-btn3{background:red;color:#fff;border:1px solid red;border-radius:3px}body .layer-ext-moon .layui-layer-title span.layui-layer-tabnow{height:47px} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..29814ace --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,85 @@ +/** + layer 构建 +*/ + +var pkg = require('./package.json'); + +var gulp = require('gulp'); +var uglify = require('gulp-uglify'); +var minify = require('gulp-minify-css'); +var rename = require('gulp-rename'); +var header = require('gulp-header'); +var del = require('del'); + +var task = { + layer: function() { + gulp.src('./src/**/*.css') + .pipe(minify({ + compatibility: 'ie7' + })) + .pipe(gulp.dest('./dist')); + + return gulp.src('./src/layer.js').pipe(uglify({ + output: { + ascii_only: true //escape Unicode characters in strings and regexps + } + })) + .pipe(header('/*! <%= pkg.realname %>-v<%= pkg.version %> <%= pkg.description %> <%= pkg.license %> License */\n ;', {pkg: pkg})) + .pipe(gulp.dest('./dist')); + + } + ,mobile: function() { + return gulp.src('./src/mobile/layer.js').pipe(uglify({ + output: { + ascii_only: true //escape Unicode characters in strings and regexps + } + })) + .pipe(header('/*! <%= pkg.realname %> mobile-v<%= pkg.mobile %> <%= pkg.description %> <%= pkg.license %> License */\n ;', {pkg: pkg})) + .pipe(gulp.dest('./dist/mobile')); + } + ,other: function(){ + gulp.src('./src/**/*.{png,gif}').pipe(rename({})) + .pipe(gulp.dest('./dist')); + } +}; + + +gulp.task('clear', function(cb){ //清理 + return del(['./dist/*'], cb); +}); +gulp.task('layer', task.minjs); //压缩PC版本 +gulp.task('mobile', task.mincss); //压缩Mobile文件 +gulp.task('other', task.other); //移动一些配件 + +//发行版本目录 +var releaseDir = './release/zip/layer-v' + pkg.version; +var release = releaseDir + '/layer'; + +//打包发行版 +gulp.task('clearZip', function(cb){ //清理 + return del([releaseDir], cb); +}); +gulp.task('r', ['clearZip'], function(){ + gulp.src('./release/doc/**/*') + .pipe(gulp.dest(releaseDir)); + + return gulp.src([ + './dist/**/*' + ,'!./dist/**/moon' + ,'!./dist/**/moon/*' + ]) + .pipe(gulp.dest(release)); +}); + +//全部 +gulp.task('default', ['clear'], function(){ + for(var key in task){ + task[key](); + } +}); + + + + + + diff --git a/layer/extend/layer.ext.js b/layer/extend/layer.ext.js deleted file mode 100644 index 3c6223ea..00000000 --- a/layer/extend/layer.ext.js +++ /dev/null @@ -1,372 +0,0 @@ -/** - - @Name: layer拓展类,依赖于layer - @Date: 2014年05月16日 - @Author: 贤心 - @Versions:1.3 - @Api:http://sentsin.com/jquery/layer - @Desc: 本拓展会持续更新 - - **/ - -layer.use('skin/layer.ext.css', function(){ - layer.ext && layer.ext(); -}); - -layer.extv = '1.3'; - - -/** - - 系统prompt - 2014年5月11日 - By 贤心 - -**/ - -layer.prompt = function(parme, yes, no){ - var log = {}, parme = parme || {}, conf = { - area: ['auto', 'auto'], - offset: [parme.top || '200px', ''], - title: parme.title || '信息', - dialog: { - btns: 2, - type: -1, - msg: '', - yes: function(index){ - var val = log.prompt.val(); - if(val === ''){ - log.prompt.focus(); - } else if(val.replace(/\s/g, '').length> (parme.length || 1000)) { - layer.tips('最多输入'+ (parme.length || 1000) +'个字数', '#xubox_prompt', 2); - } else { - layer.close(index); - yes && yes(val); - } - - }, no: no - }, success: function(){ - log.prompt = $('#xubox_prompt'); - } - }; - if(parme.type === 3){ - conf.dialog.msg = '' - } - return $.layer(conf); -}; - - -/** - - tab层 v1.0.0 - 2014年5月11日 - By 贤心 - -**/ - -layer.tab = function(parme){ - var log = {}, parme = parme || {}, data = parme.data || [], conf = { - type: 1, - border: [0], - area: ['auto', 'auto'], - title: false, - shade : parme.shade, - offset: parme.offset, - move: '.xubox_tabmove', - closeBtn: false, - page: {html: '
'; - }() - +'' - +'
' - +function(){ - var len = data.length, ii = 1, str = ''; - if(len> 0){ - str = ''+ data[0].title +''; - for(; ii < len; ii++){ - str += ''+ data[ii].title +''; - } - } - return str; - }() +'
' - +'
    '+ function(){ - var len = data.length, ii = 1, str = ''; - if(len> 0){ - str = '
  • '+ (data[0].content || 'content未传入') +'
  • '; - for(; ii < len; ii++){ - str += '
  • '+ (data[ii].content || 'content未传入') +'
  • '; - } - } - return str; - }() +'
' - +'X' - +'
' - }, success: function(layerE){ - //切换事件 - var btn = $('.xubox_tabtit').children(), main = $('.xubox_tab_main').children(), close = $('.xubox_tabclose'); - btn.on('click', function(){ - var othis = $(this), index = othis.index(); - othis.addClass('xubox_tabnow').siblings().removeClass('xubox_tabnow'); - main.eq(index).show().siblings().hide(); - }); - //关闭层 - close.on('click', function(){ - layer.close(layerE.attr('times')); - }); - } - }; - return $.layer(conf); -}; - - - -/** - - 相册层 v1.0.0 - 2014年5月11日 - By 贤心 - -**/ - - -layer.photos = function(options){ - options = options || {}; - var log = { - imgIndex: 1, - end: null, - html: $('html') - }, win = $(window), json = options.json, page = options.page; - - if(json){ - var data = json.data; - if(json.status === 1){ - log.imgLen = data.length; - if(data.length> 0){ - log.thissrc = data[json.start].src; - log.pid = data[json.start].pid; - log.imgsname = (json.title || ''); - log.name = data[json.start].name; - log.imgIndex = json.start + 1; - } else { - layer.msg('没有任何图片', 2, 8); - return; - } - - } else { - layer.msg('未请求到数据', 2, 8); - return; - } - } else { - var imgs = $(page.parent).find('img'), nowimg = imgs.eq(page.start); - log.thissrc = (nowimg.attr('layer-img') || nowimg.attr('src')); - log.pid = nowimg.attr('pid'); - log.imgLen = imgs.length; - log.imgsname = (page.title || ''); - log.name = nowimg.attr('layer-pname'); - log.imgIndex = page.start + 1; - } - - var conf = { - type: 1, - border: [0], - area: [(options.html ? 915 : 600) + 'px', 'auto'], - title: false, - shade: [0.9, '#000', true], - shadeClose: true, - offset: ['25px', ''], - bgcolor: '', - page: { - html: '
'+ (log.name || '') +'
'+ function(){ - if(log.imgLen> 1){ - return '' - } else { - return ''; - } - }() +'
'+ log.imgIndex +'/'+ log.imgLen +'
'+ function(){ - if(options.html){ - return '
'+ options.html +'
'; - } else { - return ''; - } - }() - }, success: function(layero){ - log.bigimg = layero.find('.xubox_bigimg'); - log.imgsee = log.bigimg.find('.xubox_imgsee'); - log.imgbar = log.imgsee.find('.xubox_imgbar'); - log.imgtit = log.imgbar.find('.xubox_imgtit'); - log.layero = layero; - - var img = log.imgs = log.bigimg.find('img'); - - clearTimeout(log.timerr); - log.timerr = setTimeout(function(){ - $('html').css('overflow', 'hidden').attr('layer-full', log.index); - }, 10); - - img.load(function(){ - log.imgarea = [img.outerWidth(), img.outerHeight()]; - log.resize(layero); - options.success && options.success(json || page); - }); - - log.event(); - - }, end: function(){ - layer.closeAll(); - log.end = true; - } - }; - - //一些动作 - log.event = function(){ - log.bigimg.hover(function(){ - log.imgsee.show(); - }, function(){ - log.imgsee.hide(); - }); - - //上一张 - conf.imgprev = function(){ - log.imgIndex--; - if(log.imgIndex < 1){ - log.imgIndex = log.imgLen; - } - log.tabimg(); - }; - log.bigimg.find('.xubox_prev').on('click', function(event){ - event.preventDefault(); - conf.imgprev(); - }); - - //下一张 - conf.imgnext = function(){ - log.imgIndex++; - if(log.imgIndex> log.imgLen){ - log.imgIndex = 1; - } - log.tabimg() - }; - log.bigimg.find('.xubox_next').on('click', function(event){ - event.preventDefault(); - conf.imgnext(); - }); - - //方向键 - $(document).keyup(function(event){ - if(!log.end){ - var code = event.keyCode; - event.preventDefault(); - if(code === 37){ - conf.imgprev(); - } else if(code === 39) { - conf.imgnext(); - } else if(code === 27) { - layer.close(log.index); - } - } - }); - - - log.tabimg = function(){ - var timer, src, pid, name; - log.imgs.removeAttr('style'); - if(json){ - var nowdata = data[log.imgIndex - 1]; - src = nowdata.src; - pid = nowdata.pid; - name = nowdata.name; - } else { - var thisimg = imgs.eq(log.imgIndex - 1); - src = thisimg.attr('layer-img') || thisimg.attr('src'); - pid = thisimg.attr('layer-pid') || ''; - name = thisimg.attr('layer-pname') || ''; - } - log.imgs.attr({ - src: src, - 'layer-pid': pid, - alt: name - }); - log.imgtit.find('em').text(log.imgIndex + '/' + log.imgLen); - log.imgsee.show(); - } - }; - - //相册响应式 - log.resize = function(layero){ - var relog = {}, wa = [win.width(), win.height()]; - relog.limit = wa[0] - wa[0]/wa[1]*(60*wa[0]/wa[1]); - if(relog.limit < 600){ - relog.limit = 600; - } - var area = [relog.limit, wa[1]> 400 ? wa[1] - 50 : 400]; - area[0] = options.html ? area[0] : (area[0] - 300); - layer.area(log.index, { - width: area[0] + (options.html ? 15 : 0), - height: area[1] - }); - relog.flwidth = area[0] - (options.html ? 300 : 0); - if(log.imgarea[0]> relog.flwidth){ - log.imgs.css({width: relog.flwidth}); - } else { - log.imgs.css({width: log.imgarea[0]}); - } - if(log.imgs.outerHeight() < area[1]){ - log.imgs.css({top: (area[1] - log.imgs.outerHeight())/2}); - } - log.imgs.css({visibility: 'visible'}); - log.bigimg.css({width: relog.flwidth, height: area[1], 'background-color': options.bgcolor}); - if(options.html){ - layero.find('.xubox_intro').css({height: area[1]}); - } - relog = null; - wa = null; - area = null; - }; - - win.on('resize', function(){ - if(log.end){ - return; - } - if(log.timer){ - clearTimeout(log.timer); - } - log.timer = setTimeout(function(){ - log.resize(log.layero); - }, 200); - }); - - log.index = $.layer(conf); - return log.index; -}; - -//获取页面元素包含的所有图片,快捷调用 -layer.photosPage = function(options){ - var log = {}; - log.run = function(index){ - layer.photos({ - html: options.html, - success: options.success, - page: { - title: options.title, - id: options.id, - start: index, - parent: options.parent - } - }); - }; - options = options || {}; - $(options.parent).find('img').each(function(index){ - $(this).on('click', function(){ - log.run(index); - }); - }); -}; diff --git a/layer/layer.js b/layer/layer.js deleted file mode 100644 index a168576b..00000000 --- a/layer/layer.js +++ /dev/null @@ -1,908 +0,0 @@ -/************************************************************** - - @Name:layer v1.8.3 弹层组件开发版 - @Author:贤心 - @Date:2014-06-04 - @Blog:http://sentsin.com - @QQ群:78803422 (layer组件群3) - @Copyright:Sentsin Xu(贤心) - @官网:http://sentsin.com/jquery/layer - @授权:http://url.cn/RAejZY - - *************************************************************/ - -;!function(window, undefined){ -"use strict"; - -var pathType = true, //是否采用自动获取绝对路径。false:将采用下述变量中的配置 -pathUrl = '/lily/lib/layer/', //上述变量为false才有效,当前layerjs所在目录(不用填写host,相对站点的根目录即可)。 - -,ドル win, ready = { - host: 'http://' + location.host, - getPath: function(){ - var js = document.scripts, jsPath = js[js.length - 1].src; - if(pathType){ - return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); - } else { - return this.host + pathUrl; - } - }, - - //五种原始层模式 - type: ['dialog', 'page', 'iframe', 'loading', 'tips'] -}; - -//默认内置方法。 -window.layer = { - v: '1.8.3', //版本号 - 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.type = 'text/css'; - node.rel = 'stylesheet'; - } - node[iscss ? 'href' : 'src'] = /^http:\/\//.test(module) ? module : layer.path + module; - node.id = id; - if(!$('#'+ id)[0]){ - head.appendChild(node); - } - if(callback){ - if(document.all){ - $(node).ready(callback); - } else { - $(node).load(callback); - } - } - }, - - ready: function(callback){ - layer.use('skin/layer.css', callback); - }, - - alert: function(msg, icon, fn, yes){ - var isfn = (typeof fn === 'function'), conf = { - dialog: {msg: msg, type: icon, yes: isfn ? fn : yes}, - area: ['auto', 'auto'] - }; - isfn || (conf.title = fn); - return $.layer(conf); - }, - - confirm: function(msg, yes, fn, no){ - var isfn = (typeof fn === 'function'), conf = { - dialog: {msg: msg, type: 4, btns: 2, yes: yes, no: isfn ? fn : no} - }; - isfn || (conf.title = fn); - return $.layer(conf); - }, - - msg: function(msg, time, parme, end){ - var conf = { - title: false, - closeBtn: false, - time: time === undefined ? 2 : time, - dialog: {msg: (msg === '' || msg === undefined) ? ' ' : msg}, - end: end - }; - if(typeof parme === 'object'){ - conf.dialog.type = parme.type; - conf.shade = parme.shade; - conf.success = function(){layer.shift(parme.rate)}; - } else if(typeof parme === 'function') { - conf.end = parme - } else { - conf.dialog.type = parme; - } - return $.layer(conf); - }, - - //加载层快捷引用 - load: function(parme, icon){ - if(typeof parme === 'string'){ - return layer.msg(parme, icon || 0, 16); - } else { - return $.layer({ - time: parme, - loading: {type : icon}, - bgcolor: icon ? '#fff' : '', - shade: icon ? [0.1, '#000'] : [0], - border: (icon === 3 || !icon) ? false : [6, 0.3, '#000'], - 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 doms = {lay: 'xubox_layer', ifr: 'xubox_iframe', title: '.xubox_title', text: '.xubox_text', page: '.xubox_page'}; - -var Class = function(setings){ - var that = this, config = that.config; - layer.index++; - that.index = layer.index; - that.config = $.extend({} , config , setings); - that.config.dialog = $.extend({}, config.dialog , setings.dialog); - that.config.page = $.extend({}, config.page , setings.page); - that.config.iframe = $.extend({}, config.iframe , setings.iframe); - that.config.loading = $.extend({}, config.loading , setings.loading); - that.config.tips = $.extend({}, config.tips , setings.tips); - that.creat(); -}; - -Class.pt = Class.prototype; - -//默认配置 -Class.pt.config = layer.config || { - type: 0, - shade: [0.3, '#000'], - shadeClose: false, - fix: true, - move: '.xubox_title', - moveOut: false, - title: ['信息', true], - offset: ['200px', '50%'], - area: ['310px', 'auto'], - closeBtn: [0, true], - time: 0, - bgcolor: '#fff', - border: [6, 0.3, '#000'], - zIndex: 19891014, - maxWidth: 400, - dialog: {btns : 1, btn : ['确定','取消'], type : 8, msg : '', yes : function(index){ layer.close(index);}, no : function(index){ layer.close(index);} - }, - page: {dom: '#xulayer', html: '', url: ''}, - iframe: {src: 'http://sentsin.com', scrolling: 'auto'}, - 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.space = function(html){ - var that = this, html = html || '', times = that.index, config = that.config, dialog = config.dialog, - ico = dialog.type === -1 ? '' : '', - frame = [ - '
'+ ico +'' + dialog.msg + '
', - '
'+ html +'
', - '[フレーム]', - '', - '
'+ config.tips.msg +'
' - ], - 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[0] && (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[0] && (border = '
'); - - if(config.maxmin && (config.type === 1 || config.type === 2) && (!/^\d+%$/.test(config.area[0]) || !/^\d+%$/.test(config.area[1]))){ - closebtn = ''; - } - config.closeBtn[1] && (closebtn += ''); - - config.title[1] && (title = '
' + config.title[0] + '
'); - return [shade, - '
' - + '
' - + frame[config.type] - + title - + ''+ closebtn + '' - + '' - + '
'+ border + '
' - ]; -}; - -//创建骨架 -Class.pt.creat = function(){ - var that = this , space = '', config = that.config, dialog = config.dialog, times = that.index; - var page = config.page, body = $("body"), setSpace = function(html){ - var html = html || ''; - space = that.space(html); - body.append($(space[0])); - }; - if(config.title === false){ - config.title = []; - } else if(typeof config.title === 'string') { - config.title = [config.title, true] - } - switch(config.type){ - case 0: - config.title[1] || (config.area = ['auto','auto']); - $('.xubox_dialog')[0] && layer.close($('.xubox_dialog').parents('.'+ doms.lay).attr('times')); - break; - - 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.toString()); - page.ok && page.ok(datas); - }); - } else { - if($(page.dom).parents(doms.page).length == 0){ - setSpace(); - $(page.dom).show().wrap($(space[1])); - } else { - return; - } - } - break; - - case 3: - config.title = []; - config.area = ['auto', 'auto']; - config.closeBtn = ['', false]; - $('.xubox_loading')[0] && layer.close($('.xubox_loading').parents('.'+ doms.lay).attr('times')); - break; - - case 4: - config.title = []; - config.area = ['auto', 'auto']; - config.fix = false; - config.border = [0]; - $('.xubox_tips')[0] && layer.close($('.xubox_tips').parents('.'+ doms.lay).attr('times')); - break; - }; - if(config.type !== 1){ - setSpace(); - body.append($(space[1])); - } - - var layerE = that.layerE = $('#'+ doms.lay + times); - - //设置layer面积坐标等数据 - if(config.offset[0].indexOf("px") != -1){ - that.offsetTop = parseFloat(config.offset[0]); - } else { - that.offsetTop = parseFloat(config.offset[0])/100 * win.height(); - } - that.offsetTop = that.offsetTop + config.border[0] + (config.fix ? 0 : win.scrollTop()); - if(config.offset[1].indexOf("px") != -1){ - that.offsetLeft = parseFloat(config.offset[1]) + config.border[0]; - } else { - config.offset[1] = config.offset[1] === '' ? '50%' : config.offset[1]; - if(config.offset[1] === '50%'){ - that.offsetLeft = config.offset[1]; - }else{ - that.offsetLeft = parseFloat(config.offset[1])/100 * win.width() + config.border[0]; - } - }; - layerE.css({left: that.offsetLeft, top: that.offsetTop, width: config.area[0], height: config.area[1]}); - config.fix || layerE.css({position: 'absolute'}); - - //配置按钮 - if(config.title[1] && (config.type !== 3 || config.type !== 4)){ - var confbtn = config.type === 0 ? dialog : config, layerBtn = layerE.find('.xubox_botton'); - confbtn.btn = config.btn || dialog.btn; - switch(confbtn.btns){ - case 0: - layerBtn.html('').hide(); - break; - case 1: - layerBtn.html(''); - break; - case 2: - layerBtn.html('' + ''); - break; - } - } - - if(layerE.css('left') === 'auto'){ - layerE.hide(); - setTimeout(function(){ - layerE.show(); - that.set(times); - }, 500); - }else{ - that.set(times); - } - config.time <= 0 || that.autoclose(); - that.callback(); -}; - -ready.fade = function(obj, time, opa){ - obj.css({opacity: 0}).animate({opacity: opa}, time); -}; - -//初始化骨架 -Class.pt.set = function(times){ - var that = this, layerE = that.layerE, layerTitle = layerE.find(doms.title); - var config = that.config, dialog = config.dialog, page = config.page, loading = config.loading; - that.autoArea(times); - if(config.title[1]){ - if(config.type === 0){ - layer.ie6 && layerTitle.css({width : layerE.outerWidth()}); - } - }else{ - config.type != 4 && layerE.find('.xubox_close').addClass('xubox_close1'); - }; - - layerE.attr({'type' : ready.type[config.type]}); - - switch(config.type){ - case 0: - layerE.find('.xubox_main').css({'background-color': '#fff'}); - if(config.title[1]){ - layerE.find(doms.text).css({paddingTop: 18 + layerTitle.outerHeight()}); - }else{ - layerE.find('.xubox_msgico').css({top: 8}); - layerE.find(doms.text).css({marginTop : 11}); - } - break; - - case 1: - layerE.find(page.dom).addClass('layer_pageContent'); - config.shade[0] && layerE.css({zIndex: config.zIndex + 1}); - config.title[1] && layerE.find(doms.page).css({top: layerTitle.outerHeight()}); - break; - - case 2: - var iframe = layerE.find('.'+ doms.ifr), heg = layerE.height(); - iframe.addClass('xubox_load').css({width: layerE.width()}); - config.title[1] ? iframe.css({top: layerTitle.height(), height: heg - layerTitle.height()}) : iframe.css({top: 0, height : heg}); - layer.ie6 && iframe.attr('src', config.iframe.src); - 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; - }; - - if(config.fadeIn){ - ready.fade(layerE, config.fadeIn, 1); - ready.fade($('#xubox_shade'+ times), config.fadeIn, config.shade[0]); - } - that.move(); -}; - -//自适应宽高 -Class.pt.autoArea = function(times){ - var that = this, times = times || that.index, config = that.config, page = config.page; - var layerE = $('#'+ doms.lay + times), layerTitle = layerE.find(doms.title), layerMian = layerE.find('.xubox_main'); - var titHeight = config.title[1] ? layerTitle.innerHeight() : 0, outHeight, btnHeight = 0; - if(config.area[0] === 'auto' && layerMian.outerWidth()>= config.maxWidth){ - layerE.css({width : config.maxWidth}); - } - switch(config.type){ - case 0: - var aBtn = layerE.find('.xubox_botton>a'); - outHeight = layerE.find(doms.text).outerHeight() + 20; - if(aBtn.length> 0){ - btnHeight = aBtn.outerHeight() + 20; - } - break; - case 1: - var layerPage = layerE.find(doms.page); - outHeight = $(page.dom).outerHeight(); - config.area[0] === 'auto' && layerE.css({width : layerPage.outerWidth()}); - if(page.html !== '' || page.url !== ''){ - outHeight = layerPage.outerHeight(); - } - break; - case 2: - layerE.find('iframe').css({width: layerE.outerWidth(), height: layerE.outerHeight() - (config.title[1] ? layerTitle.innerHeight() : 0)}); - break; - case 3: - var load = layerE.find(".xubox_loading"); - outHeight = load.outerHeight(); - layerMian.css({width: load.width()}); - break; - }; - (config.area[1] === 'auto') && layerMian.css({height: titHeight + outHeight + btnHeight}); - $('#xubox_border' + times).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 = that.config, 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 && that.layerE.find(config.move).attr('move','ok'); - config.move ? that.layerE.find(config.move).css({cursor: 'move'}) : that.layerE.find(config.move).css({cursor: 'auto'}); - - $(config.move).on('mousedown', function(M){ - M.preventDefault(); - if($(this).attr('move') === 'ok'){ - conf.ismove = true; - conf.layerE = $(this).parents('.'+ doms.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 = that.config.time, maxLoad = function(){ - time--; - if(time === 0){ - layer.close(that.index); - clearInterval(that.autotime); - } - }; - that.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); - - layerE.find('.xubox_close').on('click', function(){ - config.close(that.index); - layer.close(that.index); - }); - - layerE.find('.xubox_yes').on('click',function(){ - config.yes ? config.yes(that.index) : dialog.yes(that.index); - }); - - layerE.find('.xubox_no').on('click',function(){ - config.no ? config.no(that.index) : dialog.no(that.index); - layer.close(that.index); - }); - - if(that.config.shadeClose){ - $('#xubox_shade'+ that.index).on('click', function(){ - layer.close(that.index); - }); - } - - //最小化 - layerE.find('.xubox_min').on('click', function(){ - layer.min(that.index, config); - config.min && config.min(layerE); - }); - - //全屏/还原 - layerE.find('.xubox_max').on('click', function(){ - if($(this).hasClass('xubox_maxmin')){ - layer.restore(that.index); - config.restore && config.restore(layerE); - } else { - layer.full(that.index, config); - config.full && config.full(layerE); - } - }); - - ready.config.end[that.index] = config.end; -}; - -//恢复select -ready.reselect = function(){ - $.each($('select'), function(index , value){ - var sthis = $(this); - if(!sthis.parents('.'+doms.lay)[0]){ - (sthis.attr('layer') == 1 && $('.'+doms.lay).length < 1) && sthis.removeAttr('layer').show(); - } - sthis = null; - }); -}; - -Class.pt.IE6 = function(layerE){ - var that = this; - var _ieTop = layerE.offset().top; - //ie6的固定与相对定位 - if(that.config.fix){ - var ie6Fix = function(){ - layerE.css({top : win.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('.'+doms.lay)[0]){ - sthis.css('display') == 'none' || sthis.attr({'layer' : '1'}).hide(); - } - sthis = null; - }); -}; - -//给layer对象拓展方法 -Class.pt.openLayer = function(){ - var that = this; - - //自适应宽高 - layer.autoArea = function(index){ - return that.autoArea(index); - }; - - //出场内置动画 - layer.shift = function(type, rate, stop){ - if(layer.ie6){ - return; - } - var config = that.config, layerE = that.layerE, cutWth = 0, ww = win.width(), wh = win.height() + (config.fix ? 0 : win.scrollTop()); - (config.offset[1] == '50%' || config.offset[1] == '') ? cutWth = layerE.outerWidth()/2 : cutWth = layerE.outerWidth(); - var anim = { - t: {top: that.offsetTop}, - b: {top : wh - layerE.outerHeight() - config.border[0]}, - cl: cutWth + config.border[0], - ct: -layerE.outerHeight(), - cr: ww - cutWth - config.border[0] - }; - switch(type){ - case 'left-top': layerE.css({left: anim.cl, top: anim.ct}).animate(anim.t, rate); - break; - case 'top': layerE.css({top: anim.ct}).animate(anim.t, rate); - break; - case 'right-top': layerE.css({left: anim.cr, top: anim.ct}).animate(anim.t, rate); - break; - case 'right-bottom': layerE.css({left: anim.cr, top: wh}).animate(stop ? anim.t : anim.b, rate); - break; - case 'bottom': layerE.css({top: wh}).animate(stop ? anim.t : anim.b, rate); - break; - case 'left-bottom': layerE.css({left: anim.cl, top: wh}).animate(stop ? anim.t : anim.b, rate); - break; - case 'left': layerE.css({left: -layerE.outerWidth()}).animate({left: that.offsetLeft}, rate); - break; - } - }; - - //初始化拖拽元素 - layer.setMove = function(){ - return that.move(); - }; - - //置顶当前窗口 - 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.isauto = function(layero, options, offset){ - options.area[0] === 'auto' && (options.area[0] = layero.outerWidth()); - options.area[1] === 'auto' && (options.area[1] = layero.outerHeight()); - layero.attr({area: options.area + ',' + offset}); - layero.find('.xubox_max').addClass('xubox_maxmin'); -}; - -ready.rescollbar = function(index){ - if(doms.html.attr('layer-full') == index){ - if(doms.html[0].style.removeProperty){ - doms.html[0].style.removeProperty('overflow'); - } else { - doms.html[0].style.removeAttribute('overflow'); - } - doms.html.removeAttr('layer-full'); - } -}; - - -/** - * 集成属性/方法 - **/ - - -//获取page层所在索引 -layer.getIndex = function(selector){ - return $(selector).parents('.'+doms.lay).attr('times'); -}; - -//获取子iframe的DOM -layer.getChildFrame = function(selector, index){ - index = index || $('.'+ doms.ifr).parents('.'+doms.lay).attr('times'); - return $('#'+ doms.lay + index).find('.'+ doms.ifr).contents().find(selector); -}; - -//得到当前iframe层的索引,子iframe时使用 -layer.getFrameIndex = function(name){ - return $(name ? '#'+ name : '.'+ doms.ifr).parents('.'+doms.lay).attr('times'); -}; - -//iframe层自适应宽高 -layer.iframeAuto = function(index){ - index = index || $('.'+ doms.ifr).parents('.'+doms.lay).attr('times'); - var heg = layer.getChildFrame('body', index).outerHeight(), - layero = $('#'+ doms.lay + index), tit = layero.find(doms.title), titHt = 0; - tit && (titHt = tit.height()); - layero.css({height: heg + titHt}); - var bs = -parseInt($('#xubox_border'+ index).css('top')); - $('#xubox_border'+ index).css({height: heg + 2*bs + titHt}); - $('#'+ doms.ifr + index).css({height: heg}); -}; - -//重置iframe url -layer.iframeSrc = function(index, url){ - $('#'+ doms.lay + index).find('iframe').attr('src', url); -}; - -//重置层 -layer.area = function(index, options){ - var layero = [$('#'+ doms.lay + index), $('#xubox_border'+ index)], - type = layero[0].attr('type'), main = layero[0].find('.xubox_main'), - title = layero[0].find(doms.title); - - if(type === ready.type[1] || type === ready.type[2]){ - layero[0].css(options); - main.css({width: options.width, height: options.height}); - if(type === ready.type[2]){ - var iframe = layero[0].find('iframe'); - iframe.css({width: options.width, height: title ? options.height - title.innerHeight() : options.height}); - } - if(layero[0].css('margin-left') !== '0px') { - options.hasOwnProperty('top') && layero[0].css({top: options.top - (layero[1][0] ? parseFloat(layero[1].css('top')) : 0)}); - options.hasOwnProperty('left') && layero[0].css({left: options.left + layero[0].outerWidth()/2 - (layero[1][0] ? parseFloat(layero[1].css('left')) : 0)}); - layero[0].css({marginLeft : -layero[0].outerWidth()/2}); - } - if(layero[1][0]){ - layero[1].css({ - width: parseFloat(options.width) - 2*parseFloat(layero[1].css('left')), - height: parseFloat(options.height) - 2*parseFloat(layero[1].css('top')) - }); - } - } -}; - -//最小化 -layer.min = function(index, options){ - var layero = $('#'+ doms.lay + index), offset = [layero.position().top, layero.position().left + parseFloat(layero.css('margin-left'))]; - ready.isauto(layero, options, offset); - layer.area(index, {width: 180, height: 35}); - layero.find('.xubox_min').hide(); - layero.attr('type') === 'page' && layero.find(doms.page).hide(); - ready.rescollbar(index); -}; - -//还原 -layer.restore = function(index){ - var layero = $('#'+ doms.lay + index), area = layero.attr('area').split(','); - var type = layero.attr('type'); - layer.area(index, { - width: parseFloat(area[0]), - height: parseFloat(area[1]), - top: parseFloat(area[2]), - left: parseFloat(area[3]) - }); - layero.find('.xubox_max').removeClass('xubox_maxmin'); - layero.find('.xubox_min').show(); - layero.attr('type') === 'page' && layero.find(doms.page).show(); - ready.rescollbar(index); -}; - -//全屏 -layer.full = function(index, options){ - var layero = $('#'+ doms.lay + index), borders = options.border[0]*2, timer; - var offset = [layero.position().top, layero.position().left + parseFloat(layero.css('margin-left'))]; - ready.isauto(layero, options, offset); - if(!doms.html.attr('layer-full')){ - doms.html.css('overflow','hidden').attr('layer-full', index); - } - clearTimeout(timer); - timer = setTimeout(function(){ - layer.area(index, { - top: layero.css('position') === 'fixed' ? 0 : win.scrollTop(), - left: layero.css('position') === 'fixed' ? 0 : win.scrollLeft(), - width: win.width() - borders, - height: win.height() - borders - }); - }, 100); -}; - -//关闭layer总方法 -layer.close = function(index){ - var layero = $('#'+ doms.lay + index), type = layero.attr('type'), shadeNow = $('#xubox_moves, #xubox_shade' + index); - if(!layero[0]){ - return; - } - if(type == ready.type[1]){ - if(layero.find('.xuboxPageHtml')[0]){ - layero[0].innerHTML = ''; - layero.remove(); - }else{ - layero.find('.xubox_setwin,.xubox_close,.xubox_botton,.xubox_title,.xubox_border').remove(); - for(var i = 0 ; i < 3 ; i++){ - layero.find('.layer_pageContent').unwrap().hide(); - } - } - }else{ - layero[0].innerHTML = ''; - layero.remove(); - } - shadeNow.remove(); - layer.ie6 && ready.reselect(); - ready.rescollbar(index); - typeof ready.config.end[index] === 'function' && ready.config.end[index](); - delete ready.config.end[index]; -}; - -//关闭loading层 -layer.closeLoad = function(){ - layer.close($('.xubox_loading').parents('.'+doms.lay).attr('times')); -}; - -//关闭tips层 -layer.closeTips = function(){ - layer.close($('.xubox_tips').parents('.'+doms.lay).attr('times')); -}; - -//关闭所有层 -layer.closeAll = function(){ - $.each($('.'+doms.lay), function(){ - layer.close($(this).attr('times')); - }); -}; - - -//主入口 -ready.run = function(){ - $ = jQuery; - win = $(window); - doms.html = $('html'); - layer.use('skin/layer.css'); - $.layer = function(deliver){ - var o = new Class(deliver); - return o.index; - }; - (new Image()).src = layer.path + 'skin/default/xubox_ico0.png'; -}; - -//为支持seajs模块加载 -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); \ No newline at end of file diff --git a/layer/layer.min.js b/layer/layer.min.js deleted file mode 100644 index f0d41588..00000000 --- a/layer/layer.min.js +++ /dev/null @@ -1,19 +0,0 @@ -/************************************************************** - - @Name:layer v1.8.3 弹层组件压缩版 - @Author:贤心 - @Date:2014-06-04 - @Blog:http://sentsin.com - @QQ群:78803422 (layer组件群3) - @Copyright:Sentsin Xu(贤心) - @官网:http://sentsin.com/jquery/layer - @授权:http://url.cn/RAejZY - - *************************************************************/ - -;!function(a,b){ -"use strict"; -var e,f,h,i,j, -c=!0, //是否采用自动获取绝对路径。!1:将采用下述变量中的配置 -d="/lily/lib/layer/", //上述变量为!1才有效,当前layerjs所在目录(不用填写host,相对站点的根目录即可)。 -g={host:"http://"+location.host,getPath:function(){var a=document.scripts,b=a[a.length-1].src;return c?b.substring(0,b.lastIndexOf("/")+1):this.host+d},type:["dialog","page","iframe","loading","tips"]};a.layer={v:"1.8.3",ie6:!-[1,]&&!a.XMLHttpRequest,index:0,path:g.getPath(),use:function(a,b){var f,g,h,d=e("head")[0];a=a.replace(/\s/g,""),f=/\.css$/.test(a),g=document.createElement(f?"link":"script"),h=a.replace(/\.|\//g,""),f&&(g.type="text/css",g.rel="stylesheet"),g[f?"href":"src"]=/^http:\/\//.test(a)?a:layer.path+a,g.id=h,e("#"+h)[0]||d.appendChild(g),b&&(document.all?e(g).ready(b):e(g).load(b))},ready:function(a){layer.use("skin/layer.css",a)},alert:function(a,b,c,d){var f="function"==typeof c,g={dialog:{msg:a,type:b,yes:f?c:d},area:["auto","auto"]};return f||(g.title=c),e.layer(g)},confirm:function(a,b,c,d){var f="function"==typeof c,g={dialog:{msg:a,type:4,btns:2,yes:b,no:f?c:d}};return f||(g.title=c),e.layer(g)},msg:function(a,c,d,f){var g={title:!1,closeBtn:!1,time:c===b?2:c,dialog:{msg:""===a||a===b?" ":a},end:f};return"object"==typeof d?(g.dialog.type=d.type,g.shade=d.shade,g.success=function(){layer.shift(d.rate)}):"function"==typeof d?g.end=d:g.dialog.type=d,e.layer(g)},load:function(a,b){return"string"==typeof a?layer.msg(a,b||0,16):e.layer({time:a,loading:{type:b},bgcolor:b?"#fff":"",shade:b?[.1,"#000"]:[0],border:3!==b&&b?[6,.3,"#000"]:!1,type:3,title:["",!1],closeBtn:[0,!1]})},tips:function(a,b,c,d,f,g){var h={type:4,shade:!1,success:function(a){this.closeBtn||a.find(".xubox_tips").css({"padding-right":10})},bgcolor:"",tips:{msg:a,follow:b}};return c=c||{},h.time=c.time||c,h.closeBtn=c.closeBtn||!1,h.maxxubox_layer",ifr:"xubox_iframe",title:".xubox_title",text:".xubox_text",page:".xubox_page"},i=function(a){var" b=this,c=b.config;layer.index++,b.index=layer.index,b.config=e.extend({},c,a),b.config.dialog=e.extend({},c.dialog,a.dialog),b.config.page=e.extend({},c.page,a.page),b.config.iframe=e.extend({},c.iframe,a.iframe),b.config.loading=e.extend({},c.loading,a.loading),b.config.tips=e.extend({},c.tips,a.tips),b.creat()},i.pt=i.prototype,i.pt.config=layer.config||{type:0,shade:[.3,"#000"],shadeClose:!1,fix:!0,move:".xubox_title",moveOut:!1,title:["信息",!0],offset:["200px","50%"],area:["310px","auto"],closeBtn:[0,!0],time:0,bgcolor:"#fff",border:[6,.3,"#000"],zIndex:19891014,maxWidth:400,dialog:{btns:1,btn:["确定","取消"],type:8,msg:"",yes:function(a){layer.close(a)},no:function(a){layer.close(a)}},page:{dom:"#xulayer",html:"",url:""},iframe:{src:"http://sentsin.com",scrolling:"auto"},loading:{type:0},tips:{msg:"",follow:"",guide:0,isGuide:!0,style:["background-color:#FF9900; color:#fff;","#FF9900"]},success:function(){},close:function(a){layer.close(a)},end:function(){}},i.pt.space=function(a){var c,d,e,f,g,i,j,k,l,m,n,o,b=this;return a=a||"",c=b.index,d=b.config,e=d.dialog,f=-1===e.type?"":'',g=['
'+f+''+e.msg+"
",'
'+a+"
",'[フレーム]','','
'+d.tips.msg+'
'],i="",j="",k=d.zIndex+c,l="z-index:"+k+"; background-color:"+d.shade[1]+"; opacity:"+d.shade[0]+"; filter:alpha(opacity="+100*d.shade[0]+");",d.shade[0]&&(i='
'),d.zIndex=k,m="",n="",o="z-index:"+(k-1)+"; background-color: "+d.border[2]+"; opacity:"+d.border[1]+"; filter:alpha(opacity="+100*d.border[1]+"); top:-"+d.border[0]+"px; left:-"+d.border[0]+"px;",d.border[0]&&(j='
'),!d.maxmin||1!==d.type&&2!==d.type||/^\d+%$/.test(d.area[0])&&/^\d+%$/.test(d.area[1])||(n=''),d.closeBtn[1]&&(n+=''),d.title[1]&&(m='
'+d.title[0]+"
"),[i,'
'+'
'+g[d.type]+m+''+n+""+''+"
"+j+"
"]},i.pt.creat=function(){var l,m,n,a=this,b="",c=a.config,d=c.dialog,g=a.index,i=c.page,j=e("body"),k=function(c){var c=c||"";b=a.space(c),j.append(e(b[0]))};switch(c.title===!1?c.title=[]:"string"==typeof c.title&&(c.title=[c.title,!0]),c.type){case 0:c.title[1]||(c.area=["auto","auto"]),e(".xubox_dialog")[0]&&layer.close(e(".xubox_dialog").parents("."+h.lay).attr("times"));break;case 1:if(""!==i.html)k('
'+i.html+"
"),j.append(e(b[1]));else if(""!==i.url)k('
'+i.html+"
"),j.append(e(b[1])),e.get(i.url,function(a){e("#xuboxPageHtml"+g).html(a.toString()),i.ok&&i.ok(a)});else{if(0!=e(i.dom).parents(h.page).length)return;k(),e(i.dom).show().wrap(e(b[1]))}break;case 3:c.title=[],c.area=["auto","auto"],c.closeBtn=["",!1],e(".xubox_loading")[0]&&layer.close(e(".xubox_loading").parents("."+h.lay).attr("times"));break;case 4:c.title=[],c.area=["auto","auto"],c.fix=!1,c.border=[0],e(".xubox_tips")[0]&&layer.close(e(".xubox_tips").parents("."+h.lay).attr("times"))}if(1!==c.type&&(k(),j.append(e(b[1]))),l=a.layerE=e("#"+h.lay+g),a.offsetTop=-1!=c.offset[0].indexOf("px")?parseFloat(c.offset[0]):parseFloat(c.offset[0])/100*f.height(),a.offsetTop=a.offsetTop+c.border[0]+(c.fix?0:f.scrollTop()),-1!=c.offset[1].indexOf("px")?a.offsetLeft=parseFloat(c.offset[1])+c.border[0]:(c.offset[1]=""===c.offset[1]?"50%":c.offset[1],a.offsetLeft="50%"===c.offset[1]?c.offset[1]:parseFloat(c.offset[1])/100*f.width()+c.border[0]),l.css({left:a.offsetLeft,top:a.offsetTop,width:c.area[0],height:c.area[1]}),c.fix||l.css({position:"absolute"}),c.title[1]&&(3!==c.type||4!==c.type))switch(m=0===c.type?d:c,n=l.find(".xubox_botton"),m.btn=c.btn||d.btn,m.btns){case 0:n.html("").hide();break;case 1:n.html('");break;case 2:n.html('"+'")}"auto"===l.css("left")?(l.hide(),setTimeout(function(){l.show(),a.set(g)},500)):a.set(g),c.time<=0||a.autoclose(),a.callback()},g.fade=function(a,b,c){a.css({opacity:0}).animate({opacity:c},b)},i.pt.set=function(a){var m,n,o,p,q,r,b=this,c=b.layerE,d=c.find(h.title),i=b.config,k=(i.dialog,i.page);switch(i.loading,b.autoArea(a),i.title[1]?0===i.type&&layer.ie6&&d.css({width:c.outerWidth()}):4!=i.type&&c.find(".xubox_close").addClass("xubox_close1"),c.attr({type:g.type[i.type]}),i.type){case 0:c.find(".xubox_main").css({"background-color":"#fff"}),i.title[1]?c.find(h.text).css({paddingTop:18+d.outerHeight()}):(c.find(".xubox_msgico").css({top:8}),c.find(h.text).css({marginTop:11}));break;case 1:c.find(k.dom).addClass("layer_pageContent"),i.shade[0]&&c.css({zIndex:i.zIndex+1}),i.title[1]&&c.find(h.page).css({top:d.outerHeight()});break;case 2:m=c.find("."+h.ifr),n=c.height(),m.addClass("xubox_load").css({width:c.width()}),i.title[1]?m.css({top:d.height(),height:n-d.height()}):m.css({top:0,height:n}),layer.ie6&&m.attr("src",i.iframe.src);break;case 4:o=[0,c.outerHeight()],p=e(i.tips.follow),q={width:p.outerWidth(),height:p.outerHeight(),top:p.offset().top,left:p.offset().left},r=c.find(".layerTipsG"),i.tips.isGuide||r.remove(),c.outerWidth()>i.maxWidth&&c.width(i.maxWidth),q.tipColor=i.tips.style[1],o[0]=c.outerWidth(),q.where=[function(){q.tipLeft=q.left,q.tipTop=q.top-o[1]-10,r.removeClass("layerTipsB").addClass("layerTipsT").css({"border-right-color":q.tipColor})},function(){q.tipLeft=q.left+q.width+10,q.tipTop=q.top,r.removeClass("layerTipsL").addClass("layerTipsR").css({"border-bottom-color":q.tipColor})},function(){q.tipLeft=q.left,q.tipTop=q.top+q.height+10,r.removeClass("layerTipsT").addClass("layerTipsB").css({"border-right-color":q.tipColor})},function(){q.tipLeft=q.left-o[0]+10,q.tipTop=q.top,r.removeClass("layerTipsR").addClass("layerTipsL").css({"border-bottom-color":q.tipColor})}],q.where[i.tips.guide](),0===i.tips.guide?q.top-(f.scrollTop()+o[1]+16)<0&&q.where[2]():1===i.tips.guide?f.width()-(q.left+q.width+o[0]+16)>0||q.where[3]():2===i.tips.guide?q.top-f.scrollTop()+q.height+o[1]+16-f.height()>0&&q.where[0]():3===i.tips.guide&&o[0]+16-q.left>0&&q.where[1](),c.css({left:q.tipLeft,top:q.tipTop})}i.fadeIn&&(g.fade(c,i.fadeIn,1),g.fade(e("#xubox_shade"+a),i.fadeIn,i.shade[0])),b.move()},i.pt.autoArea=function(a){var c,d,f,g,i,k,j,l,m,n,o,b=this;switch(a=a||b.index,c=b.config,d=c.page,f=e("#"+h.lay+a),g=f.find(h.title),i=f.find(".xubox_main"),j=c.title[1]?g.innerHeight():0,l=0,"auto"===c.area[0]&&i.outerWidth()>=c.maxWidth&&f.css({width:c.maxWidth}),c.type){case 0:m=f.find(".xubox_botton>a"),k=f.find(h.text).outerHeight()+20,m.length>0&&(l=m.outerHeight()+20);break;case 1:n=f.find(h.page),k=e(d.dom).outerHeight(),"auto"===c.area[0]&&f.css({width:n.outerWidth()}),(""!==d.html||""!==d.url)&&(k=n.outerHeight());break;case 2:f.find("iframe").css({width:f.outerWidth(),height:f.outerHeight()-(c.title[1]?g.innerHeight():0)});break;case 3:o=f.find(".xubox_loading"),k=o.outerHeight(),i.css({width:o.width()})}"auto"===c.area[1]&&i.css({height:j+k+l}),e("#xubox_border"+a).css({width:f.outerWidth()+2*c.border[0],height:f.outerHeight()+2*c.border[0]}),layer.ie6&&"auto"!==c.area[0]&&i.css({width:f.outerWidth()}),"50%"!==c.offset[1]&&""!=c.offset[1]||4===c.type?f.css({marginLeft:0}):f.css({marginLeft:-f.outerWidth()/2})},i.pt.move=function(){var a=this,b=a.config,c={setY:0,moveLayer:function(){var a;a=0==parseInt(c.layerE.css("margin-left"))?parseInt(c.move.css("left")):parseInt(c.move.css("left"))+-parseInt(c.layerE.css("margin-left")),"fixed"!==c.layerE.css("position")&&(a-=c.layerE.parent().offset().left,c.setY=0),c.layerE.css({left:a,top:parseInt(c.move.css("top"))-c.setY})}};b.move&&a.layerE.find(b.move).attr("move","ok"),b.move?a.layerE.find(b.move).css({cursor:"move"}):a.layerE.find(b.move).css({cursor:"auto"}),e(b.move).on("mousedown",function(a){if(a.preventDefault(),"ok"===e(this).attr("move")){c.ismove=!0,c.layerE=e(this).parents("."+h.lay);var d=c.layerE.offset().left,g=c.layerE.offset().top,i=c.layerE.width()-6,j=c.layerE.height()-6;e("#xubox_moves")[0]||e("body").append('
'),c.move=e("#xubox_moves"),b.moveType&&c.move.css({opacity:0}),c.moveX=a.pageX-c.move.position().left,c.moveY=a.pageY-c.move.position().top,"fixed"!==c.layerE.css("position")||(c.setY=f.scrollTop())}}),e(document).mousemove(function(a){var d,e,g,h;c.ismove&&(d=a.pageX-c.moveX,e=a.pageY-c.moveY,a.preventDefault(),b.moveOut||(c.setY=f.scrollTop(),g=f.width()-c.move.outerWidth()-b.border[0],h=b.border[0]+c.setY,dg&&(d=g),h>e&&(e=h),e>f.height()-c.move.outerHeight()-b.border[0]+c.setY&&(e=f.height()-c.move.outerHeight()-b.border[0]+c.setY)),c.move.css({left:d,top:e}),b.moveType&&c.moveLayer(),d=null,e=null,g=null,h=null)}).mouseup(function(){try{c.ismove&&(c.moveLayer(),c.move.remove()),c.ismove=!1}catch(a){c.ismove=!1}b.moveEnd&&b.moveEnd()})},i.pt.autoclose=function(){var a=this,b=a.config.time,c=function(){b--,0===b&&(layer.close(a.index),clearInterval(a.autotime))};a.autotime=setInterval(c,1e3)},g.config={end:{}},i.pt.callback=function(){var a=this,b=a.layerE,c=a.config,d=c.dialog;a.openLayer(),a.config.success(b),layer.ie6&&a.IE6(b),b.find(".xubox_close").on("click",function(){c.close(a.index),layer.close(a.index)}),b.find(".xubox_yes").on("click",function(){c.yes?c.yes(a.index):d.yes(a.index)}),b.find(".xubox_no").on("click",function(){c.no?c.no(a.index):d.no(a.index),layer.close(a.index)}),a.config.shadeClose&&e("#xubox_shade"+a.index).on("click",function(){layer.close(a.index)}),b.find(".xubox_min").on("click",function(){layer.min(a.index,c),c.min&&c.min(b)}),b.find(".xubox_max").on("click",function(){e(this).hasClass("xubox_maxmin")?(layer.restore(a.index),c.restore&&c.restore(b)):(layer.full(a.index,c),c.full&&c.full(b))}),g.config.end[a.index]=c.end},g.reselect=function(){e.each(e("select"),function(){var c=e(this);c.parents("."+h.lay)[0]||1==c.attr("layer")&&e("."+h.lay).length<1&&c.removeattr("layer").show(),c=null})},i.pt.ie6=function(a){var d,b=this,c=a.offset().top;d=b.config.fix?function(){a.css({top:f.scrollTop()+c})}:function(){a.css({top:c})},d(),f.scroll(d),e.each(e("select"),function(){var c=e(this);c.parents("."+h.lay)[0]||"none"==c.css("display")||c.attr({layer:"1"}).hide(),c=null})},i.pt.openLayer=function(){var a=this;layer.autoArea=function(b){return a.autoArea(b)},layer.shift=function(b,c,d){var e,g,h,i,j,k;if(!layer.ie6)switch(e=a.config,g=a.layerE,h=0,i=f.width(),j=f.height()+(e.fix?0:f.scrollTop()),h="50%"==e.offset[1]||""==e.offset[1]?g.outerWidth()/2:g.outerWidth(),k={t:{top:a.offsetTop},b:{top:j-g.outerHeight()-e.border[0]},cl:h+e.border[0],ct:-g.outerHeight(),cr:i-h-e.border[0]},b){case"left-top":g.css({left:k.cl,top:k.ct}).animate(k.t,c);break;case"top":g.css({top:k.ct}).animate(k.t,c);break;case"right-top":g.css({left:k.cr,top:k.ct}).animate(k.t,c);break;case"right-bottom":g.css({left:k.cr,top:j}).animate(d?k.t:k.b,c);break;case"bottom":g.css({top:j}).animate(d?k.t:k.b,c);break;case"left-bottom":g.css({left:k.cl,top:j}).animate(d?k.t:k.b,c);break;case"left":g.css({left:-g.outerWidth()}).animate({left:a.offsetLeft},c)}},layer.setMove=function(){return a.move()},layer.zIndex=a.config.zIndex,layer.setTop=function(a){var b=function(){layer.zIndex++,a.css("z-index",layer.zIndex+1)};return layer.zIndex=parseInt(a[0].style.zIndex),a.on("mousedown",b),layer.zIndex}},g.isauto=function(a,b,c){"auto"===b.area[0]&&(b.area[0]=a.outerWidth()),"auto"===b.area[1]&&(b.area[1]=a.outerHeight()),a.attr({area:b.area+","+c}),a.find(".xubox_max").addClass("xubox_maxmin")},g.rescollbar=function(a){h.html.attr("layer-full")==a&&(h.html[0].style.removeProperty?h.html[0].style.removeProperty("overflow"):h.html[0].style.removeAttribute("overflow"),h.html.removeAttr("layer-full"))},layer.getIndex=function(a){return e(a).parents("."+h.lay).attr("times")},layer.getChildFrame=function(a,b){return b=b||e("."+h.ifr).parents("."+h.lay).attr("times"),e("#"+h.lay+b).find("."+h.ifr).contents().find(a)},layer.getFrameIndex=function(a){return e(a?"#"+a:"."+h.ifr).parents("."+h.lay).attr("times")},layer.iframeAuto=function(a){var b,c,d,f,g;a=a||e("."+h.ifr).parents("."+h.lay).attr("times"),b=layer.getChildFrame("body",a).outerHeight(),c=e("#"+h.lay+a),d=c.find(h.title),f=0,d&&(f=d.height()),c.css({height:b+f}),g=-parseInt(e("#xubox_border"+a).css("top")),e("#xubox_border"+a).css({height:b+2*g+f}),e("#"+h.ifr+a).css({height:b})},layer.iframeSrc="function(a,b){e("#"+h.lay+a).find("iframe").attr("src",b)},layer.area=function(a,b){var" j,c=[e("#"+h.lay+a),e("#xubox_border"+a)],d=c[0].attr("type"),f=c[0].find(".xubox_main"),i=c[0].find(h.title);(d===g.type[1]||d===g.type[2])&&(c[0].css(b),f.css({width:b.width,height:b.height}),d===g.type[2]&&(j=c[0].find("iframe"),j.css({width:b.width,height:i?b.height-i.innerHeight():b.height})),"0px"!==c[0].css("margin-left")&&(b.hasOwnProperty("top")&&c[0].css({top:b.top-(c[1][0]?parseFloat(c[1].css("top")):0)}),b.hasOwnProperty("left")&&c[0].css({left:b.left+c[0].outerWidth()/2-(c[1][0]?parseFloat(c[1].css("left")):0)}),c[0].css({marginLeft:-c[0].outerWidth()/2})),c[1][0]&&c[1].css({width:parseFloat(b.width)-2*parseFloat(c[1].css("left")),height:parseFloat(b.height)-2*parseFloat(c[1].css("top"))}))},layer.min=function(a,b){var c=e("#"+h.lay+a),d=[c.position().top,c.position().left+parseFloat(c.css("margin-left"))];g.isauto(c,b,d),layer.area(a,{width:180,height:35}),c.find(".xubox_min").hide(),"page"===c.attr("type")&&c.find(h.page).hide(),g.rescollbar(a)},layer.restore=function(a){var b=e("#"+h.lay+a),c=b.attr("area").split(",");b.attr("type"),layer.area(a,{width:parseFloat(c[0]),height:parseFloat(c[1]),top:parseFloat(c[2]),left:parseFloat(c[3])}),b.find(".xubox_max").removeClass("xubox_maxmin"),b.find(".xubox_min").show(),"page"===b.attr("type")&&b.find(h.page).show(),g.rescollbar(a)},layer.full=function(a,b){var i,c=e("#"+h.lay+a),d=2*b.border[0],j=[c.position().top,c.position().left+parseFloat(c.css("margin-left"))];g.isauto(c,b,j),h.html.attr("layer-full")||h.html.css("overflow","hidden").attr("layer-full",a),clearTimeout(i),i=setTimeout(function(){layer.area(a,{top:"fixed"===c.css("position")?0:f.scrollTop(),left:"fixed"===c.css("position")?0:f.scrollLeft(),width:f.width()-d,height:f.height()-d})},100)},layer.close=function(a){var f,b=e("#"+h.lay+a),c=b.attr("type"),d=e("#xubox_moves, #xubox_shade"+a);if(b[0]){if(c==g.type[1])if(b.find(".xuboxPageHtml")[0])b[0].innerHTML="",b.remove();else for(b.find(".xubox_setwin,.xubox_close,.xubox_botton,.xubox_title,.xubox_border").remove(),f=0;3>f;f++)b.find(".layer_pageContent").unwrap().hide();else b[0].innerHTML="",b.remove();d.remove(),layer.ie6&&g.reselect(),g.rescollbar(a),"function"==typeof g.config.end[a]&&g.config.end[a](),delete g.config.end[a]}},layer.closeLoad=function(){layer.close(e(".xubox_loading").parents("."+h.lay).attr("times"))},layer.closeTips=function(){layer.close(e(".xubox_tips").parents("."+h.lay).attr("times"))},layer.closeAll=function(){e.each(e("."+h.lay),function(){layer.close(e(this).attr("times"))})},g.run=function(){e=jQuery,f=e(a),h.html=e("html"),layer.use("skin/layer.css"),e.layer=function(a){var b=new i(a);return b.index},(new Image).src=layer.path+"skin/default/xubox_ico0.png"},j="../../init/jquery",a.seajs?define([j],function(b,c){g.run(),c.layer=[a.layer,a.$.layer]}):g.run()}(window); \ No newline at end of file diff --git a/layer/skin/default/icon_ext.png b/layer/skin/default/icon_ext.png deleted file mode 100644 index 8baee597..00000000 Binary files a/layer/skin/default/icon_ext.png and /dev/null differ diff --git a/layer/skin/default/textbg.png b/layer/skin/default/textbg.png deleted file mode 100644 index ad1040c4..00000000 Binary files a/layer/skin/default/textbg.png and /dev/null differ diff --git a/layer/skin/default/xubox_ico0.png b/layer/skin/default/xubox_ico0.png deleted file mode 100644 index 7754a47f..00000000 Binary files a/layer/skin/default/xubox_ico0.png and /dev/null differ diff --git a/layer/skin/default/xubox_loading3.gif b/layer/skin/default/xubox_loading3.gif deleted file mode 100644 index fbe57be3..00000000 Binary files a/layer/skin/default/xubox_loading3.gif and /dev/null differ diff --git a/layer/skin/default/xubox_title0.png b/layer/skin/default/xubox_title0.png deleted file mode 100644 index 4ffbe315..00000000 Binary files a/layer/skin/default/xubox_title0.png and /dev/null differ diff --git a/layer/skin/layer.css b/layer/skin/layer.css deleted file mode 100644 index 3a8fe375..00000000 --- a/layer/skin/layer.css +++ /dev/null @@ -1,83 +0,0 @@ -/** - - @Name: layer's style - @Date: 2012年09月15日 - @Author: 贤心 - @blog: sentsin.com - -**/ - -*html{background-image:url(about:blank); background-attachment:fixed;} - -/** common **/ -.xubox_shade, .xubox_layer{position:fixed; _position:absolute;} -.xubox_shade{top:0; left:0; width:100%; height:100%; _height:expression(document.body.offsetHeight+"px");} -.xubox_layer{top:150px; left:50%; height:auto; width:310px; margin-left:-155px;} -.xubox_border, .xubox_title, .xubox_title i, .xubox_page, .xubox_iframe, .xubox_title em, .xubox_close, .xubox_msgico, .xubox_moves{position:absolute;} -.xubox_border{border-radius: 5px;} -.xubox_title{left:0; top:0;} -.xubox_main{position:relative; height:100%; _float:left;} -.xubox_page{top:0; left:0;} -.xubox_load{background:url(default/xubox_loading0.gif) #fff center center no-repeat;} -.xubox_loading{display:block; float:left; text-decoration:none; color:#FFF; _float:none; } -.xulayer_png32{background:url(default/xubox_ico0.png) no-repeat;} -.xubox_moves{border:3px solid #666; cursor:move; background-color:rgba(255,255,255,.3); background-color:#fff9円; filter:alpha(opacity=50);} - -.xubox_msgico{width:32px; height:32px; top:52px; left:15px; background:url(default/xubox_ico0.png) no-repeat;} -.xubox_text{ padding-left:55px; float:left; line-height:25px; word-break:break-all; padding-right:20px; overflow:hidden; font-size:14px;} -.xubox_msgtype0{background-position:-91px -38px;} -.xubox_msgtype1{background-position:-128px -38px } -.xubox_msgtype2{background-position:-163px -38px;} -.xubox_msgtype3{background-position:-91px -75px;} -.xubox_msgtype4{background-position:-163px -75px;} -.xubox_msgtype5{background-position:-163px -112px;} -.xubox_msgtype6{background-position:-163px -148px;} -.xubox_msgtype7{background-position:-128px -75px;} -.xubox_msgtype8{background-position:-91px -6px;} -.xubox_msgtype9{background-position:-129px -6px;} -.xubox_msgtype10{background-position:-163px -6px;} -.xubox_msgtype11{background-position:-206px -6px;} -.xubox_msgtype12{background-position:-206px -44px;} -.xubox_msgtype13{background-position:-206px -81px;} -.xubox_msgtype14{background-position:-206px -122px;} -.xubox_msgtype15{background-position:-206px -157px;} -.xubox_loading_0{width:60px; height:24px; background:url(default/xubox_loading0.gif) no-repeat;} -.xubox_loading_1{width:37px; height:37px; background:url(default/xubox_loading1.gif) no-repeat;} -.xubox_loading_2, .xubox_msgtype16{width:32px; height:32px; background:url(default/xubox_loading2.gif) no-repeat;} -.xubox_loading_3{width:126px; height:22px; background:url(default/xubox_loading3.gif) no-repeat;} - -.xubox_setwin{position:absolute; right:10px; *right:0; top:10px; font-size:0;} -.xubox_setwin a{position:relative; display:inline-block; *display:inline; *zoom:1; vertical-align:top; width: 14px; height:14px; margin-left:10px; font-size:12px; _overflow:hidden;} -.xubox_setwin .xubox_min cite{position:absolute; width:14px; height:2px; left:0; top:50%; margin-top:-1px; background-color:#919191; cursor:pointer; _overflow:hidden;} -.xubox_setwin .xubox_min:hover cite{background-color:#2D93CA; } -.xubox_setwin .xubox_max{background-position:-6px -189px;} -.xubox_setwin .xubox_max:hover{background-position:-6px -206px;} -.xubox_setwin .xubox_maxmin{background-position:-29px -189px;} -.xubox_setwin .xubox_maxmin:hover{background-position:-29px -206px;} -.xubox_setwin .xubox_close0{ width:14px; height:14px; background-position: -31px -7px; cursor:pointer;} -.xubox_setwin .xubox_close0:hover{background-position:-51px -7px;} -.xubox_setwin .xubox_close1{position:absolute; right:-28px; top:-28px; width:30px; height:30px; margin-left:0; background-position:-60px -195px; *right:-18px; _right:-15px; _top:-23px; _width:14px; _height:14px; _background-position:-31px -7px;} -.xubox_setwin .xubox_close1:hover{ background-position:-91px -195px; _background-position:-51px -7px;} - -.xubox_title{width:100%; height:35px; line-height:35px; border-bottom:1px solid #D5D5D5; background:url(default/xubox_title0.png) #EBEBEB repeat-x; cursor:move; font-size:14px; color:#333;} -.xubox_title em{height:20px; line-height:20px; width:60%; top:7px; left:10px; font-style:normal; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;} - -.xubox_botton a{position:absolute; bottom:10px; left:50%; background:url(default/xubox_ico0.png) repeat; text-decoration:none; color:#FFF; font-size:14px; text-align:center; font-weight:bold; overflow:hidden; } -.xubox_botton a:hover{text-decoration:none; color:#FFF; } -.xubox_botton .xubox_botton1{ width:79px; height:32px; line-height:32px; margin-left:-39px; background-position:-6px -34px;} -.xubox_botton1:hover{background-position:-6px -72px;} -.xubox_botton .xubox_botton2{margin-left:-76px; width:71px; height:29px; line-height:29px; background-position:-5px -114px;} -.xubox_botton2:hover{ background-position:-5px -146px;} -.xubox_botton .xubox_botton3{width:71px; height:29px; line-height:29px; margin-left:10px; background-position:-81px -114px;} -.xubox_botton3:hover{background-position:-81px -146px;} -.xubox_tips{position:relative; line-height:20px; padding:3px 30px 3px 10px; font-size:12px; _float:left; border-radius:3px; box-shadow: 1px 1px 3px rgba(0,0,0,.3);} -.xubox_tips i.layerTipsG{ position:absolute; width:0; height:0; border-width:8px; border-color:transparent; border-style:dashed; *overflow:hidden;} -.xubox_tips i.layerTipsT, .xubox_tips i.layerTipsB{left:5px; border-right-style:solid;} -.xubox_tips i.layerTipsT{bottom:-8px;} -.xubox_tips i.layerTipsB{top:-8px;} -.xubox_tips i.layerTipsR, .xubox_tips i.layerTipsL{top:1px; border-bottom-style:solid;} -.xubox_tips i.layerTipsR{left:-8px;} -.xubox_tips i.layerTipsL{right:-8px;} - - - diff --git a/layer/skin/layer.ext.css b/layer/skin/layer.ext.css deleted file mode 100644 index d0de7965..00000000 --- a/layer/skin/layer.ext.css +++ /dev/null @@ -1,45 +0,0 @@ -/** - - @Name: layer拓展样式 - @Date: 2012年12月13日 - @Author: 贤心 - @blog: sentsin.com - -**/ - -.xubox_iconext{background:url(default/icon_ext.png) no-repeat;} - -/* prompt模式 */ -.xubox_layer .xubox_form{width:240px; height:30px; line-height:30px; padding: 0 5px; border: 1px solid #ccc; background: url(default/textbg.png) #fff repeat-x; color:#333;} -.xubox_layer .xubox_formArea{width:300px; height:100px; line-height:20px;} - -/* tab模式 */ -.xubox_layer .xubox_tab{position:relative; border:1px solid #ccc;} -.xubox_layer .xubox_tabmove{position:absolute; width:600px; height:30px; top:0; left:0;} -.xubox_layer .xubox_tabtit{ display:block; height:30px; border-bottom:1px solid #ccc; background-color:#eee;} -.xubox_layer .xubox_tabtit span{position:relative; float:left; width:120px; height:30px; line-height:30px; text-align:center; cursor:default;} -.xubox_layer .xubox_tabtit span.xubox_tabnow{left:-1px; _top:1px; height:31px; border-left:1px solid #ccc; border-right:1px solid #ccc; background-color:#fff; z-index:10;} -.xubox_layer .xubox_tab_main{line-height:24px; clear:both;} -.xubox_layer .xubox_tab_main .xubox_tabli{display:none;} -.xubox_layer .xubox_tab_main .xubox_tabli.xubox_tab_layer{display:block;} -.xubox_layer .xubox_tabclose{position:absolute; right:10px; top:5px; cursor:pointer;} - -/* photo模式 */ -.xubox_bigimg, .xubox_intro{height:300px} -.xubox_bigimg{position:relative; display:block; width:600px; text-align:center; background:url(default/xubox_loading1.gif) center center no-repeat #000; overflow:hidden; } -.xubox_bigimg img{position:relative; display:inline-block; visibility: hidden;} -.xubox_intro{position:absolute; right:-315px; top:0; width:300px; background-color:#fff; overflow-x:hidden; overflow-y:auto;} -.xubox_imgsee{display:none;} -.xubox_prev, .xubox_next{position:absolute; top:50%; width:27px; _width:44px; height:44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());} -.xubox_prev{left:10px; background-position:-5px -5px; _background-position:-70px -5px;} -.xubox_prev:hover{background-position:-33px -5px; _background-position:-120px -5px;} -.xubox_next{right:10px; _right:8px; background-position:-5px -50px; _background-position:-70px -50px;} -.xubox_next:hover{background-position:-33px -50px; _background-position:-120px -50px;} -.xubox_imgbar{position:absolute; left:0; bottom:0; width:100%; height:32px; line-height:32px; background-color:rgba(0,0,0,.8); background-color:#0009円; filter:Alpha(opacity=80); color:#fff; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size:0;} -.xubox_imgtit{/*position:absolute; left:20px;*/} -.xubox_imgtit *{display:inline-block; *display:inline; *zoom:1; vertical-align:top; font-size:12px;} -.xubox_imgtit a{max-width:65%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color:#fff;} -.xubox_imgtit a:hover{color:#fff; text-decoration:underline;} -.xubox_imgtit em{padding-left:10px;} - - diff --git a/package.json b/package.json index 0578b2e5..7b0f29ac 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,40 @@ -{ - "name": "layer", - "version": "1.8", - "readmeFilename": "README.md", - "description": "最懂你的弹层组件,想到即可做到", - "main": "layer/layer.js", +{ + "name": "layer-src", + "realname": "layer", + "version": "3.5.1", + "mobile": "2.0.0", + "description": "Web 通用弹出层组件", + "main": "src/layer.js", + "license": "MIT", "scripts": { - "test": "layer.msg('hello')" + "run": "gulp" }, "repository": { - "type": "git", - "url": "https://github.com/sentsin/layer.git" + "type": "https", + "url": "git+https://github.com/sentsin/layer.git" + }, + "devDependencies": { + "gulp": "^3.9.0", + "gulp-minify-css": "^1.2.4", + "gulp-uglify": "^1.5.4", + "gulp-rename": "^1.2.2", + "gulp-header": "^1.8.8", + "del": "^2.2.2" }, - "keywords": [ - "layer" - ], - "author": "贤心", - "license": "LGPL", "bugs": { "url": "https://github.com/sentsin/layer/issues" }, - "homepage": "http://sentsin.com/sentsin/layer", - "devDependencies": { - "grunt": "~0.4.5" - } + "directories": { + "test": "test" + }, + "dependencies": {}, + "keywords": [ + "layui", + "layer", + "dialog", + "tips", + "alert", + "confirm", + "window" + ] } diff --git a/src/README.md b/src/README.md new file mode 100644 index 00000000..f9a84aae --- /dev/null +++ b/src/README.md @@ -0,0 +1,3 @@ + +## 注意 +开发版源码随时可能会提交,因此生产环境更建议 dist 目录中压缩后的 layer.js。 \ No newline at end of file diff --git a/src/layer.js b/src/layer.js new file mode 100644 index 00000000..9c753518 --- /dev/null +++ b/src/layer.js @@ -0,0 +1,1390 @@ + +/*! + * layer - 通用 Web 弹出层组件 + * MIT Licensed + */ + +;!function(window, undefined){ +"use strict"; + +var isLayui = window.layui && layui.define, ,ドル win, ready = { + getPath: function(){ + var jsPath = document.currentScript ? document.currentScript.src : function(){ + var js = document.scripts + ,last = js.length - 1 + ,src; + for(var i = last; i> 0; i--){ + if(js[i].readyState === 'interactive'){ + src = js[i].src; + break; + } + } + return src || js[last].src; + }() + ,GLOBAL = window.LAYUI_GLOBAL || {}; + return GLOBAL.layer_dir || jsPath.substring(0, jsPath.lastIndexOf('/') + 1); + }(), + + config: {}, end: {}, minIndex: 0, minLeft: [], + btn: ['确定', '取消'], + + //五种原始层模式 + type: ['dialog', 'page', 'iframe', 'loading', 'tips'], + + //获取节点的style属性值 + getStyle: function(node, name){ + var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null); + return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name); + }, + + //载入 CSS 依赖 + link: function(href, fn, cssname){ + //未设置路径,则不主动加载css + if(!layer.path) return; + + var head = document.getElementsByTagName("head")[0] + ,link = document.createElement('link'); + + if(typeof fn === 'string') cssname = fn; + + var app = (cssname || href).replace(/\.|\//g, ''); + var id = 'layuicss-'+ app + ,STAUTS_NAME = 'creating' + ,timeout = 0; + + link.rel = 'stylesheet'; + link.href = layer.path + href; + link.id = id; + + if(!document.getElementById(id)){ + head.appendChild(link); + } + + if(typeof fn !== 'function') return; + + //轮询 css 是否加载完毕 + (function poll(status) { + var delay = 100 + ,getLinkElem = document.getElementById(id); //获取动态插入的 link 元素 + + //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范 + if(++timeout> 10 * 1000 / delay){ + return window.console && console.error(app +'.css: Invalid'); + }; + + //css 加载就绪 + if(parseInt(ready.getStyle(getLinkElem, 'width')) === 1989){ + //如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态 + if(status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status'); + //如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调 + getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn(); + } else { + getLinkElem.setAttribute('lay-status', STAUTS_NAME); + setTimeout(function(){ + poll(STAUTS_NAME); + }, delay); + } + + //parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 1000); + }()); + + } +}; + +//默认内置方法。 +var layer = { + v: '3.5.1', + ie: function(){ //ie版本 + var agent = navigator.userAgent.toLowerCase(); + return (!!window.ActiveXObject || "ActiveXObject" in window) ? ( + (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 + ) : false; + }(), + index: (window.layer && window.layer.v) ? 100000 : 0, + path: ready.getPath, + config: function(options, fn){ + options = options || {}; + layer.cache = ready.config = $.extend({}, ready.config, options); + layer.path = ready.config.path || layer.path; + typeof options.extend === 'string' && (options.extend = [options.extend]); + + //如果设置了路径,则加载样式 + if(ready.config.path) layer.ready(); + + if(!options.extend) return this; + + isLayui + ? layui.addcss('modules/layer/' + options.extend) + : ready.link('theme/' + options.extend); + + return this; + }, + + //主体CSS等待事件 + ready: function(callback){ + var cssname = 'layer', ver = '' + ,path = (isLayui ? 'modules/layer/' : 'theme/') + 'default/layer.css?v='+ layer.v + ver; + isLayui ? layui.addcss(path, callback, cssname) : ready.link(path, callback, cssname); + return this; + }, + + //各种快捷引用 + alert: function(content, options, yes){ + var type = typeof options === 'function'; + if(type) yes = options; + return layer.open($.extend({ + content: content, + yes: yes + }, type ? {} : options)); + }, + + confirm: function(content, options, yes, cancel){ + var type = typeof options === 'function'; + if(type){ + cancel = yes; + yes = options; + } + return layer.open($.extend({ + content: content, + btn: ready.btn, + yes: yes, + btn2: cancel + }, type ? {} : options)); + }, + + msg: function(content, options, end){ //最常用提示层 + var type = typeof options === 'function', rskin = ready.config.skin; + var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; + var anim = doms.anim.length - 1; + if(type) end = options; + return layer.open($.extend({ + content: content, + time: 3000, + shade: false, + skin: skin, + title: false, + closeBtn: false, + btn: false, + resize: false, + end: end + }, (type && !ready.config.skin) ? { + skin: skin + ' layui-layer-hui', + anim: anim + } : function(){ + options = options || {}; + if(options.icon === -1 || options.icon === undefined && !ready.config.skin){ + options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); + } + return options; + }())); + }, + + load: function(icon, options){ + return layer.open($.extend({ + type: 3, + icon: icon || 0, + resize: false, + shade: 0.01 + }, options)); + }, + + tips: function(content, follow, options){ + return layer.open($.extend({ + type: 4, + content: [content, follow], + closeBtn: false, + time: 3000, + shade: false, + resize: false, + fixed: false, + maxWidth: 260 + }, options)); + } +}; + +var Class = function(setings){ + var that = this, creat = function(){ + that.creat(); + }; + that.index = ++layer.index; + that.config.maxWidth = $(win).width() - 15*2; //初始最大宽度:当前屏幕宽,左右留 15px 边距 + that.config = $.extend({}, that.config, ready.config, setings); + document.body ? creat() : setTimeout(function(){ + creat(); + }, 30); +}; + +Class.pt = Class.prototype; + +//缓存常用字符 +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']; +doms.anim = ['layer-anim-00', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06']; + +doms.SHADE = 'layui-layer-shade'; +doms.MOVE = 'layui-layer-move'; + +//默认配置 +Class.pt.config = { + type: 0, + shade: 0.3, + fixed: true, + move: doms[1], + title: '信息', + offset: 'auto', + area: 'auto', + closeBtn: 1, + time: 0, //0表示不自动关闭 + zIndex: 19891014, + maxWidth: 360, + anim: 0, + isOutAnim: true, //退出动画 + minStack: true, //最小化堆叠 + icon: -1, + moveType: 1, + resize: true, + scrollbar: true, //是否允许浏览器滚动条 + tips: 2 +}; + +//容器 +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 titleHTML = (config.title ? '
' + + (titype ? config.title[0] : config.title) + + '
' : ''); + + config.zIndex = zIndex; + callback([ + //遮罩 + config.shade ? ('
') : '', + + //主体 + '
' + + (conType && config.type != 2 ? '' : titleHTML) + + '
' + + (config.type == 0 && config.icon !== -1 ? '' : '') + + (config.type == 1 && conType ? '' : (config.content||'')) + + '
' + + ''+ function(){ + var closebtn = ismax ? '' : ''; + config.closeBtn && (closebtn += ''); + return closebtn; + }() + '' + + (config.btn ? function(){ + var button = ''; + typeof config.btn === 'string' && (config.btn = [config.btn]); + for(var i = 0, len = config.btn.length; i < len; i++){ + button += ''+ config.btn[i] +'' + } + return '
'+ button +'
' + }() : '') + + (config.resize ? '' : '') + + '
' + ], titleHTML, $('
')); + return that; +}; + +//创建骨架 +Class.pt.creat = function(){ + var that = this + ,config = that.config + ,times = that.index, nodeIndex + ,content = config.content + ,conType = typeof content === 'object' + ,body = $('body'); + + if(config.id && $('#'+config.id)[0]) return; + + if(typeof config.area === 'string'){ + config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; + } + + //anim兼容旧版shift + if(config.shift){ + config.anim = config.shift; + } + + if(layer.ie == 6){ + config.fixed = false; + } + + switch(config.type){ + case 0: + config.btn = ('btn' in config) ? config.btn : ready.btn[0]; + layer.closeAll('dialog'); + break; + case 2: + var content = config.content = conType ? config.content : [config.content||'', 'auto']; + config.content = '[フレーム]'; + break; + case 3: + delete config.title; + delete config.closeBtn; + config.icon === -1 && (config.icon === 0); + layer.closeAll('loading'); + break; + case 4: + conType || (config.content = [config.content, 'body']); + config.follow = config.content[1]; + config.content = config.content[0] + ''; + delete config.title; + config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true]; + config.tipsMore || layer.closeAll('tips'); + break; + } + + //建立容器 + that.vessel(conType, function(html, titleHTML, moveElem){ + body.append(html[0]); + conType ? function(){ + (config.type == 2 || config.type == 4) ? function(){ + $('body').append(html[1]); + }() : function(){ + if(!content.parents('.'+doms[0])[0]){ + content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]); + $('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML); + } + }(); + }() : body.append(html[1]); + $('#'+ doms.MOVE)[0] || body.append(ready.moveElem = moveElem); + + that.layero = $('#'+ doms[0] + times); + that.shadeo = $('#'+ doms.SHADE + times); + + config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times); + }).auto(times); + + //遮罩 + that.shadeo.css({ + 'background-color': config.shade[1] || '#000' + ,'opacity': config.shade[0] || config.shade + }); + + config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]); + + //坐标自适应浏览器窗口尺寸 + config.type == 4 ? that.tips() : function(){ + that.offset() + //首次弹出时,若 css 尚未加载,则等待 css 加载完毕后,重新设定尺寸 + parseInt(ready.getStyle(document.getElementById(doms.MOVE), 'z-index')) || function(){ + that.layero.css('visibility', 'hidden'); + layer.ready(function(){ + that.offset(); + that.layero.css('visibility', 'visible'); + }); + }(); + }(); + + //如果是固定定位 + if(config.fixed){ + win.on('resize', function(){ + that.offset(); + (/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times); + config.type == 4 && that.tips(); + }); + } + + config.time <= 0 || setTimeout(function(){ + layer.close(that.index); + }, config.time); + that.move().callback(); + + //为兼容jQuery3.0的css动画影响元素尺寸计算 + if(doms.anim[config.anim]){ + var animClass = 'layer-anim '+ doms.anim[config.anim]; + that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function(){ + $(this).removeClass(animClass); + }); + }; + + //记录关闭动画 + if(config.isOutAnim){ + that.layero.data('isOutAnim', true); + } +}; + +//自适应 +Class.pt.auto = function(index){ + var that = this, config = that.config, layero = $('#'+ doms[0] + index); + + if(config.area[0] === '' && config.maxWidth> 0){ + //为了修复IE7下一个让人难以理解的bug + if(layer.ie && layer.ie < 8 && config.btn){ + layero.width(layero.innerWidth()); + } + layero.outerWidth()> config.maxWidth && layero.width(config.maxWidth); + } + + var area = [layero.innerWidth(), layero.innerHeight()] + ,titHeight = layero.find(doms[1]).outerHeight() || 0 + ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 + ,setHeight = function(elem){ + elem = layero.find(elem); + elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding-top'))|0)); + }; + + switch(config.type){ + case 2: + setHeight('iframe'); + break; + default: + if(config.area[1] === ''){ + if(config.maxHeight> 0 && layero.outerHeight()> config.maxHeight){ + area[1] = config.maxHeight; + setHeight('.'+doms[5]); + } else if(config.fixed && area[1]>= win.height()){ + area[1] = win.height(); + setHeight('.'+doms[5]); + } + } else { + setHeight('.'+doms[5]); + } + break; + }; + + return that; +}; + +//计算坐标 +Class.pt.offset = function(){ + var that = this, config = that.config, layero = that.layero; + var area = [layero.outerWidth(), layero.outerHeight()]; + var type = typeof config.offset === 'object'; + that.offsetTop = (win.height() - area[1])/2; + that.offsetLeft = (win.width() - area[0])/2; + + if(type){ + that.offsetTop = config.offset[0]; + that.offsetLeft = config.offset[1]||that.offsetLeft; + } else if(config.offset !== 'auto'){ + + if(config.offset === 't'){ //上 + that.offsetTop = 0; + } else if(config.offset === 'r'){ //右 + that.offsetLeft = win.width() - area[0]; + } else if(config.offset === 'b'){ //下 + that.offsetTop = win.height() - area[1]; + } else if(config.offset === 'l'){ //左 + that.offsetLeft = 0; + } else if(config.offset === 'lt'){ //左上角 + that.offsetTop = 0; + that.offsetLeft = 0; + } else if(config.offset === 'lb'){ //左下角 + that.offsetTop = win.height() - area[1]; + that.offsetLeft = 0; + } else if(config.offset === 'rt'){ //右上角 + that.offsetTop = 0; + that.offsetLeft = win.width() - area[0]; + } else if(config.offset === 'rb'){ //右下角 + that.offsetTop = win.height() - area[1]; + that.offsetLeft = win.width() - area[0]; + } else { + that.offsetTop = config.offset; + } + + } + + if(!config.fixed){ + 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.offsetLeft += win.scrollLeft(); + } + + if(layero.attr('minLeft')){ + that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); + that.offsetLeft = layero.css('left'); + } + + layero.css({top: that.offsetTop, left: that.offsetLeft}); +}; + +//Tips +Class.pt.tips = function(){ + var that = this, config = that.config, layero = that.layero; + var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow); + if(!follow[0]) follow = $('body'); + var goal = { + width: follow.outerWidth(), + height: follow.outerHeight(), + top: follow.offset().top, + left: follow.offset().left + }, tipsG = layero.find('.layui-layer-TipsG'); + + var guide = config.tips[0]; + config.tips[1] || tipsG.remove(); + + goal.autoLeft = function(){ + if(goal.left + layArea[0] - win.width()> 0){ + goal.tipLeft = goal.left + goal.width - layArea[0]; + tipsG.css({right: 12, left: 'auto'}); + } else { + goal.tipLeft = goal.left; + }; + }; + + //辨别tips的方位 + goal.where = [function(){ //上 + goal.autoLeft(); + goal.tipTop = goal.top - layArea[1] - 10; + tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); + }, function(){ //右 + goal.tipLeft = goal.left + goal.width + 10; + goal.tipTop = goal.top; + tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); + }, function(){ //下 + goal.autoLeft(); + goal.tipTop = goal.top + goal.height + 10; + tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]); + }, function(){ //左 + goal.tipLeft = goal.left - layArea[0] - 10; + goal.tipTop = goal.top; + tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); + }]; + goal.where[guide-1](); + + /* 8*2为小三角形占据的空间 */ + if(guide === 1){ + goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); + } else if(guide === 2){ + win.width() - (goal.left + goal.width + layArea[0] + 8*2)> 0 || goal.where[3]() + } else if(guide === 3){ + (goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height()> 0 && goal.where[0](); + } else if(guide === 4){ + layArea[0] + 8*2 - goal.left> 0 && goal.where[1]() + } + + layero.find('.'+doms[5]).css({ + 'background-color': config.tips[1], + 'padding-right': (config.closeBtn ? '30px' : '') + }); + layero.css({ + left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), + top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) + }); +} + +//拖拽层 +Class.pt.move = function(){ + var that = this + ,config = that.config + ,_DOC = $(document) + ,layero = that.layero + ,moveElem = layero.find(config.move) + ,resizeElem = layero.find('.layui-layer-resize') + ,dict = {}; + + if(config.move){ + moveElem.css('cursor', 'move'); + } + + moveElem.on('mousedown', function(e){ + e.preventDefault(); + if(config.move){ + dict.moveStart = true; + dict.offset = [ + e.clientX - parseFloat(layero.css('left')) + ,e.clientY - parseFloat(layero.css('top')) + ]; + ready.moveElem.css('cursor', 'move').show(); + } + }); + + resizeElem.on('mousedown', function(e){ + e.preventDefault(); + dict.resizeStart = true; + dict.offset = [e.clientX, e.clientY]; + dict.area = [ + layero.outerWidth() + ,layero.outerHeight() + ]; + ready.moveElem.css('cursor', 'se-resize').show(); + }); + + _DOC.on('mousemove', function(e){ + + //拖拽移动 + if(dict.moveStart){ + var X = e.clientX - dict.offset[0] + ,Y = e.clientY - dict.offset[1] + ,fixed = layero.css('position') === 'fixed'; + + e.preventDefault(); + + dict.stX = fixed ? 0 : win.scrollLeft(); + dict.stY = fixed ? 0 : win.scrollTop(); + + //控制元素不被拖出窗口外 + if(!config.moveOut){ + var setRig = win.width() - layero.outerWidth() + dict.stX + ,setBot = win.height() - layero.outerHeight() + dict.stY; + X < dict.stX && (X = dict.stX); + X> setRig && (X = setRig); + Y < dict.stY && (Y = dict.stY); + Y> setBot && (Y = setBot); + } + + layero.css({ + left: X + ,top: Y + }); + } + + //Resize + if(config.resize && dict.resizeStart){ + var X = e.clientX - dict.offset[0] + ,Y = e.clientY - dict.offset[1]; + + e.preventDefault(); + + layer.style(that.index, { + width: dict.area[0] + X + ,height: dict.area[1] + Y + }) + dict.isResize = true; + config.resizing && config.resizing(layero); + } + }).on('mouseup', function(e){ + if(dict.moveStart){ + delete dict.moveStart; + ready.moveElem.hide(); + config.moveEnd && config.moveEnd(layero); + } + if(dict.resizeStart){ + delete dict.resizeStart; + ready.moveElem.hide(); + } + }); + + return that; +}; + +Class.pt.callback = function(){ + var that = this, layero = that.layero, config = that.config; + that.openLayer(); + if(config.success){ + if(config.type == 2){ + layero.find('iframe').on('load', function(){ + config.success(layero, that.index); + }); + } else { + config.success(layero, that.index); + } + } + layer.ie == 6 && that.IE6(layero); + + //按钮 + layero.find('.'+ doms[6]).children('a').on('click', function(){ + var index = $(this).index(); + if(index === 0){ + if(config.yes){ + config.yes(that.index, layero) + } else if(config['btn1']){ + config['btn1'](that.index, layero) + } else { + layer.close(that.index); + } + } else { + var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero); + close === false || layer.close(that.index); + } + }); + + //取消 + function cancel(){ + var close = config.cancel && config.cancel(that.index, layero); + close === false || layer.close(that.index); + } + + //右上角关闭回调 + layero.find('.'+ doms[7]).on('click', cancel); + + //点遮罩关闭 + if(config.shadeClose){ + that.shadeo.on('click', function(){ + layer.close(that.index); + }); + } + + //最小化 + layero.find('.layui-layer-min').on('click', function(){ + var min = config.min && config.min(layero, that.index); + min === false || layer.min(that.index, config); + }); + + //全屏/还原 + layero.find('.layui-layer-max').on('click', function(){ + if($(this).hasClass('layui-layer-maxmin')){ + layer.restore(that.index); + config.restore && config.restore(layero, that.index); + } else { + layer.full(that.index, config); + setTimeout(function(){ + config.full && config.full(layero, that.index); + }, 100); + } + }); + + config.end && (ready.end[that.index] = config.end); +}; + +//for ie6 恢复select +ready.reselect = function(){ + $.each($('select'), function(index , value){ + var sthis = $(this); + if(!sthis.parents('.'+doms[0])[0]){ + (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); + } + sthis = null; + }); +}; + +Class.pt.IE6 = function(layero){ + //隐藏select + $('select').each(function(index , value){ + var sthis = $(this); + if(!sthis.parents('.'+doms[0])[0]){ + sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide(); + } + sthis = null; + }); +}; + +//需依赖原型的对外方法 +Class.pt.openLayer = function(){ + var that = this; + + //置顶当前窗口 + layer.zIndex = that.config.zIndex; + layer.setTop = function(layero){ + var setZindex = function(){ + layer.zIndex++; + layero.css('z-index', layer.zIndex + 1); + }; + layer.zIndex = parseInt(layero[0].style.zIndex); + layero.on('mousedown', setZindex); + return layer.zIndex; + }; +}; + +//记录宽高坐标,用于还原 +ready.record = function(layero){ + var area = [ + layero.width(), + layero.height(), + layero.position().top, + layero.position().left + parseFloat(layero.css('margin-left')) + ]; + layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); + layero.attr({area: area}); +}; + +ready.rescollbar = function(index){ + if(doms.html.attr('layer-full') == index){ + if(doms.html[0].style.removeProperty){ + doms.html[0].style.removeProperty('overflow'); + } else { + doms.html[0].style.removeAttribute('overflow'); + } + doms.html.removeAttr('layer-full'); + } +}; + +/** 内置成员 */ + +window.layer = layer; + +//获取子iframe的DOM +layer.getChildFrame = function(selector, index){ + index = index || $('.'+doms[4]).attr('times'); + return $('#'+ doms[0] + index).find('iframe').contents().find(selector); +}; + +//得到当前iframe层的索引,子iframe时使用 +layer.getFrameIndex = function(name){ + return $('#'+ name).parents('.'+doms[4]).attr('times'); +}; + +//iframe层自适应宽高 +layer.iframeAuto = function(index){ + if(!index) return; + var heg = layer.getChildFrame('html', index).outerHeight(); + var layero = $('#'+ doms[0] + index); + var titHeight = layero.find(doms[1]).outerHeight() || 0; + var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; + layero.css({height: heg + titHeight + btnHeight}); + layero.find('iframe').css({height: heg}); +}; + +//重置iframe url +layer.iframeSrc = function(index, url){ + $('#'+ doms[0] + index).find('iframe').attr('src', url); +}; + +//设定层的样式 +layer.style = function(index, options, limit){ + var layero = $('#'+ doms[0] + index) + ,contElem = layero.find('.layui-layer-content') + ,type = layero.attr('type') + ,titHeight = layero.find(doms[1]).outerHeight() || 0 + ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 + ,minLeft = layero.attr('minLeft'); + + if(type === ready.type[3] || type === ready.type[4]){ + return; + } + + if(!limit){ + if(parseFloat(options.width) <= 260){ + options.width = 260; + }; + + if(parseFloat(options.height) - titHeight - btnHeight <= 64){ + options.height = 64 + titHeight + btnHeight; + }; + } + + layero.css(options); + btnHeight = layero.find('.'+doms[6]).outerHeight(); + + if(type === ready.type[2]){ + layero.find('iframe').css({ + height: parseFloat(options.height) - titHeight - btnHeight + }); + } else { + contElem.css({ + height: parseFloat(options.height) - titHeight - btnHeight + - parseFloat(contElem.css('padding-top')) + - parseFloat(contElem.css('padding-bottom')) + }) + } +}; + +//最小化 +layer.min = function(index, options){ + options = options || {}; + var layero = $('#'+ doms[0] + index) + ,shadeo = $('#'+ doms.SHADE + index) + ,titHeight = layero.find(doms[1]).outerHeight() || 0 + ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' + ,position = layero.css('position') + ,settings = { + width: 180 + ,height: titHeight + ,position: 'fixed' + ,overflow: 'hidden' + }; + + //记录宽高坐标,用于还原 + ready.record(layero); + + if(ready.minLeft[0]){ + left = ready.minLeft[0]; + ready.minLeft.shift(); + } + + //是否堆叠在左下角 + if(options.minStack){ + settings.left = left; + settings.top = win.height() - titHeight; + layero.attr('minLeft') || ready.minIndex++; //初次执行,最小化操作索引自增 + layero.attr('minLeft', left); + } + + layero.attr('position', position); + layer.style(index, settings, true); + + layero.find('.layui-layer-min').hide(); + layero.attr('type') === 'page' && layero.find(doms[4]).hide(); + ready.rescollbar(index); + + //隐藏遮罩 + shadeo.hide(); +}; + +//还原 +layer.restore = function(index){ + var layero = $('#'+ doms[0] + index) + ,shadeo = $('#'+ doms.SHADE + index) + ,area = layero.attr('area').split(',') + ,type = layero.attr('type'); + + //恢复原来尺寸 + layer.style(index, { + width: parseFloat(area[0]), + height: parseFloat(area[1]), + top: parseFloat(area[2]), + left: parseFloat(area[3]), + position: layero.attr('position'), + overflow: 'visible' + }, true); + + layero.find('.layui-layer-max').removeClass('layui-layer-maxmin'); + layero.find('.layui-layer-min').show(); + layero.attr('type') === 'page' && layero.find(doms[4]).show(); + ready.rescollbar(index); + + //恢复遮罩 + shadeo.show(); +}; + +//全屏 +layer.full = function(index){ + var layero = $('#'+ doms[0] + index), timer; + ready.record(layero); + if(!doms.html.attr('layer-full')){ + doms.html.css('overflow','hidden').attr('layer-full', index); + } + clearTimeout(timer); + timer = setTimeout(function(){ + var isfix = layero.css('position') === 'fixed'; + layer.style(index, { + top: isfix ? 0 : win.scrollTop(), + left: isfix ? 0 : win.scrollLeft(), + width: win.width(), + height: win.height() + }, true); + layero.find('.layui-layer-min').hide(); + }, 100); +}; + +//改变title +layer.title = function(name, index){ + var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]); + title.html(name); +}; + +//关闭layer总方法 +layer.close = function(index, callback){ + var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close'; + if(!layero[0]) return; + var WRAP = 'layui-layer-wrap', remove = function(){ + if(type === ready.type[1] && layero.attr('conType') === 'object'){ + layero.children(':not(.'+ doms[5] +')').remove(); + var wrap = layero.find('.'+WRAP); + for(var i = 0; i < 2; i++){ + wrap.unwrap(); + } + wrap.css('display', wrap.data('display')).removeClass(WRAP); + } else { + //低版本IE 回收 iframe + if(type === ready.type[2]){ + try { + var iframe = $('#'+doms[4]+index)[0]; + iframe.contentWindow.document.write(''); + iframe.contentWindow.close(); + layero.find('.'+doms[5])[0].removeChild(iframe); + } catch(e){} + } + layero[0].innerHTML = ''; + layero.remove(); + } + typeof ready.end[index] === 'function' && ready.end[index](); + delete ready.end[index]; + typeof callback === 'function' && callback(); + }; + + if(layero.data('isOutAnim')){ + layero.addClass('layer-anim '+ closeAnim); + } + + $('#layui-layer-moves, #'+ doms.SHADE + index).remove(); + layer.ie == 6 && ready.reselect(); + ready.rescollbar(index); + if(layero.attr('minLeft')){ + ready.minIndex--; + ready.minLeft.push(layero.attr('minLeft')); + } + + if((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')){ + remove() + } else { + setTimeout(function(){ + remove(); + }, 200); + } +}; + +//关闭所有层 +layer.closeAll = function(type, callback){ + if(typeof type === 'function'){ + callback = type; + type = null; + }; + var domsElem = $('.'+doms[0]); + $.each(domsElem, function(_index){ + var othis = $(this); + var is = type ? (othis.attr('type') === type) : 1; + is && layer.close(othis.attr('times'), _index === domsElem.length - 1 ? callback : null); + is = null; + }); + if(domsElem.length === 0) typeof callback === 'function' && callback(); +}; + +/** + + 拓展模块,layui 开始合并在一起 + + */ + +var cache = layer.cache||{}, skin = function(type){ + return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); +}; + +//仿系统prompt +layer.prompt = function(options, yes){ + var style = ''; + options = options || {}; + + if(typeof options === 'function') yes = options; + + if(options.area){ + var area = options.area; + style = '+ area[0] +'; height: '+ area[1] + ';"'; + delete options.area; + } + var prompt, content = options.formType == 2 ? '' : function(){ + return ''; + }(); + + var success = options.success; + delete options.success; + + return layer.open($.extend({ + type: 1 + ,btn: ['确定','取消'] + ,content: content + ,skin: 'layui-layer-prompt' + skin('prompt') + ,maxWidth: win.width() + ,success: function(layero){ + prompt = layero.find('.layui-layer-input'); + prompt.val(options.value || '').focus(); + typeof success === 'function' && success(layero); + } + ,resize: false + ,yes: function(index){ + var value = prompt.val(); + if(value === ''){ + prompt.focus(); + } else if(value.length> (options.maxlength||500)) { + layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1}); + } else { + yes && yes(value, index, prompt); + } + } + }, options)); +}; + +//tab层 +layer.tab = function(options){ + options = options || {}; + + var tab = options.tab || {} + ,THIS = 'layui-this' + ,success = options.success; + + delete options.success; + + return layer.open($.extend({ + type: 1, + skin: 'layui-layer-tab' + skin('tab'), + resize: false, + title: function(){ + var len = tab.length, ii = 1, str = ''; + if(len> 0){ + str = ''+ tab[0].title +''; + for(; ii < len; ii++){ + str += ''+ tab[ii].title +''; + } + } + return str; + }(), + content: '
    '+ function(){ + var len = tab.length, ii = 1, str = ''; + if(len> 0){ + str = '
  • '+ (tab[0].content || 'no content') +'
  • '; + for(; ii < len; ii++){ + str += '
  • '+ (tab[ii].content || 'no content') +'
  • '; + } + } + return str; + }() +'
', + success: function(layero){ + var btn = layero.find('.layui-layer-title').children(); + var main = layero.find('.layui-layer-tabmain').children(); + btn.on('mousedown', function(e){ + e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; + var othis = $(this), index = othis.index(); + othis.addClass(THIS).siblings().removeClass(THIS); + main.eq(index).show().siblings().hide(); + typeof options.change === 'function' && options.change(index); + }); + typeof success === 'function' && success(layero); + } + }, options)); +}; + +//相册层 +layer.photos = function(options, loop, key){ + var dict = {}; + options = options || {}; + if(!options.photos) return; + + //若 photos 并非选择器或 jQuery 对象,则为普通 object + var isObject = !(typeof options.photos === 'string' || options.photos instanceof $) + ,photos = isObject ? options.photos : {} + ,data = photos.data || [] + ,start = photos.start || 0; + + dict.imgIndex = (start|0) + 1; + options.img = options.img || 'img'; + + var success = options.success; + delete options.success; + + //如果 options.photos 不是一个对象 + if(!isObject){ //页面直接获取 + var parent = $(options.photos), pushData = function(){ + data = []; + parent.find(options.img).each(function(index){ + var othis = $(this); + othis.attr('layer-index', index); + data.push({ + alt: othis.attr('alt'), + pid: othis.attr('layer-pid'), + src: othis.attr('layer-src') || othis.attr('src'), + thumb: othis.attr('src') + }); + }); + }; + + pushData(); + + if (data.length === 0) return; + + loop || parent.on('click', options.img, function(){ + pushData(); + var othis = $(this), index = othis.attr('layer-index'); + layer.photos($.extend(options, { + photos: { + start: index, + data: data, + tab: options.tab + }, + full: options.full + }), true); + }); + + //不直接弹出 + if(!loop) return; + + } else if (data.length === 0){ + return layer.msg('没有图片'); + } + + //上一张 + dict.imgprev = function(key){ + dict.imgIndex--; + if(dict.imgIndex < 1){ + dict.imgIndex = data.length; + } + dict.tabimg(key); + }; + + //下一张 + dict.imgnext = function(key,errorMsg){ + dict.imgIndex++; + if(dict.imgIndex> data.length){ + dict.imgIndex = 1; + if (errorMsg) {return}; + } + dict.tabimg(key) + }; + + //方向键 + dict.keyup = function(event){ + if(!dict.end){ + var code = event.keyCode; + event.preventDefault(); + if(code === 37){ + dict.imgprev(true); + } else if(code === 39) { + dict.imgnext(true); + } else if(code === 27) { + layer.close(dict.index); + } + } + } + + //切换 + dict.tabimg = function(key){ + if(data.length <= 1) return; + photos.start = dict.imgIndex - 1; + layer.close(dict.index); + return layer.photos(options, true, key); + setTimeout(function(){ + layer.photos(options, true, key); + }, 200); + } + + //一些动作 + dict.event = function(){ + /* + dict.bigimg.hover(function(){ + dict.imgsee.show(); + }, function(){ + dict.imgsee.hide(); + }); + */ + + dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ + event.preventDefault(); + dict.imgprev(true); + }); + + dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ + event.preventDefault(); + dict.imgnext(true); + }); + + $(document).on('keyup', dict.keyup); + }; + + //图片预加载 + function loadImage(url, callback, error) { + var img = new Image(); + img.src = url; + if(img.complete){ + return callback(img); + } + img.onload = function(){ + img.onload = null; + callback(img); + }; + img.onerror = function(e){ + img.onerror = null; + error(e); + }; + }; + + dict.loadi = layer.load(1, { + shade: 'shade' in options ? false : 0.9, + scrollbar: false + }); + + loadImage(data[start].src, function(img){ + layer.close(dict.loadi); + + //切换图片时不出现动画 + if(key) options.anim = -1; + + //弹出图片层 + dict.index = layer.open($.extend({ + type: 1, + id: 'layui-layer-photos', + area: function(){ + var imgarea = [img.width, img.height]; + var winarea = [$(window).width() - 100, $(window).height() - 100]; + + //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) + if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ + var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 + if(wh[0]> wh[1]){//取缩放比例最大的进行缩放 + imgarea[0] = imgarea[0]/wh[0]; + imgarea[1] = imgarea[1]/wh[0]; + } else if(wh[0] < wh[1]){ + imgarea[0] = imgarea[0]/wh[1]; + imgarea[1] = imgarea[1]/wh[1]; + } + } + + return [imgarea[0]+'px', imgarea[1]+'px']; + }(), + title: false, + shade: 0.9, + shadeClose: true, + closeBtn: false, + move: '.layui-layer-phimg img', + moveType: 1, + scrollbar: false, + moveOut: true, + anim: 5, + isOutAnim: false, + skin: 'layui-layer-photos' + skin('photos'), + content: '
' + +'' + +function(){ + if(data.length> 1){ + return '
' + +'' + +'
'+ dict.imgIndex +' / '+ data.length +'
' + +'
' + } + return ''; + }() + +'
', + success: function(layero, index){ + dict.bigimg = layero.find('.layui-layer-phimg'); + dict.imgsee = layero.find('.layui-layer-imgbar'); + dict.event(layero); + options.tab && options.tab(data[start], layero); + typeof success === 'function' && success(layero); + }, end: function(){ + dict.end = true; + $(document).off('keyup', dict.keyup); + } + }, options)); + }, function(){ + layer.close(dict.loadi); + layer.msg('当前图片地址异常
是否继续查看下一张?', { + time: 30000, + btn: ['下一张', '不看了'], + yes: function(){ + data.length> 1 && dict.imgnext(true,true); + } + }); + }); +}; + +//主入口 +ready.run = function(_$){ + $ = _$; + win = $(window); + doms.html = $('html'); + layer.open = function(deliver){ + var o = new Class(deliver); + return o.index; + }; +}; + +//加载方式 +window.layui && layui.define ? ( + layer.ready() + ,layui.define('jquery', function(exports){ //layui 加载 + layer.path = layui.cache.dir; + ready.run(layui.$); + + //暴露模块 + window.layer = layer; + exports('layer', layer); + }) +) : ( + (typeof define === 'function' && define.amd) ? define(['jquery'], function(){ //requirejs 加载 + ready.run(window.jQuery); + return layer; + }) : function(){ //普通 script 标签加载 + layer.ready(); + ready.run(window.jQuery); + }() +); + +}(window); + + + diff --git a/src/mobile/README.md b/src/mobile/README.md new file mode 100644 index 00000000..1e217a7e --- /dev/null +++ b/src/mobile/README.md @@ -0,0 +1,14 @@ + +## layer mobile +layer mobile是为移动设备(手机、平板等webkit内核浏览器/webview)量身定做的弹层支撑,采用Native JavaScript编写,完全独立于PC版的layer,您需要按照场景选择使用。 + +[文档与演示](http://sentsin.com/layui/layer/) + +1. 无需依赖任何库,只加载layer.m.js即可 +2. 小巧玲珑,性能卓越、柔情似水... +3. 具备无以伦比的自适应功能 +4. 灵活的皮肤自定义支撑,充分确保弹层风格多样化 +5. 丰富、科学的接口,让弹弹弹层无所不能 + +## 备注 +[官网](http://sentsin.com/layui/layer/)、[有问必答](http://say.sentsin.com/home-48.html) diff --git a/src/mobile/layer.js b/src/mobile/layer.js new file mode 100644 index 00000000..23116171 --- /dev/null +++ b/src/mobile/layer.js @@ -0,0 +1,207 @@ +/*! + + @Name:layer mobile v2.0 弹层组件移动版 + @Author:贤心 + @License:MIT + + */ + +;!function(win){ + +"use strict"; + +var doc = document, query = 'querySelectorAll', claname = 'getElementsByClassName', S = function(s){ + return doc[query](s); +}; + +//默认配置 +var config = { + type: 0 + ,shade: true + ,shadeClose: true + ,fixed: true + ,anim: 'scale' //默认动画类型 +}; + +var ready = { + extend: function(obj){ + var newobj = JSON.parse(JSON.stringify(config)); + for(var i in obj){ + newobj[i] = obj[i]; + } + return newobj; + }, + timer: {}, end: {} +}; + +//点触事件 +ready.touch = function(elem, fn){ + elem.addEventListener('click', function(e){ + fn.call(this, e); + }, false); +}; + +var index = 0, classs = ['layui-m-layer'], Layer = function(options){ + var that = this; + that.config = ready.extend(options); + that.view(); +}; + +Layer.prototype.view = function(){ + var that = this, config = that.config, layerbox = doc.createElement('div'); + + that.id = layerbox.id = classs[0] + index; + layerbox.setAttribute('class', classs[0] + ' ' + classs[0]+(config.type || 0)); + layerbox.setAttribute('index', index); + + //标题区域 + var title = (function(){ + var titype = typeof config.title === 'object'; + return config.title + ? '

'+ (titype ? config.title[0] : config.title) +'

' + : ''; + }()); + + //按钮区域 + var button = (function(){ + typeof config.btn === 'string' && (config.btn = [config.btn]); + var btns = (config.btn || []).length, btndom; + if(btns === 0 || !config.btn){ + return ''; + } + btndom = ''+ config.btn[0] +'' + if(btns === 2){ + btndom = ''+ config.btn[1] +'' + btndom; + } + return '
'+ btndom + '
'; + }()); + + if(!config.fixed){ + config.top = config.hasOwnProperty('top') ? config.top : 100; + config.style = config.style || ''; + config.style += ' top:'+ ( doc.body.scrollTop + config.top) + 'px'; + } + + if(config.type === 2){ + config.content = '

'+ (config.content||'') +'

'; + } + + if(config.skin) config.anim = 'up'; + if(config.skin === 'msg') config.shade = false; + + layerbox.innerHTML = (config.shade ? '
' : '') + +'
' + +'
' + +'
' + + title + +'
'+ config.content +'
' + + button + +'
' + +'
' + +'
'; + + if(!config.type || config.type === 2){ + var dialogs = doc[claname](classs[0] + config.type), dialen = dialogs.length; + if(dialen>= 1){ + layer.close(dialogs[0].getAttribute('index')) + } + } + + document.body.appendChild(layerbox); + var elem = that.elem = S('#'+that.id)[0]; + config.success && config.success(elem); + + that.index = index++; + that.action(config, elem); +}; + +Layer.prototype.action = function(config, elem){ + var that = this; + + //自动关闭 + if(config.time){ + ready.timer[that.index] = setTimeout(function(){ + layer.close(that.index); + }, config.time*1000); + } + + //确认取消 + var btn = function(){ + var type = this.getAttribute('type'); + if(type == 0){ + config.no && config.no(); + layer.close(that.index); + } else { + config.yes ? config.yes(that.index) : layer.close(that.index); + } + }; + if(config.btn){ + var btns = elem[claname]('layui-m-layerbtn')[0].children, btnlen = btns.length; + for(var ii = 0; ii < btnlen; ii++){ + ready.touch(btns[ii], btn); + } + } + + //点遮罩关闭 + if(config.shade && config.shadeClose){ + var shade = elem[claname]('layui-m-layershade')[0]; + ready.touch(shade, function(){ + layer.close(that.index, config.end); + }); + } + + config.end && (ready.end[that.index] = config.end); +}; + +win.layer = { + v: '2.0', + index: index, + + //核心方法 + open: function(options){ + var o = new Layer(options || {}); + return o.index; + }, + + close: function(index){ + var ibox = S('#'+classs[0]+index)[0]; + if(!ibox) return; + ibox.innerHTML = ''; + doc.body.removeChild(ibox); + clearTimeout(ready.timer[index]); + delete ready.timer[index]; + typeof ready.end[index] === 'function' && ready.end[index](); + delete ready.end[index]; + }, + + //关闭所有layer层 + closeAll: function(){ + var boxs = doc[claname](classs[0]); + for(var i = 0, len = boxs.length; i < len; i++){ + layer.close((boxs[0].getAttribute('index')|0)); + } + } +}; + +'function' == typeof define ? define(function() { + return layer; +}) : function(){ + + var js = document.scripts, script = js[js.length - 1], jsPath = script.src; + var path = jsPath.substring(0, jsPath.lastIndexOf("/") + 1); + + //如果合并方式,则需要单独引入layer.css + if(script.getAttribute('merge')) return; + + document.head.appendChild(function(){ + var link = doc.createElement('link'); + link.href = path + 'need/layer.css?2.0'; + link.type = 'text/css'; + link.rel = 'styleSheet' + link.id = 'layermcss'; + return link; + }()); + +}(); + +}(window); \ No newline at end of file diff --git a/src/mobile/need/layer.css b/src/mobile/need/layer.css new file mode 100644 index 00000000..c8b32e07 --- /dev/null +++ b/src/mobile/need/layer.css @@ -0,0 +1,87 @@ + +/* + layer mobile +*/ + +.layui-m-layer{position:relative; z-index: 19891014;} +.layui-m-layer *{-webkit-box-sizing: content-box; -moz-box-sizing: content-box; box-sizing: content-box;} +.layui-m-layershade, +.layui-m-layermain{position:fixed; left:0; top:0; width:100%; height:100%;} +.layui-m-layershade{background-color:rgba(0,0,0, .7); pointer-events:auto;} +.layui-m-layermain{display:table; font-family: Helvetica, arial, sans-serif; pointer-events: none;} +.layui-m-layermain .layui-m-layersection{display:table-cell; vertical-align:middle; text-align:center;} +.layui-m-layerchild{position:relative; display:inline-block; text-align:left; background-color:#fff; font-size:14px; border-radius: 5px; box-shadow: 0 0 8px rgba(0, 0, 0, 0.1); pointer-events:auto; -webkit-overflow-scrolling: touch;} +.layui-m-layerchild{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration: .2s; animation-duration: .2s;} + + +/* 弹出动画 */ +@-webkit-keyframes layui-m-anim-scale { /* 默认 */ + 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} + 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} +} +@keyframes layui-m-anim-scale { /* 默认 */ + 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} + 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} +} +.layui-m-anim-scale{animation-name: layui-m-anim-scale; -webkit-animation-name: layui-m-anim-scale;} + +@-webkit-keyframes layui-m-anim-up{ + 0%{opacity: 0; -webkit-transform: translateY(800px); transform: translateY(800px)} + 100%{opacity: 1; -webkit-transform: translateY(0); transform: translateY(0)} +} +@keyframes layui-m-anim-up{ + 0%{opacity: 0; -webkit-transform: translateY(800px); transform: translateY(800px)} + 100%{opacity: 1; -webkit-transform: translateY(0); transform: translateY(0)} +} +.layui-m-anim-up{-webkit-animation-name: layui-m-anim-up;animation-name: layui-m-anim-up} + + +.layui-m-layer0 .layui-m-layerchild{width: 90%; max-width: 640px;} +.layui-m-layer1 .layui-m-layerchild{border:none; border-radius:0;} +.layui-m-layer2 .layui-m-layerchild{width:auto; max-width:260px; min-width:40px; border:none; background: none; box-shadow: none; color:#fff;} +.layui-m-layerchild h3{padding: 0 10px; height: 60px; line-height: 60px; font-size:16px; font-weight: 400; border-radius: 5px 5px 0 0; text-align: center;} +.layui-m-layerchild h3, +.layui-m-layerbtn span{ text-overflow:ellipsis; overflow:hidden; white-space:nowrap;} +.layui-m-layercont{padding: 50px 30px; line-height: 22px; text-align:center;} +.layui-m-layer1 .layui-m-layercont{padding:0; text-align:left;} +.layui-m-layer2 .layui-m-layercont{text-align:center; padding: 0; line-height: 0;} +.layui-m-layer2 .layui-m-layercont i{width:25px; height:25px; margin-left:8px; display:inline-block; background-color:#fff; border-radius:100%;} +.layui-m-layer2 .layui-m-layercont p{margin-top: 20px;} + +/* loading */ +@-webkit-keyframes layui-m-anim-loading{ + 0%,80%,100%{transform:scale(0); -webkit-transform:scale(0)} + 40%{transform:scale(1); -webkit-transform:scale(1)} +} +@keyframes layui-m-anim-loading{ + 0%,80%,100%{transform:scale(0); -webkit-transform:scale(0)} + 40%{transform:scale(1); -webkit-transform:scale(1)} +} +.layui-m-layer2 .layui-m-layercont i{-webkit-animation: layui-m-anim-loading 1.4s infinite ease-in-out; animation: layui-m-anim-loading 1.4s infinite ease-in-out; -webkit-animation-fill-mode: both; animation-fill-mode: both;} + +.layui-m-layer2 .layui-m-layercont i:first-child{margin-left:0; -webkit-animation-delay: -.32s; animation-delay: -.32s;} +.layui-m-layer2 .layui-m-layercont i.layui-m-layerload{-webkit-animation-delay: -.16s; animation-delay: -.16s;} +.layui-m-layer2 .layui-m-layercont>div{line-height:22px; padding-top:7px; margin-bottom:20px; font-size: 14px;} +.layui-m-layerbtn{display: box; display: -moz-box; display: -webkit-box; width: 100%; position:relative; height: 50px; line-height: 50px; font-size: 0; text-align:center; border-top:1px solid #D0D0D0; background-color: #F2F2F2; border-radius: 0 0 5px 5px;} +.layui-m-layerbtn span{position:relative; display: block; -moz-box-flex: 1; box-flex: 1; -webkit-box-flex: 1; text-align:center; font-size:14px; border-radius: 0 0 5px 5px; cursor:pointer;} +.layui-m-layerbtn span[yes]{color: #40AFFE;} +.layui-m-layerbtn span[no]{border-right: 1px solid #D0D0D0; border-radius: 0 0 0 5px;} +.layui-m-layerbtn span:active{background-color: #F6F6F6;} +.layui-m-layerend{position:absolute; right:7px; top:10px; width:30px; height:30px; border: 0; font-weight:400; background: transparent; cursor: pointer; -webkit-appearance: none; font-size:30px;} +.layui-m-layerend::before, .layui-m-layerend::after{position:absolute; left:5px; top:15px; content:''; width:18px; height:1px; background-color:#999; transform:rotate(45deg); -webkit-transform:rotate(45deg); border-radius: 3px;} +.layui-m-layerend::after{transform:rotate(-45deg); -webkit-transform:rotate(-45deg);} + +/* 底部对话框风格 */ +body .layui-m-layer .layui-m-layer-footer{position: fixed; width: 95%; max-width: 100%; margin: 0 auto; left:0; right: 0; bottom: 10px; background: none;} +.layui-m-layer-footer .layui-m-layercont{padding: 20px; border-radius: 5px 5px 0 0; background-color: rgba(255,255,255,.8);} +.layui-m-layer-footer .layui-m-layerbtn{display: block; height: auto; background: none; border-top: none;} +.layui-m-layer-footer .layui-m-layerbtn span{background-color: rgba(255,255,255,.8);} +.layui-m-layer-footer .layui-m-layerbtn span[no]{color: #FD482C; border-top: 1px solid #c2c2c2; border-radius: 0 0 5px 5px;} +.layui-m-layer-footer .layui-m-layerbtn span[yes]{margin-top: 10px; border-radius: 5px;} + +/* 通用提示 */ +body .layui-m-layer .layui-m-layer-msg{width: auto; max-width: 90%; margin: 0 auto; bottom: -150px; background-color: rgba(0,0,0,.7); color: #fff;} +.layui-m-layer-msg .layui-m-layercont{padding: 10px 20px;} + + + diff --git a/src/theme/default/icon-ext.png b/src/theme/default/icon-ext.png new file mode 100644 index 00000000..bbbb669b Binary files /dev/null and b/src/theme/default/icon-ext.png differ diff --git a/src/theme/default/icon.png b/src/theme/default/icon.png new file mode 100644 index 00000000..3e17da8b Binary files /dev/null and b/src/theme/default/icon.png differ diff --git a/src/theme/default/layer.css b/src/theme/default/layer.css new file mode 100644 index 00000000..54a6aeee --- /dev/null +++ b/src/theme/default/layer.css @@ -0,0 +1,179 @@ +/** + + @Name: layer + + **/ + +/* *html{background-image: url(about:blank); background-attachment: fixed;} */ +html #layuicss-layer{display: none; position: absolute; width: 1989px;} + +/* common */ +.layui-layer-shade, .layui-layer{position:fixed; _position:absolute; pointer-events: auto;} +.layui-layer-shade{top:0; left:0; width:100%; height:100%; _height:expression(document.body.offsetHeight+"px");} +.layui-layer{-webkit-overflow-scrolling: touch;} +.layui-layer{top:150px; left: 0; margin:0; padding:0; background-color:#fff; -webkit-background-clip: content; border-radius: 2px; box-shadow: 1px 1px 50px rgba(0,0,0,.3);} +.layui-layer-close{position:absolute;} +.layui-layer-content{position:relative;} +.layui-layer-border{border: 1px solid #B2B2B2; border: 1px solid rgba(0,0,0,.1); box-shadow: 1px 1px 5px rgba(0,0,0,.2);} +.layui-layer-load{background:url(loading-1.gif) #eee center center no-repeat;} +.layui-layer-ico{ background:url(icon.png) no-repeat;} +.layui-layer-dialog .layui-layer-ico, +.layui-layer-setwin a, +.layui-layer-btn a{display:inline-block; *display:inline; *zoom:1; vertical-align:top;} + +.layui-layer-move{display: none; position: fixed; *position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; cursor: move; opacity: 0; filter:alpha(opacity=0); background-color: #fff; z-index: 2147483647;} +.layui-layer-resize{position: absolute; width: 15px; height: 15px; right: 0; bottom: 0; cursor: se-resize;} + +/* 动画 */ +.layer-anim{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.3s; animation-duration:.3s;} + +@-webkit-keyframes layer-bounceIn { /* 默认 */ + 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)} + 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)} +} +@keyframes layer-bounceIn { + 0% {opacity: 0; -webkit-transform: scale(.5); -ms-transform: scale(.5); transform: scale(.5)} + 100% {opacity: 1; -webkit-transform: scale(1); -ms-transform: scale(1); transform: scale(1)} +} +.layer-anim-00{-webkit-animation-name: layer-bounceIn;animation-name: layer-bounceIn} + +@-webkit-keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);-ms-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);-ms-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-01{-webkit-animation-name:layer-zoomInDown;animation-name:layer-zoomInDown} + +@-webkit-keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.layer-anim-02{-webkit-animation-name:layer-fadeInUpBig;animation-name:layer-fadeInUpBig} + +@-webkit-keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);-ms-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);-ms-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-03{-webkit-animation-name:layer-zoomInLeft;animation-name:layer-zoomInLeft} + +@-webkit-keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}@keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);-ms-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);-ms-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}.layer-anim-04{-webkit-animation-name:layer-rollIn;animation-name:layer-rollIn} + +@keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn} + +@-webkit-keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);transform:translateX(10px)}}@keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);-ms-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);-ms-transform:translateX(10px);transform:translateX(10px)}}.layer-anim-06{-webkit-animation-name:layer-shake;animation-name:layer-shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}} + +/* 标题栏 */ +.layui-layer-title{padding:0 80px 0 20px; height: 50px; line-height: 50px; border-bottom:1px solid #F0F0F0; font-size: 14px; color:#333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 2px 2px 0 0;} +.layui-layer-setwin{position:absolute; right: 15px; *right:0; top: 17px; font-size:0; line-height: initial;} +.layui-layer-setwin a{position:relative; width: 16px; height:16px; margin-left:10px; font-size:12px; _overflow:hidden;} +.layui-layer-setwin .layui-layer-min cite{position:absolute; width:14px; height:2px; left:0; top:50%; margin-top:-1px; background-color:#2E2D3C; cursor:pointer; _overflow:hidden;} +.layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA; } +.layui-layer-setwin .layui-layer-max{background-position:-32px -40px;} +.layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px;} +.layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px;} +.layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px;} +.layui-layer-setwin .layui-layer-close1{background-position: 1px -40px; cursor: pointer;} +.layui-layer-setwin .layui-layer-close1:hover{opacity:0.7;} +.layui-layer-setwin .layui-layer-close2{position:absolute; right:-28px; top:-28px; width:30px; height:30px; margin-left:0; background-position:-149px -31px; *right:-18px; _display:none;} +.layui-layer-setwin .layui-layer-close2:hover{ background-position:-180px -31px;} + +/* 按钮栏 */ +.layui-layer-btn{text-align: right; padding: 0 15px 12px; pointer-events: auto; user-select: none; -webkit-user-select: none;} +.layui-layer-btn a{height: 28px; line-height: 28px; margin: 5px 5px 0; padding: 0 15px; border: 1px solid #dedede; background-color:#fff; color: #333; border-radius: 2px; font-weight:400; cursor:pointer; text-decoration: none;} +.layui-layer-btn a:hover{opacity: 0.9; text-decoration: none;} +.layui-layer-btn a:active{opacity: 0.8;} +.layui-layer-btn .layui-layer-btn0{border-color: #1E9FFF; background-color: #1E9FFF; color:#fff;} +.layui-layer-btn-l{text-align: left;} +.layui-layer-btn-c{text-align: center;} + +/* 定制化 */ +.layui-layer-dialog{min-width: 300px;} +.layui-layer-dialog .layui-layer-content{position: relative; padding:20px; line-height:24px; word-break: break-all; overflow:hidden; font-size:14px; overflow-x: hidden; overflow-y:auto;} +.layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute; top:16px; left:15px; _left:-40px; width:30px; height:30px;} +.layui-layer-ico1{background-position:-30px 0 } +.layui-layer-ico2{background-position:-60px 0;} +.layui-layer-ico3{background-position:-90px 0;} +.layui-layer-ico4{background-position:-120px 0;} +.layui-layer-ico5{background-position:-150px 0;} +.layui-layer-ico6{background-position:-180px 0;} +.layui-layer-rim{border:6px solid #8D8D8D; border:6px solid rgba(0,0,0,.3); border-radius:5px; box-shadow: none;} +.layui-layer-msg{min-width:180px; border:1px solid #D3D4D3; box-shadow: none;} +.layui-layer-hui{min-width:100px; background-color: #000; filter:alpha(opacity=60); background-color: rgba(0,0,0,0.6); color: #fff; border:none;} +.layui-layer-hui .layui-layer-content{padding:12px 25px; text-align:center;} +.layui-layer-dialog .layui-layer-padding{padding: 20px 20px 20px 55px; text-align: left;} +.layui-layer-page .layui-layer-content{position:relative; overflow:auto;} +.layui-layer-page .layui-layer-btn,.layui-layer-iframe .layui-layer-btn{padding-top:10px;} +.layui-layer-nobg{background:none;} +.layui-layer-iframe iframe{display: block; width: 100%;} + +.layui-layer-loading{border-radius:100%; background:none; box-shadow:none; border:none;} +.layui-layer-loading .layui-layer-content{width:60px; height:24px; background:url(loading-0.gif) no-repeat;} +.layui-layer-loading .layui-layer-loading1{width:37px; height:37px; background:url(loading-1.gif) no-repeat;} +.layui-layer-loading .layui-layer-loading2, .layui-layer-ico16{width:32px; height:32px; background:url(loading-2.gif) no-repeat;} +.layui-layer-tips{background: none; box-shadow:none; border:none;} +.layui-layer-tips .layui-layer-content{position: relative; line-height: 22px; min-width: 12px; padding: 8px 15px; font-size: 12px; _float:left; border-radius: 2px; box-shadow: 1px 1px 3px rgba(0,0,0,.2); background-color: #000; color: #fff;} +.layui-layer-tips .layui-layer-close{right:-2px; top:-1px;} +.layui-layer-tips i.layui-layer-TipsG{ position:absolute; width:0; height:0; border-width:8px; border-color:transparent; border-style:dashed; *overflow:hidden;} +.layui-layer-tips i.layui-layer-TipsT, .layui-layer-tips i.layui-layer-TipsB{left:5px; border-right-style:solid; border-right-color: #000;} +.layui-layer-tips i.layui-layer-TipsT{bottom:-8px;} +.layui-layer-tips i.layui-layer-TipsB{top:-8px;} +.layui-layer-tips i.layui-layer-TipsR, .layui-layer-tips i.layui-layer-TipsL{top: 5px; border-bottom-style:solid; border-bottom-color: #000;} +.layui-layer-tips i.layui-layer-TipsR{left:-8px;} +.layui-layer-tips i.layui-layer-TipsL{right:-8px;} + +/* skin */ +.layui-layer-lan[type="dialog"]{min-width:280px;} +.layui-layer-lan .layui-layer-title{background:#4476A7; color:#fff; border: none;} +.layui-layer-lan .layui-layer-btn{padding: 5px 10px 10px; text-align: right; border-top:1px solid #E9E7E7} +.layui-layer-lan .layui-layer-btn a{background: #fff; border-color: #E9E7E7; color: #333;} +.layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;} +.layui-layer-molv .layui-layer-title{background: #009f95; color:#fff; border: none;} +.layui-layer-molv .layui-layer-btn a{background: #009f95; border-color: #009f95;} +.layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;} + + +/** + + @Name: layer拓展样式 + + */ + +.layui-layer-iconext{background:url(icon-ext.png) no-repeat;} + +/* prompt模式 */ +.layui-layer-prompt .layui-layer-input{display: block; width: 260px; height: 36px; margin: 0 auto; line-height: 30px; padding-left: 10px; border: 1px solid #e6e6e6; color: #333;} +.layui-layer-prompt textarea.layui-layer-input{width: 300px; height: 100px; line-height: 20px; padding: 6px 10px;} +.layui-layer-prompt .layui-layer-content{padding: 20px;} +.layui-layer-prompt .layui-layer-btn{padding-top: 0;} + +/* tab模式 */ +.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4);} +.layui-layer-tab .layui-layer-title{padding-left:0; overflow: visible;} +.layui-layer-tab .layui-layer-title span{position:relative; float:left; min-width:80px; max-width: 300px; padding:0 20px; text-align:center; cursor:default; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; cursor: pointer;} +.layui-layer-tab .layui-layer-title span.layui-this{height: 51px; border-left: 1px solid #eee; border-right: 1px solid #eee; background-color: #fff; z-index: 10;} +.layui-layer-tab .layui-layer-title span:first-child{border-left:none;} +.layui-layer-tabmain{line-height:24px; clear:both;} +.layui-layer-tabmain .layui-layer-tabli{display:none;} +.layui-layer-tabmain .layui-layer-tabli.layui-this{display: block;} + +/* photo模式 */ +.layui-layer-photos{background: none; box-shadow: none;} +.layui-layer-photos .layui-layer-content{overflow:hidden; text-align: center;} +.layui-layer-photos .layui-layer-phimg img{position: relative; width:100%; display: inline-block; *display:inline; *zoom:1; vertical-align:top;} +.layui-layer-imgprev, .layui-layer-imgnext{position: fixed; top: 50%; width: 27px; _width: 44px; height: 44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());} +.layui-layer-imgprev{left: 30px; background-position:-5px -5px; _background-position:-70px -5px;} +.layui-layer-imgprev:hover{background-position:-33px -5px; _background-position:-120px -5px;} +.layui-layer-imgnext{right: 30px; _right:8px; background-position:-5px -50px; _background-position:-70px -50px;} +.layui-layer-imgnext:hover{background-position: -33px -50px; _background-position: -120px -50px;} +.layui-layer-imgbar{position: fixed; left:0; right: 0; bottom:0; width:100%; height: 40px; line-height: 40px; background-color:#0009円; filter:Alpha(opacity=60); background-color: rgba(2,0,0,.35); color: #fff; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size:0;} +.layui-layer-imgtit{/*position:absolute; left:20px;*/} +.layui-layer-imgtit *{display:inline-block; *display:inline; *zoom:1; vertical-align:top; font-size:12px;} +.layui-layer-imgtit a{max-width:65%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color:#fff;} +.layui-layer-imgtit a:hover{color:#fff; text-decoration:underline;} +.layui-layer-imgtit em{padding-left:10px; font-style: normal;} + +/* 关闭动画 */ +@-webkit-keyframes layer-bounceOut { + 100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)} + 30% {-webkit-transform: scale(1.05); transform: scale(1.05)} + 0% {-webkit-transform: scale(1); transform: scale(1);} +} +@keyframes layer-bounceOut { + 100% {opacity: 0; -webkit-transform: scale(.7); -ms-transform: scale(.7); transform: scale(.7);} + 30% {-webkit-transform: scale(1.05); -ms-transform: scale(1.05); transform: scale(1.05);} + 0% {-webkit-transform: scale(1); -ms-transform: scale(1);transform: scale(1);} +} +.layer-anim-close{-webkit-animation-name: layer-bounceOut; animation-name: layer-bounceOut; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.2s; animation-duration:.2s;} + +@media screen and (max-width: 1100px) { + .layui-layer-iframe{overflow-y: auto; -webkit-overflow-scrolling: touch;} +} + + diff --git a/src/theme/default/loading-0.gif b/src/theme/default/loading-0.gif new file mode 100644 index 00000000..6f3c9539 Binary files /dev/null and b/src/theme/default/loading-0.gif differ diff --git a/src/theme/default/loading-1.gif b/src/theme/default/loading-1.gif new file mode 100644 index 00000000..db3a483e Binary files /dev/null and b/src/theme/default/loading-1.gif differ diff --git a/src/theme/default/loading-2.gif b/src/theme/default/loading-2.gif new file mode 100644 index 00000000..5bb90fd6 Binary files /dev/null and b/src/theme/default/loading-2.gif differ diff --git a/src/theme/moon/default.png b/src/theme/moon/default.png new file mode 100644 index 00000000..77dfaf30 Binary files /dev/null and b/src/theme/moon/default.png differ diff --git a/src/theme/moon/style.css b/src/theme/moon/style.css new file mode 100644 index 00000000..e8264cec --- /dev/null +++ b/src/theme/moon/style.css @@ -0,0 +1,140 @@ +/* + * layer皮肤 + * + */ + +html #layui_layer_skinmoonstylecss { + display: none; + position: absolute; + width: 1989px; +} + +body .layer-ext-moon[type="dialog"] { + min-width: 320px; +} +body .layer-ext-moon-msg[type="dialog"]{min-width:200px;} +body .layer-ext-moon .layui-layer-title { + background: #f6f6f6; + color: #212a31; + font-size: 16px; + font-weight: bold; + height: 46px; + line-height: 46px; + border-bottom: 1px solid #D5D5D5; +} + + + +body .layer-ext-moon .layui-layer-content .layui-layer-ico { + height: 32px; + width: 32px; + top:18.5px; +} +body .layer-ext-moon .layui-layer-ico0 { + background: url(default.png) no-repeat -96px 0; + ; +} +body .layer-ext-moon .layui-layer-ico1 { + background: url(default.png) no-repeat -224px 0; + ; +} +body .layer-ext-moon .layui-layer-ico2 { + background: url(default.png) no-repeat -192px 0; +} +body .layer-ext-moon .layui-layer-ico3 { + background: url(default.png) no-repeat -160px 0; +} +body .layer-ext-moon .layui-layer-ico4 { + background: url(default.png) no-repeat -320px 0; +} +body .layer-ext-moon .layui-layer-ico5 { + background: url(default.png) no-repeat -288px 0; +} +body .layer-ext-moon .layui-layer-ico6 { + background: url(default.png) -256px 0; +} +body .layer-ext-moon .layui-layer-ico7 { + background: url(default.png) no-repeat -128px 0; +} +body .layer-ext-moon .layui-layer-setwin { + top: 15px; + right: 15px; +} +body .layer-ext-moon .layui-layer-setwin a { + width: 16px; + height: 16px; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-min cite:hover { + background-color: #56abe4; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-max { + background: url(default.png) no-repeat -80px 0; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-max:hover { + background: url(default.png) no-repeat -64px 0; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin { + background: url(default.png) no-repeat -32px 0; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-maxmin:hover { + background: url(default.png) no-repeat -16px 0; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-close1,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2 { + background: url(default.png) 0 0; +} +body .layer-ext-moon .layui-layer-setwin .layui-layer-close1:hover,body .layer-ext-moon .layui-layer-setwin .layui-layer-close2:hover { + background: url(default.png) -48px 0; +} +body .layer-ext-moon .layui-layer-padding{padding-top: 24px;} +body .layer-ext-moon .layui-layer-btn { + text-align: center; + padding-top: 15px; + padding-bottom:15px; + background: #f0f4f7; + border-top: 1px #c7c7c7 solid; +} +body .layer-ext-moon .layui-layer-btn a { + font-size: 12px; + font-weight: normal; + margin: 0 3px; + margin-right: 7px; + margin-left: 7px; + padding: 6px 20px; + color: #fff; + border: 1px solid #0064b6; + background: #0071ce; + border-radius: 3px; + display: inline-block; + height: 20px; + line-height: 20px; + text-align: center; + vertical-align: middle; + background-repeat: no-repeat; + text-decoration: none; + outline: none; +} +body .layer-ext-moon .layui-layer-btn .layui-layer-btn0 { + background: #0071ce; +} +body .layer-ext-moon .layui-layer-btn .layui-layer-btn1 { + background: #fff; + color: #404a58; + border: 1px solid #c0c4cd; + border-radius: 3px; +} +body .layer-ext-moon .layui-layer-btn .layui-layer-btn2 { + background: #f60; + color: #fff; + border: 1px solid #f60; + border-radius: 3px; +} +body .layer-ext-moon .layui-layer-btn .layui-layer-btn3 { + background: #f00; + color: #fff; + border: 1px solid #f00; + border-radius: 3px; +} + +body .layer-ext-moon .layui-layer-title span.layui-layer-tabnow{ + height:47px; +} diff --git a/test/demo.html b/test/demo.html new file mode 100644 index 00000000..d091df12 --- /dev/null +++ b/test/demo.html @@ -0,0 +1,76 @@ + + + + + + + + layer-更懂你的web弹窗解决方案 + + + + + + + +
+
+ @Name:layer
+ @Version:v
+ @Description:通用 Web 弹层组件
+
+
+【注意事项】
+一、使用时,请把文件夹 layer 整个放置在您站点的任何一个目录,只需引入 layer.js 即可,除 jQuery 外,其它文件无需再引入。
+二、如果您的 js 引入是通过合并处理或者您不想采用layer自动获取的绝对路径,您可以通过 layer.config() 来配置(详见官网 API 页)
+三、jQuery 需 1.8+
+四、更多使用说明与演示,请参见 layer 官网。
+五、使用时请务必保留来源,请勿用于违反我国法律法规的 Web 平台。
+六、layer 是一款无偿的公益性项目,遵循 MIT 开源协议。
+
+
+ + + + + + \ No newline at end of file