commit 64bec465f45b8fdcddbff3d91155b999451ce3ae Author: sentsin Date: Thu Oct 27 08:50:05 2016 +0800 2.4 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ce77899 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,135 @@ +# v2.4(2016.07.03) +* 兼容jQuery3.0 +* 优化tips,可支持配置参数fix(之前是强制fix: false),用于决定是固定的tips还是非固定的。 +* min回调可通过return false来设定不执行默认最小化。 +* 修复在移动端使用iframe,IOS下无法滑动的bug。 +* 细节优化及样式微调 + +# 【2.3】2016.05.18 +* 通过对使用频率的调查,将layer.ext.js(拓展模块)合并到了layer.js,即不用再通过layer.config来加载调用。 +* cancel回调不再对第二个按钮有效,只作为右上角关闭按钮触发。并且除yes回调外,所以按钮的回调都可以通过return false来设定不默认关闭。 +* 修复相册层,点击任意图片查看,弹出的并非当前图片的bug。 +* 修复相册层在移动端显示不佳的bug。 +* 修复msg、alert等对话框类型的弹层,在手机使用时未水平居中的bug。 + +# 【2.2】2015.03.18 +* 增加参数id,用于控制弹层唯一标识。如不想重复弹出,可设置该值。 +* layer.tips允许出现遮罩,即不对shade参数做限制。 +* 对layer.photos方法直接弹出页面图片进行了事件委托,修复了之前由于动态插入的img而无法执行弹出的bug,并且修复了当图片信息改变时,仍然弹出了之前的图片的bug +* layer.photos方法多处代码进行了优化 +* 对layer.tab方法新增回调函数change,用于监听选项卡的切换事件,返回一个选项卡索引参数。 +* 样式微调 + + +# 【2.1】2015.11.04 +* 修复在使用seajs或者requirejs后,layer.ext.js报layer未定义的错误。 +* 修复弹出层后,回车键无效的bug。 +* 修复iframe层的success回调在ie8以下浏览器无效的bug +* 修复只有一张图片时,并且该图片地址异常,不断弹出提示的bug。 +* 修复当设定moveEnd回调,即便层关闭,仍然触发该回调的bug +* 即便采用模块加载,layer对象仍然保留全局,原因是layer自有模块需要。 +* 优化图标锯齿消的回调除了yes和cancel外,还可用btn1/btn2。 btn2可解决取消遇右上角关闭共用cancel回调的问题。即如果你只需要接受取消的回调,可以使用 btn2: function(){} + + + +# 【2.0】2015.09.01 +* 全新的默认皮肤 +* 修复按住Enter键时,出现不断弹层的bug。 +* 修复模块加载时,layer仍然暴露给了全局的bug。 +* 修复拖拽完毕回调moveEnd,在层关闭后拖拽鼠标仍然触发该回调的bug。 +* 确认和取消的回调除了yes和cancel外,还可用btn1/btn2。 btn2可解决取消遇右上角关闭共用cancel回调的问题。即如果你只需要接受取消的回调,可以使用 btn2: function(){} + +## == 拓展模块 == +* 修复通过script标签引入layer.ext.js时,出现Cannot read property 'skin' of undefined的报错问题。(虽然我们更推荐用layer.config()方式加载layer.ext.js)。 +* 如果相册只有一张图片,则不触发上/下一张。 + + +# 【1.9.3】2015.05.23 +* 修复全局设置皮肤时,部分类型层未起作用的bug。 +* 增加skin值:layui-layer-rim,用于给层加边框(类似1.85的风格) +* 样式微调 + +## == 拓展模块 == +* 修复相册层设定基础参数时,只有首次有效的bug。 + + +# 【1.9.2】2015.05.08 +* 增加关闭动画样式:layui-layer-close +* 优化默认弹出动画 +* 优化默认图标,默认的icon支持缩减到0-6(拓展皮肤可自己任意设定支持的数目) +* 优化部分样式 +* 机智地修复了一个隐藏得非常深的但是不是太重要的bug。 +* 剔除了一些图片。 + +# 【1.9.1】2015.04.29 +* btn设定多个按钮时,新增对应的回调(支持只有yes和cancel回调),如btn: ['按钮一','按钮二','按钮三'],按钮一和按钮二还是之前的yes和cancel,按钮三,则回调为 btn3: function(){},以此类推。 +* 对cancel回调进行了微完善,如果不想关闭,return false即可,如cancel: function(){return false},取消则不会关闭。 +* 修复当设置了fix:false时,offset的设置无效的bug +* 为低版本IE回收iframe占用的内存,从而修复偶尔无法获焦的bug +* 修复当设置了btn时,最小化不能愉快地呈现的bug。 +* 修复全局设置skin时,某些层类型出现样式异常的bug。 +* 修复area设置了百分比时,maxmin参数无效的bug。 +* 完善当采用script标签合并路径的方式引入layer,加载了错误的css路径的问题。这种情况需在script标签上加一个自定义属性merge="true",然后通过layer.config({path: 'layer所在目录'})来完成初始化的配置 +* 样式微调 + +# 【1.9.0】2015.04.19 + +* 新增laye.open(options),抛弃了之前的$.layer(options)调用方法,目的是与layer mobile保持统一。 +* 新增layer.config(options)方法,用于进行全局化配置。除了用于展现弹层的基础参数外,还支持path,用于模块化加载layer时设定目录以便加载所需配件,如layer.config({path: '所在路径', extend: ''}); +* 新增content参数,用于统一传入内容。支持string类型和jquery dom对象。如果是type:2,即iframe的url。 +* 新增icon参数,用于统一配置对话框和loading的icon类型。 +* 新增cancel参数,用于统一取消回调。 +* 新增skin参数,用于控制层的不同外观。 +* 新增layer.ready(path, callback),用于页面加载时即调用弹层。如果通过layer.config配置了path,此方法的path可以不填,即直接layer.ready(callback); +* 新增tipsMore,用于开启多个tips +* 新增scrollbar,用于设定是否屏蔽浏览器滚动条 + +* 完善offset参数,除了跟之前一样,[Y坐标, X坐标],还支持传入'rd',表示右下角。另外还支持只传入Y坐标,如offset: '120px'。默认'auto',即垂直水平居中。 +* 完善自适应,只要设定了固定高度,任何层都会自适应出现滚动条 +* 完善shift,全新的CSS3动画模式,支持传入0-6。 +* 完善area,支持传入宽度、[宽,高],默认'auto',表示自适应 +* 完善time,传入值改为毫秒,比如2秒关闭,time: 2000 +* 完善use方法,修复之前初始调用时部分浏览器一些不稳定因素 +* 完善layer.full/layer.min方法,只要传入index即可,不用跟之前一样还要传入area和offset。。。 +* layer.alert/confirm/msg/load/tips五种快捷引用重写,更灵活,更易使用。 + +* 剔除border参数,因为它没有本质的作用,自定义层样式可以通过新增的skin参数 +* 剔除dialog的msg,page的html/url/dom,统一采用content +* 剔除dialog和loading的type,统一采用icon +* 剔除dialog中用于配置按钮数的btns,因为可直接通过btn本身来获取。 +* 剔除no和close回调,统一采用cancel取代,不过仍然对前两者兼容。 +* 剔除layer.closeLoad()、layer.closeTips()方法,统一用layer.closeAll('loading/tips')来对指定类型层进行关闭 +* 剔除bgcolor参数,因为自定义的样式一律采用skin参数控制 +* 剔除tips一些列子元素,只保留自身,并且支持number和object形,用于设定方向和显示箭头。 +* 剔除layer.getIndex方法,获取索引统一用返回值 +* 剔除layer.autoArea方法,因为已经采取更好的自适应方案。 + +* 默认不显示dialog图标,需要显示配置dialog指定的type即可 +* 很多不可见只可感受的细节改动 + +### << 拓展模块 >> +* layer.prompt/layer.tab/layer.photos重写,代码更强健,功能更强大,详见Api。 + + +总之!总之…layer1.9.0有着太多的调整,爱她,就认真去感受她!么么哒 + +——贤心 2015/4/15 + +# 【1.8.5】 +* 新增对title样式的自定义控制 +* 修复layer.prompt多行文本,设置默认值无效的bug + +# 【1.8.4】 +* 新增浏览器窗口尺寸改变时的自适应定位 +* 新增属性shift,用于配置动画弹出(需要注意的是,之前的layer.shift()方法将在layer1.9遗弃,用shift属性取代) +* 新增方法layer.title(name, index); 用于动态改变层的标题。 +* 修改弹出层默认初始坐标为垂直左右居中。 +* 开放多个tips,可通过配置tips: {more: true}开启。 +* 进一步完善tips的智能定位。 +* 放弃layer.ready方法,用jQuery的ready取代。 +* 进一步优化内部代码 + +## == 拓展模块 == +* layer.prompt支持给表单传入默认值,如layer.prompt({val:'默认'}); 新增yes回调函数第二个参数为索引、第三个参数为表单元素。 +* 相册层新增tab回调函数,用于切换图片时进行相关操作 +* 相册层内部代码优化。 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..74d0f55 --- /dev/null +++ b/LICENSE @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + Copyright (c) 2016 贤心 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/] + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) 2015 贤心 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7df2b38 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ + +## 简要 +layer是一款近年来口碑非常不错的web弹层组件,她具备全方位的解决方案,致力于服务各个水平段的开发人员,您的页面会轻松地拥有丰富友好的操作体验。 + +在与同类组件的比较中,layer总是能轻易获胜。她尽可能地在以更少的代码展现更强健的功能,且格外注重性能的提升、易用和实用性,正因如此,越来越多的开发者将媚眼投上了layer。layer兼容了包括IE6在内的所有主流浏览器。 她数量可观的接口,使得您可以自定义太多您需要的风格,每一种弹层模式各具特色,皆广受欢迎。当然,这种“王婆卖瓜”的陈述听起来总是有点难受,因此你需要进一步了解她是否真的如你所愿。 + +[文档与演示](http://layer.layui.com/) + +## 愿景 +致力于打造国内最盛行的弹层组件,为web开发提供强劲动力。 + +## 现状 +从两年前初出茅庐,到后来成为小众组件,再发展到今天,已为数以万计的人所熟知。 +据不完全统计,截至到2015年09月01号,layer已服务于10万余家web平台。 + + +## 备注 +[官网](http://layer.layui.com/)、[更新日志](https://github.com/sentsin/layer/blob/2.x/CHANGELOG.md)、[社区交流](http://fly.layui.com) \ No newline at end of file diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..ce19898 --- /dev/null +++ b/bower.json @@ -0,0 +1,20 @@ +{ + "name": "layer", + "main": "src/layer.js", + "version": "2.4.0", + "homepage": "https://github.com/sentsin/layer", + "authors": [ + "sentsin " + ], + "description": "弹窗组件", + "moduleType": [ + "amd", + "globals" + ], + "keywords": [ + "layer", + "layui", + "dialog" + ], + "license": "LGPL" +} diff --git a/build/layer.js b/build/layer.js new file mode 100644 index 0000000..1bf5d1c --- /dev/null +++ b/build/layer.js @@ -0,0 +1,2 @@ +/*! layer-v2.4.0 Web弹层组件 LGPL License http://layer.layui.com/ By 贤心 */ + ;!function(e,t){"use strict";var i,n,a={getPath:function(){var e=document.scripts,t=e[e.length-1],i=t.src;if(!t.getAttribute("merge"))return i.substring(0,i.lastIndexOf("/")+1)}(),enter:function(e){13===e.keyCode&&e.preventDefault()},config:{},end:{},btn:["确定","取消"],type:["dialog","page","iframe","loading","tips"]},o={v:"2.4",ie6:!!e.ActiveXObject&&!e.XMLHttpRequest,index:e.layer&&e.layer.v?1e5:0,path:a.getPath,config:function(e,t){var n=0;return e=e||{},o.cache=a.config=i.extend(a.config,e),o.path=a.config.path||o.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.use("skin/default/layer.css",e.extend&&e.extend.length>0?function r(){var i=e.extend;o.use(i[i[n]?n:n-1],n'+(s?o.title[0]:o.title)+"":"";return o.zIndex=r,t([o.shade?'
':"",'
'+(e&&2!=o.type?"":f)+'
'+(0==o.type&&o.icon!==-1?'':"")+(1==o.type&&e?"":o.content||"")+'
'+function(){var e=c?'':"";return o.closeBtn&&(e+=''),e}()+""+(o.btn?function(){var e="";"string"==typeof o.btn&&(o.btn=[o.btn]);for(var t=0,i=o.btn.length;t'+o.btn[t]+"";return'
'+e+"
"}():"")+"
"],f),i},r.pt.creat=function(){var e=this,t=e.config,r=e.index,s=t.content,c="object"==typeof s;if(!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.type){case 0:t.btn="btn"in t?t.btn:a.btn[0],o.closeAll("dialog");break;case 2:var s=t.content=c?t.content:[t.content||"http://layer.layui.com","auto"];t.content='';break;case 3:t.title=!1,t.closeBtn=!1,t.icon===-1&&0===t.icon,o.closeAll("loading");break;case 4:c||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',t.title=!1,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||o.closeAll("tips")}e.vessel(c,function(n,a){i("body").append(n[0]),c?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+r).find("."+l[5]).before(a))}()}():i("body").append(n[1]),e.layero=i("#"+l[0]+r),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",r)}).auto(r),2==t.type&&o.ie6&&e.layero.find("iframe").attr("src",s[0]),i(document).off("keydown",a.enter).on("keydown",a.enter),e.layero.on("keydown",function(e){i(document).off("keydown",a.enter)}),4==t.type?e.tips():e.offset(),t.fix&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(r),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){o.close(e.index)},t.time),e.move().callback(),l.anim[t.shift]&&e.layero.addClass(l.anim[t.shift])}},r.pt.auto=function(e){function t(e){e=r.find(e),e.height(s[1]-c-f-2*(0|parseFloat(e.css("padding"))))}var a=this,o=a.config,r=i("#"+l[0]+e);""===o.area[0]&&o.maxWidth>0&&(/MSIE 7/.test(navigator.userAgent)&&o.btn&&r.width(r.innerWidth()),r.outerWidth()>o.maxWidth&&r.width(o.maxWidth));var s=[r.innerWidth(),r.innerHeight()],c=r.find(l[1]).outerHeight()||0,f=r.find("."+l[6]).outerHeight()||0;switch(o.type){case 2:t("iframe");break;default:""===o.area[1]?o.fix&&s[1]>=n.height()&&(s[1]=n.height(),t("."+l[5])):t("."+l[5])}return a},r.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&&(e.offsetTop=t.offset,"rb"===t.offset&&(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0])),t.fix||(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.css({top:e.offsetTop,left:e.offsetLeft})},r.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},c=a.find(".layui-layer-TipsG"),f=t.tips[0];t.tips[1]||c.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],c.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,c.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,c.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,c.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,c.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[f-1](),1===f?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===f?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===f?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===f&&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.fix?n.scrollLeft():0),top:s.tipTop-(t.fix?n.scrollTop():0)})},r.pt.move=function(){var e=this,t=e.config,a={setY:0,moveLayer:function(){var e=a.layero,t=parseInt(e.css("margin-left")),i=parseInt(a.move.css("left"));0===t||(i-=t),"fixed"!==e.css("position")&&(i-=e.parent().offset().left,a.setY=0),e.css({left:i,top:parseInt(a.move.css("top"))-a.setY})}},o=e.layero.find(t.move);return t.move&&o.attr("move","ok"),o.css({cursor:t.move?"move":"auto"}),i(t.move).on("mousedown",function(e){if(e.preventDefault(),"ok"===i(this).attr("move")){a.ismove=!0,a.layero=i(this).parents("."+l[0]);var o=a.layero.offset().left,r=a.layero.offset().top,s=a.layero.outerWidth()-6,c=a.layero.outerHeight()-6;i("#layui-layer-moves")[0]||i("body").append('
'),a.move=i("#layui-layer-moves"),t.moveType&&a.move.css({visibility:"hidden"}),a.moveX=e.pageX-a.move.position().left,a.moveY=e.pageY-a.move.position().top,"fixed"!==a.layero.css("position")||(a.setY=n.scrollTop())}}),i(document).mousemove(function(e){if(a.ismove){var i=e.pageX-a.moveX,o=e.pageY-a.moveY;if(e.preventDefault(),!t.moveOut){a.setY=n.scrollTop();var r=n.width()-a.move.outerWidth(),l=a.setY;i<0&&(i=0),i>r&&(i=r),on.height()-a.move.outerHeight()+a.setY&&(o=n.height()-a.move.outerHeight()+a.setY)}a.move.css({left:i,top:o}),t.moveType&&a.moveLayer(),i=o=r=l=null}}).mouseup(function(){try{a.ismove&&(a.moveLayer(),a.move.remove(),t.moveEnd&&t.moveEnd()),a.ismove=!1}catch(e){a.ismove=!1}}),e},r.pt.callback=function(){function e(){var e=r.cancel&&r.cancel(t.index,n);e===!1||o.close(t.index)}var t=this,n=t.layero,r=t.config;t.openLayer(),r.success&&(2==r.type?n.find("iframe").on("load",function(){r.success(n,t.index)}):r.success(n,t.index)),o.ie6&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)r.yes?r.yes(t.index,n):r.btn1?r.btn1(t.index,n):o.close(t.index);else{var a=r["btn"+(e+1)]&&r["btn"+(e+1)](t.index,n);a===!1||o.close(t.index)}}),n.find("."+l[7]).on("click",e),r.shadeClose&&i("#layui-layer-shade"+t.index).on("click",function(){o.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=r.min&&r.min(n);e===!1||o.min(t.index,r)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(o.restore(t.index),r.restore&&r.restore(n)):(o.full(t.index,r),setTimeout(function(){r.full&&r.full(n)},100))}),r.end&&(a.end[t.index]=r.end)},a.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})},r.pt.IE6=function(e){function t(){e.css({top:o+(a.config.fix?n.scrollTop():0)})}var a=this,o=e.offset().top;t(),n.scroll(t),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})},r.pt.openLayer=function(){var e=this;o.zIndex=e.config.zIndex,o.setTop=function(e){var t=function(){o.zIndex++,e.css("z-index",o.zIndex+1)};return o.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),o.zIndex}},a.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})},a.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=o,o.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},o.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},o.iframeAuto=function(e){if(e){var t=o.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,r=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+r}),n.find("iframe").css({height:t})}},o.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},o.style=function(e,t){var n=i("#"+l[0]+e),o=n.attr("type"),r=n.find(l[1]).outerHeight()||0,s=n.find("."+l[6]).outerHeight()||0;o!==a.type[1]&&o!==a.type[2]||(n.css(t),o===a.type[2]&&n.find("iframe").css({height:parseFloat(t.height)-r-s}))},o.min=function(e,t){var n=i("#"+l[0]+e),r=n.find(l[1]).outerHeight()||0;a.record(n),o.style(e,{width:180,height:r,overflow:"hidden"}),n.find(".layui-layer-min").hide(),"page"===n.attr("type")&&n.find(l[4]).hide(),a.rescollbar(e)},o.restore=function(e){var t=i("#"+l[0]+e),n=t.attr("area").split(",");t.attr("type");o.style(e,{width:parseFloat(n[0]),height:parseFloat(n[1]),top:parseFloat(n[2]),left:parseFloat(n[3]),overflow:"visible"}),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),a.rescollbar(e)},o.full=function(e){var t,r=i("#"+l[0]+e);a.record(r),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===r.css("position");o.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()}),r.find(".layui-layer-min").hide()},100)},o.title=function(e,t){var n=i("#"+l[0]+(t||o.index)).find(l[1]);n.html(e)},o.close=function(e){var t=i("#"+l[0]+e),n=t.attr("type");if(t[0]){if(n===a.type[1]&&"object"===t.attr("conType")){t.children(":not(."+l[5]+")").remove();for(var r=0;r<2;r++)t.find(".layui-layer-wrap").unwrap().hide()}else{if(n===a.type[2])try{var s=i("#"+l[4]+e)[0];s.contentWindow.document.write(""),s.contentWindow.close(),t.find("."+l[5])[0].removeChild(s)}catch(c){}t[0].innerHTML="",t.remove()}i("#layui-layer-moves, #layui-layer-shade"+e).remove(),o.ie6&&a.reselect(),a.rescollbar(e),i(document).off("keydown",a.enter),"function"==typeof a.end[e]&&a.end[e](),delete a.end[e]}},o.closeAll=function(e){i.each(i("."+l[0]),function(){var t=i(this),n=e?t.attr("type")===e:1;n&&o.close(t.attr("times")),n=null})};var s=o.cache||{},c=function(e){return s.skin?" "+s.skin+" "+s.skin+"-"+e:""};o.prompt=function(e,t){e=e||{},"function"==typeof e&&(t=e);var n,a=2==e.formType?'":function(){return''}();return o.open(i.extend({btn:["确定","取消"],content:a,skin:"layui-layer-prompt"+c("prompt"),success:function(e){n=e.find(".layui-layer-input"),n.focus()},yes:function(i){var a=n.val();""===a?n.focus():a.length>(e.maxlength||500)?o.tips("最多输入"+(e.maxlength||500)+"个字数",n,{tips:1}):t&&t(a,i,n)}},e))},o.tab=function(e){e=e||{};var t=e.tab||{};return o.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),title:function(){var e=t.length,i=1,n="";if(e>0)for(n=''+t[0].title+"";i"+t[i].title+"";return n}(),content:'
    '+function(){var e=t.length,i=1,n="";if(e>0)for(n='
  • '+(t[0].content||"no content")+"
  • ";i'+(t[i].content||"no content")+"";return n}()+"
",success:function(t){var n=t.find(".layui-layer-title").children(),a=t.find(".layui-layer-tabmain").children();n.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var n=i(this),o=n.index();n.addClass("layui-layer-tabnow").siblings().removeClass("layui-layer-tabnow"),a.eq(o).show().siblings().hide(),"function"==typeof e.change&&e.change(o)})}},e))},o.photos=function(t,n,a){function r(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 l={};if(t=t||{},t.photos){var s=t.photos.constructor===Object,f=s?t.photos:{},u=f.data||[],d=f.start||0;if(l.imgIndex=(0|d)+1,t.img=t.img||"img",s){if(0===u.length)return o.msg("没有图片")}else{var y=i(t.photos),p=function(){u=[],y.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(p(),0===u.length)return;if(n||y.on("click",t.img,function(){var e=i(this),n=e.attr("layer-index");o.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0),p()}),!n)return}l.imgprev=function(e){l.imgIndex--,l.imgIndex<1&&(l.imgIndex=u.length),l.tabimg(e)},l.imgnext=function(e,t){l.imgIndex++,l.imgIndex>u.length&&(l.imgIndex=1,t)||l.tabimg(e)},l.keyup=function(e){if(!l.end){var t=e.keyCode;e.preventDefault(),37===t?l.imgprev(!0):39===t?l.imgnext(!0):27===t&&o.close(l.index)}},l.tabimg=function(e){u.length<=1||(f.start=l.imgIndex-1,o.close(l.index),o.photos(t,!0,e))},l.event=function(){l.bigimg.hover(function(){l.imgsee.show()},function(){l.imgsee.hide()}),l.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),l.imgprev()}),l.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),l.imgnext()}),i(document).on("keyup",l.keyup)},l.loadi=o.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),r(u[d].src,function(n){o.close(l.loadi),l.index=o.open(i.extend({type:1,area:function(){var a=[n.width,n.height],o=[i(e).width()-50,i(e).height()-50];return!t.full&&a[0]>o[0]&&(a[0]=o[0],a[1]=a[0]*n.height/n.width),[a[0]+"px",a[1]+"px"]}(),title:!1,shade:.9,shadeClose:!0,closeBtn:!1,move:".layui-layer-phimg img",moveType:1,scrollbar:!1,moveOut:!0,shift:5*Math.random()|0,skin:"layui-layer-photos"+c("photos"),content:'
'+(u[d].alt||
'+(u.length>1?'':"")+'
'+(u[d].alt||"")+""+l.imgIndex+"/"+u.length+"
",success:function(e,i){l.bigimg=e.find(".layui-layer-phimg"),l.imgsee=e.find(".layui-layer-imguide,.layui-layer-imgbar"),l.event(e),t.tab&&t.tab(u[d],e)},end:function(){l.end=!0,i(document).off("keyup",l.keyup)}},t))},function(){o.close(l.loadi),o.msg("当前图片地址异常
是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&l.imgnext(!0,!0)}})})}},a.run=function(){i=jQuery,n=i(e),l.html=i("html"),o.open=function(e){var t=new r(e);return t.index}},"function"==typeof define?define(function(){return a.run(),o}):function(){a.run(),o.use("skin/default/layer.css")}()}(window); \ No newline at end of file diff --git a/build/mobile/layer.js b/build/mobile/layer.js new file mode 100644 index 0000000..66e53a2 --- /dev/null +++ b/build/mobile/layer.js @@ -0,0 +1,2 @@ +/*! layer mobile-v2.0.0 Web弹层组件 LGPL License http://layer.layui.com/mobile By 贤心 */ + ;!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/build/skin/default/icon-ext.png b/build/skin/default/icon-ext.png new file mode 100644 index 0000000..bbbb669 Binary files /dev/null and b/build/skin/default/icon-ext.png differ diff --git a/build/skin/default/icon.png b/build/skin/default/icon.png new file mode 100644 index 0000000..3e17da8 Binary files /dev/null and b/build/skin/default/icon.png differ diff --git a/build/skin/default/layer.css b/build/skin/default/layer.css new file mode 100644 index 0000000..69af310 --- /dev/null +++ b/build/skin/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{background-image:url(about:blank);background-attachment:fixed}html #layui_layer_skindefaultlayercss{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;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,.3);box-shadow:1px 1px 5px rgba(0,0,0,.2)}.layui-layer-moves{position:absolute;border:3px solid #666;border:3px solid rgba(0,0,0,.5);cursor:move;background-color:#fff;background-color:rgba(255,255,255,.3);filter:alpha(opacity=50)}.layui-layer-load{background:url(loading-0.gif) center center no-repeat #fff}.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{border-radius:2px;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:.3s;animation-duration:.3s}@-webkit-keyframes bounceIn{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5)}100%{opacity:1;-webkit-transform:scale(1);transform:scale(1)}}@keyframes 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{-webkit-animation-name:bounceIn;animation-name:bounceIn}@-webkit-keyframes bounceOut{100%{opacity:0;-webkit-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.03);transform:scale(1.03)}0%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes bounceOut{100%{opacity:0;-webkit-transform:scale(.7);-ms-transform:scale(.7);transform:scale(.7)}30%{-webkit-transform:scale(1.03);-ms-transform:scale(1.03);transform:scale(1.03)}0%{-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}}.layer-anim-close{-webkit-animation-name:bounceOut;animation-name:bounceOut;-webkit-animation-duration:.2s;animation-duration:.2s}@-webkit-keyframes 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 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:zoomInDown;animation-name:zoomInDown}@-webkit-keyframes fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes 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:fadeInUpBig;animation-name:fadeInUpBig}@-webkit-keyframes 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 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:zoomInLeft;animation-name:zoomInLeft}@-webkit-keyframes 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 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:rollIn;animation-name:rollIn}@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:fadeIn;animation-name:fadeIn}@-webkit-keyframes 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 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:shake;animation-name:shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.layui-layer-title{padding:0 80px 0 20px;height:42px;line-height:42px;border-bottom:1px solid #eee;font-size:14px;color:#333;overflow:hidden;background-color:#F8F8F8;border-radius:2px 2px 0 0}.layui-layer-setwin{position:absolute;right:15px;*right:0;top:15px;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:0 -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 10px 12px;pointer-events:auto}.layui-layer-btn a{height:28px;line-height:28px;margin:0 6px;padding:0 15px;border:1px solid #dedede;background-color:#f1f1f1;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:.7}.layui-layer-btn .layui-layer-btn0{border-color:#4898d5;background-color:#2e8ded;color:#fff}.layui-layer-dialog{min-width:260px}.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 .layui-layer-content{-webkit-overflow-scrolling:touch;overflow-y:auto}.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:5px 10px;font-size:12px;_float:left;border-radius:3px;box-shadow:1px 1px 3px rgba(0,0,0,.3);background-color:#F90;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:#F90}.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:1px;border-bottom-style:solid;border-bottom-color:#F90}.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:10px;text-align:right;border-top:1px solid #E9E7E7}.layui-layer-lan .layui-layer-btn a{background:#BBB5B5;border:none}.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}.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:220px;height:30px;margin:0 auto;line-height:30px;padding:0 5px;border:1px solid #ccc;box-shadow:1px 1px 5px rgba(0,0,0,.1) inset;color:#333}.layui-layer-prompt textarea.layui-layer-input{width:300px;height:100px;line-height:20px}.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4)}.layui-layer-tab .layui-layer-title{padding-left:0;border-bottom:1px solid #ccc;background-color:#eee;overflow:visible}.layui-layer-tab .layui-layer-title span{position:relative;float:left;min-width:80px;max-width:260px;padding:0 20px;text-align:center;cursor:default;overflow:hidden}.layui-layer-tab .layui-layer-title span.layui-layer-tabnow{height:43px;border-left:1px solid #ccc;border-right:1px solid #ccc;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.xubox_tab_layer{display:block}.xubox_tabclose{position:absolute;right:10px;top:5px;cursor:pointer}.layui-layer-photos{-webkit-animation-duration:1s;animation-duration:1s}.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-imgbar,.layui-layer-imguide{display:none}.layui-layer-imgnext,.layui-layer-imgprev{position:absolute;top:50%;width:27px;_width:44px;height:44px;margin-top:-22px;outline:0;blr:expression(this.onFocus=this.blur())}.layui-layer-imgprev{left:10px;background-position:-5px -5px;_background-position:-70px -5px}.layui-layer-imgprev:hover{background-position:-33px -5px;_background-position:-120px -5px}.layui-layer-imgnext{right:10px;_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:absolute;left:0;bottom:0;width:100%;height:32px;line-height:32px;background-color:rgba(0,0,0,.8);background-color:#000\9;filter:Alpha(opacity=80);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} \ No newline at end of file diff --git a/build/skin/default/loading-0.gif b/build/skin/default/loading-0.gif new file mode 100644 index 0000000..6f3c953 Binary files /dev/null and b/build/skin/default/loading-0.gif differ diff --git a/build/skin/default/loading-1.gif b/build/skin/default/loading-1.gif new file mode 100644 index 0000000..db3a483 Binary files /dev/null and b/build/skin/default/loading-1.gif differ diff --git a/build/skin/default/loading-2.gif b/build/skin/default/loading-2.gif new file mode 100644 index 0000000..5bb90fd Binary files /dev/null and b/build/skin/default/loading-2.gif differ diff --git a/build/skin/moon/default.png b/build/skin/moon/default.png new file mode 100644 index 0000000..77dfaf3 Binary files /dev/null and b/build/skin/moon/default.png differ diff --git a/build/skin/moon/style.css b/build/skin/moon/style.css new file mode 100644 index 0000000..027dd1e --- /dev/null +++ b/build/skin/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 0000000..b74698a --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,57 @@ +/** + layui构建 +*/ + +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('./build')); + + return gulp.src('./src/layer.js').pipe(uglify()) + .pipe(header('/*! <%= pkg.name %>-v<%= pkg.version %> <%= pkg.description %> <%= pkg.license %> License <%= pkg.homepage %> By <%= pkg.author %> */\n ;', {pkg: pkg})) + .pipe(gulp.dest('./build')); + + } + ,mobile: function() { + return gulp.src('./src/mobile/layer.js').pipe(uglify()) + .pipe(header('/*! <%= pkg.name %> mobile-v<%= pkg.mobile %> <%= pkg.description %> <%= pkg.license %> License <%= pkg.homepage %>mobile By <%= pkg.author %> */\n ;', {pkg: pkg})) + .pipe(gulp.dest('./build/mobile')); + } + ,other: function(){ + gulp.src('./src/**/*.{png,gif}').pipe(rename({})) + .pipe(gulp.dest('./build')); + } +}; + + +gulp.task('clear', function(cb){ //清理 + return del(['./build/*'], cb); +}); +gulp.task('layer', task.minjs); //压缩PC版本 +gulp.task('mobile', task.mincss); //压缩Mobile文件 +gulp.task('other', task.other); //移动一些配件 + +//全部 +gulp.task('default', ['clear'], function(){ + for(var key in task){ + task[key](); + } +}); + + + + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..cc8bc36 --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name": "layer", + "version": "2.4.0", + "mobile": "2.0.0", + "description": "Web弹层组件", + "main": "src/layer.js", + "license": "LGPL", + "scripts": { + "run": "gulp" + }, + "repository": { + "type": "https", + "url": "https://github.com/sentsin/layer.git" + }, + "author": "贤心", + "homepage": "http://layer.layui.com/", + "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" + } +} diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..a4935ee --- /dev/null +++ b/src/README.md @@ -0,0 +1,3 @@ + +## 源码 +开发版源码随时可能会提交,因此生产环境更建议使用外面根目录压缩后的js。 \ No newline at end of file diff --git a/src/layer.js b/src/layer.js new file mode 100644 index 0000000..e6cb1ef --- /dev/null +++ b/src/layer.js @@ -0,0 +1,1077 @@ +/*! + + @Name:layer v2.4 弹层组件 + @Author:贤心 + @Site:http://layer.layui.com + @License:LGPL + + */ + +;!function(window, undefined){ +"use strict"; + +var $, win, ready = { + getPath: function(){ + var js = document.scripts, script = js[js.length - 1], jsPath = script.src; + if(script.getAttribute('merge')) return; + return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); + }(), + + //屏蔽Enter触发弹层 + enter: function(e){ + if(e.keyCode === 13) e.preventDefault(); + }, + config: {}, end: {}, + btn: ['确定','取消'], + + //五种原始层模式 + type: ['dialog', 'page', 'iframe', 'loading', 'tips'] +}; + +//默认内置方法。 +var layer = { + v: '2.4', + ie6: !!window.ActiveXObject&&!window.XMLHttpRequest, + index: (window.layer && window.layer.v) ? 100000 : 0, + path: ready.getPath, + config: function(options, fn){ + var item = 0; + 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]); + layer.use('skin/default/layer.css', (options.extend && options.extend.length > 0) ? (function loop(){ + var ext = options.extend; + layer.use(ext[ext[item] ? item : item-1], item < ext.length ? function(){ + ++item; + return loop; + }() : fn); + }()) : fn); + return this; + }, + + //载入配件 + use: function(module, fn, readyMethod){ + 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 = 'layui_layer_' + module.replace(/\.|\//g, ''); + if(!layer.path) return; + if(iscss){ + node.rel = 'stylesheet'; + } + node[iscss ? 'href' : 'src'] = /^http:\/\//.test(module) ? module : layer.path + module; + node.id = id; + if(!$('#'+ id)[0]){ + head.appendChild(node); + } + //轮询加载就绪 + ;(function poll() { + ;(iscss ? parseInt($('#'+id).css('width')) === 1989 : layer[readyMethod||id]) ? function(){ + fn && fn(); + try { iscss || head.removeChild(node); } catch(e){}; + }() : setTimeout(poll, 100); + }()); + return this; + }, + + ready: function(path, fn){ + var type = typeof path === 'function'; + if(type) fn = path; + layer.config($.extend(ready.config, function(){ + return type ? {} : {path: path}; + }()), fn); + 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 shift = 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, + end: end + }, (type && !ready.config.skin) ? { + skin: skin + ' layui-layer-hui', + shift: shift + } : 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, + shade: 0.01 + }, options)); + }, + + tips: function(content, follow, options){ + return layer.open($.extend({ + type: 4, + content: [content, follow], + closeBtn: false, + time: 3000, + shade: false, + fix: false, + maxWidth: 210 + }, options)); + } +}; + +var Class = function(setings){ + var that = this; + that.index = ++layer.index; + that.config = $.extend({}, that.config, ready.config, setings); + that.creat(); +}; + +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', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06']; + +//默认配置 +Class.pt.config = { + type: 0, + shade: 0.3, + fix: true, + move: doms[1], + title: '信息', + offset: 'auto', + area: 'auto', + closeBtn: 1, + time: 0, //0表示不自动关闭 + zIndex: 19891014, + maxWidth: 360, + shift: 0, + icon: -1, + 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 +'
' + }() : '') + +'
' + ], titleHTML); + return that; +}; + +//创建骨架 +Class.pt.creat = function(){ + var that = this, config = that.config, times = that.index, nodeIndex; + var content = config.content, conType = typeof content === 'object'; + + if($('#'+config.id)[0]) return; + + if(typeof config.area === 'string'){ + config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; + } + + 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||'http://layer.layui.com', 'auto']; + config.content = ''; + break; + case 3: + config.title = false; + config.closeBtn = false; + 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] + ''; + config.title = false; + config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true]; + config.tipsMore || layer.closeAll('tips'); + break; + } + + //建立容器 + that.vessel(conType, function(html, titleHTML){ + $('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.show().addClass('layui-layer-wrap').wrap(html[1]); + $('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML); + } + }(); + }() : $('body').append(html[1]); + that.layero = $('#'+ doms[0] + times); + config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times); + }).auto(times); + + config.type == 2 && layer.ie6 && that.layero.find('iframe').attr('src', content[0]); + $(document).off('keydown', ready.enter).on('keydown', ready.enter); + that.layero.on('keydown', function(e){ + $(document).off('keydown', ready.enter); + }); + + //坐标自适应浏览器窗口尺寸 + config.type == 4 ? that.tips() : that.offset(); + if(config.fix){ + 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.shift]){ + that.layero.addClass(doms.anim[config.shift]); + }; + +}; + +//自适应 +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(/MSIE 7/.test(navigator.userAgent) && config.btn){ + layero.width(layero.innerWidth()); + } + layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth); + } + var area = [layero.innerWidth(), layero.innerHeight()]; + var titHeight = layero.find(doms[1]).outerHeight() || 0; + var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; + function setHeight(elem){ + elem = layero.find(elem); + elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0)); + } + switch(config.type){ + case 2: + setHeight('iframe'); + break; + default: + if(config.area[1] === ''){ + if(config.fix && 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'){ + that.offsetTop = config.offset; + if(config.offset === 'rb'){ //右下角 + that.offsetTop = win.height() - area[1]; + that.offsetLeft = win.width() - area[0]; + } + } + if(!config.fix){ + that.offsetTop = /%$/.test(that.offsetTop) ? + win.height()*parseFloat(that.offsetTop)/100 + : parseFloat(that.offsetTop); + that.offsetLeft = /%$/.test(that.offsetLeft) ? + win.width()*parseFloat(that.offsetLeft)/100 + : parseFloat(that.offsetLeft); + that.offsetTop += win.scrollTop(); + that.offsetLeft += win.scrollLeft(); + } + 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.fix ? win.scrollLeft() : 0), + top: goal.tipTop - (config.fix ? win.scrollTop() : 0) + }); +} + +//拖拽层 +Class.pt.move = function(){ + var that = this, config = that.config, conf = { + setY: 0, + moveLayer: function(){ + var layero = conf.layero, mgleft = parseInt(layero.css('margin-left')); + var lefts = parseInt(conf.move.css('left')); + mgleft === 0 || (lefts = lefts - mgleft); + if(layero.css('position') !== 'fixed'){ + lefts = lefts - layero.parent().offset().left; + conf.setY = 0; + } + layero.css({left: lefts, top: parseInt(conf.move.css('top')) - conf.setY}); + } + }; + + var movedom = that.layero.find(config.move); + config.move && movedom.attr('move', 'ok'); + movedom.css({cursor: config.move ? 'move' : 'auto'}); + + $(config.move).on('mousedown', function(M){ + M.preventDefault(); + if($(this).attr('move') === 'ok'){ + conf.ismove = true; + conf.layero = $(this).parents('.'+ doms[0]); + var xx = conf.layero.offset().left, yy = conf.layero.offset().top, ww = conf.layero.outerWidth() - 6, hh = conf.layero.outerHeight() - 6; + if(!$('#layui-layer-moves')[0]){ + $('body').append('
'); + } + conf.move = $('#layui-layer-moves'); + config.moveType && conf.move.css({visibility: 'hidden'}); + + conf.moveX = M.pageX - conf.move.position().left; + conf.moveY = M.pageY - conf.move.position().top; + conf.layero.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(), setTop = conf.setY; + offsetX < 0 && (offsetX = 0); + offsetX > setRig && (offsetX = setRig); + offsetY < setTop && (offsetY = setTop); + offsetY > win.height() - conf.move.outerHeight() + conf.setY && (offsetY = win.height() - conf.move.outerHeight() + conf.setY); + } + + conf.move.css({left: offsetX, top: offsetY}); + config.moveType && conf.moveLayer(); + + offsetX = offsetY = setRig = setTop = null; + } + }).mouseup(function(){ + try{ + if(conf.ismove){ + conf.moveLayer(); + conf.move.remove(); + config.moveEnd && config.moveEnd(); + } + conf.ismove = false; + }catch(e){ + conf.ismove = false; + } + }); + 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.ie6 && 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){ + $('#layui-layer-shade'+ that.index).on('click', function(){ + layer.close(that.index); + }); + } + + //最小化 + layero.find('.layui-layer-min').on('click', function(){ + var min = config.min && config.min(layero); + 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); + } else { + layer.full(that.index, config); + setTimeout(function(){ + config.full && config.full(layero); + }, 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){ + var that = this, _ieTop = layero.offset().top; + + //ie6的固定与相对定位 + function ie6Fix(){ + layero.css({top : _ieTop + (that.config.fix ? win.scrollTop() : 0)}); + }; + ie6Fix(); + win.scroll(ie6Fix); + + //隐藏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){ + var layero = $('#'+ doms[0] + index), type = layero.attr('type'); + var titHeight = layero.find(doms[1]).outerHeight() || 0; + var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; + if(type === ready.type[1] || type === ready.type[2]){ + layero.css(options); + if(type === ready.type[2]){ + layero.find('iframe').css({ + height: parseFloat(options.height) - titHeight - btnHeight + }); + } + } +}; + +//最小化 +layer.min = function(index, options){ + var layero = $('#'+ doms[0] + index); + var titHeight = layero.find(doms[1]).outerHeight() || 0; + ready.record(layero); + layer.style(index, {width: 180, height: titHeight, overflow: 'hidden'}); + layero.find('.layui-layer-min').hide(); + layero.attr('type') === 'page' && layero.find(doms[4]).hide(); + ready.rescollbar(index); +}; + +//还原 +layer.restore = function(index){ + var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); + var type = layero.attr('type'); + layer.style(index, { + width: parseFloat(area[0]), + height: parseFloat(area[1]), + top: parseFloat(area[2]), + left: parseFloat(area[3]), + overflow: 'visible' + }); + 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); +}; + +//全屏 +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() + }); + 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){ + var layero = $('#'+ doms[0] + index), type = layero.attr('type'); + if(!layero[0]) return; + if(type === ready.type[1] && layero.attr('conType') === 'object'){ + layero.children(':not(.'+ doms[5] +')').remove(); + for(var i = 0; i < 2; i++){ + layero.find('.layui-layer-wrap').unwrap().hide(); + } + } 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(); + } + $('#layui-layer-moves, #layui-layer-shade' + index).remove(); + layer.ie6 && ready.reselect(); + ready.rescollbar(index); + $(document).off('keydown', ready.enter); + typeof ready.end[index] === 'function' && ready.end[index](); + delete ready.end[index]; +}; + +//关闭所有层 +layer.closeAll = function(type){ + $.each($('.'+doms[0]), function(){ + var othis = $(this); + var is = type ? (othis.attr('type') === type) : 1; + is && layer.close(othis.attr('times')); + is = null; + }); +}; + +/** + + 拓展模块,layui开始合并在一起 + + */ + +var cache = layer.cache||{}, skin = function(type){ + return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); +}; + +//仿系统prompt +layer.prompt = function(options, yes){ + options = options || {}; + if(typeof options === 'function') yes = options; + var prompt, content = options.formType == 2 ? '' : function(){ + return ''; + }(); + return layer.open($.extend({ + btn: ['确定','取消'], + content: content, + skin: 'layui-layer-prompt' + skin('prompt'), + success: function(layero){ + prompt = layero.find('.layui-layer-input'); + prompt.focus(); + }, 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 || {}; + return layer.open($.extend({ + type: 1, + skin: 'layui-layer-tab' + skin('tab'), + 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('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow'); + main.eq(index).show().siblings().hide(); + typeof options.change === 'function' && options.change(index); + }); + } + }, options)); +}; + +//相册层 +layer.photos = function(options, loop, key){ + var dict = {}; + options = options || {}; + if(!options.photos) return; + var type = options.photos.constructor === Object; + var photos = type ? options.photos : {}, data = photos.data || []; + var start = photos.start || 0; + dict.imgIndex = (start|0) + 1; + + options.img = options.img || 'img'; + + if(!type){ //页面直接获取 + 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(){ + var othis = $(this), index = othis.attr('layer-index'); + layer.photos($.extend(options, { + photos: { + start: index, + data: data, + tab: options.tab + }, + full: options.full + }), true); + pushData(); + }) + + //不直接弹出 + 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); + layer.photos(options, true, key); + } + + //一些动作 + 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(); + }); + + dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ + event.preventDefault(); + dict.imgnext(); + }); + + $(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); + dict.index = layer.open($.extend({ + type: 1, + area: function(){ + var imgarea = [img.width, img.height]; + var winarea = [$(window).width() - 50, $(window).height() - 50]; + if(!options.full && imgarea[0] > winarea[0]){ + imgarea[0] = winarea[0]; + imgarea[1] = imgarea[0]*img.height/img.width; + } + 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, + shift: Math.random()*5|0, + skin: 'layui-layer-photos' + skin('photos'), + content: '
' + +''+ (data[start].alt||'') +'' + +'
' + +(data.length > 1 ? '' : '') + +'
'+ (data[start].alt||'') +''+ dict.imgIndex +'/'+ data.length +'
' + +'
' + +'
', + success: function(layero, index){ + dict.bigimg = layero.find('.layui-layer-phimg'); + dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar'); + dict.event(layero); + options.tab && options.tab(data[start], 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(){ + $ = jQuery; + win = $(window); + doms.html = $('html'); + layer.open = function(deliver){ + var o = new Class(deliver); + return o.index; + }; +}; + +'function' === typeof define ? define(function(){ + ready.run(); + return layer; +}) : function(){ + ready.run(); + layer.use('skin/default/layer.css'); +}(); + +}(window); \ No newline at end of file diff --git a/src/mobile/README.md b/src/mobile/README.md new file mode 100644 index 0000000..1e217a7 --- /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 0000000..1d97d9e --- /dev/null +++ b/src/mobile/layer.js @@ -0,0 +1,208 @@ +/*! + + @Name:layer mobile v2.0 弹层组件移动版 + @Author:贤心 + @Site:http://layer.layui.com/mobie/ + @License:LGPL + + */ + +;!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 0000000..c8b32e0 --- /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/skin/default/icon-ext.png b/src/skin/default/icon-ext.png new file mode 100644 index 0000000..bbbb669 Binary files /dev/null and b/src/skin/default/icon-ext.png differ diff --git a/src/skin/default/icon.png b/src/skin/default/icon.png new file mode 100644 index 0000000..3e17da8 Binary files /dev/null and b/src/skin/default/icon.png differ diff --git a/src/skin/default/layer.css b/src/skin/default/layer.css new file mode 100644 index 0000000..ac535b0 --- /dev/null +++ b/src/skin/default/layer.css @@ -0,0 +1,213 @@ +/** + + @Name: layer + @Author: 贤心 + + **/ + +*html{background-image:url(about:blank); background-attachment:fixed;} +html #layui_layer_skindefaultlayercss{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; 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,.3); box-shadow: 1px 1px 5px rgba(0,0,0,.2);} +.layui-layer-moves{position:absolute; border:3px solid #666; border:3px solid rgba(0,0,0,.5); cursor:move; background-color:#fff; background-color:rgba(255,255,255,.3); filter:alpha(opacity=50);} +.layui-layer-load{background:url(loading-0.gif) #fff 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{border-radius: 2px; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.3s; animation-duration:.3s;} + +@-webkit-keyframes bounceIn { /* 默认 */ + 0% { + opacity: 0; + -webkit-transform: scale(.5); + transform: scale(.5) + } + 100% { + opacity: 1; + -webkit-transform: scale(1); + transform: scale(1) + } +} +@keyframes 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{-webkit-animation-name: bounceIn;animation-name: bounceIn} +@-webkit-keyframes bounceOut { + 100% { + opacity: 0; + -webkit-transform: scale(.7); + transform: scale(.7) + } + 30% { + -webkit-transform: scale(1.03); + transform: scale(1.03) + } + 0% { + -webkit-transform: scale(1); + transform: scale(1); + } +} +@keyframes bounceOut { + 100% { + opacity: 0; + -webkit-transform: scale(.7); + -ms-transform: scale(.7); + transform: scale(.7) + } + 30% { + -webkit-transform: scale(1.03); + -ms-transform: scale(1.03); + transform: scale(1.03) + } + 0% { + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1) + } +} +.layer-anim-close{-webkit-animation-name: bounceOut;animation-name: bounceOut; -webkit-animation-duration:.2s; animation-duration:.2s;} + +@-webkit-keyframes 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 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:zoomInDown;animation-name:zoomInDown} + +@-webkit-keyframes fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes 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:fadeInUpBig;animation-name:fadeInUpBig} + +@-webkit-keyframes 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 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:zoomInLeft;animation-name:zoomInLeft} + +@-webkit-keyframes 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 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:rollIn;animation-name:rollIn} + +@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:fadeIn;animation-name:fadeIn} + +@-webkit-keyframes 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 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:shake;animation-name:shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}} + +/* 标题栏 */ +.layui-layer-title{padding:0 80px 0 20px; height:42px; line-height:42px; border-bottom:1px solid #eee; font-size:14px; color:#333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background-color: #F8F8F8; border-radius: 2px 2px 0 0;} +.layui-layer-setwin{position:absolute; right:15px; *right:0; top:15px; 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:0 -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 10px 12px; pointer-events: auto;} +.layui-layer-btn a{height: 28px; line-height: 28px; margin: 0 6px; padding: 0 15px; border:1px #dedede solid; background-color:#f1f1f1; 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.7;} +.layui-layer-btn .layui-layer-btn0{border-color: #4898d5; background-color: #2e8ded; color:#fff;} + +/* 定制化 */ +.layui-layer-dialog{min-width:260px;} +.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 .layui-layer-content{-webkit-overflow-scrolling: touch; overflow-y: auto;} +.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:5px 10px; font-size:12px; _float:left; border-radius:3px; box-shadow: 1px 1px 3px rgba(0,0,0,.3); background-color:#FF9900; 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:#FF9900;} +.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:1px; border-bottom-style:solid; border-bottom-color:#FF9900;} +.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:10px; text-align: right; border-top:1px solid #E9E7E7} +.layui-layer-lan .layui-layer-btn a{background:#BBB5B5; border:none;} +.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;} +.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:220px; height:30px; margin:0 auto; line-height:30px; padding: 0 5px; border: 1px solid #ccc; box-shadow: 1px 1px 5px rgba(0,0,0,.1) inset; color:#333;} +.layui-layer-prompt textarea.layui-layer-input{width:300px; height:100px; line-height:20px;} + +/* tab模式 */ +.layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4);} +.layui-layer-tab .layui-layer-title{padding-left:0; border-bottom:1px solid #ccc; background-color:#eee; overflow: visible;} +.layui-layer-tab .layui-layer-title span{position:relative; float:left; min-width:80px; max-width:260px; padding:0 20px; text-align:center; cursor:default; text-overflow: ellipsis; overflow: hidden; white-space: nowrap;} +.layui-layer-tab .layui-layer-title span.layui-layer-tabnow{height:43px; border-left:1px solid #ccc; border-right:1px solid #ccc; 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.xubox_tab_layer{display:block;} +.xubox_tabclose{position:absolute; right:10px; top:5px; cursor:pointer;} + +/* photo模式 */ +.layui-layer-photos{-webkit-animation-duration:1s; animation-duration:1s;} +.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-imguide,.layui-layer-imgbar{display:none;} +.layui-layer-imgprev, .layui-layer-imgnext{position:absolute; top:50%; width:27px; _width:44px; height:44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());} +.layui-layer-imgprev{left:10px; background-position:-5px -5px; _background-position:-70px -5px;} +.layui-layer-imgprev:hover{background-position:-33px -5px; _background-position:-120px -5px;} +.layui-layer-imgnext{right:10px; _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:absolute; left:0; bottom:0; width:100%; height:32px; line-height:32px; background-color:rgba(0,0,0,.8); background-color:#000\9; filter:Alpha(opacity=80); 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;} + + diff --git a/src/skin/default/loading-0.gif b/src/skin/default/loading-0.gif new file mode 100644 index 0000000..6f3c953 Binary files /dev/null and b/src/skin/default/loading-0.gif differ diff --git a/src/skin/default/loading-1.gif b/src/skin/default/loading-1.gif new file mode 100644 index 0000000..db3a483 Binary files /dev/null and b/src/skin/default/loading-1.gif differ diff --git a/src/skin/default/loading-2.gif b/src/skin/default/loading-2.gif new file mode 100644 index 0000000..5bb90fd Binary files /dev/null and b/src/skin/default/loading-2.gif differ diff --git a/test/demo.html b/test/demo.html new file mode 100644 index 0000000..3ad8237 --- /dev/null +++ b/test/demo.html @@ -0,0 +1,76 @@ + + + + + layer-更懂你的web弹窗解决方案 + + + + + + +
+
+ @Name:layer-v 弹层组件说明
+ @Author:贤心
+ @Site:http://layer.layui.com/
+
+
+【注意事项】
+一、使用时,请把文件夹layer整个放置在您站点的任何一个目录,只需引入layer.js即可,除jQuery外,其它文件无需再引入。
+二、如果您的js引入是通过合并处理或者您不想采用layer自动获取的绝对路径,您可以通过layer.config()来配置(详见官网API页)
+三、jquery需1.8+
+四、更多使用说明与演示,请参见layer官网。
+五、使用时请务必保留来源,请勿用于违反我国法律的web平台。
+六、layer遵循LGPL协议,将永久性提供无偿服务。版权最终解释权:贤心。
+
+
+ + + + + + \ No newline at end of file