Commit 1fccb1ce457534a5302b9ea4bdf65818d7b78ecd
update...
Showing
3 changed files
with
1132 additions
and
1127 deletions
src/main/resources/static/real_control_v2/assets/plugins/layer3.0.3/layer.js
| @@ -4,222 +4,222 @@ | @@ -4,222 +4,222 @@ | ||
| 4 | @Author:贤心 | 4 | @Author:贤心 |
| 5 | @Site:http://layer.layui.com | 5 | @Site:http://layer.layui.com |
| 6 | @License:MIT | 6 | @License:MIT |
| 7 | - | 7 | + |
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | ;!function(window, undefined){ | 10 | ;!function(window, undefined){ |
| 11 | -"use strict"; | 11 | + "use strict"; |
| 12 | 12 | ||
| 13 | -var isLayui = window.layui && layui.define, $, win, ready = { | ||
| 14 | - getPath: function(){ | ||
| 15 | - var js = document.scripts, script = js[js.length - 1], jsPath = script.src; | ||
| 16 | - if(script.getAttribute('merge')) return; | ||
| 17 | - return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); | ||
| 18 | - }(), | 13 | + var isLayui = window.layui && layui.define, $, win, ready = { |
| 14 | + getPath: function(){ | ||
| 15 | + var js = document.scripts, script = js[js.length - 1], jsPath = script.src; | ||
| 16 | + if(script.getAttribute('merge')) return; | ||
| 17 | + return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); | ||
| 18 | + }(), | ||
| 19 | 19 | ||
| 20 | - config: {}, end: {}, minIndex: 0, minLeft: [], | ||
| 21 | - btn: ['确定', '取消'], | 20 | + config: {}, end: {}, minIndex: 0, minLeft: [], |
| 21 | + btn: ['确定', '取消'], | ||
| 22 | 22 | ||
| 23 | - //五种原始层模式 | ||
| 24 | - type: ['dialog', 'page', 'iframe', 'loading', 'tips'] | ||
| 25 | -}; | 23 | + //五种原始层模式 |
| 24 | + type: ['dialog', 'page', 'iframe', 'loading', 'tips'] | ||
| 25 | + }; | ||
| 26 | 26 | ||
| 27 | //默认内置方法。 | 27 | //默认内置方法。 |
| 28 | -var layer = { | ||
| 29 | - v: '3.0.3', | ||
| 30 | - ie: function(){ //ie版本 | ||
| 31 | - var agent = navigator.userAgent.toLowerCase(); | ||
| 32 | - return (!!window.ActiveXObject || "ActiveXObject" in window) ? ( | ||
| 33 | - (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 | ||
| 34 | - ) : false; | ||
| 35 | - }(), | ||
| 36 | - index: (window.layer && window.layer.v) ? 100000 : 0, | ||
| 37 | - path: ready.getPath, | ||
| 38 | - config: function(options, fn){ | ||
| 39 | - options = options || {}; | ||
| 40 | - layer.cache = ready.config = $.extend({}, ready.config, options); | ||
| 41 | - layer.path = ready.config.path || layer.path; | ||
| 42 | - typeof options.extend === 'string' && (options.extend = [options.extend]); | ||
| 43 | - | ||
| 44 | - if(ready.config.path) layer.ready(); | ||
| 45 | - | ||
| 46 | - if(!options.extend) return this; | ||
| 47 | - | ||
| 48 | - isLayui | ||
| 49 | - ? layui.addcss('modules/layer/' + options.extend) | ||
| 50 | - : layer.link('skin/' + options.extend); | ||
| 51 | - | ||
| 52 | - return this; | ||
| 53 | - }, | ||
| 54 | - | ||
| 55 | - //载入CSS配件 | ||
| 56 | - link: function(href, fn, cssname){ | ||
| 57 | - | ||
| 58 | - //未设置路径,则不主动加载css | ||
| 59 | - if(!layer.path) return; | ||
| 60 | - | ||
| 61 | - var head = $('head')[0], link = document.createElement('link'); | ||
| 62 | - if(typeof fn === 'string') cssname = fn; | ||
| 63 | - var app = (cssname || href).replace(/\.|\//g, ''); | ||
| 64 | - var id = 'layuicss-'+app, timeout = 0; | ||
| 65 | - | ||
| 66 | - link.rel = 'stylesheet'; | ||
| 67 | - link.href = layer.path + href; | ||
| 68 | - link.id = id; | ||
| 69 | - | ||
| 70 | - if(!$('#'+ id)[0]){ | ||
| 71 | - head.appendChild(link); | ||
| 72 | - } | ||
| 73 | - | ||
| 74 | - if(typeof fn !== 'function') return; | ||
| 75 | - | ||
| 76 | - //轮询css是否加载完毕 | ||
| 77 | - (function poll() { | ||
| 78 | - if(++timeout > 8 * 1000 / 100){ | ||
| 79 | - return window.console && console.error('layer.css: Invalid'); | ||
| 80 | - }; | ||
| 81 | - parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100); | ||
| 82 | - }()); | ||
| 83 | - }, | ||
| 84 | - | ||
| 85 | - ready: function(callback){ | ||
| 86 | - var cssname = 'skinlayercss', ver = '303'; | ||
| 87 | - isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname) | ||
| 88 | - : layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname); | ||
| 89 | - return this; | ||
| 90 | - }, | ||
| 91 | - | ||
| 92 | - //各种快捷引用 | ||
| 93 | - alert: function(content, options, yes){ | ||
| 94 | - var type = typeof options === 'function'; | ||
| 95 | - if(type) yes = options; | ||
| 96 | - return layer.open($.extend({ | ||
| 97 | - content: content, | ||
| 98 | - yes: yes | ||
| 99 | - }, type ? {} : options)); | ||
| 100 | - }, | ||
| 101 | - | ||
| 102 | - confirm: function(content, options, yes, cancel){ | ||
| 103 | - var type = typeof options === 'function'; | ||
| 104 | - if(type){ | ||
| 105 | - cancel = yes; | ||
| 106 | - yes = options; | 28 | + var layer = { |
| 29 | + v: '3.0.3', | ||
| 30 | + ie: function(){ //ie版本 | ||
| 31 | + var agent = navigator.userAgent.toLowerCase(); | ||
| 32 | + return (!!window.ActiveXObject || "ActiveXObject" in window) ? ( | ||
| 33 | + (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识 | ||
| 34 | + ) : false; | ||
| 35 | + }(), | ||
| 36 | + index: (window.layer && window.layer.v) ? 100000 : 0, | ||
| 37 | + path: ready.getPath, | ||
| 38 | + config: function(options, fn){ | ||
| 39 | + options = options || {}; | ||
| 40 | + layer.cache = ready.config = $.extend({}, ready.config, options); | ||
| 41 | + layer.path = ready.config.path || layer.path; | ||
| 42 | + typeof options.extend === 'string' && (options.extend = [options.extend]); | ||
| 43 | + | ||
| 44 | + if(ready.config.path) layer.ready(); | ||
| 45 | + | ||
| 46 | + if(!options.extend) return this; | ||
| 47 | + | ||
| 48 | + isLayui | ||
| 49 | + ? layui.addcss('modules/layer/' + options.extend) | ||
| 50 | + : layer.link('skin/' + options.extend); | ||
| 51 | + | ||
| 52 | + return this; | ||
| 53 | + }, | ||
| 54 | + | ||
| 55 | + //载入CSS配件 | ||
| 56 | + link: function(href, fn, cssname){ | ||
| 57 | + | ||
| 58 | + //未设置路径,则不主动加载css | ||
| 59 | + if(!layer.path) return; | ||
| 60 | + | ||
| 61 | + var head = $('head')[0], link = document.createElement('link'); | ||
| 62 | + if(typeof fn === 'string') cssname = fn; | ||
| 63 | + var app = (cssname || href).replace(/\.|\//g, ''); | ||
| 64 | + var id = 'layuicss-'+app, timeout = 0; | ||
| 65 | + | ||
| 66 | + link.rel = 'stylesheet'; | ||
| 67 | + link.href = layer.path + href; | ||
| 68 | + link.id = id; | ||
| 69 | + | ||
| 70 | + if(!$('#'+ id)[0]){ | ||
| 71 | + head.appendChild(link); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + if(typeof fn !== 'function') return; | ||
| 75 | + | ||
| 76 | + //轮询css是否加载完毕 | ||
| 77 | + /* (function poll() { | ||
| 78 | + if(++timeout > 8 * 1000 / 100){ | ||
| 79 | + return window.console && console.error('layer.css: Invalid'); | ||
| 80 | + }; | ||
| 81 | + parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100); | ||
| 82 | + }());*/ | ||
| 83 | + }, | ||
| 84 | + | ||
| 85 | + ready: function(callback){ | ||
| 86 | + /*var cssname = 'skinlayercss', ver = '303'; | ||
| 87 | + isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname) | ||
| 88 | + : layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname);*/ | ||
| 89 | + return this; | ||
| 90 | + }, | ||
| 91 | + | ||
| 92 | + //各种快捷引用 | ||
| 93 | + alert: function(content, options, yes){ | ||
| 94 | + var type = typeof options === 'function'; | ||
| 95 | + if(type) yes = options; | ||
| 96 | + return layer.open($.extend({ | ||
| 97 | + content: content, | ||
| 98 | + yes: yes | ||
| 99 | + }, type ? {} : options)); | ||
| 100 | + }, | ||
| 101 | + | ||
| 102 | + confirm: function(content, options, yes, cancel){ | ||
| 103 | + var type = typeof options === 'function'; | ||
| 104 | + if(type){ | ||
| 105 | + cancel = yes; | ||
| 106 | + yes = options; | ||
| 107 | + } | ||
| 108 | + return layer.open($.extend({ | ||
| 109 | + content: content, | ||
| 110 | + btn: ready.btn, | ||
| 111 | + yes: yes, | ||
| 112 | + btn2: cancel | ||
| 113 | + }, type ? {} : options)); | ||
| 114 | + }, | ||
| 115 | + | ||
| 116 | + msg: function(content, options, end){ //最常用提示层 | ||
| 117 | + var type = typeof options === 'function', rskin = ready.config.skin; | ||
| 118 | + var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; | ||
| 119 | + var anim = doms.anim.length - 1; | ||
| 120 | + if(type) end = options; | ||
| 121 | + return layer.open($.extend({ | ||
| 122 | + content: content, | ||
| 123 | + time: 3000, | ||
| 124 | + shade: false, | ||
| 125 | + skin: skin, | ||
| 126 | + title: false, | ||
| 127 | + closeBtn: false, | ||
| 128 | + btn: false, | ||
| 129 | + resize: false, | ||
| 130 | + end: end | ||
| 131 | + }, (type && !ready.config.skin) ? { | ||
| 132 | + skin: skin + ' layui-layer-hui', | ||
| 133 | + anim: anim | ||
| 134 | + } : function(){ | ||
| 135 | + options = options || {}; | ||
| 136 | + if(options.icon === -1 || options.icon === undefined && !ready.config.skin){ | ||
| 137 | + options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); | ||
| 138 | + } | ||
| 139 | + return options; | ||
| 140 | + }())); | ||
| 141 | + }, | ||
| 142 | + | ||
| 143 | + load: function(icon, options){ | ||
| 144 | + return layer.open($.extend({ | ||
| 145 | + type: 3, | ||
| 146 | + icon: icon || 0, | ||
| 147 | + resize: false, | ||
| 148 | + shade: 0.01 | ||
| 149 | + }, options)); | ||
| 150 | + }, | ||
| 151 | + | ||
| 152 | + tips: function(content, follow, options){ | ||
| 153 | + return layer.open($.extend({ | ||
| 154 | + type: 4, | ||
| 155 | + content: [content, follow], | ||
| 156 | + closeBtn: false, | ||
| 157 | + time: 3000, | ||
| 158 | + shade: false, | ||
| 159 | + resize: false, | ||
| 160 | + fixed: false, | ||
| 161 | + maxWidth: 210 | ||
| 162 | + }, options)); | ||
| 107 | } | 163 | } |
| 108 | - return layer.open($.extend({ | ||
| 109 | - content: content, | ||
| 110 | - btn: ready.btn, | ||
| 111 | - yes: yes, | ||
| 112 | - btn2: cancel | ||
| 113 | - }, type ? {} : options)); | ||
| 114 | - }, | ||
| 115 | - | ||
| 116 | - msg: function(content, options, end){ //最常用提示层 | ||
| 117 | - var type = typeof options === 'function', rskin = ready.config.skin; | ||
| 118 | - var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg'; | ||
| 119 | - var anim = doms.anim.length - 1; | ||
| 120 | - if(type) end = options; | ||
| 121 | - return layer.open($.extend({ | ||
| 122 | - content: content, | ||
| 123 | - time: 3000, | ||
| 124 | - shade: false, | ||
| 125 | - skin: skin, | ||
| 126 | - title: false, | ||
| 127 | - closeBtn: false, | ||
| 128 | - btn: false, | ||
| 129 | - resize: false, | ||
| 130 | - end: end | ||
| 131 | - }, (type && !ready.config.skin) ? { | ||
| 132 | - skin: skin + ' layui-layer-hui', | ||
| 133 | - anim: anim | ||
| 134 | - } : function(){ | ||
| 135 | - options = options || {}; | ||
| 136 | - if(options.icon === -1 || options.icon === undefined && !ready.config.skin){ | ||
| 137 | - options.skin = skin + ' ' + (options.skin||'layui-layer-hui'); | ||
| 138 | - } | ||
| 139 | - return options; | ||
| 140 | - }())); | ||
| 141 | - }, | ||
| 142 | - | ||
| 143 | - load: function(icon, options){ | ||
| 144 | - return layer.open($.extend({ | ||
| 145 | - type: 3, | ||
| 146 | - icon: icon || 0, | ||
| 147 | - resize: false, | ||
| 148 | - shade: 0.01 | ||
| 149 | - }, options)); | ||
| 150 | - }, | ||
| 151 | - | ||
| 152 | - tips: function(content, follow, options){ | ||
| 153 | - return layer.open($.extend({ | ||
| 154 | - type: 4, | ||
| 155 | - content: [content, follow], | ||
| 156 | - closeBtn: false, | ||
| 157 | - time: 3000, | ||
| 158 | - shade: false, | ||
| 159 | - resize: false, | ||
| 160 | - fixed: false, | ||
| 161 | - maxWidth: 210 | ||
| 162 | - }, options)); | ||
| 163 | - } | ||
| 164 | -}; | 164 | + }; |
| 165 | 165 | ||
| 166 | -var Class = function(setings){ | ||
| 167 | - var that = this; | ||
| 168 | - that.index = ++layer.index; | ||
| 169 | - that.config = $.extend({}, that.config, ready.config, setings); | ||
| 170 | - document.body ? that.creat() : setTimeout(function(){ | ||
| 171 | - that.creat(); | ||
| 172 | - }, 30); | ||
| 173 | -}; | 166 | + var Class = function(setings){ |
| 167 | + var that = this; | ||
| 168 | + that.index = ++layer.index; | ||
| 169 | + that.config = $.extend({}, that.config, ready.config, setings); | ||
| 170 | + document.body ? that.creat() : setTimeout(function(){ | ||
| 171 | + that.creat(); | ||
| 172 | + }, 30); | ||
| 173 | + }; | ||
| 174 | 174 | ||
| 175 | -Class.pt = Class.prototype; | 175 | + Class.pt = Class.prototype; |
| 176 | 176 | ||
| 177 | //缓存常用字符 | 177 | //缓存常用字符 |
| 178 | -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']; | ||
| 179 | -doms.anim = ['layer-anim', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06']; | 178 | + 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']; |
| 179 | + doms.anim = ['layer-anim', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06']; | ||
| 180 | 180 | ||
| 181 | //默认配置 | 181 | //默认配置 |
| 182 | -Class.pt.config = { | ||
| 183 | - type: 0, | ||
| 184 | - shade: 0.3, | ||
| 185 | - fixed: true, | ||
| 186 | - move: doms[1], | ||
| 187 | - title: '信息', | ||
| 188 | - offset: 'auto', | ||
| 189 | - area: 'auto', | ||
| 190 | - closeBtn: 1, | ||
| 191 | - time: 0, //0表示不自动关闭 | ||
| 192 | - zIndex: 19891014, | ||
| 193 | - maxWidth: 360, | ||
| 194 | - anim: 0, | ||
| 195 | - isOutAnim: true, | ||
| 196 | - icon: -1, | ||
| 197 | - moveType: 1, | ||
| 198 | - resize: true, | ||
| 199 | - scrollbar: true, //是否允许浏览器滚动条 | ||
| 200 | - tips: 2 | ||
| 201 | -}; | 182 | + Class.pt.config = { |
| 183 | + type: 0, | ||
| 184 | + shade: 0.3, | ||
| 185 | + fixed: true, | ||
| 186 | + move: doms[1], | ||
| 187 | + title: '信息', | ||
| 188 | + offset: 'auto', | ||
| 189 | + area: 'auto', | ||
| 190 | + closeBtn: 1, | ||
| 191 | + time: 0, //0表示不自动关闭 | ||
| 192 | + zIndex: 19891014, | ||
| 193 | + maxWidth: 360, | ||
| 194 | + anim: 0, | ||
| 195 | + isOutAnim: true, | ||
| 196 | + icon: -1, | ||
| 197 | + moveType: 1, | ||
| 198 | + resize: true, | ||
| 199 | + scrollbar: true, //是否允许浏览器滚动条 | ||
| 200 | + tips: 2 | ||
| 201 | + }; | ||
| 202 | 202 | ||
| 203 | //容器 | 203 | //容器 |
| 204 | -Class.pt.vessel = function(conType, callback){ | ||
| 205 | - var that = this, times = that.index, config = that.config; | ||
| 206 | - var zIndex = config.zIndex + times, titype = typeof config.title === 'object'; | ||
| 207 | - var ismax = config.maxmin && (config.type === 1 || config.type === 2); | ||
| 208 | - var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">' | ||
| 209 | - + (titype ? config.title[0] : config.title) | ||
| 210 | - + '</div>' : ''); | ||
| 211 | - | ||
| 212 | - config.zIndex = zIndex; | ||
| 213 | - callback([ | ||
| 214 | - //遮罩 | ||
| 215 | - config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '', | ||
| 216 | - | ||
| 217 | - //主体 | ||
| 218 | - '<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">' | 204 | + Class.pt.vessel = function(conType, callback){ |
| 205 | + var that = this, times = that.index, config = that.config; | ||
| 206 | + var zIndex = config.zIndex + times, titype = typeof config.title === 'object'; | ||
| 207 | + var ismax = config.maxmin && (config.type === 1 || config.type === 2); | ||
| 208 | + var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">' | ||
| 209 | + + (titype ? config.title[0] : config.title) | ||
| 210 | + + '</div>' : ''); | ||
| 211 | + | ||
| 212 | + config.zIndex = zIndex; | ||
| 213 | + callback([ | ||
| 214 | + //遮罩 | ||
| 215 | + config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '', | ||
| 216 | + | ||
| 217 | + //主体 | ||
| 218 | + '<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">' | ||
| 219 | + (conType && config.type != 2 ? '' : titleHTML) | 219 | + (conType && config.type != 2 ? '' : titleHTML) |
| 220 | + '<div id="'+ (config.id||'') +'" class="layui-layer-content'+ ((config.type == 0 && config.icon !== -1) ? ' layui-layer-padding' :'') + (config.type == 3 ? ' layui-layer-loading'+config.icon : '') +'">' | 220 | + '<div id="'+ (config.id||'') +'" class="layui-layer-content'+ ((config.type == 0 && config.icon !== -1) ? ' layui-layer-padding' :'') + (config.type == 3 ? ' layui-layer-loading'+config.icon : '') +'">' |
| 221 | - + (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico'+ config.icon +'"></i>' : '') | ||
| 222 | - + (config.type == 1 && conType ? '' : (config.content||'')) | 221 | + + (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico'+ config.icon +'"></i>' : '') |
| 222 | + + (config.type == 1 && conType ? '' : (config.content||'')) | ||
| 223 | + '</div>' | 223 | + '</div>' |
| 224 | + '<span class="layui-layer-setwin">'+ function(){ | 224 | + '<span class="layui-layer-setwin">'+ function(){ |
| 225 | var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : ''; | 225 | var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : ''; |
| @@ -235,1036 +235,1036 @@ Class.pt.vessel = function(conType, callback){ | @@ -235,1036 +235,1036 @@ Class.pt.vessel = function(conType, callback){ | ||
| 235 | return '<div class="'+ doms[6] + (config.btnAlign ? (' layui-layer-btn-' + config.btnAlign) : '') +'">'+ button +'</div>' | 235 | return '<div class="'+ doms[6] + (config.btnAlign ? (' layui-layer-btn-' + config.btnAlign) : '') +'">'+ button +'</div>' |
| 236 | }() : '') | 236 | }() : '') |
| 237 | + (config.resize ? '<span class="layui-layer-resize"></span>' : '') | 237 | + (config.resize ? '<span class="layui-layer-resize"></span>' : '') |
| 238 | - + '</div>' | ||
| 239 | - ], titleHTML, $('<div class="layui-layer-move"></div>')); | ||
| 240 | - return that; | ||
| 241 | -}; | 238 | + + '</div>' |
| 239 | + ], titleHTML, $('<div class="layui-layer-move"></div>')); | ||
| 240 | + return that; | ||
| 241 | + }; | ||
| 242 | 242 | ||
| 243 | //创建骨架 | 243 | //创建骨架 |
| 244 | -Class.pt.creat = function(){ | ||
| 245 | - var that = this | ||
| 246 | - ,config = that.config | ||
| 247 | - ,times = that.index, nodeIndex | ||
| 248 | - ,content = config.content | ||
| 249 | - ,conType = typeof content === 'object' | ||
| 250 | - ,body = $('body'); | ||
| 251 | - | ||
| 252 | - if(config.id && $('#'+config.id)[0]) return; | ||
| 253 | - | ||
| 254 | - if(typeof config.area === 'string'){ | ||
| 255 | - config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; | ||
| 256 | - } | ||
| 257 | - | ||
| 258 | - //anim兼容旧版shift | ||
| 259 | - if(config.shift){ | ||
| 260 | - config.anim = config.shift; | ||
| 261 | - } | ||
| 262 | - | ||
| 263 | - if(layer.ie == 6){ | ||
| 264 | - config.fixed = false; | ||
| 265 | - } | ||
| 266 | - | ||
| 267 | - switch(config.type){ | ||
| 268 | - case 0: | ||
| 269 | - config.btn = ('btn' in config) ? config.btn : ready.btn[0]; | ||
| 270 | - layer.closeAll('dialog'); | ||
| 271 | - break; | ||
| 272 | - case 2: | ||
| 273 | - var content = config.content = conType ? config.content : [config.content, 'auto']; | ||
| 274 | - config.content = '<iframe scrolling="'+ (config.content[1]||'auto') +'" allowtransparency="true" id="'+ doms[4] +''+ times +'" name="'+ doms[4] +''+ times +'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + config.content[0] + '"></iframe>'; | ||
| 275 | - break; | ||
| 276 | - case 3: | ||
| 277 | - delete config.title; | ||
| 278 | - delete config.closeBtn; | ||
| 279 | - config.icon === -1 && (config.icon === 0); | ||
| 280 | - layer.closeAll('loading'); | ||
| 281 | - break; | ||
| 282 | - case 4: | ||
| 283 | - conType || (config.content = [config.content, 'body']); | ||
| 284 | - config.follow = config.content[1]; | ||
| 285 | - config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>'; | ||
| 286 | - delete config.title; | ||
| 287 | - config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true]; | ||
| 288 | - config.tipsMore || layer.closeAll('tips'); | ||
| 289 | - break; | ||
| 290 | - } | ||
| 291 | - | ||
| 292 | - //建立容器 | ||
| 293 | - that.vessel(conType, function(html, titleHTML, moveElem){ | ||
| 294 | - body.append(html[0]); | ||
| 295 | - conType ? function(){ | ||
| 296 | - (config.type == 2 || config.type == 4) ? function(){ | ||
| 297 | - $('body').append(html[1]); | ||
| 298 | - }() : function(){ | ||
| 299 | - if(!content.parents('.'+doms[0])[0]){ | ||
| 300 | - content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]); | ||
| 301 | - $('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML); | ||
| 302 | - } | ||
| 303 | - }(); | ||
| 304 | - }() : body.append(html[1]); | ||
| 305 | - $('.layui-layer-move')[0] || body.append(ready.moveElem = moveElem); | ||
| 306 | - that.layero = $('#'+ doms[0] + times); | ||
| 307 | - config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times); | ||
| 308 | - }).auto(times); | ||
| 309 | - | ||
| 310 | - config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]); | ||
| 311 | - | ||
| 312 | - //坐标自适应浏览器窗口尺寸 | ||
| 313 | - config.type == 4 ? that.tips() : that.offset(); | ||
| 314 | - if(config.fixed){ | ||
| 315 | - win.on('resize', function(){ | ||
| 316 | - that.offset(); | ||
| 317 | - (/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times); | ||
| 318 | - config.type == 4 && that.tips(); | ||
| 319 | - }); | ||
| 320 | - } | ||
| 321 | - | ||
| 322 | - config.time <= 0 || setTimeout(function(){ | ||
| 323 | - layer.close(that.index) | ||
| 324 | - }, config.time); | ||
| 325 | - that.move().callback(); | ||
| 326 | - | ||
| 327 | - //为兼容jQuery3.0的css动画影响元素尺寸计算 | ||
| 328 | - if(doms.anim[config.anim]){ | ||
| 329 | - that.layero.addClass(doms.anim[config.anim]); | 244 | + Class.pt.creat = function(){ |
| 245 | + var that = this | ||
| 246 | + ,config = that.config | ||
| 247 | + ,times = that.index, nodeIndex | ||
| 248 | + ,content = config.content | ||
| 249 | + ,conType = typeof content === 'object' | ||
| 250 | + ,body = $('body'); | ||
| 251 | + | ||
| 252 | + if(config.id && $('#'+config.id)[0]) return; | ||
| 253 | + | ||
| 254 | + if(typeof config.area === 'string'){ | ||
| 255 | + config.area = config.area === 'auto' ? ['', ''] : [config.area, '']; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + //anim兼容旧版shift | ||
| 259 | + if(config.shift){ | ||
| 260 | + config.anim = config.shift; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + if(layer.ie == 6){ | ||
| 264 | + config.fixed = false; | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + switch(config.type){ | ||
| 268 | + case 0: | ||
| 269 | + config.btn = ('btn' in config) ? config.btn : ready.btn[0]; | ||
| 270 | + layer.closeAll('dialog'); | ||
| 271 | + break; | ||
| 272 | + case 2: | ||
| 273 | + var content = config.content = conType ? config.content : [config.content, 'auto']; | ||
| 274 | + config.content = '<iframe scrolling="'+ (config.content[1]||'auto') +'" allowtransparency="true" id="'+ doms[4] +''+ times +'" name="'+ doms[4] +''+ times +'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + config.content[0] + '"></iframe>'; | ||
| 275 | + break; | ||
| 276 | + case 3: | ||
| 277 | + delete config.title; | ||
| 278 | + delete config.closeBtn; | ||
| 279 | + config.icon === -1 && (config.icon === 0); | ||
| 280 | + layer.closeAll('loading'); | ||
| 281 | + break; | ||
| 282 | + case 4: | ||
| 283 | + conType || (config.content = [config.content, 'body']); | ||
| 284 | + config.follow = config.content[1]; | ||
| 285 | + config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>'; | ||
| 286 | + delete config.title; | ||
| 287 | + config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true]; | ||
| 288 | + config.tipsMore || layer.closeAll('tips'); | ||
| 289 | + break; | ||
| 290 | + } | ||
| 291 | + | ||
| 292 | + //建立容器 | ||
| 293 | + that.vessel(conType, function(html, titleHTML, moveElem){ | ||
| 294 | + body.append(html[0]); | ||
| 295 | + conType ? function(){ | ||
| 296 | + (config.type == 2 || config.type == 4) ? function(){ | ||
| 297 | + $('body').append(html[1]); | ||
| 298 | + }() : function(){ | ||
| 299 | + if(!content.parents('.'+doms[0])[0]){ | ||
| 300 | + content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]); | ||
| 301 | + $('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML); | ||
| 302 | + } | ||
| 303 | + }(); | ||
| 304 | + }() : body.append(html[1]); | ||
| 305 | + $('.layui-layer-move')[0] || body.append(ready.moveElem = moveElem); | ||
| 306 | + that.layero = $('#'+ doms[0] + times); | ||
| 307 | + config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times); | ||
| 308 | + }).auto(times); | ||
| 309 | + | ||
| 310 | + config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]); | ||
| 311 | + | ||
| 312 | + //坐标自适应浏览器窗口尺寸 | ||
| 313 | + config.type == 4 ? that.tips() : that.offset(); | ||
| 314 | + if(config.fixed){ | ||
| 315 | + win.on('resize', function(){ | ||
| 316 | + that.offset(); | ||
| 317 | + (/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times); | ||
| 318 | + config.type == 4 && that.tips(); | ||
| 319 | + }); | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + config.time <= 0 || setTimeout(function(){ | ||
| 323 | + layer.close(that.index) | ||
| 324 | + }, config.time); | ||
| 325 | + that.move().callback(); | ||
| 326 | + | ||
| 327 | + //为兼容jQuery3.0的css动画影响元素尺寸计算 | ||
| 328 | + if(doms.anim[config.anim]){ | ||
| 329 | + that.layero.addClass(doms.anim[config.anim]); | ||
| 330 | + }; | ||
| 331 | + | ||
| 332 | + //记录关闭动画 | ||
| 333 | + if(config.isOutAnim){ | ||
| 334 | + that.layero.data('isOutAnim', true); | ||
| 335 | + } | ||
| 330 | }; | 336 | }; |
| 331 | - | ||
| 332 | - //记录关闭动画 | ||
| 333 | - if(config.isOutAnim){ | ||
| 334 | - that.layero.data('isOutAnim', true); | ||
| 335 | - } | ||
| 336 | -}; | ||
| 337 | 337 | ||
| 338 | //自适应 | 338 | //自适应 |
| 339 | -Class.pt.auto = function(index){ | ||
| 340 | - var that = this, config = that.config, layero = $('#'+ doms[0] + index); | ||
| 341 | - if(config.area[0] === '' && config.maxWidth > 0){ | ||
| 342 | - //为了修复IE7下一个让人难以理解的bug | ||
| 343 | - if(layer.ie && layer.ie < 8 && config.btn){ | ||
| 344 | - layero.width(layero.innerWidth()); | 339 | + Class.pt.auto = function(index){ |
| 340 | + var that = this, config = that.config, layero = $('#'+ doms[0] + index); | ||
| 341 | + if(config.area[0] === '' && config.maxWidth > 0){ | ||
| 342 | + //为了修复IE7下一个让人难以理解的bug | ||
| 343 | + if(layer.ie && layer.ie < 8 && config.btn){ | ||
| 344 | + layero.width(layero.innerWidth()); | ||
| 345 | + } | ||
| 346 | + layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth); | ||
| 345 | } | 347 | } |
| 346 | - layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth); | ||
| 347 | - } | ||
| 348 | - var area = [layero.innerWidth(), layero.innerHeight()]; | ||
| 349 | - var titHeight = layero.find(doms[1]).outerHeight() || 0; | ||
| 350 | - var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; | ||
| 351 | - function setHeight(elem){ | ||
| 352 | - elem = layero.find(elem); | ||
| 353 | - elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding-top'))|0)); | ||
| 354 | - } | ||
| 355 | - switch(config.type){ | ||
| 356 | - case 2: | ||
| 357 | - setHeight('iframe'); | ||
| 358 | - break; | ||
| 359 | - default: | ||
| 360 | - if(config.area[1] === ''){ | ||
| 361 | - if(config.fixed && area[1] >= win.height()){ | ||
| 362 | - area[1] = win.height(); | 348 | + var area = [layero.innerWidth(), layero.innerHeight()]; |
| 349 | + var titHeight = layero.find(doms[1]).outerHeight() || 0; | ||
| 350 | + var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; | ||
| 351 | + function setHeight(elem){ | ||
| 352 | + elem = layero.find(elem); | ||
| 353 | + elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding-top'))|0)); | ||
| 354 | + } | ||
| 355 | + switch(config.type){ | ||
| 356 | + case 2: | ||
| 357 | + setHeight('iframe'); | ||
| 358 | + break; | ||
| 359 | + default: | ||
| 360 | + if(config.area[1] === ''){ | ||
| 361 | + if(config.fixed && area[1] >= win.height()){ | ||
| 362 | + area[1] = win.height(); | ||
| 363 | + setHeight('.'+doms[5]); | ||
| 364 | + } | ||
| 365 | + } else { | ||
| 363 | setHeight('.'+doms[5]); | 366 | setHeight('.'+doms[5]); |
| 364 | } | 367 | } |
| 368 | + break; | ||
| 369 | + } | ||
| 370 | + return that; | ||
| 371 | + }; | ||
| 372 | + | ||
| 373 | +//计算坐标 | ||
| 374 | + Class.pt.offset = function(){ | ||
| 375 | + var that = this, config = that.config, layero = that.layero; | ||
| 376 | + var area = [layero.outerWidth(), layero.outerHeight()]; | ||
| 377 | + var type = typeof config.offset === 'object'; | ||
| 378 | + that.offsetTop = (win.height() - area[1])/2; | ||
| 379 | + that.offsetLeft = (win.width() - area[0])/2; | ||
| 380 | + | ||
| 381 | + if(type){ | ||
| 382 | + that.offsetTop = config.offset[0]; | ||
| 383 | + that.offsetLeft = config.offset[1]||that.offsetLeft; | ||
| 384 | + } else if(config.offset !== 'auto'){ | ||
| 385 | + | ||
| 386 | + if(config.offset === 't'){ //上 | ||
| 387 | + that.offsetTop = 0; | ||
| 388 | + } else if(config.offset === 'r'){ //右 | ||
| 389 | + that.offsetLeft = win.width() - area[0]; | ||
| 390 | + } else if(config.offset === 'b'){ //下 | ||
| 391 | + that.offsetTop = win.height() - area[1]; | ||
| 392 | + } else if(config.offset === 'l'){ //左 | ||
| 393 | + that.offsetLeft = 0; | ||
| 394 | + } else if(config.offset === 'lt'){ //左上角 | ||
| 395 | + that.offsetTop = 0; | ||
| 396 | + that.offsetLeft = 0; | ||
| 397 | + } else if(config.offset === 'lb'){ //左下角 | ||
| 398 | + that.offsetTop = win.height() - area[1]; | ||
| 399 | + that.offsetLeft = 0; | ||
| 400 | + } else if(config.offset === 'rt'){ //右上角 | ||
| 401 | + that.offsetTop = 0; | ||
| 402 | + that.offsetLeft = win.width() - area[0]; | ||
| 403 | + } else if(config.offset === 'rb'){ //右下角 | ||
| 404 | + that.offsetTop = win.height() - area[1]; | ||
| 405 | + that.offsetLeft = win.width() - area[0]; | ||
| 365 | } else { | 406 | } else { |
| 366 | - setHeight('.'+doms[5]); | 407 | + that.offsetTop = config.offset; |
| 367 | } | 408 | } |
| 368 | - break; | ||
| 369 | - } | ||
| 370 | - return that; | ||
| 371 | -}; | ||
| 372 | 409 | ||
| 373 | -//计算坐标 | ||
| 374 | -Class.pt.offset = function(){ | ||
| 375 | - var that = this, config = that.config, layero = that.layero; | ||
| 376 | - var area = [layero.outerWidth(), layero.outerHeight()]; | ||
| 377 | - var type = typeof config.offset === 'object'; | ||
| 378 | - that.offsetTop = (win.height() - area[1])/2; | ||
| 379 | - that.offsetLeft = (win.width() - area[0])/2; | ||
| 380 | - | ||
| 381 | - if(type){ | ||
| 382 | - that.offsetTop = config.offset[0]; | ||
| 383 | - that.offsetLeft = config.offset[1]||that.offsetLeft; | ||
| 384 | - } else if(config.offset !== 'auto'){ | ||
| 385 | - | ||
| 386 | - if(config.offset === 't'){ //上 | ||
| 387 | - that.offsetTop = 0; | ||
| 388 | - } else if(config.offset === 'r'){ //右 | ||
| 389 | - that.offsetLeft = win.width() - area[0]; | ||
| 390 | - } else if(config.offset === 'b'){ //下 | ||
| 391 | - that.offsetTop = win.height() - area[1]; | ||
| 392 | - } else if(config.offset === 'l'){ //左 | ||
| 393 | - that.offsetLeft = 0; | ||
| 394 | - } else if(config.offset === 'lt'){ //左上角 | ||
| 395 | - that.offsetTop = 0; | ||
| 396 | - that.offsetLeft = 0; | ||
| 397 | - } else if(config.offset === 'lb'){ //左下角 | ||
| 398 | - that.offsetTop = win.height() - area[1]; | ||
| 399 | - that.offsetLeft = 0; | ||
| 400 | - } else if(config.offset === 'rt'){ //右上角 | ||
| 401 | - that.offsetTop = 0; | ||
| 402 | - that.offsetLeft = win.width() - area[0]; | ||
| 403 | - } else if(config.offset === 'rb'){ //右下角 | ||
| 404 | - that.offsetTop = win.height() - area[1]; | ||
| 405 | - that.offsetLeft = win.width() - area[0]; | ||
| 406 | - } else { | ||
| 407 | - that.offsetTop = config.offset; | ||
| 408 | } | 410 | } |
| 409 | - | ||
| 410 | - } | ||
| 411 | - | ||
| 412 | - if(!config.fixed){ | ||
| 413 | - that.offsetTop = /%$/.test(that.offsetTop) ? | 411 | + |
| 412 | + if(!config.fixed){ | ||
| 413 | + that.offsetTop = /%$/.test(that.offsetTop) ? | ||
| 414 | win.height()*parseFloat(that.offsetTop)/100 | 414 | win.height()*parseFloat(that.offsetTop)/100 |
| 415 | - : parseFloat(that.offsetTop); | ||
| 416 | - that.offsetLeft = /%$/.test(that.offsetLeft) ? | 415 | + : parseFloat(that.offsetTop); |
| 416 | + that.offsetLeft = /%$/.test(that.offsetLeft) ? | ||
| 417 | win.width()*parseFloat(that.offsetLeft)/100 | 417 | win.width()*parseFloat(that.offsetLeft)/100 |
| 418 | - : parseFloat(that.offsetLeft); | ||
| 419 | - that.offsetTop += win.scrollTop(); | ||
| 420 | - that.offsetLeft += win.scrollLeft(); | ||
| 421 | - } | ||
| 422 | - | ||
| 423 | - if(layero.attr('minLeft')){ | ||
| 424 | - that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); | ||
| 425 | - that.offsetLeft = layero.css('left'); | ||
| 426 | - } | 418 | + : parseFloat(that.offsetLeft); |
| 419 | + that.offsetTop += win.scrollTop(); | ||
| 420 | + that.offsetLeft += win.scrollLeft(); | ||
| 421 | + } | ||
| 427 | 422 | ||
| 428 | - layero.css({top: that.offsetTop, left: that.offsetLeft}); | ||
| 429 | -}; | 423 | + if(layero.attr('minLeft')){ |
| 424 | + that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0); | ||
| 425 | + that.offsetLeft = layero.css('left'); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + layero.css({top: that.offsetTop, left: that.offsetLeft}); | ||
| 429 | + }; | ||
| 430 | 430 | ||
| 431 | //Tips | 431 | //Tips |
| 432 | -Class.pt.tips = function(){ | ||
| 433 | - var that = this, config = that.config, layero = that.layero; | ||
| 434 | - var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow); | ||
| 435 | - if(!follow[0]) follow = $('body'); | ||
| 436 | - var goal = { | ||
| 437 | - width: follow.outerWidth(), | ||
| 438 | - height: follow.outerHeight(), | ||
| 439 | - top: follow.offset().top, | ||
| 440 | - left: follow.offset().left | ||
| 441 | - }, tipsG = layero.find('.layui-layer-TipsG'); | ||
| 442 | - | ||
| 443 | - var guide = config.tips[0]; | ||
| 444 | - config.tips[1] || tipsG.remove(); | ||
| 445 | - | ||
| 446 | - goal.autoLeft = function(){ | ||
| 447 | - if(goal.left + layArea[0] - win.width() > 0){ | ||
| 448 | - goal.tipLeft = goal.left + goal.width - layArea[0]; | ||
| 449 | - tipsG.css({right: 12, left: 'auto'}); | ||
| 450 | - } else { | ||
| 451 | - goal.tipLeft = goal.left; | 432 | + Class.pt.tips = function(){ |
| 433 | + var that = this, config = that.config, layero = that.layero; | ||
| 434 | + var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow); | ||
| 435 | + if(!follow[0]) follow = $('body'); | ||
| 436 | + var goal = { | ||
| 437 | + width: follow.outerWidth(), | ||
| 438 | + height: follow.outerHeight(), | ||
| 439 | + top: follow.offset().top, | ||
| 440 | + left: follow.offset().left | ||
| 441 | + }, tipsG = layero.find('.layui-layer-TipsG'); | ||
| 442 | + | ||
| 443 | + var guide = config.tips[0]; | ||
| 444 | + config.tips[1] || tipsG.remove(); | ||
| 445 | + | ||
| 446 | + goal.autoLeft = function(){ | ||
| 447 | + if(goal.left + layArea[0] - win.width() > 0){ | ||
| 448 | + goal.tipLeft = goal.left + goal.width - layArea[0]; | ||
| 449 | + tipsG.css({right: 12, left: 'auto'}); | ||
| 450 | + } else { | ||
| 451 | + goal.tipLeft = goal.left; | ||
| 452 | + }; | ||
| 452 | }; | 453 | }; |
| 453 | - }; | ||
| 454 | - | ||
| 455 | - //辨别tips的方位 | ||
| 456 | - goal.where = [function(){ //上 | ||
| 457 | - goal.autoLeft(); | ||
| 458 | - goal.tipTop = goal.top - layArea[1] - 10; | ||
| 459 | - tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); | ||
| 460 | - }, function(){ //右 | ||
| 461 | - goal.tipLeft = goal.left + goal.width + 10; | ||
| 462 | - goal.tipTop = goal.top; | ||
| 463 | - tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); | ||
| 464 | - }, function(){ //下 | ||
| 465 | - goal.autoLeft(); | ||
| 466 | - goal.tipTop = goal.top + goal.height + 10; | ||
| 467 | - tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]); | ||
| 468 | - }, function(){ //左 | ||
| 469 | - goal.tipLeft = goal.left - layArea[0] - 10; | ||
| 470 | - goal.tipTop = goal.top; | ||
| 471 | - tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); | ||
| 472 | - }]; | ||
| 473 | - goal.where[guide-1](); | ||
| 474 | - | ||
| 475 | - /* 8*2为小三角形占据的空间 */ | ||
| 476 | - if(guide === 1){ | ||
| 477 | - goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); | ||
| 478 | - } else if(guide === 2){ | ||
| 479 | - win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]() | ||
| 480 | - } else if(guide === 3){ | ||
| 481 | - (goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0](); | ||
| 482 | - } else if(guide === 4){ | ||
| 483 | - layArea[0] + 8*2 - goal.left > 0 && goal.where[1]() | ||
| 484 | - } | ||
| 485 | 454 | ||
| 486 | - layero.find('.'+doms[5]).css({ | ||
| 487 | - 'background-color': config.tips[1], | ||
| 488 | - 'padding-right': (config.closeBtn ? '30px' : '') | ||
| 489 | - }); | ||
| 490 | - layero.css({ | ||
| 491 | - left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), | ||
| 492 | - top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) | ||
| 493 | - }); | ||
| 494 | -} | 455 | + //辨别tips的方位 |
| 456 | + goal.where = [function(){ //上 | ||
| 457 | + goal.autoLeft(); | ||
| 458 | + goal.tipTop = goal.top - layArea[1] - 10; | ||
| 459 | + tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]); | ||
| 460 | + }, function(){ //右 | ||
| 461 | + goal.tipLeft = goal.left + goal.width + 10; | ||
| 462 | + goal.tipTop = goal.top; | ||
| 463 | + tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]); | ||
| 464 | + }, function(){ //下 | ||
| 465 | + goal.autoLeft(); | ||
| 466 | + goal.tipTop = goal.top + goal.height + 10; | ||
| 467 | + tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]); | ||
| 468 | + }, function(){ //左 | ||
| 469 | + goal.tipLeft = goal.left - layArea[0] - 10; | ||
| 470 | + goal.tipTop = goal.top; | ||
| 471 | + tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]); | ||
| 472 | + }]; | ||
| 473 | + goal.where[guide-1](); | ||
| 495 | 474 | ||
| 496 | -//拖拽层 | ||
| 497 | -Class.pt.move = function(){ | ||
| 498 | - var that = this | ||
| 499 | - ,config = that.config | ||
| 500 | - ,_DOC = $(document) | ||
| 501 | - ,layero = that.layero | ||
| 502 | - ,moveElem = layero.find(config.move) | ||
| 503 | - ,resizeElem = layero.find('.layui-layer-resize') | ||
| 504 | - ,dict = {}; | ||
| 505 | - | ||
| 506 | - if(config.move){ | ||
| 507 | - moveElem.css('cursor', 'move'); | 475 | + /* 8*2为小三角形占据的空间 */ |
| 476 | + if(guide === 1){ | ||
| 477 | + goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2](); | ||
| 478 | + } else if(guide === 2){ | ||
| 479 | + win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]() | ||
| 480 | + } else if(guide === 3){ | ||
| 481 | + (goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0](); | ||
| 482 | + } else if(guide === 4){ | ||
| 483 | + layArea[0] + 8*2 - goal.left > 0 && goal.where[1]() | ||
| 484 | + } | ||
| 485 | + | ||
| 486 | + layero.find('.'+doms[5]).css({ | ||
| 487 | + 'background-color': config.tips[1], | ||
| 488 | + 'padding-right': (config.closeBtn ? '30px' : '') | ||
| 489 | + }); | ||
| 490 | + layero.css({ | ||
| 491 | + left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0), | ||
| 492 | + top: goal.tipTop - (config.fixed ? win.scrollTop() : 0) | ||
| 493 | + }); | ||
| 508 | } | 494 | } |
| 509 | 495 | ||
| 510 | - moveElem.on('mousedown', function(e){ | ||
| 511 | - e.preventDefault(); | 496 | +//拖拽层 |
| 497 | + Class.pt.move = function(){ | ||
| 498 | + var that = this | ||
| 499 | + ,config = that.config | ||
| 500 | + ,_DOC = $(document) | ||
| 501 | + ,layero = that.layero | ||
| 502 | + ,moveElem = layero.find(config.move) | ||
| 503 | + ,resizeElem = layero.find('.layui-layer-resize') | ||
| 504 | + ,dict = {}; | ||
| 505 | + | ||
| 512 | if(config.move){ | 506 | if(config.move){ |
| 513 | - dict.moveStart = true; | ||
| 514 | - dict.offset = [ | ||
| 515 | - e.clientX - parseFloat(layero.css('left')) | ||
| 516 | - ,e.clientY - parseFloat(layero.css('top')) | ||
| 517 | - ]; | ||
| 518 | - ready.moveElem.css('cursor', 'move').show(); | 507 | + moveElem.css('cursor', 'move'); |
| 519 | } | 508 | } |
| 520 | - }); | ||
| 521 | - | ||
| 522 | - resizeElem.on('mousedown', function(e){ | ||
| 523 | - e.preventDefault(); | ||
| 524 | - dict.resizeStart = true; | ||
| 525 | - dict.offset = [e.clientX, e.clientY]; | ||
| 526 | - dict.area = [ | ||
| 527 | - layero.outerWidth() | ||
| 528 | - ,layero.outerHeight() | ||
| 529 | - ]; | ||
| 530 | - ready.moveElem.css('cursor', 'se-resize').show(); | ||
| 531 | - }); | ||
| 532 | - | ||
| 533 | - _DOC.on('mousemove', function(e){ | ||
| 534 | - | ||
| 535 | - //拖拽移动 | ||
| 536 | - if(dict.moveStart){ | ||
| 537 | - var X = e.clientX - dict.offset[0] | ||
| 538 | - ,Y = e.clientY - dict.offset[1] | ||
| 539 | - ,fixed = layero.css('position') === 'fixed'; | ||
| 540 | - | 509 | + |
| 510 | + moveElem.on('mousedown', function(e){ | ||
| 541 | e.preventDefault(); | 511 | e.preventDefault(); |
| 542 | - | ||
| 543 | - dict.stX = fixed ? 0 : win.scrollLeft(); | ||
| 544 | - dict.stY = fixed ? 0 : win.scrollTop(); | ||
| 545 | - | ||
| 546 | - //控制元素不被拖出窗口外 | ||
| 547 | - if(!config.moveOut){ | ||
| 548 | - var setRig = win.width() - layero.outerWidth() + dict.stX | ||
| 549 | - ,setBot = win.height() - layero.outerHeight() + dict.stY; | ||
| 550 | - X < dict.stX && (X = dict.stX); | ||
| 551 | - X > setRig && (X = setRig); | ||
| 552 | - Y < dict.stY && (Y = dict.stY); | ||
| 553 | - Y > setBot && (Y = setBot); | 512 | + if(config.move){ |
| 513 | + dict.moveStart = true; | ||
| 514 | + dict.offset = [ | ||
| 515 | + e.clientX - parseFloat(layero.css('left')) | ||
| 516 | + ,e.clientY - parseFloat(layero.css('top')) | ||
| 517 | + ]; | ||
| 518 | + ready.moveElem.css('cursor', 'move').show(); | ||
| 554 | } | 519 | } |
| 555 | - | ||
| 556 | - layero.css({ | ||
| 557 | - left: X | ||
| 558 | - ,top: Y | ||
| 559 | - }); | ||
| 560 | - } | ||
| 561 | - | ||
| 562 | - //Resize | ||
| 563 | - if(config.resize && dict.resizeStart){ | ||
| 564 | - var X = e.clientX - dict.offset[0] | ||
| 565 | - ,Y = e.clientY - dict.offset[1]; | ||
| 566 | - | 520 | + }); |
| 521 | + | ||
| 522 | + resizeElem.on('mousedown', function(e){ | ||
| 567 | e.preventDefault(); | 523 | e.preventDefault(); |
| 568 | - | ||
| 569 | - layer.style(that.index, { | ||
| 570 | - width: dict.area[0] + X | ||
| 571 | - ,height: dict.area[1] + Y | ||
| 572 | - }) | ||
| 573 | - dict.isResize = true; | ||
| 574 | - config.resizing && config.resizing(layero); | ||
| 575 | - } | ||
| 576 | - }).on('mouseup', function(e){ | ||
| 577 | - if(dict.moveStart){ | ||
| 578 | - delete dict.moveStart; | ||
| 579 | - ready.moveElem.hide(); | ||
| 580 | - config.moveEnd && config.moveEnd(layero); | ||
| 581 | - } | ||
| 582 | - if(dict.resizeStart){ | ||
| 583 | - delete dict.resizeStart; | ||
| 584 | - ready.moveElem.hide(); | ||
| 585 | - } | ||
| 586 | - }); | ||
| 587 | - | ||
| 588 | - return that; | ||
| 589 | -}; | ||
| 590 | - | ||
| 591 | -Class.pt.callback = function(){ | ||
| 592 | - var that = this, layero = that.layero, config = that.config; | ||
| 593 | - that.openLayer(); | ||
| 594 | - if(config.success){ | ||
| 595 | - if(config.type == 2){ | ||
| 596 | - layero.find('iframe').on('load', function(){ | 524 | + dict.resizeStart = true; |
| 525 | + dict.offset = [e.clientX, e.clientY]; | ||
| 526 | + dict.area = [ | ||
| 527 | + layero.outerWidth() | ||
| 528 | + ,layero.outerHeight() | ||
| 529 | + ]; | ||
| 530 | + ready.moveElem.css('cursor', 'se-resize').show(); | ||
| 531 | + }); | ||
| 532 | + | ||
| 533 | + _DOC.on('mousemove', function(e){ | ||
| 534 | + | ||
| 535 | + //拖拽移动 | ||
| 536 | + if(dict.moveStart){ | ||
| 537 | + var X = e.clientX - dict.offset[0] | ||
| 538 | + ,Y = e.clientY - dict.offset[1] | ||
| 539 | + ,fixed = layero.css('position') === 'fixed'; | ||
| 540 | + | ||
| 541 | + e.preventDefault(); | ||
| 542 | + | ||
| 543 | + dict.stX = fixed ? 0 : win.scrollLeft(); | ||
| 544 | + dict.stY = fixed ? 0 : win.scrollTop(); | ||
| 545 | + | ||
| 546 | + //控制元素不被拖出窗口外 | ||
| 547 | + if(!config.moveOut){ | ||
| 548 | + var setRig = win.width() - layero.outerWidth() + dict.stX | ||
| 549 | + ,setBot = win.height() - layero.outerHeight() + dict.stY; | ||
| 550 | + X < dict.stX && (X = dict.stX); | ||
| 551 | + X > setRig && (X = setRig); | ||
| 552 | + Y < dict.stY && (Y = dict.stY); | ||
| 553 | + Y > setBot && (Y = setBot); | ||
| 554 | + } | ||
| 555 | + | ||
| 556 | + layero.css({ | ||
| 557 | + left: X | ||
| 558 | + ,top: Y | ||
| 559 | + }); | ||
| 560 | + } | ||
| 561 | + | ||
| 562 | + //Resize | ||
| 563 | + if(config.resize && dict.resizeStart){ | ||
| 564 | + var X = e.clientX - dict.offset[0] | ||
| 565 | + ,Y = e.clientY - dict.offset[1]; | ||
| 566 | + | ||
| 567 | + e.preventDefault(); | ||
| 568 | + | ||
| 569 | + layer.style(that.index, { | ||
| 570 | + width: dict.area[0] + X | ||
| 571 | + ,height: dict.area[1] + Y | ||
| 572 | + }) | ||
| 573 | + dict.isResize = true; | ||
| 574 | + config.resizing && config.resizing(layero); | ||
| 575 | + } | ||
| 576 | + }).on('mouseup', function(e){ | ||
| 577 | + if(dict.moveStart){ | ||
| 578 | + delete dict.moveStart; | ||
| 579 | + ready.moveElem.hide(); | ||
| 580 | + config.moveEnd && config.moveEnd(layero); | ||
| 581 | + } | ||
| 582 | + if(dict.resizeStart){ | ||
| 583 | + delete dict.resizeStart; | ||
| 584 | + ready.moveElem.hide(); | ||
| 585 | + } | ||
| 586 | + }); | ||
| 587 | + | ||
| 588 | + return that; | ||
| 589 | + }; | ||
| 590 | + | ||
| 591 | + Class.pt.callback = function(){ | ||
| 592 | + var that = this, layero = that.layero, config = that.config; | ||
| 593 | + that.openLayer(); | ||
| 594 | + if(config.success){ | ||
| 595 | + if(config.type == 2){ | ||
| 596 | + layero.find('iframe').on('load', function(){ | ||
| 597 | + config.success(layero, that.index); | ||
| 598 | + }); | ||
| 599 | + } else { | ||
| 597 | config.success(layero, that.index); | 600 | config.success(layero, that.index); |
| 598 | - }); | ||
| 599 | - } else { | ||
| 600 | - config.success(layero, that.index); | 601 | + } |
| 601 | } | 602 | } |
| 602 | - } | ||
| 603 | - layer.ie == 6 && that.IE6(layero); | ||
| 604 | - | ||
| 605 | - //按钮 | ||
| 606 | - layero.find('.'+ doms[6]).children('a').on('click', function(){ | ||
| 607 | - var index = $(this).index(); | ||
| 608 | - if(index === 0){ | ||
| 609 | - if(config.yes){ | ||
| 610 | - config.yes(that.index, layero) | ||
| 611 | - } else if(config['btn1']){ | ||
| 612 | - config['btn1'](that.index, layero) | 603 | + layer.ie == 6 && that.IE6(layero); |
| 604 | + | ||
| 605 | + //按钮 | ||
| 606 | + layero.find('.'+ doms[6]).children('a').on('click', function(){ | ||
| 607 | + var index = $(this).index(); | ||
| 608 | + if(index === 0){ | ||
| 609 | + if(config.yes){ | ||
| 610 | + config.yes(that.index, layero) | ||
| 611 | + } else if(config['btn1']){ | ||
| 612 | + config['btn1'](that.index, layero) | ||
| 613 | + } else { | ||
| 614 | + layer.close(that.index); | ||
| 615 | + } | ||
| 613 | } else { | 616 | } else { |
| 614 | - layer.close(that.index); | 617 | + var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero); |
| 618 | + close === false || layer.close(that.index); | ||
| 615 | } | 619 | } |
| 616 | - } else { | ||
| 617 | - var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero); | 620 | + }); |
| 621 | + | ||
| 622 | + //取消 | ||
| 623 | + function cancel(){ | ||
| 624 | + var close = config.cancel && config.cancel(that.index, layero); | ||
| 618 | close === false || layer.close(that.index); | 625 | close === false || layer.close(that.index); |
| 619 | } | 626 | } |
| 620 | - }); | ||
| 621 | - | ||
| 622 | - //取消 | ||
| 623 | - function cancel(){ | ||
| 624 | - var close = config.cancel && config.cancel(that.index, layero); | ||
| 625 | - close === false || layer.close(that.index); | ||
| 626 | - } | ||
| 627 | - | ||
| 628 | - //右上角关闭回调 | ||
| 629 | - layero.find('.'+ doms[7]).on('click', cancel); | ||
| 630 | - | ||
| 631 | - //点遮罩关闭 | ||
| 632 | - if(config.shadeClose){ | ||
| 633 | - $('#layui-layer-shade'+ that.index).on('click', function(){ | ||
| 634 | - layer.close(that.index); | ||
| 635 | - }); | ||
| 636 | - } | ||
| 637 | - | ||
| 638 | - //最小化 | ||
| 639 | - layero.find('.layui-layer-min').on('click', function(){ | ||
| 640 | - var min = config.min && config.min(layero); | ||
| 641 | - min === false || layer.min(that.index, config); | ||
| 642 | - }); | ||
| 643 | - | ||
| 644 | - //全屏/还原 | ||
| 645 | - layero.find('.layui-layer-max').on('click', function(){ | ||
| 646 | - if($(this).hasClass('layui-layer-maxmin')){ | ||
| 647 | - layer.restore(that.index); | ||
| 648 | - config.restore && config.restore(layero); | ||
| 649 | - } else { | ||
| 650 | - layer.full(that.index, config); | ||
| 651 | - setTimeout(function(){ | ||
| 652 | - config.full && config.full(layero); | ||
| 653 | - }, 100); | 627 | + |
| 628 | + //右上角关闭回调 | ||
| 629 | + layero.find('.'+ doms[7]).on('click', cancel); | ||
| 630 | + | ||
| 631 | + //点遮罩关闭 | ||
| 632 | + if(config.shadeClose){ | ||
| 633 | + $('#layui-layer-shade'+ that.index).on('click', function(){ | ||
| 634 | + layer.close(that.index); | ||
| 635 | + }); | ||
| 654 | } | 636 | } |
| 655 | - }); | ||
| 656 | 637 | ||
| 657 | - config.end && (ready.end[that.index] = config.end); | ||
| 658 | -}; | 638 | + //最小化 |
| 639 | + layero.find('.layui-layer-min').on('click', function(){ | ||
| 640 | + var min = config.min && config.min(layero); | ||
| 641 | + min === false || layer.min(that.index, config); | ||
| 642 | + }); | ||
| 643 | + | ||
| 644 | + //全屏/还原 | ||
| 645 | + layero.find('.layui-layer-max').on('click', function(){ | ||
| 646 | + if($(this).hasClass('layui-layer-maxmin')){ | ||
| 647 | + layer.restore(that.index); | ||
| 648 | + config.restore && config.restore(layero); | ||
| 649 | + } else { | ||
| 650 | + layer.full(that.index, config); | ||
| 651 | + setTimeout(function(){ | ||
| 652 | + config.full && config.full(layero); | ||
| 653 | + }, 100); | ||
| 654 | + } | ||
| 655 | + }); | ||
| 656 | + | ||
| 657 | + config.end && (ready.end[that.index] = config.end); | ||
| 658 | + }; | ||
| 659 | 659 | ||
| 660 | //for ie6 恢复select | 660 | //for ie6 恢复select |
| 661 | -ready.reselect = function(){ | ||
| 662 | - $.each($('select'), function(index , value){ | ||
| 663 | - var sthis = $(this); | ||
| 664 | - if(!sthis.parents('.'+doms[0])[0]){ | ||
| 665 | - (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); | ||
| 666 | - } | ||
| 667 | - sthis = null; | ||
| 668 | - }); | ||
| 669 | -}; | ||
| 670 | - | ||
| 671 | -Class.pt.IE6 = function(layero){ | ||
| 672 | - //隐藏select | ||
| 673 | - $('select').each(function(index , value){ | ||
| 674 | - var sthis = $(this); | ||
| 675 | - if(!sthis.parents('.'+doms[0])[0]){ | ||
| 676 | - sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide(); | ||
| 677 | - } | ||
| 678 | - sthis = null; | ||
| 679 | - }); | ||
| 680 | -}; | 661 | + ready.reselect = function(){ |
| 662 | + $.each($('select'), function(index , value){ | ||
| 663 | + var sthis = $(this); | ||
| 664 | + if(!sthis.parents('.'+doms[0])[0]){ | ||
| 665 | + (sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show(); | ||
| 666 | + } | ||
| 667 | + sthis = null; | ||
| 668 | + }); | ||
| 669 | + }; | ||
| 670 | + | ||
| 671 | + Class.pt.IE6 = function(layero){ | ||
| 672 | + //隐藏select | ||
| 673 | + $('select').each(function(index , value){ | ||
| 674 | + var sthis = $(this); | ||
| 675 | + if(!sthis.parents('.'+doms[0])[0]){ | ||
| 676 | + sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide(); | ||
| 677 | + } | ||
| 678 | + sthis = null; | ||
| 679 | + }); | ||
| 680 | + }; | ||
| 681 | 681 | ||
| 682 | //需依赖原型的对外方法 | 682 | //需依赖原型的对外方法 |
| 683 | -Class.pt.openLayer = function(){ | ||
| 684 | - var that = this; | ||
| 685 | - | ||
| 686 | - //置顶当前窗口 | ||
| 687 | - layer.zIndex = that.config.zIndex; | ||
| 688 | - layer.setTop = function(layero){ | ||
| 689 | - var setZindex = function(){ | ||
| 690 | - layer.zIndex++; | ||
| 691 | - layero.css('z-index', layer.zIndex + 1); | 683 | + Class.pt.openLayer = function(){ |
| 684 | + var that = this; | ||
| 685 | + | ||
| 686 | + //置顶当前窗口 | ||
| 687 | + layer.zIndex = that.config.zIndex; | ||
| 688 | + layer.setTop = function(layero){ | ||
| 689 | + var setZindex = function(){ | ||
| 690 | + layer.zIndex++; | ||
| 691 | + layero.css('z-index', layer.zIndex + 1); | ||
| 692 | + }; | ||
| 693 | + layer.zIndex = parseInt(layero[0].style.zIndex); | ||
| 694 | + layero.on('mousedown', setZindex); | ||
| 695 | + return layer.zIndex; | ||
| 692 | }; | 696 | }; |
| 693 | - layer.zIndex = parseInt(layero[0].style.zIndex); | ||
| 694 | - layero.on('mousedown', setZindex); | ||
| 695 | - return layer.zIndex; | ||
| 696 | }; | 697 | }; |
| 697 | -}; | ||
| 698 | - | ||
| 699 | -ready.record = function(layero){ | ||
| 700 | - var area = [ | ||
| 701 | - layero.width(), | ||
| 702 | - layero.height(), | ||
| 703 | - layero.position().top, | ||
| 704 | - layero.position().left + parseFloat(layero.css('margin-left')) | ||
| 705 | - ]; | ||
| 706 | - layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); | ||
| 707 | - layero.attr({area: area}); | ||
| 708 | -}; | ||
| 709 | - | ||
| 710 | -ready.rescollbar = function(index){ | ||
| 711 | - if(doms.html.attr('layer-full') == index){ | ||
| 712 | - if(doms.html[0].style.removeProperty){ | ||
| 713 | - doms.html[0].style.removeProperty('overflow'); | ||
| 714 | - } else { | ||
| 715 | - doms.html[0].style.removeAttribute('overflow'); | 698 | + |
| 699 | + ready.record = function(layero){ | ||
| 700 | + var area = [ | ||
| 701 | + layero.width(), | ||
| 702 | + layero.height(), | ||
| 703 | + layero.position().top, | ||
| 704 | + layero.position().left + parseFloat(layero.css('margin-left')) | ||
| 705 | + ]; | ||
| 706 | + layero.find('.layui-layer-max').addClass('layui-layer-maxmin'); | ||
| 707 | + layero.attr({area: area}); | ||
| 708 | + }; | ||
| 709 | + | ||
| 710 | + ready.rescollbar = function(index){ | ||
| 711 | + if(doms.html.attr('layer-full') == index){ | ||
| 712 | + if(doms.html[0].style.removeProperty){ | ||
| 713 | + doms.html[0].style.removeProperty('overflow'); | ||
| 714 | + } else { | ||
| 715 | + doms.html[0].style.removeAttribute('overflow'); | ||
| 716 | + } | ||
| 717 | + doms.html.removeAttr('layer-full'); | ||
| 716 | } | 718 | } |
| 717 | - doms.html.removeAttr('layer-full'); | ||
| 718 | - } | ||
| 719 | -}; | 719 | + }; |
| 720 | 720 | ||
| 721 | -/** 内置成员 */ | 721 | + /** 内置成员 */ |
| 722 | 722 | ||
| 723 | -window.layer = layer; | 723 | + window.layer = layer; |
| 724 | 724 | ||
| 725 | //获取子iframe的DOM | 725 | //获取子iframe的DOM |
| 726 | -layer.getChildFrame = function(selector, index){ | ||
| 727 | - index = index || $('.'+doms[4]).attr('times'); | ||
| 728 | - return $('#'+ doms[0] + index).find('iframe').contents().find(selector); | ||
| 729 | -}; | 726 | + layer.getChildFrame = function(selector, index){ |
| 727 | + index = index || $('.'+doms[4]).attr('times'); | ||
| 728 | + return $('#'+ doms[0] + index).find('iframe').contents().find(selector); | ||
| 729 | + }; | ||
| 730 | 730 | ||
| 731 | //得到当前iframe层的索引,子iframe时使用 | 731 | //得到当前iframe层的索引,子iframe时使用 |
| 732 | -layer.getFrameIndex = function(name){ | ||
| 733 | - return $('#'+ name).parents('.'+doms[4]).attr('times'); | ||
| 734 | -}; | 732 | + layer.getFrameIndex = function(name){ |
| 733 | + return $('#'+ name).parents('.'+doms[4]).attr('times'); | ||
| 734 | + }; | ||
| 735 | 735 | ||
| 736 | //iframe层自适应宽高 | 736 | //iframe层自适应宽高 |
| 737 | -layer.iframeAuto = function(index){ | ||
| 738 | - if(!index) return; | ||
| 739 | - var heg = layer.getChildFrame('html', index).outerHeight(); | ||
| 740 | - var layero = $('#'+ doms[0] + index); | ||
| 741 | - var titHeight = layero.find(doms[1]).outerHeight() || 0; | ||
| 742 | - var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; | ||
| 743 | - layero.css({height: heg + titHeight + btnHeight}); | ||
| 744 | - layero.find('iframe').css({height: heg}); | ||
| 745 | -}; | 737 | + layer.iframeAuto = function(index){ |
| 738 | + if(!index) return; | ||
| 739 | + var heg = layer.getChildFrame('html', index).outerHeight(); | ||
| 740 | + var layero = $('#'+ doms[0] + index); | ||
| 741 | + var titHeight = layero.find(doms[1]).outerHeight() || 0; | ||
| 742 | + var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0; | ||
| 743 | + layero.css({height: heg + titHeight + btnHeight}); | ||
| 744 | + layero.find('iframe').css({height: heg}); | ||
| 745 | + }; | ||
| 746 | 746 | ||
| 747 | //重置iframe url | 747 | //重置iframe url |
| 748 | -layer.iframeSrc = function(index, url){ | ||
| 749 | - $('#'+ doms[0] + index).find('iframe').attr('src', url); | ||
| 750 | -}; | 748 | + layer.iframeSrc = function(index, url){ |
| 749 | + $('#'+ doms[0] + index).find('iframe').attr('src', url); | ||
| 750 | + }; | ||
| 751 | 751 | ||
| 752 | //设定层的样式 | 752 | //设定层的样式 |
| 753 | -layer.style = function(index, options, limit){ | ||
| 754 | - var layero = $('#'+ doms[0] + index) | ||
| 755 | - ,contElem = layero.find('.layui-layer-content') | ||
| 756 | - ,type = layero.attr('type') | ||
| 757 | - ,titHeight = layero.find(doms[1]).outerHeight() || 0 | ||
| 758 | - ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 | ||
| 759 | - ,minLeft = layero.attr('minLeft'); | ||
| 760 | - | ||
| 761 | - if(type === ready.type[3] || type === ready.type[4]){ | ||
| 762 | - return; | ||
| 763 | - } | ||
| 764 | - | ||
| 765 | - if(!limit){ | ||
| 766 | - if(parseFloat(options.width) <= 260){ | ||
| 767 | - options.width = 260; | ||
| 768 | - }; | ||
| 769 | - | ||
| 770 | - if(parseFloat(options.height) - titHeight - btnHeight <= 64){ | ||
| 771 | - options.height = 64 + titHeight + btnHeight; | ||
| 772 | - }; | ||
| 773 | - } | ||
| 774 | - | ||
| 775 | - layero.css(options); | ||
| 776 | - btnHeight = layero.find('.'+doms[6]).outerHeight(); | ||
| 777 | - | ||
| 778 | - if(type === ready.type[2]){ | ||
| 779 | - layero.find('iframe').css({ | ||
| 780 | - height: parseFloat(options.height) - titHeight - btnHeight | ||
| 781 | - }); | ||
| 782 | - } else { | ||
| 783 | - contElem.css({ | ||
| 784 | - height: parseFloat(options.height) - titHeight - btnHeight | ||
| 785 | - - parseFloat(contElem.css('padding-top')) | ||
| 786 | - - parseFloat(contElem.css('padding-bottom')) | ||
| 787 | - }) | ||
| 788 | - } | ||
| 789 | -}; | 753 | + layer.style = function(index, options, limit){ |
| 754 | + var layero = $('#'+ doms[0] + index) | ||
| 755 | + ,contElem = layero.find('.layui-layer-content') | ||
| 756 | + ,type = layero.attr('type') | ||
| 757 | + ,titHeight = layero.find(doms[1]).outerHeight() || 0 | ||
| 758 | + ,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0 | ||
| 759 | + ,minLeft = layero.attr('minLeft'); | ||
| 760 | + | ||
| 761 | + if(type === ready.type[3] || type === ready.type[4]){ | ||
| 762 | + return; | ||
| 763 | + } | ||
| 764 | + | ||
| 765 | + if(!limit){ | ||
| 766 | + if(parseFloat(options.width) <= 260){ | ||
| 767 | + options.width = 260; | ||
| 768 | + }; | ||
| 769 | + | ||
| 770 | + if(parseFloat(options.height) - titHeight - btnHeight <= 64){ | ||
| 771 | + options.height = 64 + titHeight + btnHeight; | ||
| 772 | + }; | ||
| 773 | + } | ||
| 774 | + | ||
| 775 | + layero.css(options); | ||
| 776 | + btnHeight = layero.find('.'+doms[6]).outerHeight(); | ||
| 777 | + | ||
| 778 | + if(type === ready.type[2]){ | ||
| 779 | + layero.find('iframe').css({ | ||
| 780 | + height: parseFloat(options.height) - titHeight - btnHeight | ||
| 781 | + }); | ||
| 782 | + } else { | ||
| 783 | + contElem.css({ | ||
| 784 | + height: parseFloat(options.height) - titHeight - btnHeight | ||
| 785 | + - parseFloat(contElem.css('padding-top')) | ||
| 786 | + - parseFloat(contElem.css('padding-bottom')) | ||
| 787 | + }) | ||
| 788 | + } | ||
| 789 | + }; | ||
| 790 | 790 | ||
| 791 | //最小化 | 791 | //最小化 |
| 792 | -layer.min = function(index, options){ | ||
| 793 | - var layero = $('#'+ doms[0] + index) | ||
| 794 | - ,titHeight = layero.find(doms[1]).outerHeight() || 0 | ||
| 795 | - ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' | ||
| 796 | - ,position = layero.css('position'); | ||
| 797 | - | ||
| 798 | - ready.record(layero); | ||
| 799 | - | ||
| 800 | - if(ready.minLeft[0]){ | ||
| 801 | - left = ready.minLeft[0]; | ||
| 802 | - ready.minLeft.shift(); | ||
| 803 | - } | ||
| 804 | - | ||
| 805 | - layero.attr('position', position); | ||
| 806 | - | ||
| 807 | - layer.style(index, { | ||
| 808 | - width: 180 | ||
| 809 | - ,height: titHeight | ||
| 810 | - ,left: left | ||
| 811 | - ,top: win.height() - titHeight | ||
| 812 | - ,position: 'fixed' | ||
| 813 | - ,overflow: 'hidden' | ||
| 814 | - }, true); | ||
| 815 | - | ||
| 816 | - layero.find('.layui-layer-min').hide(); | ||
| 817 | - layero.attr('type') === 'page' && layero.find(doms[4]).hide(); | ||
| 818 | - ready.rescollbar(index); | ||
| 819 | - | ||
| 820 | - if(!layero.attr('minLeft')){ | ||
| 821 | - ready.minIndex++; | ||
| 822 | - } | ||
| 823 | - layero.attr('minLeft', left); | ||
| 824 | -}; | 792 | + layer.min = function(index, options){ |
| 793 | + var layero = $('#'+ doms[0] + index) | ||
| 794 | + ,titHeight = layero.find(doms[1]).outerHeight() || 0 | ||
| 795 | + ,left = layero.attr('minLeft') || (181*ready.minIndex)+'px' | ||
| 796 | + ,position = layero.css('position'); | ||
| 825 | 797 | ||
| 826 | -//还原 | ||
| 827 | -layer.restore = function(index){ | ||
| 828 | - var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); | ||
| 829 | - var type = layero.attr('type'); | ||
| 830 | - layer.style(index, { | ||
| 831 | - width: parseFloat(area[0]), | ||
| 832 | - height: parseFloat(area[1]), | ||
| 833 | - top: parseFloat(area[2]), | ||
| 834 | - left: parseFloat(area[3]), | ||
| 835 | - position: layero.attr('position'), | ||
| 836 | - overflow: 'visible' | ||
| 837 | - }, true); | ||
| 838 | - layero.find('.layui-layer-max').removeClass('layui-layer-maxmin'); | ||
| 839 | - layero.find('.layui-layer-min').show(); | ||
| 840 | - layero.attr('type') === 'page' && layero.find(doms[4]).show(); | ||
| 841 | - ready.rescollbar(index); | ||
| 842 | -}; | 798 | + ready.record(layero); |
| 799 | + | ||
| 800 | + if(ready.minLeft[0]){ | ||
| 801 | + left = ready.minLeft[0]; | ||
| 802 | + ready.minLeft.shift(); | ||
| 803 | + } | ||
| 804 | + | ||
| 805 | + layero.attr('position', position); | ||
| 843 | 806 | ||
| 844 | -//全屏 | ||
| 845 | -layer.full = function(index){ | ||
| 846 | - var layero = $('#'+ doms[0] + index), timer; | ||
| 847 | - ready.record(layero); | ||
| 848 | - if(!doms.html.attr('layer-full')){ | ||
| 849 | - doms.html.css('overflow','hidden').attr('layer-full', index); | ||
| 850 | - } | ||
| 851 | - clearTimeout(timer); | ||
| 852 | - timer = setTimeout(function(){ | ||
| 853 | - var isfix = layero.css('position') === 'fixed'; | ||
| 854 | layer.style(index, { | 807 | layer.style(index, { |
| 855 | - top: isfix ? 0 : win.scrollTop(), | ||
| 856 | - left: isfix ? 0 : win.scrollLeft(), | ||
| 857 | - width: win.width(), | ||
| 858 | - height: win.height() | 808 | + width: 180 |
| 809 | + ,height: titHeight | ||
| 810 | + ,left: left | ||
| 811 | + ,top: win.height() - titHeight | ||
| 812 | + ,position: 'fixed' | ||
| 813 | + ,overflow: 'hidden' | ||
| 859 | }, true); | 814 | }, true); |
| 815 | + | ||
| 860 | layero.find('.layui-layer-min').hide(); | 816 | layero.find('.layui-layer-min').hide(); |
| 861 | - }, 100); | ||
| 862 | -}; | 817 | + layero.attr('type') === 'page' && layero.find(doms[4]).hide(); |
| 818 | + ready.rescollbar(index); | ||
| 819 | + | ||
| 820 | + if(!layero.attr('minLeft')){ | ||
| 821 | + ready.minIndex++; | ||
| 822 | + } | ||
| 823 | + layero.attr('minLeft', left); | ||
| 824 | + }; | ||
| 825 | + | ||
| 826 | +//还原 | ||
| 827 | + layer.restore = function(index){ | ||
| 828 | + var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(','); | ||
| 829 | + var type = layero.attr('type'); | ||
| 830 | + layer.style(index, { | ||
| 831 | + width: parseFloat(area[0]), | ||
| 832 | + height: parseFloat(area[1]), | ||
| 833 | + top: parseFloat(area[2]), | ||
| 834 | + left: parseFloat(area[3]), | ||
| 835 | + position: layero.attr('position'), | ||
| 836 | + overflow: 'visible' | ||
| 837 | + }, true); | ||
| 838 | + layero.find('.layui-layer-max').removeClass('layui-layer-maxmin'); | ||
| 839 | + layero.find('.layui-layer-min').show(); | ||
| 840 | + layero.attr('type') === 'page' && layero.find(doms[4]).show(); | ||
| 841 | + ready.rescollbar(index); | ||
| 842 | + }; | ||
| 843 | + | ||
| 844 | +//全屏 | ||
| 845 | + layer.full = function(index){ | ||
| 846 | + var layero = $('#'+ doms[0] + index), timer; | ||
| 847 | + ready.record(layero); | ||
| 848 | + if(!doms.html.attr('layer-full')){ | ||
| 849 | + doms.html.css('overflow','hidden').attr('layer-full', index); | ||
| 850 | + } | ||
| 851 | + clearTimeout(timer); | ||
| 852 | + timer = setTimeout(function(){ | ||
| 853 | + var isfix = layero.css('position') === 'fixed'; | ||
| 854 | + layer.style(index, { | ||
| 855 | + top: isfix ? 0 : win.scrollTop(), | ||
| 856 | + left: isfix ? 0 : win.scrollLeft(), | ||
| 857 | + width: win.width(), | ||
| 858 | + height: win.height() | ||
| 859 | + }, true); | ||
| 860 | + layero.find('.layui-layer-min').hide(); | ||
| 861 | + }, 100); | ||
| 862 | + }; | ||
| 863 | 863 | ||
| 864 | //改变title | 864 | //改变title |
| 865 | -layer.title = function(name, index){ | ||
| 866 | - var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]); | ||
| 867 | - title.html(name); | ||
| 868 | -}; | 865 | + layer.title = function(name, index){ |
| 866 | + var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]); | ||
| 867 | + title.html(name); | ||
| 868 | + }; | ||
| 869 | 869 | ||
| 870 | //关闭layer总方法 | 870 | //关闭layer总方法 |
| 871 | -layer.close = function(index){ | ||
| 872 | - var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close'; | ||
| 873 | - if(!layero[0]) return; | ||
| 874 | - var WRAP = 'layui-layer-wrap', remove = function(){ | ||
| 875 | - if(type === ready.type[1] && layero.attr('conType') === 'object'){ | ||
| 876 | - layero.children(':not(.'+ doms[5] +')').remove(); | ||
| 877 | - var wrap = layero.find('.'+WRAP); | ||
| 878 | - for(var i = 0; i < 2; i++){ | ||
| 879 | - wrap.unwrap(); | 871 | + layer.close = function(index){ |
| 872 | + var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close'; | ||
| 873 | + if(!layero[0]) return; | ||
| 874 | + var WRAP = 'layui-layer-wrap', remove = function(){ | ||
| 875 | + if(type === ready.type[1] && layero.attr('conType') === 'object'){ | ||
| 876 | + layero.children(':not(.'+ doms[5] +')').remove(); | ||
| 877 | + var wrap = layero.find('.'+WRAP); | ||
| 878 | + for(var i = 0; i < 2; i++){ | ||
| 879 | + wrap.unwrap(); | ||
| 880 | + } | ||
| 881 | + wrap.css('display', wrap.data('display')).removeClass(WRAP); | ||
| 882 | + } else { | ||
| 883 | + //低版本IE 回收 iframe | ||
| 884 | + if(type === ready.type[2]){ | ||
| 885 | + try { | ||
| 886 | + var iframe = $('#'+doms[4]+index)[0]; | ||
| 887 | + iframe.contentWindow.document.write(''); | ||
| 888 | + iframe.contentWindow.close(); | ||
| 889 | + layero.find('.'+doms[5])[0].removeChild(iframe); | ||
| 890 | + } catch(e){} | ||
| 891 | + } | ||
| 892 | + layero[0].innerHTML = ''; | ||
| 893 | + layero.remove(); | ||
| 880 | } | 894 | } |
| 881 | - wrap.css('display', wrap.data('display')).removeClass(WRAP); | 895 | + typeof ready.end[index] === 'function' && ready.end[index](); |
| 896 | + delete ready.end[index]; | ||
| 897 | + }; | ||
| 898 | + | ||
| 899 | + if(layero.data('isOutAnim')){ | ||
| 900 | + layero.addClass(closeAnim); | ||
| 901 | + } | ||
| 902 | + | ||
| 903 | + $('#layui-layer-moves, #layui-layer-shade' + index).remove(); | ||
| 904 | + layer.ie == 6 && ready.reselect(); | ||
| 905 | + ready.rescollbar(index); | ||
| 906 | + if(layero.attr('minLeft')){ | ||
| 907 | + ready.minIndex--; | ||
| 908 | + ready.minLeft.push(layero.attr('minLeft')); | ||
| 909 | + } | ||
| 910 | + | ||
| 911 | + if((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')){ | ||
| 912 | + remove() | ||
| 882 | } else { | 913 | } else { |
| 883 | - //低版本IE 回收 iframe | ||
| 884 | - if(type === ready.type[2]){ | ||
| 885 | - try { | ||
| 886 | - var iframe = $('#'+doms[4]+index)[0]; | ||
| 887 | - iframe.contentWindow.document.write(''); | ||
| 888 | - iframe.contentWindow.close(); | ||
| 889 | - layero.find('.'+doms[5])[0].removeChild(iframe); | ||
| 890 | - } catch(e){} | ||
| 891 | - } | ||
| 892 | - layero[0].innerHTML = ''; | ||
| 893 | - layero.remove(); | 914 | + setTimeout(function(){ |
| 915 | + remove(); | ||
| 916 | + }, 200); | ||
| 894 | } | 917 | } |
| 895 | - typeof ready.end[index] === 'function' && ready.end[index](); | ||
| 896 | - delete ready.end[index]; | ||
| 897 | }; | 918 | }; |
| 898 | - | ||
| 899 | - if(layero.data('isOutAnim')){ | ||
| 900 | - layero.addClass(closeAnim); | ||
| 901 | - } | ||
| 902 | - | ||
| 903 | - $('#layui-layer-moves, #layui-layer-shade' + index).remove(); | ||
| 904 | - layer.ie == 6 && ready.reselect(); | ||
| 905 | - ready.rescollbar(index); | ||
| 906 | - if(layero.attr('minLeft')){ | ||
| 907 | - ready.minIndex--; | ||
| 908 | - ready.minLeft.push(layero.attr('minLeft')); | ||
| 909 | - } | ||
| 910 | - | ||
| 911 | - if((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')){ | ||
| 912 | - remove() | ||
| 913 | - } else { | ||
| 914 | - setTimeout(function(){ | ||
| 915 | - remove(); | ||
| 916 | - }, 200); | ||
| 917 | - } | ||
| 918 | -}; | ||
| 919 | 919 | ||
| 920 | //关闭所有层 | 920 | //关闭所有层 |
| 921 | -layer.closeAll = function(type){ | ||
| 922 | - $.each($('.'+doms[0]), function(){ | ||
| 923 | - var othis = $(this); | ||
| 924 | - var is = type ? (othis.attr('type') === type) : 1; | ||
| 925 | - is && layer.close(othis.attr('times')); | ||
| 926 | - is = null; | ||
| 927 | - }); | ||
| 928 | -}; | 921 | + layer.closeAll = function(type){ |
| 922 | + $.each($('.'+doms[0]), function(){ | ||
| 923 | + var othis = $(this); | ||
| 924 | + var is = type ? (othis.attr('type') === type) : 1; | ||
| 925 | + is && layer.close(othis.attr('times')); | ||
| 926 | + is = null; | ||
| 927 | + }); | ||
| 928 | + }; | ||
| 929 | 929 | ||
| 930 | -/** | 930 | + /** |
| 931 | 931 | ||
| 932 | - 拓展模块,layui开始合并在一起 | 932 | + 拓展模块,layui开始合并在一起 |
| 933 | 933 | ||
| 934 | - */ | 934 | + */ |
| 935 | + | ||
| 936 | + var cache = layer.cache||{}, skin = function(type){ | ||
| 937 | + return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); | ||
| 938 | + }; | ||
| 935 | 939 | ||
| 936 | -var cache = layer.cache||{}, skin = function(type){ | ||
| 937 | - return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : ''); | ||
| 938 | -}; | ||
| 939 | - | ||
| 940 | //仿系统prompt | 940 | //仿系统prompt |
| 941 | -layer.prompt = function(options, yes){ | ||
| 942 | - var style = ''; | ||
| 943 | - options = options || {}; | ||
| 944 | - | ||
| 945 | - if(typeof options === 'function') yes = options; | ||
| 946 | - | ||
| 947 | - if(options.area){ | ||
| 948 | - var area = options.area; | ||
| 949 | - style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"'; | ||
| 950 | - delete options.area; | ||
| 951 | - } | ||
| 952 | - var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){ | ||
| 953 | - return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">'; | ||
| 954 | - }(); | ||
| 955 | - | ||
| 956 | - var success = options.success; | ||
| 957 | - delete options.success; | ||
| 958 | - | ||
| 959 | - return layer.open($.extend({ | ||
| 960 | - type: 1 | ||
| 961 | - ,btn: ['确定','取消'] | ||
| 962 | - ,content: content | ||
| 963 | - ,skin: 'layui-layer-prompt' + skin('prompt') | ||
| 964 | - ,maxWidth: win.width() | ||
| 965 | - ,success: function(layero){ | ||
| 966 | - prompt = layero.find('.layui-layer-input'); | ||
| 967 | - prompt.focus(); | ||
| 968 | - typeof success === 'function' && success(layero); | 941 | + layer.prompt = function(options, yes){ |
| 942 | + var style = ''; | ||
| 943 | + options = options || {}; | ||
| 944 | + | ||
| 945 | + if(typeof options === 'function') yes = options; | ||
| 946 | + | ||
| 947 | + if(options.area){ | ||
| 948 | + var area = options.area; | ||
| 949 | + style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"'; | ||
| 950 | + delete options.area; | ||
| 969 | } | 951 | } |
| 970 | - ,resize: false | ||
| 971 | - ,yes: function(index){ | ||
| 972 | - var value = prompt.val(); | ||
| 973 | - if(value === ''){ | 952 | + var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){ |
| 953 | + return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">'; | ||
| 954 | + }(); | ||
| 955 | + | ||
| 956 | + var success = options.success; | ||
| 957 | + delete options.success; | ||
| 958 | + | ||
| 959 | + return layer.open($.extend({ | ||
| 960 | + type: 1 | ||
| 961 | + ,btn: ['确定','取消'] | ||
| 962 | + ,content: content | ||
| 963 | + ,skin: 'layui-layer-prompt' + skin('prompt') | ||
| 964 | + ,maxWidth: win.width() | ||
| 965 | + ,success: function(layero){ | ||
| 966 | + prompt = layero.find('.layui-layer-input'); | ||
| 974 | prompt.focus(); | 967 | prompt.focus(); |
| 975 | - } else if(value.length > (options.maxlength||500)) { | ||
| 976 | - layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1}); | ||
| 977 | - } else { | ||
| 978 | - yes && yes(value, index, prompt); | 968 | + typeof success === 'function' && success(layero); |
| 979 | } | 969 | } |
| 980 | - } | ||
| 981 | - }, options)); | ||
| 982 | -}; | 970 | + ,resize: false |
| 971 | + ,yes: function(index){ | ||
| 972 | + var value = prompt.val(); | ||
| 973 | + if(value === ''){ | ||
| 974 | + prompt.focus(); | ||
| 975 | + } else if(value.length > (options.maxlength||500)) { | ||
| 976 | + layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1}); | ||
| 977 | + } else { | ||
| 978 | + yes && yes(value, index, prompt); | ||
| 979 | + } | ||
| 980 | + } | ||
| 981 | + }, options)); | ||
| 982 | + }; | ||
| 983 | 983 | ||
| 984 | //tab层 | 984 | //tab层 |
| 985 | -layer.tab = function(options){ | ||
| 986 | - options = options || {}; | ||
| 987 | - | ||
| 988 | - var tab = options.tab || {} | ||
| 989 | - ,success = options.success; | ||
| 990 | - | ||
| 991 | - delete options.success; | ||
| 992 | - | ||
| 993 | - return layer.open($.extend({ | ||
| 994 | - type: 1, | ||
| 995 | - skin: 'layui-layer-tab' + skin('tab'), | ||
| 996 | - resize: false, | ||
| 997 | - title: function(){ | ||
| 998 | - var len = tab.length, ii = 1, str = ''; | ||
| 999 | - if(len > 0){ | ||
| 1000 | - str = '<span class="layui-layer-tabnow">'+ tab[0].title +'</span>'; | ||
| 1001 | - for(; ii < len; ii++){ | ||
| 1002 | - str += '<span>'+ tab[ii].title +'</span>'; | 985 | + layer.tab = function(options){ |
| 986 | + options = options || {}; | ||
| 987 | + | ||
| 988 | + var tab = options.tab || {} | ||
| 989 | + ,success = options.success; | ||
| 990 | + | ||
| 991 | + delete options.success; | ||
| 992 | + | ||
| 993 | + return layer.open($.extend({ | ||
| 994 | + type: 1, | ||
| 995 | + skin: 'layui-layer-tab' + skin('tab'), | ||
| 996 | + resize: false, | ||
| 997 | + title: function(){ | ||
| 998 | + var len = tab.length, ii = 1, str = ''; | ||
| 999 | + if(len > 0){ | ||
| 1000 | + str = '<span class="layui-layer-tabnow">'+ tab[0].title +'</span>'; | ||
| 1001 | + for(; ii < len; ii++){ | ||
| 1002 | + str += '<span>'+ tab[ii].title +'</span>'; | ||
| 1003 | + } | ||
| 1003 | } | 1004 | } |
| 1004 | - } | ||
| 1005 | - return str; | ||
| 1006 | - }(), | ||
| 1007 | - content: '<ul class="layui-layer-tabmain">'+ function(){ | ||
| 1008 | - var len = tab.length, ii = 1, str = ''; | ||
| 1009 | - if(len > 0){ | ||
| 1010 | - str = '<li class="layui-layer-tabli xubox_tab_layer">'+ (tab[0].content || 'no content') +'</li>'; | ||
| 1011 | - for(; ii < len; ii++){ | ||
| 1012 | - str += '<li class="layui-layer-tabli">'+ (tab[ii].content || 'no content') +'</li>'; | 1005 | + return str; |
| 1006 | + }(), | ||
| 1007 | + content: '<ul class="layui-layer-tabmain">'+ function(){ | ||
| 1008 | + var len = tab.length, ii = 1, str = ''; | ||
| 1009 | + if(len > 0){ | ||
| 1010 | + str = '<li class="layui-layer-tabli xubox_tab_layer">'+ (tab[0].content || 'no content') +'</li>'; | ||
| 1011 | + for(; ii < len; ii++){ | ||
| 1012 | + str += '<li class="layui-layer-tabli">'+ (tab[ii].content || 'no content') +'</li>'; | ||
| 1013 | + } | ||
| 1013 | } | 1014 | } |
| 1015 | + return str; | ||
| 1016 | + }() +'</ul>', | ||
| 1017 | + success: function(layero){ | ||
| 1018 | + var btn = layero.find('.layui-layer-title').children(); | ||
| 1019 | + var main = layero.find('.layui-layer-tabmain').children(); | ||
| 1020 | + btn.on('mousedown', function(e){ | ||
| 1021 | + e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; | ||
| 1022 | + var othis = $(this), index = othis.index(); | ||
| 1023 | + othis.addClass('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow'); | ||
| 1024 | + main.eq(index).show().siblings().hide(); | ||
| 1025 | + typeof options.change === 'function' && options.change(index); | ||
| 1026 | + }); | ||
| 1027 | + typeof success === 'function' && success(layero); | ||
| 1014 | } | 1028 | } |
| 1015 | - return str; | ||
| 1016 | - }() +'</ul>', | ||
| 1017 | - success: function(layero){ | ||
| 1018 | - var btn = layero.find('.layui-layer-title').children(); | ||
| 1019 | - var main = layero.find('.layui-layer-tabmain').children(); | ||
| 1020 | - btn.on('mousedown', function(e){ | ||
| 1021 | - e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; | ||
| 1022 | - var othis = $(this), index = othis.index(); | ||
| 1023 | - othis.addClass('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow'); | ||
| 1024 | - main.eq(index).show().siblings().hide(); | ||
| 1025 | - typeof options.change === 'function' && options.change(index); | ||
| 1026 | - }); | ||
| 1027 | - typeof success === 'function' && success(layero); | ||
| 1028 | - } | ||
| 1029 | - }, options)); | ||
| 1030 | -}; | 1029 | + }, options)); |
| 1030 | + }; | ||
| 1031 | 1031 | ||
| 1032 | //相册层 | 1032 | //相册层 |
| 1033 | -layer.photos = function(options, loop, key){ | ||
| 1034 | - var dict = {}; | ||
| 1035 | - options = options || {}; | ||
| 1036 | - if(!options.photos) return; | ||
| 1037 | - var type = options.photos.constructor === Object; | ||
| 1038 | - var photos = type ? options.photos : {}, data = photos.data || []; | ||
| 1039 | - var start = photos.start || 0; | ||
| 1040 | - dict.imgIndex = (start|0) + 1; | ||
| 1041 | - | ||
| 1042 | - options.img = options.img || 'img'; | ||
| 1043 | - | ||
| 1044 | - var success = options.success; | ||
| 1045 | - delete options.success; | ||
| 1046 | - | ||
| 1047 | - if(!type){ //页面直接获取 | ||
| 1048 | - var parent = $(options.photos), pushData = function(){ | ||
| 1049 | - data = []; | ||
| 1050 | - parent.find(options.img).each(function(index){ | ||
| 1051 | - var othis = $(this); | ||
| 1052 | - othis.attr('layer-index', index); | ||
| 1053 | - data.push({ | ||
| 1054 | - alt: othis.attr('alt'), | ||
| 1055 | - pid: othis.attr('layer-pid'), | ||
| 1056 | - src: othis.attr('layer-src') || othis.attr('src'), | ||
| 1057 | - thumb: othis.attr('src') | ||
| 1058 | - }); | ||
| 1059 | - }) | ||
| 1060 | - }; | ||
| 1061 | - | ||
| 1062 | - pushData(); | ||
| 1063 | - | ||
| 1064 | - if (data.length === 0) return; | ||
| 1065 | - | ||
| 1066 | - loop || parent.on('click', options.img, function(){ | ||
| 1067 | - var othis = $(this), index = othis.attr('layer-index'); | ||
| 1068 | - layer.photos($.extend(options, { | ||
| 1069 | - photos: { | ||
| 1070 | - start: index, | ||
| 1071 | - data: data, | ||
| 1072 | - tab: options.tab | ||
| 1073 | - }, | ||
| 1074 | - full: options.full | ||
| 1075 | - }), true); | 1033 | + layer.photos = function(options, loop, key){ |
| 1034 | + var dict = {}; | ||
| 1035 | + options = options || {}; | ||
| 1036 | + if(!options.photos) return; | ||
| 1037 | + var type = options.photos.constructor === Object; | ||
| 1038 | + var photos = type ? options.photos : {}, data = photos.data || []; | ||
| 1039 | + var start = photos.start || 0; | ||
| 1040 | + dict.imgIndex = (start|0) + 1; | ||
| 1041 | + | ||
| 1042 | + options.img = options.img || 'img'; | ||
| 1043 | + | ||
| 1044 | + var success = options.success; | ||
| 1045 | + delete options.success; | ||
| 1046 | + | ||
| 1047 | + if(!type){ //页面直接获取 | ||
| 1048 | + var parent = $(options.photos), pushData = function(){ | ||
| 1049 | + data = []; | ||
| 1050 | + parent.find(options.img).each(function(index){ | ||
| 1051 | + var othis = $(this); | ||
| 1052 | + othis.attr('layer-index', index); | ||
| 1053 | + data.push({ | ||
| 1054 | + alt: othis.attr('alt'), | ||
| 1055 | + pid: othis.attr('layer-pid'), | ||
| 1056 | + src: othis.attr('layer-src') || othis.attr('src'), | ||
| 1057 | + thumb: othis.attr('src') | ||
| 1058 | + }); | ||
| 1059 | + }) | ||
| 1060 | + }; | ||
| 1061 | + | ||
| 1076 | pushData(); | 1062 | pushData(); |
| 1077 | - }) | ||
| 1078 | - | ||
| 1079 | - //不直接弹出 | ||
| 1080 | - if(!loop) return; | ||
| 1081 | - | ||
| 1082 | - } else if (data.length === 0){ | ||
| 1083 | - return layer.msg('没有图片'); | ||
| 1084 | - } | ||
| 1085 | - | ||
| 1086 | - //上一张 | ||
| 1087 | - dict.imgprev = function(key){ | ||
| 1088 | - dict.imgIndex--; | ||
| 1089 | - if(dict.imgIndex < 1){ | ||
| 1090 | - dict.imgIndex = data.length; | ||
| 1091 | - } | ||
| 1092 | - dict.tabimg(key); | ||
| 1093 | - }; | ||
| 1094 | - | ||
| 1095 | - //下一张 | ||
| 1096 | - dict.imgnext = function(key,errorMsg){ | ||
| 1097 | - dict.imgIndex++; | ||
| 1098 | - if(dict.imgIndex > data.length){ | ||
| 1099 | - dict.imgIndex = 1; | ||
| 1100 | - if (errorMsg) {return}; | 1063 | + |
| 1064 | + if (data.length === 0) return; | ||
| 1065 | + | ||
| 1066 | + loop || parent.on('click', options.img, function(){ | ||
| 1067 | + var othis = $(this), index = othis.attr('layer-index'); | ||
| 1068 | + layer.photos($.extend(options, { | ||
| 1069 | + photos: { | ||
| 1070 | + start: index, | ||
| 1071 | + data: data, | ||
| 1072 | + tab: options.tab | ||
| 1073 | + }, | ||
| 1074 | + full: options.full | ||
| 1075 | + }), true); | ||
| 1076 | + pushData(); | ||
| 1077 | + }) | ||
| 1078 | + | ||
| 1079 | + //不直接弹出 | ||
| 1080 | + if(!loop) return; | ||
| 1081 | + | ||
| 1082 | + } else if (data.length === 0){ | ||
| 1083 | + return layer.msg('没有图片'); | ||
| 1101 | } | 1084 | } |
| 1102 | - dict.tabimg(key) | ||
| 1103 | - }; | ||
| 1104 | - | ||
| 1105 | - //方向键 | ||
| 1106 | - dict.keyup = function(event){ | ||
| 1107 | - if(!dict.end){ | ||
| 1108 | - var code = event.keyCode; | ||
| 1109 | - event.preventDefault(); | ||
| 1110 | - if(code === 37){ | ||
| 1111 | - dict.imgprev(true); | ||
| 1112 | - } else if(code === 39) { | ||
| 1113 | - dict.imgnext(true); | ||
| 1114 | - } else if(code === 27) { | ||
| 1115 | - layer.close(dict.index); | 1085 | + |
| 1086 | + //上一张 | ||
| 1087 | + dict.imgprev = function(key){ | ||
| 1088 | + dict.imgIndex--; | ||
| 1089 | + if(dict.imgIndex < 1){ | ||
| 1090 | + dict.imgIndex = data.length; | ||
| 1091 | + } | ||
| 1092 | + dict.tabimg(key); | ||
| 1093 | + }; | ||
| 1094 | + | ||
| 1095 | + //下一张 | ||
| 1096 | + dict.imgnext = function(key,errorMsg){ | ||
| 1097 | + dict.imgIndex++; | ||
| 1098 | + if(dict.imgIndex > data.length){ | ||
| 1099 | + dict.imgIndex = 1; | ||
| 1100 | + if (errorMsg) {return}; | ||
| 1101 | + } | ||
| 1102 | + dict.tabimg(key) | ||
| 1103 | + }; | ||
| 1104 | + | ||
| 1105 | + //方向键 | ||
| 1106 | + dict.keyup = function(event){ | ||
| 1107 | + if(!dict.end){ | ||
| 1108 | + var code = event.keyCode; | ||
| 1109 | + event.preventDefault(); | ||
| 1110 | + if(code === 37){ | ||
| 1111 | + dict.imgprev(true); | ||
| 1112 | + } else if(code === 39) { | ||
| 1113 | + dict.imgnext(true); | ||
| 1114 | + } else if(code === 27) { | ||
| 1115 | + layer.close(dict.index); | ||
| 1116 | + } | ||
| 1116 | } | 1117 | } |
| 1117 | } | 1118 | } |
| 1118 | - } | ||
| 1119 | - | ||
| 1120 | - //切换 | ||
| 1121 | - dict.tabimg = function(key){ | ||
| 1122 | - if(data.length <= 1) return; | ||
| 1123 | - photos.start = dict.imgIndex - 1; | ||
| 1124 | - layer.close(dict.index); | ||
| 1125 | - return layer.photos(options, true, key); | ||
| 1126 | - setTimeout(function(){ | ||
| 1127 | - layer.photos(options, true, key); | ||
| 1128 | - }, 200); | ||
| 1129 | - } | ||
| 1130 | - | ||
| 1131 | - //一些动作 | ||
| 1132 | - dict.event = function(){ | ||
| 1133 | - dict.bigimg.hover(function(){ | ||
| 1134 | - dict.imgsee.show(); | ||
| 1135 | - }, function(){ | ||
| 1136 | - dict.imgsee.hide(); | ||
| 1137 | - }); | ||
| 1138 | - | ||
| 1139 | - dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ | ||
| 1140 | - event.preventDefault(); | ||
| 1141 | - dict.imgprev(); | ||
| 1142 | - }); | ||
| 1143 | - | ||
| 1144 | - dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ | ||
| 1145 | - event.preventDefault(); | ||
| 1146 | - dict.imgnext(); | ||
| 1147 | - }); | ||
| 1148 | - | ||
| 1149 | - $(document).on('keyup', dict.keyup); | ||
| 1150 | - }; | ||
| 1151 | - | ||
| 1152 | - //图片预加载 | ||
| 1153 | - function loadImage(url, callback, error) { | ||
| 1154 | - var img = new Image(); | ||
| 1155 | - img.src = url; | ||
| 1156 | - if(img.complete){ | ||
| 1157 | - return callback(img); | 1119 | + |
| 1120 | + //切换 | ||
| 1121 | + dict.tabimg = function(key){ | ||
| 1122 | + if(data.length <= 1) return; | ||
| 1123 | + photos.start = dict.imgIndex - 1; | ||
| 1124 | + layer.close(dict.index); | ||
| 1125 | + return layer.photos(options, true, key); | ||
| 1126 | + setTimeout(function(){ | ||
| 1127 | + layer.photos(options, true, key); | ||
| 1128 | + }, 200); | ||
| 1158 | } | 1129 | } |
| 1159 | - img.onload = function(){ | ||
| 1160 | - img.onload = null; | ||
| 1161 | - callback(img); | 1130 | + |
| 1131 | + //一些动作 | ||
| 1132 | + dict.event = function(){ | ||
| 1133 | + dict.bigimg.hover(function(){ | ||
| 1134 | + dict.imgsee.show(); | ||
| 1135 | + }, function(){ | ||
| 1136 | + dict.imgsee.hide(); | ||
| 1137 | + }); | ||
| 1138 | + | ||
| 1139 | + dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){ | ||
| 1140 | + event.preventDefault(); | ||
| 1141 | + dict.imgprev(); | ||
| 1142 | + }); | ||
| 1143 | + | ||
| 1144 | + dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){ | ||
| 1145 | + event.preventDefault(); | ||
| 1146 | + dict.imgnext(); | ||
| 1147 | + }); | ||
| 1148 | + | ||
| 1149 | + $(document).on('keyup', dict.keyup); | ||
| 1162 | }; | 1150 | }; |
| 1163 | - img.onerror = function(e){ | ||
| 1164 | - img.onerror = null; | ||
| 1165 | - error(e); | ||
| 1166 | - }; | ||
| 1167 | - }; | ||
| 1168 | - | ||
| 1169 | - dict.loadi = layer.load(1, { | ||
| 1170 | - shade: 'shade' in options ? false : 0.9, | ||
| 1171 | - scrollbar: false | ||
| 1172 | - }); | ||
| 1173 | - | ||
| 1174 | - loadImage(data[start].src, function(img){ | ||
| 1175 | - layer.close(dict.loadi); | ||
| 1176 | - dict.index = layer.open($.extend({ | ||
| 1177 | - type: 1, | ||
| 1178 | - id: 'layui-layer-photos', | ||
| 1179 | - area: function(){ | ||
| 1180 | - var imgarea = [img.width, img.height]; | ||
| 1181 | - var winarea = [$(window).width() - 100, $(window).height() - 100]; | ||
| 1182 | - | ||
| 1183 | - //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) | ||
| 1184 | - if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ | ||
| 1185 | - var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 | ||
| 1186 | - if(wh[0] > wh[1]){//取缩放比例最大的进行缩放 | ||
| 1187 | - imgarea[0] = imgarea[0]/wh[0]; | ||
| 1188 | - imgarea[1] = imgarea[1]/wh[0]; | ||
| 1189 | - } else if(wh[0] < wh[1]){ | ||
| 1190 | - imgarea[0] = imgarea[0]/wh[1]; | ||
| 1191 | - imgarea[1] = imgarea[1]/wh[1]; | 1151 | + |
| 1152 | + //图片预加载 | ||
| 1153 | + function loadImage(url, callback, error) { | ||
| 1154 | + var img = new Image(); | ||
| 1155 | + img.src = url; | ||
| 1156 | + if(img.complete){ | ||
| 1157 | + return callback(img); | ||
| 1158 | + } | ||
| 1159 | + img.onload = function(){ | ||
| 1160 | + img.onload = null; | ||
| 1161 | + callback(img); | ||
| 1162 | + }; | ||
| 1163 | + img.onerror = function(e){ | ||
| 1164 | + img.onerror = null; | ||
| 1165 | + error(e); | ||
| 1166 | + }; | ||
| 1167 | + }; | ||
| 1168 | + | ||
| 1169 | + dict.loadi = layer.load(1, { | ||
| 1170 | + shade: 'shade' in options ? false : 0.9, | ||
| 1171 | + scrollbar: false | ||
| 1172 | + }); | ||
| 1173 | + | ||
| 1174 | + loadImage(data[start].src, function(img){ | ||
| 1175 | + layer.close(dict.loadi); | ||
| 1176 | + dict.index = layer.open($.extend({ | ||
| 1177 | + type: 1, | ||
| 1178 | + id: 'layui-layer-photos', | ||
| 1179 | + area: function(){ | ||
| 1180 | + var imgarea = [img.width, img.height]; | ||
| 1181 | + var winarea = [$(window).width() - 100, $(window).height() - 100]; | ||
| 1182 | + | ||
| 1183 | + //如果 实际图片的宽或者高比 屏幕大(那么进行缩放) | ||
| 1184 | + if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){ | ||
| 1185 | + var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例 | ||
| 1186 | + if(wh[0] > wh[1]){//取缩放比例最大的进行缩放 | ||
| 1187 | + imgarea[0] = imgarea[0]/wh[0]; | ||
| 1188 | + imgarea[1] = imgarea[1]/wh[0]; | ||
| 1189 | + } else if(wh[0] < wh[1]){ | ||
| 1190 | + imgarea[0] = imgarea[0]/wh[1]; | ||
| 1191 | + imgarea[1] = imgarea[1]/wh[1]; | ||
| 1192 | + } | ||
| 1192 | } | 1193 | } |
| 1193 | - } | ||
| 1194 | - | ||
| 1195 | - return [imgarea[0]+'px', imgarea[1]+'px']; | ||
| 1196 | - }(), | ||
| 1197 | - title: false, | ||
| 1198 | - shade: 0.9, | ||
| 1199 | - shadeClose: true, | ||
| 1200 | - closeBtn: false, | ||
| 1201 | - move: '.layui-layer-phimg img', | ||
| 1202 | - moveType: 1, | ||
| 1203 | - scrollbar: false, | ||
| 1204 | - moveOut: true, | ||
| 1205 | - //anim: Math.random()*5|0, | ||
| 1206 | - isOutAnim: false, | ||
| 1207 | - skin: 'layui-layer-photos' + skin('photos'), | ||
| 1208 | - content: '<div class="layui-layer-phimg">' | 1194 | + |
| 1195 | + return [imgarea[0]+'px', imgarea[1]+'px']; | ||
| 1196 | + }(), | ||
| 1197 | + title: false, | ||
| 1198 | + shade: 0.9, | ||
| 1199 | + shadeClose: true, | ||
| 1200 | + closeBtn: false, | ||
| 1201 | + move: '.layui-layer-phimg img', | ||
| 1202 | + moveType: 1, | ||
| 1203 | + scrollbar: false, | ||
| 1204 | + moveOut: true, | ||
| 1205 | + //anim: Math.random()*5|0, | ||
| 1206 | + isOutAnim: false, | ||
| 1207 | + skin: 'layui-layer-photos' + skin('photos'), | ||
| 1208 | + content: '<div class="layui-layer-phimg">' | ||
| 1209 | +'<img src="'+ data[start].src +'" alt="'+ (data[start].alt||'') +'" layer-pid="'+ data[start].pid +'">' | 1209 | +'<img src="'+ data[start].src +'" alt="'+ (data[start].alt||'') +'" layer-pid="'+ data[start].pid +'">' |
| 1210 | +'<div class="layui-layer-imgsee">' | 1210 | +'<div class="layui-layer-imgsee">' |
| 1211 | - +(data.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : '') | ||
| 1212 | - +'<div class="layui-layer-imgbar" style="display:'+ (key ? 'block' : '') +'"><span class="layui-layer-imgtit"><a href="javascript:;">'+ (data[start].alt||'') +'</a><em>'+ dict.imgIndex +'/'+ data.length +'</em></span></div>' | 1211 | + +(data.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : '') |
| 1212 | + +'<div class="layui-layer-imgbar" style="display:'+ (key ? 'block' : '') +'"><span class="layui-layer-imgtit"><a href="javascript:;">'+ (data[start].alt||'') +'</a><em>'+ dict.imgIndex +'/'+ data.length +'</em></span></div>' | ||
| 1213 | +'</div>' | 1213 | +'</div>' |
| 1214 | - +'</div>', | ||
| 1215 | - success: function(layero, index){ | ||
| 1216 | - dict.bigimg = layero.find('.layui-layer-phimg'); | ||
| 1217 | - dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar'); | ||
| 1218 | - dict.event(layero); | ||
| 1219 | - options.tab && options.tab(data[start], layero); | ||
| 1220 | - typeof success === 'function' && success(layero); | ||
| 1221 | - }, end: function(){ | ||
| 1222 | - dict.end = true; | ||
| 1223 | - $(document).off('keyup', dict.keyup); | ||
| 1224 | - } | ||
| 1225 | - }, options)); | ||
| 1226 | - }, function(){ | ||
| 1227 | - layer.close(dict.loadi); | ||
| 1228 | - layer.msg('当前图片地址异常<br>是否继续查看下一张?', { | ||
| 1229 | - time: 30000, | ||
| 1230 | - btn: ['下一张', '不看了'], | ||
| 1231 | - yes: function(){ | ||
| 1232 | - data.length > 1 && dict.imgnext(true,true); | ||
| 1233 | - } | 1214 | + +'</div>', |
| 1215 | + success: function(layero, index){ | ||
| 1216 | + dict.bigimg = layero.find('.layui-layer-phimg'); | ||
| 1217 | + dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar'); | ||
| 1218 | + dict.event(layero); | ||
| 1219 | + options.tab && options.tab(data[start], layero); | ||
| 1220 | + typeof success === 'function' && success(layero); | ||
| 1221 | + }, end: function(){ | ||
| 1222 | + dict.end = true; | ||
| 1223 | + $(document).off('keyup', dict.keyup); | ||
| 1224 | + } | ||
| 1225 | + }, options)); | ||
| 1226 | + }, function(){ | ||
| 1227 | + layer.close(dict.loadi); | ||
| 1228 | + layer.msg('当前图片地址异常<br>是否继续查看下一张?', { | ||
| 1229 | + time: 30000, | ||
| 1230 | + btn: ['下一张', '不看了'], | ||
| 1231 | + yes: function(){ | ||
| 1232 | + data.length > 1 && dict.imgnext(true,true); | ||
| 1233 | + } | ||
| 1234 | + }); | ||
| 1234 | }); | 1235 | }); |
| 1235 | - }); | ||
| 1236 | -}; | 1236 | + }; |
| 1237 | 1237 | ||
| 1238 | //主入口 | 1238 | //主入口 |
| 1239 | -ready.run = function(_$){ | ||
| 1240 | - $ = _$; | ||
| 1241 | - win = $(window); | ||
| 1242 | - doms.html = $('html'); | ||
| 1243 | - layer.open = function(deliver){ | ||
| 1244 | - var o = new Class(deliver); | ||
| 1245 | - return o.index; | 1239 | + ready.run = function(_$){ |
| 1240 | + $ = _$; | ||
| 1241 | + win = $(window); | ||
| 1242 | + doms.html = $('html'); | ||
| 1243 | + layer.open = function(deliver){ | ||
| 1244 | + var o = new Class(deliver); | ||
| 1245 | + return o.index; | ||
| 1246 | + }; | ||
| 1246 | }; | 1247 | }; |
| 1247 | -}; | ||
| 1248 | 1248 | ||
| 1249 | //加载方式 | 1249 | //加载方式 |
| 1250 | -window.layui && layui.define ? ( | ||
| 1251 | - layer.ready() | ||
| 1252 | - ,layui.define('jquery', function(exports){ //layui加载 | ||
| 1253 | - layer.path = layui.cache.dir; | ||
| 1254 | - ready.run(layui.jquery); | ||
| 1255 | - | ||
| 1256 | - //暴露模块 | ||
| 1257 | - window.layer = layer; | ||
| 1258 | - exports('layer', layer); | ||
| 1259 | - }) | ||
| 1260 | -) : ( | ||
| 1261 | - (typeof define === 'function' && define.amd) ? define(['jquery'], function(){ //requirejs加载 | ||
| 1262 | - ready.run(window.jQuery); | ||
| 1263 | - return layer; | ||
| 1264 | - }) : function(){ //普通script标签加载 | ||
| 1265 | - ready.run(window.jQuery); | ||
| 1266 | - layer.ready(); | ||
| 1267 | - }() | ||
| 1268 | -); | 1250 | + window.layui && layui.define ? ( |
| 1251 | + layer.ready() | ||
| 1252 | + ,layui.define('jquery', function(exports){ //layui加载 | ||
| 1253 | + layer.path = layui.cache.dir; | ||
| 1254 | + ready.run(layui.jquery); | ||
| 1255 | + | ||
| 1256 | + //暴露模块 | ||
| 1257 | + window.layer = layer; | ||
| 1258 | + exports('layer', layer); | ||
| 1259 | + }) | ||
| 1260 | + ) : ( | ||
| 1261 | + (typeof define === 'function' && define.amd) ? define(['jquery'], function(){ //requirejs加载 | ||
| 1262 | + ready.run(window.jQuery); | ||
| 1263 | + return layer; | ||
| 1264 | + }) : function(){ //普通script标签加载 | ||
| 1265 | + ready.run(window.jQuery); | ||
| 1266 | + layer.ready(); | ||
| 1267 | + }() | ||
| 1268 | + ); | ||
| 1269 | 1269 | ||
| 1270 | }(window); | 1270 | }(window); |
src/main/resources/static/real_control_v2/js/forms/form_embed.js
| @@ -53,6 +53,10 @@ var gb_embed_form_hanlde = (function () { | @@ -53,6 +53,10 @@ var gb_embed_form_hanlde = (function () { | ||
| 53 | area: ['1093px', '600px'], | 53 | area: ['1093px', '600px'], |
| 54 | moveOut: true, | 54 | moveOut: true, |
| 55 | content: wrapUrl, | 55 | content: wrapUrl, |
| 56 | + zIndex: layer.zIndex, | ||
| 57 | + success: function(layero){ | ||
| 58 | + layer.setTop(layero); | ||
| 59 | + }, | ||
| 56 | end: function () { | 60 | end: function () { |
| 57 | 61 | ||
| 58 | } | 62 | } |
src/main/resources/static/real_control_v2/js/main.js
| @@ -170,7 +170,8 @@ function showUpdateDescription() { | @@ -170,7 +170,8 @@ function showUpdateDescription() { | ||
| 170 | //更新说明 | 170 | //更新说明 |
| 171 | var updateDescription = { | 171 | var updateDescription = { |
| 172 | date: '2017-05-18', | 172 | date: '2017-05-18', |
| 173 | - text: '<h5>现在自定义子任务,勾选是否烂班后,烂班原因必填。</h5><h5>修复了在驾驶员请求出场时,误下发分班出场指令的问题</h5>' | 173 | + text: '<h5>现在自定义子任务,勾选是否烂班后,烂班原因必填。</h5><h5>修复了在驾驶员请求出场时,误下发分班出场指令的问题</h5>' + |
| 174 | + '<h5>调整了报表的弹出窗口<br>1、取消了窗口遮罩,可同时打开多个报表窗口,窗口堆叠时,点击窗口title切换堆叠顺序<br>2、鼠标按住窗口右下角,可随意改变窗口大小。<br>3、拖动窗口时,允许拖出页面之外<br><br>注意:将窗口和窗口title拖出页面外时,会面临窗口丢失的风险,过多丢失的窗口会影响到页面性能,你可以刷新页面以重置!</h5>' | ||
| 174 | }; | 175 | }; |
| 175 | 176 | ||
| 176 | var storage = window.localStorage | 177 | var storage = window.localStorage |