layerjs-gm-with-css

layer.js 带有css样式

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/434540/1065982/layerjs-gm-with-css.js

  1. // ==UserScript==
  2. // @name layerjs-gm-with-css
  3. // @author aweleey.li
  4. // @version 1.0.1
  5. // @grant GM_addStyle
  6. // @note layer - 通用 Web 弹出层组件
  7. // @note MIT Licensed
  8. // @note add layer style
  9. // ==/UserScript==
  10.  
  11. AddLayerStyle();
  12.  
  13. !(function (window, undefined) {
  14. 'use strict';
  15. var addedByGM = true;
  16.  
  17. var isLayui = window.layui && layui.define,
  18. $,
  19. win,
  20. ready = {
  21. getPath: (function () {
  22. if (addedByGM) return '';
  23. var jsPath = document.currentScript
  24. ? document.currentScript.src
  25. : (function () {
  26. var js = document.scripts,
  27. last = js.length - 1,
  28. src;
  29. for (var i = last; i > 0; i--) {
  30. if (js[i].readyState === 'interactive') {
  31. src = js[i].src;
  32. break;
  33. }
  34. }
  35. return src || js[last].src;
  36. })(),
  37. GLOBAL = window.LAYUI_GLOBAL || {};
  38. return GLOBAL.layer_dir || jsPath.substring(0, jsPath.lastIndexOf('/') + 1);
  39. })(),
  40.  
  41. config: {},
  42. end: {},
  43. minIndex: 0,
  44. minLeft: [],
  45. btn: ['确定', '取消'],
  46.  
  47. //五种原始层模式
  48. type: ['dialog', 'page', 'iframe', 'loading', 'tips'],
  49.  
  50. //获取节点的style属性值
  51. getStyle: function (node, name) {
  52. var style = node.currentStyle ? node.currentStyle : window.getComputedStyle(node, null);
  53. return style[style.getPropertyValue ? 'getPropertyValue' : 'getAttribute'](name);
  54. },
  55.  
  56. //载入 CSS 依赖
  57. link: function (href, fn, cssname) {
  58. // console.log('layer lsakdfjslakdf', layer);
  59. //未设置路径,则不主动加载css
  60. if (!layer.path) return;
  61.  
  62. var head = document.getElementsByTagName('head')[0],
  63. link = document.createElement('link');
  64.  
  65. if (typeof fn === 'string') cssname = fn;
  66.  
  67. var app = (cssname || href).replace(/\.|\//g, '');
  68. var id = 'layuicss-' + app,
  69. STAUTS_NAME = 'creating',
  70. timeout = 0;
  71.  
  72. link.rel = 'stylesheet';
  73. link.href = layer.path + href;
  74. link.id = id;
  75.  
  76. if (!document.getElementById(id)) {
  77. head.appendChild(link);
  78. }
  79.  
  80. if (typeof fn !== 'function') return;
  81.  
  82. //轮询 css 是否加载完毕
  83. (function poll(status) {
  84. var delay = 100,
  85. getLinkElem = document.getElementById(id); //获取动态插入的 link 元素
  86.  
  87. //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
  88. if (++timeout > (10 * 1000) / delay) {
  89. return window.console && console.error(app + '.css: Invalid');
  90. }
  91.  
  92. //css 加载就绪
  93. if (parseInt(ready.getStyle(getLinkElem, 'width')) === 1989) {
  94. //如果参数来自于初始轮询(即未加载就绪时的),则移除 link 标签状态
  95. if (status === STAUTS_NAME) getLinkElem.removeAttribute('lay-status');
  96. //如果 link 标签的状态仍为「创建中」,则继续进入轮询,直到状态改变,则执行回调
  97. getLinkElem.getAttribute('lay-status') === STAUTS_NAME ? setTimeout(poll, delay) : fn();
  98. } else {
  99. getLinkElem.setAttribute('lay-status', STAUTS_NAME);
  100. setTimeout(function () {
  101. poll(STAUTS_NAME);
  102. }, delay);
  103. }
  104.  
  105. //parseInt(ready.getStyle(document.getElementById(id), 'width')) === 1989 ? fn() : setTimeout(poll, 1000);
  106. })();
  107. }
  108. };
  109.  
  110. //默认内置方法。
  111. var layer = {
  112. v: '3.5.1',
  113. ie: (function () {
  114. //ie版本
  115. var agent = navigator.userAgent.toLowerCase();
  116. return !!window.ActiveXObject || 'ActiveXObject' in window
  117. ? (agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识
  118. : false;
  119. })(),
  120. index: window.layer && window.layer.v ? 100000 : 0,
  121. path: ready.getPath,
  122. config: function (options, fn) {
  123. options = options || {};
  124. layer.cache = ready.config = $.extend({}, ready.config, options);
  125. layer.path = ready.config.path || layer.path;
  126. typeof options.extend === 'string' && (options.extend = [options.extend]);
  127.  
  128. //如果设置了路径,则加载样式
  129. if (ready.config.path) layer.ready();
  130.  
  131. if (!options.extend) return this;
  132.  
  133. isLayui ? layui.addcss('modules/layer/' + options.extend) : ready.link('theme/' + options.extend);
  134.  
  135. return this;
  136. },
  137.  
  138. //主体CSS等待事件
  139. ready: function (callback) {
  140. var cssname = 'layer',
  141. ver = '',
  142. path = (isLayui ? 'modules/layer/' : 'theme/') + 'default/layer.css?v=' + layer.v + ver;
  143. isLayui ? layui.addcss(path, callback, cssname) : ready.link(path, callback, cssname);
  144. return this;
  145. },
  146.  
  147. //各种快捷引用
  148. alert: function (content, options, yes) {
  149. var type = typeof options === 'function';
  150. if (type) yes = options;
  151. return layer.open(
  152. $.extend(
  153. {
  154. content: content,
  155. yes: yes
  156. },
  157. type ? {} : options
  158. )
  159. );
  160. },
  161.  
  162. confirm: function (content, options, yes, cancel) {
  163. var type = typeof options === 'function';
  164. if (type) {
  165. cancel = yes;
  166. yes = options;
  167. }
  168. return layer.open(
  169. $.extend(
  170. {
  171. content: content,
  172. btn: ready.btn,
  173. yes: yes,
  174. btn2: cancel
  175. },
  176. type ? {} : options
  177. )
  178. );
  179. },
  180.  
  181. msg: function (content, options, end) {
  182. //最常用提示层
  183. var type = typeof options === 'function',
  184. rskin = ready.config.skin;
  185. var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '') || 'layui-layer-msg';
  186. var anim = doms.anim.length - 1;
  187. if (type) end = options;
  188. return layer.open(
  189. $.extend(
  190. {
  191. content: content,
  192. time: 3000,
  193. shade: false,
  194. skin: skin,
  195. title: false,
  196. closeBtn: false,
  197. btn: false,
  198. resize: false,
  199. end: end
  200. },
  201. type && !ready.config.skin
  202. ? {
  203. skin: skin + ' layui-layer-hui',
  204. anim: anim
  205. }
  206. : (function () {
  207. options = options || {};
  208. if (options.icon === -1 || (options.icon === undefined && !ready.config.skin)) {
  209. options.skin = skin + ' ' + (options.skin || 'layui-layer-hui');
  210. }
  211. return options;
  212. })()
  213. )
  214. );
  215. },
  216.  
  217. load: function (icon, options) {
  218. return layer.open(
  219. $.extend(
  220. {
  221. type: 3,
  222. icon: icon || 0,
  223. resize: false,
  224. shade: 0.01
  225. },
  226. options
  227. )
  228. );
  229. },
  230.  
  231. tips: function (content, follow, options) {
  232. return layer.open(
  233. $.extend(
  234. {
  235. type: 4,
  236. content: [content, follow],
  237. closeBtn: false,
  238. time: 3000,
  239. shade: false,
  240. resize: false,
  241. fixed: false,
  242. maxWidth: 260
  243. },
  244. options
  245. )
  246. );
  247. }
  248. };
  249.  
  250. var Class = function (setings) {
  251. var that = this,
  252. creat = function () {
  253. that.creat();
  254. };
  255. that.index = ++layer.index;
  256. that.config.maxWidth = $(win).width() - 15 * 2; //初始最大宽度:当前屏幕宽,左右留 15px 边距
  257. that.config = $.extend({}, that.config, ready.config, setings);
  258. document.body
  259. ? creat()
  260. : setTimeout(function () {
  261. creat();
  262. }, 30);
  263. };
  264.  
  265. Class.pt = Class.prototype;
  266.  
  267. //缓存常用字符
  268. var doms = [
  269. 'layui-layer',
  270. '.layui-layer-title',
  271. '.layui-layer-main',
  272. '.layui-layer-dialog',
  273. 'layui-layer-iframe',
  274. 'layui-layer-content',
  275. 'layui-layer-btn',
  276. 'layui-layer-close'
  277. ];
  278. doms.anim = ['layer-anim-00', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06'];
  279.  
  280. doms.SHADE = 'layui-layer-shade';
  281. doms.MOVE = 'layui-layer-move';
  282.  
  283. //默认配置
  284. Class.pt.config = {
  285. type: 0,
  286. shade: 0.3,
  287. fixed: true,
  288. move: doms[1],
  289. title: '信息',
  290. offset: 'auto',
  291. area: 'auto',
  292. closeBtn: 1,
  293. time: 0, //0表示不自动关闭
  294. zIndex: 19891014,
  295. maxWidth: 360,
  296. anim: 0,
  297. isOutAnim: true, //退出动画
  298. minStack: true, //最小化堆叠
  299. icon: -1,
  300. moveType: 1,
  301. resize: true,
  302. scrollbar: true, //是否允许浏览器滚动条
  303. tips: 2
  304. };
  305.  
  306. //容器
  307. Class.pt.vessel = function (conType, callback) {
  308. var that = this,
  309. times = that.index,
  310. config = that.config;
  311. var zIndex = config.zIndex + times,
  312. titype = typeof config.title === 'object';
  313. var ismax = config.maxmin && (config.type === 1 || config.type === 2);
  314. var titleHTML = config.title
  315. ? '<div class="layui-layer-title" style="' +
  316. (titype ? config.title[1] : '') +
  317. '">' +
  318. (titype ? config.title[0] : config.title) +
  319. '</div>'
  320. : '';
  321.  
  322. config.zIndex = zIndex;
  323. callback(
  324. [
  325. //遮罩
  326. config.shade
  327. ? '<div class="' +
  328. doms.SHADE +
  329. '" id="' +
  330. doms.SHADE +
  331. times +
  332. '" times="' +
  333. times +
  334. '" style="' +
  335. ('z-index:' + (zIndex - 1) + '; ') +
  336. '"></div>'
  337. : '',
  338.  
  339. //主体
  340. '<div class="' +
  341. doms[0] +
  342. (' layui-layer-' + ready.type[config.type]) +
  343. ((config.type == 0 || config.type == 2) && !config.shade ? ' layui-layer-border' : '') +
  344. ' ' +
  345. (config.skin || '') +
  346. '" id="' +
  347. doms[0] +
  348. times +
  349. '" type="' +
  350. ready.type[config.type] +
  351. '" times="' +
  352. times +
  353. '" showtime="' +
  354. config.time +
  355. '" conType="' +
  356. (conType ? 'object' : 'string') +
  357. '" style="z-index: ' +
  358. zIndex +
  359. '; width:' +
  360. config.area[0] +
  361. ';height:' +
  362. config.area[1] +
  363. ';position:' +
  364. (config.fixed ? 'fixed;' : 'absolute;') +
  365. '">' +
  366. (conType && config.type != 2 ? '' : titleHTML) +
  367. '<div id="' +
  368. (config.id || '') +
  369. '" class="layui-layer-content' +
  370. (config.type == 0 && config.icon !== -1 ? ' layui-layer-padding' : '') +
  371. (config.type == 3 ? ' layui-layer-loading' + config.icon : '') +
  372. '">' +
  373. (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico' + config.icon + '"></i>' : '') +
  374. (config.type == 1 && conType ? '' : config.content || '') +
  375. '</div>' +
  376. '<span class="layui-layer-setwin">' +
  377. (function () {
  378. var closebtn = ismax
  379. ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>'
  380. : '';
  381. config.closeBtn &&
  382. (closebtn +=
  383. '<a class="layui-layer-ico ' +
  384. doms[7] +
  385. ' ' +
  386. doms[7] +
  387. (config.title ? config.closeBtn : config.type == 4 ? '1' : '2') +
  388. '" href="javascript:;"></a>');
  389. return closebtn;
  390. })() +
  391. '</span>' +
  392. (config.btn
  393. ? (function () {
  394. var button = '';
  395. typeof config.btn === 'string' && (config.btn = [config.btn]);
  396. for (var i = 0, len = config.btn.length; i < len; i++) {
  397. button += '<a class="' + doms[6] + '' + i + '">' + config.btn[i] + '</a>';
  398. }
  399. return '<div class="' + doms[6] + ' layui-layer-btn-' + (config.btnAlign || '') + '">' + button + '</div>';
  400. })()
  401. : '') +
  402. (config.resize ? '<span class="layui-layer-resize"></span>' : '') +
  403. '</div>'
  404. ],
  405. titleHTML,
  406. $('<div class="' + doms.MOVE + '" id="' + doms.MOVE + '"></div>')
  407. );
  408. return that;
  409. };
  410.  
  411. //创建骨架
  412. Class.pt.creat = function () {
  413. var that = this,
  414. config = that.config,
  415. times = that.index,
  416. nodeIndex,
  417. content = config.content,
  418. conType = typeof content === 'object',
  419. body = $('body');
  420.  
  421. if (config.id && $('#' + config.id)[0]) return;
  422.  
  423. if (typeof config.area === 'string') {
  424. config.area = config.area === 'auto' ? ['', ''] : [config.area, ''];
  425. }
  426.  
  427. //anim兼容旧版shift
  428. if (config.shift) {
  429. config.anim = config.shift;
  430. }
  431.  
  432. if (layer.ie == 6) {
  433. config.fixed = false;
  434. }
  435.  
  436. switch (config.type) {
  437. case 0:
  438. config.btn = 'btn' in config ? config.btn : ready.btn[0];
  439. layer.closeAll('dialog');
  440. break;
  441. case 2:
  442. var content = (config.content = conType ? config.content : [config.content || '', 'auto']);
  443. config.content =
  444. '<iframe scrolling="' +
  445. (config.content[1] || 'auto') +
  446. '" allowtransparency="true" id="' +
  447. doms[4] +
  448. '' +
  449. times +
  450. '" name="' +
  451. doms[4] +
  452. '' +
  453. times +
  454. '" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' +
  455. config.content[0] +
  456. '"></iframe>';
  457. break;
  458. case 3:
  459. delete config.title;
  460. delete config.closeBtn;
  461. config.icon === -1 && config.icon === 0;
  462. layer.closeAll('loading');
  463. break;
  464. case 4:
  465. conType || (config.content = [config.content, 'body']);
  466. config.follow = config.content[1];
  467. config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>';
  468. delete config.title;
  469. config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true];
  470. config.tipsMore || layer.closeAll('tips');
  471. break;
  472. }
  473.  
  474. //建立容器
  475. that.vessel(conType, function (html, titleHTML, moveElem) {
  476. body.append(html[0]);
  477. conType
  478. ? (function () {
  479. config.type == 2 || config.type == 4
  480. ? (function () {
  481. $('body').append(html[1]);
  482. })()
  483. : (function () {
  484. if (!content.parents('.' + doms[0])[0]) {
  485. content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]);
  486. $('#' + doms[0] + times)
  487. .find('.' + doms[5])
  488. .before(titleHTML);
  489. }
  490. })();
  491. })()
  492. : body.append(html[1]);
  493. $('#' + doms.MOVE)[0] || body.append((ready.moveElem = moveElem));
  494.  
  495. that.layero = $('#' + doms[0] + times);
  496. that.shadeo = $('#' + doms.SHADE + times);
  497.  
  498. config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
  499. }).auto(times);
  500.  
  501. //遮罩
  502. that.shadeo.css({
  503. 'background-color': config.shade[1] || '#000',
  504. opacity: config.shade[0] || config.shade
  505. });
  506.  
  507. config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]);
  508.  
  509. //坐标自适应浏览器窗口尺寸
  510. config.type == 4
  511. ? that.tips()
  512. : (function () {
  513. that.offset();
  514. //首次弹出时,若 css 尚未加载,则等待 css 加载完毕后,重新设定尺寸
  515. parseInt(ready.getStyle(document.getElementById(doms.MOVE), 'z-index')) ||
  516. (function () {
  517. that.layero.css('visibility', 'hidden');
  518. layer.ready(function () {
  519. that.offset();
  520. that.layero.css('visibility', 'visible');
  521. });
  522. })();
  523. })();
  524.  
  525. //如果是固定定位
  526. if (config.fixed) {
  527. win.on('resize', function () {
  528. that.offset();
  529. (/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times);
  530. config.type == 4 && that.tips();
  531. });
  532. }
  533.  
  534. config.time <= 0 ||
  535. setTimeout(function () {
  536. layer.close(that.index);
  537. }, config.time);
  538. that.move().callback();
  539.  
  540. //为兼容jQuery3.0的css动画影响元素尺寸计算
  541. if (doms.anim[config.anim]) {
  542. var animClass = 'layer-anim ' + doms.anim[config.anim];
  543. that.layero.addClass(animClass).one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
  544. $(this).removeClass(animClass);
  545. });
  546. }
  547.  
  548. //记录关闭动画
  549. if (config.isOutAnim) {
  550. that.layero.data('isOutAnim', true);
  551. }
  552. };
  553.  
  554. //自适应
  555. Class.pt.auto = function (index) {
  556. var that = this,
  557. config = that.config,
  558. layero = $('#' + doms[0] + index);
  559.  
  560. if (config.area[0] === '' && config.maxWidth > 0) {
  561. //为了修复IE7下一个让人难以理解的bug
  562. if (layer.ie && layer.ie < 8 && config.btn) {
  563. layero.width(layero.innerWidth());
  564. }
  565. layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
  566. }
  567.  
  568. var area = [layero.innerWidth(), layero.innerHeight()],
  569. titHeight = layero.find(doms[1]).outerHeight() || 0,
  570. btnHeight = layero.find('.' + doms[6]).outerHeight() || 0,
  571. setHeight = function (elem) {
  572. elem = layero.find(elem);
  573. elem.height(area[1] - titHeight - btnHeight - 2 * (parseFloat(elem.css('padding-top')) | 0));
  574. };
  575.  
  576. switch (config.type) {
  577. case 2:
  578. setHeight('iframe');
  579. break;
  580. default:
  581. if (config.area[1] === '') {
  582. if (config.maxHeight > 0 && layero.outerHeight() > config.maxHeight) {
  583. area[1] = config.maxHeight;
  584. setHeight('.' + doms[5]);
  585. } else if (config.fixed && area[1] >= win.height()) {
  586. area[1] = win.height();
  587. setHeight('.' + doms[5]);
  588. }
  589. } else {
  590. setHeight('.' + doms[5]);
  591. }
  592. break;
  593. }
  594.  
  595. return that;
  596. };
  597.  
  598. //计算坐标
  599. Class.pt.offset = function () {
  600. var that = this,
  601. config = that.config,
  602. layero = that.layero;
  603. var area = [layero.outerWidth(), layero.outerHeight()];
  604. var type = typeof config.offset === 'object';
  605. that.offsetTop = (win.height() - area[1]) / 2;
  606. that.offsetLeft = (win.width() - area[0]) / 2;
  607.  
  608. if (type) {
  609. that.offsetTop = config.offset[0];
  610. that.offsetLeft = config.offset[1] || that.offsetLeft;
  611. } else if (config.offset !== 'auto') {
  612. if (config.offset === 't') {
  613. //上
  614. that.offsetTop = 0;
  615. } else if (config.offset === 'r') {
  616. //右
  617. that.offsetLeft = win.width() - area[0];
  618. } else if (config.offset === 'b') {
  619. //下
  620. that.offsetTop = win.height() - area[1];
  621. } else if (config.offset === 'l') {
  622. //左
  623. that.offsetLeft = 0;
  624. } else if (config.offset === 'lt') {
  625. //左上角
  626. that.offsetTop = 0;
  627. that.offsetLeft = 0;
  628. } else if (config.offset === 'lb') {
  629. //左下角
  630. that.offsetTop = win.height() - area[1];
  631. that.offsetLeft = 0;
  632. } else if (config.offset === 'rt') {
  633. //右上角
  634. that.offsetTop = 0;
  635. that.offsetLeft = win.width() - area[0];
  636. } else if (config.offset === 'rb') {
  637. //右下角
  638. that.offsetTop = win.height() - area[1];
  639. that.offsetLeft = win.width() - area[0];
  640. } else {
  641. that.offsetTop = config.offset;
  642. }
  643. }
  644.  
  645. if (!config.fixed) {
  646. that.offsetTop = /%$/.test(that.offsetTop) ? (win.height() * parseFloat(that.offsetTop)) / 100 : parseFloat(that.offsetTop);
  647. that.offsetLeft = /%$/.test(that.offsetLeft) ? (win.width() * parseFloat(that.offsetLeft)) / 100 : parseFloat(that.offsetLeft);
  648. that.offsetTop += win.scrollTop();
  649. that.offsetLeft += win.scrollLeft();
  650. }
  651.  
  652. if (layero.attr('minLeft')) {
  653. that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0);
  654. that.offsetLeft = layero.css('left');
  655. }
  656.  
  657. layero.css({ top: that.offsetTop, left: that.offsetLeft });
  658. };
  659.  
  660. //Tips
  661. Class.pt.tips = function () {
  662. var that = this,
  663. config = that.config,
  664. layero = that.layero;
  665. var layArea = [layero.outerWidth(), layero.outerHeight()],
  666. follow = $(config.follow);
  667. if (!follow[0]) follow = $('body');
  668. var goal = {
  669. width: follow.outerWidth(),
  670. height: follow.outerHeight(),
  671. top: follow.offset().top,
  672. left: follow.offset().left
  673. },
  674. tipsG = layero.find('.layui-layer-TipsG');
  675.  
  676. var guide = config.tips[0];
  677. config.tips[1] || tipsG.remove();
  678.  
  679. goal.autoLeft = function () {
  680. if (goal.left + layArea[0] - win.width() > 0) {
  681. goal.tipLeft = goal.left + goal.width - layArea[0];
  682. tipsG.css({ right: 12, left: 'auto' });
  683. } else {
  684. goal.tipLeft = goal.left;
  685. }
  686. };
  687.  
  688. //辨别tips的方位
  689. goal.where = [
  690. function () {
  691. //上
  692. goal.autoLeft();
  693. goal.tipTop = goal.top - layArea[1] - 10;
  694. tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]);
  695. },
  696. function () {
  697. //右
  698. goal.tipLeft = goal.left + goal.width + 10;
  699. goal.tipTop = goal.top;
  700. tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]);
  701. },
  702. function () {
  703. //下
  704. goal.autoLeft();
  705. goal.tipTop = goal.top + goal.height + 10;
  706. tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]);
  707. },
  708. function () {
  709. //左
  710. goal.tipLeft = goal.left - layArea[0] - 10;
  711. goal.tipTop = goal.top;
  712. tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]);
  713. }
  714. ];
  715. goal.where[guide - 1]();
  716.  
  717. /* 8*2为小三角形占据的空间 */
  718. if (guide === 1) {
  719. goal.top - (win.scrollTop() + layArea[1] + 8 * 2) < 0 && goal.where[2]();
  720. } else if (guide === 2) {
  721. win.width() - (goal.left + goal.width + layArea[0] + 8 * 2) > 0 || goal.where[3]();
  722. } else if (guide === 3) {
  723. goal.top - win.scrollTop() + goal.height + layArea[1] + 8 * 2 - win.height() > 0 && goal.where[0]();
  724. } else if (guide === 4) {
  725. layArea[0] + 8 * 2 - goal.left > 0 && goal.where[1]();
  726. }
  727.  
  728. layero.find('.' + doms[5]).css({
  729. 'background-color': config.tips[1],
  730. 'padding-right': config.closeBtn ? '30px' : ''
  731. });
  732. layero.css({
  733. left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0),
  734. top: goal.tipTop - (config.fixed ? win.scrollTop() : 0)
  735. });
  736. };
  737.  
  738. //拖拽层
  739. Class.pt.move = function () {
  740. var that = this,
  741. config = that.config,
  742. _DOC = $(document),
  743. layero = that.layero,
  744. moveElem = layero.find(config.move),
  745. resizeElem = layero.find('.layui-layer-resize'),
  746. dict = {};
  747.  
  748. if (config.move) {
  749. moveElem.css('cursor', 'move');
  750. }
  751.  
  752. moveElem.on('mousedown', function (e) {
  753. e.preventDefault();
  754. if (config.move) {
  755. dict.moveStart = true;
  756. dict.offset = [e.clientX - parseFloat(layero.css('left')), e.clientY - parseFloat(layero.css('top'))];
  757. ready.moveElem.css('cursor', 'move').show();
  758. }
  759. });
  760.  
  761. resizeElem.on('mousedown', function (e) {
  762. e.preventDefault();
  763. dict.resizeStart = true;
  764. dict.offset = [e.clientX, e.clientY];
  765. dict.area = [layero.outerWidth(), layero.outerHeight()];
  766. ready.moveElem.css('cursor', 'se-resize').show();
  767. });
  768.  
  769. _DOC.on('mousemove', function (e) {
  770. //拖拽移动
  771. if (dict.moveStart) {
  772. var X = e.clientX - dict.offset[0],
  773. Y = e.clientY - dict.offset[1],
  774. fixed = layero.css('position') === 'fixed';
  775.  
  776. e.preventDefault();
  777.  
  778. dict.stX = fixed ? 0 : win.scrollLeft();
  779. dict.stY = fixed ? 0 : win.scrollTop();
  780.  
  781. //控制元素不被拖出窗口外
  782. if (!config.moveOut) {
  783. var setRig = win.width() - layero.outerWidth() + dict.stX,
  784. setBot = win.height() - layero.outerHeight() + dict.stY;
  785. X < dict.stX && (X = dict.stX);
  786. X > setRig && (X = setRig);
  787. Y < dict.stY && (Y = dict.stY);
  788. Y > setBot && (Y = setBot);
  789. }
  790.  
  791. layero.css({
  792. left: X,
  793. top: Y
  794. });
  795. }
  796.  
  797. //Resize
  798. if (config.resize && dict.resizeStart) {
  799. var X = e.clientX - dict.offset[0],
  800. Y = e.clientY - dict.offset[1];
  801.  
  802. e.preventDefault();
  803.  
  804. layer.style(that.index, {
  805. width: dict.area[0] + X,
  806. height: dict.area[1] + Y
  807. });
  808. dict.isResize = true;
  809. config.resizing && config.resizing(layero);
  810. }
  811. }).on('mouseup', function (e) {
  812. if (dict.moveStart) {
  813. delete dict.moveStart;
  814. ready.moveElem.hide();
  815. config.moveEnd && config.moveEnd(layero);
  816. }
  817. if (dict.resizeStart) {
  818. delete dict.resizeStart;
  819. ready.moveElem.hide();
  820. }
  821. });
  822.  
  823. return that;
  824. };
  825.  
  826. Class.pt.callback = function () {
  827. var that = this,
  828. layero = that.layero,
  829. config = that.config;
  830. that.openLayer();
  831. if (config.success) {
  832. if (config.type == 2) {
  833. layero.find('iframe').on('load', function () {
  834. config.success(layero, that.index);
  835. });
  836. } else {
  837. config.success(layero, that.index);
  838. }
  839. }
  840. layer.ie == 6 && that.IE6(layero);
  841.  
  842. //按钮
  843. layero
  844. .find('.' + doms[6])
  845. .children('a')
  846. .on('click', function () {
  847. var index = $(this).index();
  848. if (index === 0) {
  849. if (config.yes) {
  850. config.yes(that.index, layero);
  851. } else if (config['btn1']) {
  852. config['btn1'](that.index, layero);
  853. } else {
  854. layer.close(that.index);
  855. }
  856. } else {
  857. var close = config['btn' + (index + 1)] && config['btn' + (index + 1)](that.index, layero);
  858. close === false || layer.close(that.index);
  859. }
  860. });
  861.  
  862. //取消
  863. function cancel() {
  864. var close = config.cancel && config.cancel(that.index, layero);
  865. close === false || layer.close(that.index);
  866. }
  867.  
  868. //右上角关闭回调
  869. layero.find('.' + doms[7]).on('click', cancel);
  870.  
  871. //点遮罩关闭
  872. if (config.shadeClose) {
  873. that.shadeo.on('click', function () {
  874. layer.close(that.index);
  875. });
  876. }
  877.  
  878. //最小化
  879. layero.find('.layui-layer-min').on('click', function () {
  880. var min = config.min && config.min(layero, that.index);
  881. min === false || layer.min(that.index, config);
  882. });
  883.  
  884. //全屏/还原
  885. layero.find('.layui-layer-max').on('click', function () {
  886. if ($(this).hasClass('layui-layer-maxmin')) {
  887. layer.restore(that.index);
  888. config.restore && config.restore(layero, that.index);
  889. } else {
  890. layer.full(that.index, config);
  891. setTimeout(function () {
  892. config.full && config.full(layero, that.index);
  893. }, 100);
  894. }
  895. });
  896.  
  897. config.end && (ready.end[that.index] = config.end);
  898. };
  899.  
  900. //for ie6 恢复select
  901. ready.reselect = function () {
  902. $.each($('select'), function (index, value) {
  903. var sthis = $(this);
  904. if (!sthis.parents('.' + doms[0])[0]) {
  905. sthis.attr('layer') == 1 && $('.' + doms[0]).length < 1 && sthis.removeAttr('layer').show();
  906. }
  907. sthis = null;
  908. });
  909. };
  910.  
  911. Class.pt.IE6 = function (layero) {
  912. //隐藏select
  913. $('select').each(function (index, value) {
  914. var sthis = $(this);
  915. if (!sthis.parents('.' + doms[0])[0]) {
  916. sthis.css('display') === 'none' || sthis.attr({ layer: '1' }).hide();
  917. }
  918. sthis = null;
  919. });
  920. };
  921.  
  922. //需依赖原型的对外方法
  923. Class.pt.openLayer = function () {
  924. var that = this;
  925.  
  926. //置顶当前窗口
  927. layer.zIndex = that.config.zIndex;
  928. layer.setTop = function (layero) {
  929. var setZindex = function () {
  930. layer.zIndex++;
  931. layero.css('z-index', layer.zIndex + 1);
  932. };
  933. layer.zIndex = parseInt(layero[0].style.zIndex);
  934. layero.on('mousedown', setZindex);
  935. return layer.zIndex;
  936. };
  937. };
  938.  
  939. //记录宽高坐标,用于还原
  940. ready.record = function (layero) {
  941. var area = [layero.width(), layero.height(), layero.position().top, layero.position().left + parseFloat(layero.css('margin-left'))];
  942. layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
  943. layero.attr({ area: area });
  944. };
  945.  
  946. ready.rescollbar = function (index) {
  947. if (doms.html.attr('layer-full') == index) {
  948. if (doms.html[0].style.removeProperty) {
  949. doms.html[0].style.removeProperty('overflow');
  950. } else {
  951. doms.html[0].style.removeAttribute('overflow');
  952. }
  953. doms.html.removeAttr('layer-full');
  954. }
  955. };
  956.  
  957. /** 内置成员 */
  958.  
  959. window.layer = layer;
  960. // console.log('window.layer', window.layer);
  961.  
  962. //获取子iframe的DOM
  963. layer.getChildFrame = function (selector, index) {
  964. index = index || $('.' + doms[4]).attr('times');
  965. return $('#' + doms[0] + index)
  966. .find('iframe')
  967. .contents()
  968. .find(selector);
  969. };
  970.  
  971. //得到当前iframe层的索引,子iframe时使用
  972. layer.getFrameIndex = function (name) {
  973. return $('#' + name)
  974. .parents('.' + doms[4])
  975. .attr('times');
  976. };
  977.  
  978. //iframe层自适应宽高
  979. layer.iframeAuto = function (index) {
  980. if (!index) return;
  981. var heg = layer.getChildFrame('html', index).outerHeight();
  982. var layero = $('#' + doms[0] + index);
  983. var titHeight = layero.find(doms[1]).outerHeight() || 0;
  984. var btnHeight = layero.find('.' + doms[6]).outerHeight() || 0;
  985. layero.css({ height: heg + titHeight + btnHeight });
  986. layero.find('iframe').css({ height: heg });
  987. };
  988.  
  989. //重置iframe url
  990. layer.iframeSrc = function (index, url) {
  991. $('#' + doms[0] + index)
  992. .find('iframe')
  993. .attr('src', url);
  994. };
  995.  
  996. //设定层的样式
  997. layer.style = function (index, options, limit) {
  998. var layero = $('#' + doms[0] + index),
  999. contElem = layero.find('.layui-layer-content'),
  1000. type = layero.attr('type'),
  1001. titHeight = layero.find(doms[1]).outerHeight() || 0,
  1002. btnHeight = layero.find('.' + doms[6]).outerHeight() || 0,
  1003. minLeft = layero.attr('minLeft');
  1004.  
  1005. if (type === ready.type[3] || type === ready.type[4]) {
  1006. return;
  1007. }
  1008.  
  1009. if (!limit) {
  1010. if (parseFloat(options.width) <= 260) {
  1011. options.width = 260;
  1012. }
  1013.  
  1014. if (parseFloat(options.height) - titHeight - btnHeight <= 64) {
  1015. options.height = 64 + titHeight + btnHeight;
  1016. }
  1017. }
  1018.  
  1019. layero.css(options);
  1020. btnHeight = layero.find('.' + doms[6]).outerHeight();
  1021.  
  1022. if (type === ready.type[2]) {
  1023. layero.find('iframe').css({
  1024. height: parseFloat(options.height) - titHeight - btnHeight
  1025. });
  1026. } else {
  1027. contElem.css({
  1028. height:
  1029. parseFloat(options.height) -
  1030. titHeight -
  1031. btnHeight -
  1032. parseFloat(contElem.css('padding-top')) -
  1033. parseFloat(contElem.css('padding-bottom'))
  1034. });
  1035. }
  1036. };
  1037.  
  1038. //最小化
  1039. layer.min = function (index, options) {
  1040. options = options || {};
  1041. var layero = $('#' + doms[0] + index),
  1042. shadeo = $('#' + doms.SHADE + index),
  1043. titHeight = layero.find(doms[1]).outerHeight() || 0,
  1044. left = layero.attr('minLeft') || 181 * ready.minIndex + 'px',
  1045. position = layero.css('position'),
  1046. settings = {
  1047. width: 180,
  1048. height: titHeight,
  1049. position: 'fixed',
  1050. overflow: 'hidden'
  1051. };
  1052.  
  1053. //记录宽高坐标,用于还原
  1054. ready.record(layero);
  1055.  
  1056. if (ready.minLeft[0]) {
  1057. left = ready.minLeft[0];
  1058. ready.minLeft.shift();
  1059. }
  1060.  
  1061. //是否堆叠在左下角
  1062. if (options.minStack) {
  1063. settings.left = left;
  1064. settings.top = win.height() - titHeight;
  1065. layero.attr('minLeft') || ready.minIndex++; //初次执行,最小化操作索引自增
  1066. layero.attr('minLeft', left);
  1067. }
  1068.  
  1069. layero.attr('position', position);
  1070. layer.style(index, settings, true);
  1071.  
  1072. layero.find('.layui-layer-min').hide();
  1073. layero.attr('type') === 'page' && layero.find(doms[4]).hide();
  1074. ready.rescollbar(index);
  1075.  
  1076. //隐藏遮罩
  1077. shadeo.hide();
  1078. };
  1079.  
  1080. //还原
  1081. layer.restore = function (index) {
  1082. var layero = $('#' + doms[0] + index),
  1083. shadeo = $('#' + doms.SHADE + index),
  1084. area = layero.attr('area').split(','),
  1085. type = layero.attr('type');
  1086.  
  1087. //恢复原来尺寸
  1088. layer.style(
  1089. index,
  1090. {
  1091. width: parseFloat(area[0]),
  1092. height: parseFloat(area[1]),
  1093. top: parseFloat(area[2]),
  1094. left: parseFloat(area[3]),
  1095. position: layero.attr('position'),
  1096. overflow: 'visible'
  1097. },
  1098. true
  1099. );
  1100.  
  1101. layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
  1102. layero.find('.layui-layer-min').show();
  1103. layero.attr('type') === 'page' && layero.find(doms[4]).show();
  1104. ready.rescollbar(index);
  1105.  
  1106. //恢复遮罩
  1107. shadeo.show();
  1108. };
  1109.  
  1110. //全屏
  1111. layer.full = function (index) {
  1112. var layero = $('#' + doms[0] + index),
  1113. timer;
  1114. ready.record(layero);
  1115. if (!doms.html.attr('layer-full')) {
  1116. doms.html.css('overflow', 'hidden').attr('layer-full', index);
  1117. }
  1118. clearTimeout(timer);
  1119. timer = setTimeout(function () {
  1120. var isfix = layero.css('position') === 'fixed';
  1121. layer.style(
  1122. index,
  1123. {
  1124. top: isfix ? 0 : win.scrollTop(),
  1125. left: isfix ? 0 : win.scrollLeft(),
  1126. width: win.width(),
  1127. height: win.height()
  1128. },
  1129. true
  1130. );
  1131. layero.find('.layui-layer-min').hide();
  1132. }, 100);
  1133. };
  1134.  
  1135. //改变title
  1136. layer.title = function (name, index) {
  1137. var title = $('#' + doms[0] + (index || layer.index)).find(doms[1]);
  1138. title.html(name);
  1139. };
  1140.  
  1141. //关闭layer总方法
  1142. layer.close = function (index, callback) {
  1143. var layero = $('#' + doms[0] + index),
  1144. type = layero.attr('type'),
  1145. closeAnim = 'layer-anim-close';
  1146. if (!layero[0]) return;
  1147. var WRAP = 'layui-layer-wrap',
  1148. remove = function () {
  1149. if (type === ready.type[1] && layero.attr('conType') === 'object') {
  1150. layero.children(':not(.' + doms[5] + ')').remove();
  1151. var wrap = layero.find('.' + WRAP);
  1152. for (var i = 0; i < 2; i++) {
  1153. wrap.unwrap();
  1154. }
  1155. wrap.css('display', wrap.data('display')).removeClass(WRAP);
  1156. } else {
  1157. //低版本IE 回收 iframe
  1158. if (type === ready.type[2]) {
  1159. try {
  1160. var iframe = $('#' + doms[4] + index)[0];
  1161. iframe.contentWindow.document.write('');
  1162. iframe.contentWindow.close();
  1163. layero.find('.' + doms[5])[0].removeChild(iframe);
  1164. } catch (e) {}
  1165. }
  1166. layero[0].innerHTML = '';
  1167. layero.remove();
  1168. }
  1169. typeof ready.end[index] === 'function' && ready.end[index]();
  1170. delete ready.end[index];
  1171. typeof callback === 'function' && callback();
  1172. };
  1173.  
  1174. if (layero.data('isOutAnim')) {
  1175. layero.addClass('layer-anim ' + closeAnim);
  1176. }
  1177.  
  1178. $('#layui-layer-moves, #' + doms.SHADE + index).remove();
  1179. layer.ie == 6 && ready.reselect();
  1180. ready.rescollbar(index);
  1181. if (layero.attr('minLeft')) {
  1182. ready.minIndex--;
  1183. ready.minLeft.push(layero.attr('minLeft'));
  1184. }
  1185.  
  1186. if ((layer.ie && layer.ie < 10) || !layero.data('isOutAnim')) {
  1187. remove();
  1188. } else {
  1189. setTimeout(function () {
  1190. remove();
  1191. }, 200);
  1192. }
  1193. };
  1194.  
  1195. //关闭所有层
  1196. layer.closeAll = function (type, callback) {
  1197. if (typeof type === 'function') {
  1198. callback = type;
  1199. type = null;
  1200. }
  1201. var domsElem = $('.' + doms[0]);
  1202. $.each(domsElem, function (_index) {
  1203. var othis = $(this);
  1204. var is = type ? othis.attr('type') === type : 1;
  1205. is && layer.close(othis.attr('times'), _index === domsElem.length - 1 ? callback : null);
  1206. is = null;
  1207. });
  1208. if (domsElem.length === 0) typeof callback === 'function' && callback();
  1209. };
  1210.  
  1211. /**
  1212.  
  1213. 拓展模块,layui 开始合并在一起
  1214.  
  1215. */
  1216.  
  1217. var cache = layer.cache || {},
  1218. skin = function (type) {
  1219. return cache.skin ? ' ' + cache.skin + ' ' + cache.skin + '-' + type : '';
  1220. };
  1221.  
  1222. //仿系统prompt
  1223. layer.prompt = function (options, yes) {
  1224. var style = '';
  1225. options = options || {};
  1226.  
  1227. if (typeof options === 'function') yes = options;
  1228.  
  1229. if (options.area) {
  1230. var area = options.area;
  1231. style = 'style="width: ' + area[0] + '; height: ' + area[1] + ';"';
  1232. delete options.area;
  1233. }
  1234. var prompt,
  1235. content =
  1236. options.formType == 2
  1237. ? '<textarea class="layui-layer-input"' + style + '></textarea>'
  1238. : (function () {
  1239. return '<input type="' + (options.formType == 1 ? 'password' : 'text') + '" class="layui-layer-input">';
  1240. })();
  1241.  
  1242. var success = options.success;
  1243. delete options.success;
  1244.  
  1245. return layer.open(
  1246. $.extend(
  1247. {
  1248. type: 1,
  1249. btn: ['&#x786E;&#x5B9A;', '&#x53D6;&#x6D88;'],
  1250. content: content,
  1251. skin: 'layui-layer-prompt' + skin('prompt'),
  1252. maxWidth: win.width(),
  1253. success: function (layero) {
  1254. prompt = layero.find('.layui-layer-input');
  1255. prompt.val(options.value || '').focus();
  1256. typeof success === 'function' && success(layero);
  1257. },
  1258. resize: false,
  1259. yes: function (index) {
  1260. var value = prompt.val();
  1261. if (value === '') {
  1262. prompt.focus();
  1263. } else if (value.length > (options.maxlength || 500)) {
  1264. layer.tips('&#x6700;&#x591A;&#x8F93;&#x5165;' + (options.maxlength || 500) + '&#x4E2A;&#x5B57;&#x6570;', prompt, {
  1265. tips: 1
  1266. });
  1267. } else {
  1268. yes && yes(value, index, prompt);
  1269. }
  1270. }
  1271. },
  1272. options
  1273. )
  1274. );
  1275. };
  1276.  
  1277. //tab层
  1278. layer.tab = function (options) {
  1279. options = options || {};
  1280.  
  1281. var tab = options.tab || {},
  1282. THIS = 'layui-this',
  1283. success = options.success;
  1284.  
  1285. delete options.success;
  1286.  
  1287. return layer.open(
  1288. $.extend(
  1289. {
  1290. type: 1,
  1291. skin: 'layui-layer-tab' + skin('tab'),
  1292. resize: false,
  1293. title: (function () {
  1294. var len = tab.length,
  1295. ii = 1,
  1296. str = '';
  1297. if (len > 0) {
  1298. str = '<span class="' + THIS + '">' + tab[0].title + '</span>';
  1299. for (; ii < len; ii++) {
  1300. str += '<span>' + tab[ii].title + '</span>';
  1301. }
  1302. }
  1303. return str;
  1304. })(),
  1305. content:
  1306. '<ul class="layui-layer-tabmain">' +
  1307. (function () {
  1308. var len = tab.length,
  1309. ii = 1,
  1310. str = '';
  1311. if (len > 0) {
  1312. str = '<li class="layui-layer-tabli ' + THIS + '">' + (tab[0].content || 'no content') + '</li>';
  1313. for (; ii < len; ii++) {
  1314. str += '<li class="layui-layer-tabli">' + (tab[ii].content || 'no content') + '</li>';
  1315. }
  1316. }
  1317. return str;
  1318. })() +
  1319. '</ul>',
  1320. success: function (layero) {
  1321. var btn = layero.find('.layui-layer-title').children();
  1322. var main = layero.find('.layui-layer-tabmain').children();
  1323. btn.on('mousedown', function (e) {
  1324. e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
  1325. var othis = $(this),
  1326. index = othis.index();
  1327. othis.addClass(THIS).siblings().removeClass(THIS);
  1328. main.eq(index).show().siblings().hide();
  1329. typeof options.change === 'function' && options.change(index);
  1330. });
  1331. typeof success === 'function' && success(layero);
  1332. }
  1333. },
  1334. options
  1335. )
  1336. );
  1337. };
  1338.  
  1339. //相册层
  1340. layer.photos = function (options, loop, key) {
  1341. var dict = {};
  1342. options = options || {};
  1343. if (!options.photos) return;
  1344.  
  1345. //若 photos 并非选择器或 jQuery 对象,则为普通 object
  1346. var isObject = !(typeof options.photos === 'string' || options.photos instanceof $),
  1347. photos = isObject ? options.photos : {},
  1348. data = photos.data || [],
  1349. start = photos.start || 0;
  1350.  
  1351. dict.imgIndex = (start | 0) + 1;
  1352. options.img = options.img || 'img';
  1353.  
  1354. var success = options.success;
  1355. delete options.success;
  1356.  
  1357. //如果 options.photos 不是一个对象
  1358. if (!isObject) {
  1359. //页面直接获取
  1360. var parent = $(options.photos),
  1361. pushData = function () {
  1362. data = [];
  1363. parent.find(options.img).each(function (index) {
  1364. var othis = $(this);
  1365. othis.attr('layer-index', index);
  1366. data.push({
  1367. alt: othis.attr('alt'),
  1368. pid: othis.attr('layer-pid'),
  1369. src: othis.attr('layer-src') || othis.attr('src'),
  1370. thumb: othis.attr('src')
  1371. });
  1372. });
  1373. };
  1374.  
  1375. pushData();
  1376.  
  1377. if (data.length === 0) return;
  1378.  
  1379. loop ||
  1380. parent.on('click', options.img, function () {
  1381. pushData();
  1382. var othis = $(this),
  1383. index = othis.attr('layer-index');
  1384. layer.photos(
  1385. $.extend(options, {
  1386. photos: {
  1387. start: index,
  1388. data: data,
  1389. tab: options.tab
  1390. },
  1391. full: options.full
  1392. }),
  1393. true
  1394. );
  1395. });
  1396.  
  1397. //不直接弹出
  1398. if (!loop) return;
  1399. } else if (data.length === 0) {
  1400. return layer.msg('&#x6CA1;&#x6709;&#x56FE;&#x7247;');
  1401. }
  1402.  
  1403. //上一张
  1404. dict.imgprev = function (key) {
  1405. dict.imgIndex--;
  1406. if (dict.imgIndex < 1) {
  1407. dict.imgIndex = data.length;
  1408. }
  1409. dict.tabimg(key);
  1410. };
  1411.  
  1412. //下一张
  1413. dict.imgnext = function (key, errorMsg) {
  1414. dict.imgIndex++;
  1415. if (dict.imgIndex > data.length) {
  1416. dict.imgIndex = 1;
  1417. if (errorMsg) {
  1418. return;
  1419. }
  1420. }
  1421. dict.tabimg(key);
  1422. };
  1423.  
  1424. //方向键
  1425. dict.keyup = function (event) {
  1426. if (!dict.end) {
  1427. var code = event.keyCode;
  1428. event.preventDefault();
  1429. if (code === 37) {
  1430. dict.imgprev(true);
  1431. } else if (code === 39) {
  1432. dict.imgnext(true);
  1433. } else if (code === 27) {
  1434. layer.close(dict.index);
  1435. }
  1436. }
  1437. };
  1438.  
  1439. //切换
  1440. dict.tabimg = function (key) {
  1441. if (data.length <= 1) return;
  1442. photos.start = dict.imgIndex - 1;
  1443. layer.close(dict.index);
  1444. return layer.photos(options, true, key);
  1445. setTimeout(function () {
  1446. layer.photos(options, true, key);
  1447. }, 200);
  1448. };
  1449.  
  1450. //一些动作
  1451. dict.event = function () {
  1452. /*
  1453. dict.bigimg.hover(function(){
  1454. dict.imgsee.show();
  1455. }, function(){
  1456. dict.imgsee.hide();
  1457. });
  1458. */
  1459.  
  1460. dict.bigimg.find('.layui-layer-imgprev').on('click', function (event) {
  1461. event.preventDefault();
  1462. dict.imgprev(true);
  1463. });
  1464.  
  1465. dict.bigimg.find('.layui-layer-imgnext').on('click', function (event) {
  1466. event.preventDefault();
  1467. dict.imgnext(true);
  1468. });
  1469.  
  1470. $(document).on('keyup', dict.keyup);
  1471. };
  1472.  
  1473. //图片预加载
  1474. function loadImage(url, callback, error) {
  1475. var img = new Image();
  1476. img.src = url;
  1477. if (img.complete) {
  1478. return callback(img);
  1479. }
  1480. img.onload = function () {
  1481. img.onload = null;
  1482. callback(img);
  1483. };
  1484. img.onerror = function (e) {
  1485. img.onerror = null;
  1486. error(e);
  1487. };
  1488. }
  1489.  
  1490. dict.loadi = layer.load(1, {
  1491. shade: 'shade' in options ? false : 0.9,
  1492. scrollbar: false
  1493. });
  1494.  
  1495. loadImage(
  1496. data[start].src,
  1497. function (img) {
  1498. layer.close(dict.loadi);
  1499.  
  1500. //切换图片时不出现动画
  1501. if (key) options.anim = -1;
  1502.  
  1503. //弹出图片层
  1504. dict.index = layer.open(
  1505. $.extend(
  1506. {
  1507. type: 1,
  1508. id: 'layui-layer-photos',
  1509. area: (function () {
  1510. var imgarea = [img.width, img.height];
  1511. var winarea = [$(window).width() - 100, $(window).height() - 100];
  1512.  
  1513. //如果 实际图片的宽或者高比 屏幕大(那么进行缩放)
  1514. if (!options.full && (imgarea[0] > winarea[0] || imgarea[1] > winarea[1])) {
  1515. var wh = [imgarea[0] / winarea[0], imgarea[1] / winarea[1]]; //取宽度缩放比例、高度缩放比例
  1516. if (wh[0] > wh[1]) {
  1517. //取缩放比例最大的进行缩放
  1518. imgarea[0] = imgarea[0] / wh[0];
  1519. imgarea[1] = imgarea[1] / wh[0];
  1520. } else if (wh[0] < wh[1]) {
  1521. imgarea[0] = imgarea[0] / wh[1];
  1522. imgarea[1] = imgarea[1] / wh[1];
  1523. }
  1524. }
  1525.  
  1526. return [imgarea[0] + 'px', imgarea[1] + 'px'];
  1527. })(),
  1528. title: false,
  1529. shade: 0.9,
  1530. shadeClose: true,
  1531. closeBtn: false,
  1532. move: '.layui-layer-phimg img',
  1533. moveType: 1,
  1534. scrollbar: false,
  1535. moveOut: true,
  1536. anim: 5,
  1537. isOutAnim: false,
  1538. skin: 'layui-layer-photos' + skin('photos'),
  1539. content:
  1540. '<div class="layui-layer-phimg">' +
  1541. '<img src="' +
  1542. data[start].src +
  1543. '" alt="' +
  1544. (data[start].alt || '') +
  1545. '" layer-pid="' +
  1546. data[start].pid +
  1547. '">' +
  1548. (function () {
  1549. if (data.length > 1) {
  1550. return (
  1551. '<div class="layui-layer-imgsee">' +
  1552. '<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>' +
  1553. '<div class="layui-layer-imgbar" style="display:' +
  1554. (key ? 'block' : '') +
  1555. '"><span class="layui-layer-imgtit"><a href="javascript:;">' +
  1556. (data[start].alt || '') +
  1557. '</a><em>' +
  1558. dict.imgIndex +
  1559. ' / ' +
  1560. data.length +
  1561. '</em></span></div>' +
  1562. '</div>'
  1563. );
  1564. }
  1565. return '';
  1566. })() +
  1567. '</div>',
  1568. success: function (layero, index) {
  1569. dict.bigimg = layero.find('.layui-layer-phimg');
  1570. dict.imgsee = layero.find('.layui-layer-imgbar');
  1571. dict.event(layero);
  1572. options.tab && options.tab(data[start], layero);
  1573. typeof success === 'function' && success(layero);
  1574. },
  1575. end: function () {
  1576. dict.end = true;
  1577. $(document).off('keyup', dict.keyup);
  1578. }
  1579. },
  1580. options
  1581. )
  1582. );
  1583. },
  1584. function () {
  1585. layer.close(dict.loadi);
  1586. layer.msg(
  1587. '&#x5F53;&#x524D;&#x56FE;&#x7247;&#x5730;&#x5740;&#x5F02;&#x5E38;<br>&#x662F;&#x5426;&#x7EE7;&#x7EED;&#x67E5;&#x770B;&#x4E0B;&#x4E00;&#x5F20;&#xFF1F;',
  1588. {
  1589. time: 30000,
  1590. btn: ['&#x4E0B;&#x4E00;&#x5F20;', '&#x4E0D;&#x770B;&#x4E86;'],
  1591. yes: function () {
  1592. data.length > 1 && dict.imgnext(true, true);
  1593. }
  1594. }
  1595. );
  1596. }
  1597. );
  1598. };
  1599.  
  1600. //主入口
  1601. ready.run = function (_$) {
  1602. $ = _$;
  1603. win = $(window);
  1604. doms.html = $('html');
  1605. layer.open = function (deliver) {
  1606. var o = new Class(deliver);
  1607. return o.index;
  1608. };
  1609. };
  1610.  
  1611. //加载方式
  1612. window.layui && layui.define
  1613. ? (layer.ready(),
  1614. layui.define('jquery', function (exports) {
  1615. //layui 加载
  1616. layer.path = layui.cache.dir;
  1617. ready.run(layui.$);
  1618.  
  1619. //暴露模块
  1620. window.layer = layer;
  1621. exports('layer', layer);
  1622. }))
  1623. : typeof define === 'function' && define.amd
  1624. ? define(['jquery'], function () {
  1625. //requirejs 加载
  1626. ready.run(window.jQuery);
  1627. return layer;
  1628. })
  1629. : (function () {
  1630. //普通 script 标签加载
  1631. // console.log('layer.ready();===========');
  1632. layer.ready();
  1633. ready.run(window.jQuery);
  1634. })();
  1635. })(window);
  1636.  
  1637. function AddLayerStyle(){
  1638. GM_addStyle(`
  1639. html #layuicss-layer{display: none; position: absolute; width: 1989px;}
  1640.  
  1641. /* common */
  1642. .layui-layer-shade, .layui-layer{position:fixed; _position:absolute; pointer-events: auto;}
  1643. .layui-layer-shade{top:0; left:0; width:100%; height:100%; _height:expression(document.body.offsetHeight+"px");}
  1644. .layui-layer{-webkit-overflow-scrolling: touch;}
  1645. .layui-layer{top:150px; left: 0; margin:0; padding:0; background-color:#fff; -webkit-background-clip: content; border-radius: 2px; box-shadow: 1px 1px 50px rgba(0,0,0,.3);}
  1646. .layui-layer-close{position:absolute;}
  1647. .layui-layer-content{position:relative;}
  1648. .layui-layer-border{border: 1px solid #B2B2B2; border: 1px solid rgba(0,0,0,.1); box-shadow: 1px 1px 5px rgba(0,0,0,.2);}
  1649. .layui-layer-load{background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/loading-1.gif) #eee center center no-repeat;}
  1650. .layui-layer-ico{ background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/icon.png) no-repeat;}
  1651. .layui-layer-dialog .layui-layer-ico,
  1652. .layui-layer-setwin a,
  1653. .layui-layer-btn a{display:inline-block; *display:inline; *zoom:1; vertical-align:top;}
  1654. .layui-layer-move{display: none; position: fixed; *position: absolute; left: 0px; top: 0px; width: 100%; height: 100%; cursor: move; opacity: 0; filter:alpha(opacity=0); background-color: #fff; z-index: 2147483647;}
  1655. .layui-layer-resize{position: absolute; width: 15px; height: 15px; right: 0; bottom: 0; cursor: se-resize;}
  1656.  
  1657. /* 动画 */
  1658. .layer-anim{-webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.3s; animation-duration:.3s;}
  1659.  
  1660. @-webkit-keyframes layer-bounceIn { /* 默认 */
  1661. 0% {opacity: 0; -webkit-transform: scale(.5); transform: scale(.5)}
  1662. 100% {opacity: 1; -webkit-transform: scale(1); transform: scale(1)}
  1663. }
  1664. @keyframes layer-bounceIn {
  1665. 0% {opacity: 0; -webkit-transform: scale(.5); -ms-transform: scale(.5); transform: scale(.5)}
  1666. 100% {opacity: 1; -webkit-transform: scale(1); -ms-transform: scale(1); transform: scale(1)}
  1667. }
  1668. .layer-anim-00{-webkit-animation-name: layer-bounceIn;animation-name: layer-bounceIn}
  1669.  
  1670. @-webkit-keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInDown{0%{opacity:0;-webkit-transform:scale(.1) translateY(-2000px);-ms-transform:scale(.1) translateY(-2000px);transform:scale(.1) translateY(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateY(60px);-ms-transform:scale(.475) translateY(60px);transform:scale(.475) translateY(60px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-01{-webkit-animation-name:layer-zoomInDown;animation-name:layer-zoomInDown}
  1671. @-webkit-keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);transform:translateY(0)}}@keyframes layer-fadeInUpBig{0%{opacity:0;-webkit-transform:translateY(2000px);-ms-transform:translateY(2000px);transform:translateY(2000px)}100%{opacity:1;-webkit-transform:translateY(0);-ms-transform:translateY(0);transform:translateY(0)}}.layer-anim-02{-webkit-animation-name:layer-fadeInUpBig;animation-name:layer-fadeInUpBig}
  1672. @-webkit-keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes layer-zoomInLeft{0%{opacity:0;-webkit-transform:scale(.1) translateX(-2000px);-ms-transform:scale(.1) translateX(-2000px);transform:scale(.1) translateX(-2000px);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}60%{opacity:1;-webkit-transform:scale(.475) translateX(48px);-ms-transform:scale(.475) translateX(48px);transform:scale(.475) translateX(48px);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.layer-anim-03{-webkit-animation-name:layer-zoomInLeft;animation-name:layer-zoomInLeft}
  1673. @-webkit-keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}@keyframes layer-rollIn{0%{opacity:0;-webkit-transform:translateX(-100%) rotate(-120deg);-ms-transform:translateX(-100%) rotate(-120deg);transform:translateX(-100%) rotate(-120deg)}100%{opacity:1;-webkit-transform:translateX(0px) rotate(0deg);-ms-transform:translateX(0px) rotate(0deg);transform:translateX(0px) rotate(0deg)}}.layer-anim-04{-webkit-animation-name:layer-rollIn;animation-name:layer-rollIn}
  1674. @keyframes layer-fadeIn{0%{opacity:0}100%{opacity:1}}.layer-anim-05{-webkit-animation-name:layer-fadeIn;animation-name:layer-fadeIn}
  1675. @-webkit-keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);transform:translateX(10px)}}@keyframes layer-shake{0%,100%{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}10%,30%,50%,70%,90%{-webkit-transform:translateX(-10px);-ms-transform:translateX(-10px);transform:translateX(-10px)}20%,40%,60%,80%{-webkit-transform:translateX(10px);-ms-transform:translateX(10px);transform:translateX(10px)}}.layer-anim-06{-webkit-animation-name:layer-shake;animation-name:layer-shake}@-webkit-keyframes fadeIn{0%{opacity:0}100%{opacity:1}}
  1676.  
  1677. /* 标题栏 */
  1678. .layui-layer-title{padding:0 80px 0 20px; height: 50px; line-height: 50px; border-bottom:1px solid #F0F0F0; font-size: 14px; color:#333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 2px 2px 0 0;}
  1679. .layui-layer-setwin{position:absolute; right: 15px; *right:0; top: 17px; font-size:0; line-height: initial;}
  1680. .layui-layer-setwin a{position:relative; width: 16px; height:16px; margin-left:10px; font-size:12px; _overflow:hidden;}
  1681. .layui-layer-setwin .layui-layer-min cite{position:absolute; width:14px; height:2px; left:0; top:50%; margin-top:-1px; background-color:#2E2D3C; cursor:pointer; _overflow:hidden;}
  1682. .layui-layer-setwin .layui-layer-min:hover cite{background-color:#2D93CA; }
  1683. .layui-layer-setwin .layui-layer-max{background-position:-32px -40px;}
  1684. .layui-layer-setwin .layui-layer-max:hover{background-position:-16px -40px;}
  1685. .layui-layer-setwin .layui-layer-maxmin{background-position:-65px -40px;}
  1686. .layui-layer-setwin .layui-layer-maxmin:hover{background-position:-49px -40px;}
  1687. .layui-layer-setwin .layui-layer-close1{background-position: 1px -40px; cursor: pointer;}
  1688. .layui-layer-setwin .layui-layer-close1:hover{opacity:0.7;}
  1689. .layui-layer-setwin .layui-layer-close2{position:absolute; right:-28px; top:-28px; width:30px; height:30px; margin-left:0; background-position:-149px -31px; *right:-18px; _display:none;}
  1690. .layui-layer-setwin .layui-layer-close2:hover{ background-position:-180px -31px;}
  1691.  
  1692. /* 按钮栏 */
  1693. .layui-layer-btn{text-align: right; padding: 0 15px 12px; pointer-events: auto; user-select: none; -webkit-user-select: none;}
  1694. .layui-layer-btn a{height: 28px; line-height: 28px; margin: 5px 5px 0; padding: 0 15px; border: 1px solid #dedede; background-color:#fff; color: #333; border-radius: 2px; font-weight:400; cursor:pointer; text-decoration: none;}
  1695. .layui-layer-btn a:hover{opacity: 0.9; text-decoration: none;}
  1696. .layui-layer-btn a:active{opacity: 0.8;}
  1697. .layui-layer-btn .layui-layer-btn0{border-color: #1E9FFF; background-color: #1E9FFF; color:#fff;}
  1698. .layui-layer-btn-l{text-align: left;}
  1699. .layui-layer-btn-c{text-align: center;}
  1700.  
  1701. /* 定制化 */
  1702. .layui-layer-dialog{min-width: 300px;}
  1703. .layui-layer-dialog .layui-layer-content{position: relative; padding:20px; line-height:24px; word-break: break-all; overflow:hidden; font-size:14px; overflow-x: hidden; overflow-y:auto;}
  1704. .layui-layer-dialog .layui-layer-content .layui-layer-ico{position:absolute; top:16px; left:15px; _left:-40px; width:30px; height:30px;}
  1705. .layui-layer-ico1{background-position:-30px 0 }
  1706. .layui-layer-ico2{background-position:-60px 0;}
  1707. .layui-layer-ico3{background-position:-90px 0;}
  1708. .layui-layer-ico4{background-position:-120px 0;}
  1709. .layui-layer-ico5{background-position:-150px 0;}
  1710. .layui-layer-ico6{background-position:-180px 0;}
  1711. .layui-layer-rim{border:6px solid #8D8D8D; border:6px solid rgba(0,0,0,.3); border-radius:5px; box-shadow: none;}
  1712. .layui-layer-msg{min-width:180px; border:1px solid #D3D4D3; box-shadow: none;}
  1713. .layui-layer-hui{min-width:100px; background-color: #000; filter:alpha(opacity=60); background-color: rgba(0,0,0,0.6); color: #fff; border:none;}
  1714. .layui-layer-hui .layui-layer-content{padding:12px 25px; text-align:center;}
  1715. .layui-layer-dialog .layui-layer-padding{padding: 20px 20px 20px 55px; text-align: left;}
  1716. .layui-layer-page .layui-layer-content{position:relative; overflow:auto;}
  1717. .layui-layer-page .layui-layer-btn,.layui-layer-iframe .layui-layer-btn{padding-top:10px;}
  1718. .layui-layer-nobg{background:none;}
  1719. .layui-layer-iframe iframe{display: block; width: 100%;}
  1720.  
  1721. .layui-layer-loading{border-radius:100%; background:none; box-shadow:none; border:none;}
  1722. .layui-layer-loading .layui-layer-content{width:60px; height:24px; background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/loading-0.gif) no-repeat;}
  1723. .layui-layer-loading .layui-layer-loading1{width:37px; height:37px; background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/loading-1.gif) no-repeat;}
  1724. .layui-layer-loading .layui-layer-loading2, .layui-layer-ico16{width:32px; height:32px; background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/loading-2.gif) no-repeat;}
  1725. .layui-layer-tips{background: none; box-shadow:none; border:none;}
  1726. .layui-layer-tips .layui-layer-content{position: relative; line-height: 22px; min-width: 12px; padding: 8px 15px; font-size: 12px; _float:left; border-radius: 2px; box-shadow: 1px 1px 3px rgba(0,0,0,.2); background-color: #000; color: #fff;}
  1727. .layui-layer-tips .layui-layer-close{right:-2px; top:-1px;}
  1728. .layui-layer-tips i.layui-layer-TipsG{ position:absolute; width:0; height:0; border-width:8px; border-color:transparent; border-style:dashed; *overflow:hidden;}
  1729. .layui-layer-tips i.layui-layer-TipsT, .layui-layer-tips i.layui-layer-TipsB{left:5px; border-right-style:solid; border-right-color: #000;}
  1730. .layui-layer-tips i.layui-layer-TipsT{bottom:-8px;}
  1731. .layui-layer-tips i.layui-layer-TipsB{top:-8px;}
  1732. .layui-layer-tips i.layui-layer-TipsR, .layui-layer-tips i.layui-layer-TipsL{top: 5px; border-bottom-style:solid; border-bottom-color: #000;}
  1733. .layui-layer-tips i.layui-layer-TipsR{left:-8px;}
  1734. .layui-layer-tips i.layui-layer-TipsL{right:-8px;}
  1735.  
  1736. /* skin */
  1737. .layui-layer-lan[type="dialog"]{min-width:280px;}
  1738. .layui-layer-lan .layui-layer-title{background:#4476A7; color:#fff; border: none;}
  1739. .layui-layer-lan .layui-layer-btn{padding: 5px 10px 10px; text-align: right; border-top:1px solid #E9E7E7}
  1740. .layui-layer-lan .layui-layer-btn a{background: #fff; border-color: #E9E7E7; color: #333;}
  1741. .layui-layer-lan .layui-layer-btn .layui-layer-btn1{background:#C9C5C5;}
  1742. .layui-layer-molv .layui-layer-title{background: #009f95; color:#fff; border: none;}
  1743. .layui-layer-molv .layui-layer-btn a{background: #009f95; border-color: #009f95;}
  1744. .layui-layer-molv .layui-layer-btn .layui-layer-btn1{background:#92B8B1;}
  1745.  
  1746. .layui-layer-iconext{background:url(https://cdn.bootcdn.net/ajax/libs/layer/3.5.1/theme/default/icon-ext.png) no-repeat;}
  1747.  
  1748. /* prompt模式 */
  1749. .layui-layer-prompt .layui-layer-input{display: block; width: 260px; height: 36px; margin: 0 auto; line-height: 30px; padding-left: 10px; border: 1px solid #e6e6e6; color: #333;}
  1750. .layui-layer-prompt textarea.layui-layer-input{width: 300px; height: 100px; line-height: 20px; padding: 6px 10px;}
  1751. .layui-layer-prompt .layui-layer-content{padding: 20px;}
  1752. .layui-layer-prompt .layui-layer-btn{padding-top: 0;}
  1753.  
  1754. /* tab模式 */
  1755. .layui-layer-tab{box-shadow:1px 1px 50px rgba(0,0,0,.4);}
  1756. .layui-layer-tab .layui-layer-title{padding-left:0; overflow: visible;}
  1757. .layui-layer-tab .layui-layer-title span{position:relative; float:left; min-width:80px; max-width: 300px; padding:0 20px; text-align:center; cursor:default; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; cursor: pointer;}
  1758. .layui-layer-tab .layui-layer-title span.layui-this{height: 51px; border-left: 1px solid #eee; border-right: 1px solid #eee; background-color: #fff; z-index: 10;}
  1759. .layui-layer-tab .layui-layer-title span:first-child{border-left:none;}
  1760. .layui-layer-tabmain{line-height:24px; clear:both;}
  1761. .layui-layer-tabmain .layui-layer-tabli{display:none;}
  1762. .layui-layer-tabmain .layui-layer-tabli.layui-this{display: block;}
  1763.  
  1764. /* photo模式 */
  1765. .layui-layer-photos{background: none; box-shadow: none;}
  1766. .layui-layer-photos .layui-layer-content{overflow:hidden; text-align: center;}
  1767. .layui-layer-photos .layui-layer-phimg img{position: relative; width:100%; display: inline-block; *display:inline; *zoom:1; vertical-align:top;}
  1768. .layui-layer-imgprev, .layui-layer-imgnext{position: fixed; top: 50%; width: 27px; _width: 44px; height: 44px; margin-top:-22px; outline:none;blr:expression(this.onFocus=this.blur());}
  1769. .layui-layer-imgprev{left: 30px; background-position:-5px -5px; _background-position:-70px -5px;}
  1770. .layui-layer-imgprev:hover{background-position:-33px -5px; _background-position:-120px -5px;}
  1771. .layui-layer-imgnext{right: 30px; _right:8px; background-position:-5px -50px; _background-position:-70px -50px;}
  1772. .layui-layer-imgnext:hover{background-position: -33px -50px; _background-position: -120px -50px;}
  1773. .layui-layer-imgbar{position: fixed; left:0; right: 0; bottom:0; width:100%; height: 40px; line-height: 40px; background-color:#000; filter:Alpha(opacity=60); background-color: rgba(2,0,0,.35); color: #fff; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; font-size:0;}
  1774. .layui-layer-imgtit{}
  1775. .layui-layer-imgtit *{display:inline-block; *display:inline; *zoom:1; vertical-align:top; font-size:12px;}
  1776. .layui-layer-imgtit a{max-width:65%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; color:#fff;}
  1777. .layui-layer-imgtit a:hover{color:#fff; text-decoration:underline;}
  1778. .layui-layer-imgtit em{padding-left:10px; font-style: normal;}
  1779.  
  1780. /* 关闭动画 */
  1781. @-webkit-keyframes layer-bounceOut {
  1782. 100% {opacity: 0; -webkit-transform: scale(.7); transform: scale(.7)}
  1783. 30% {-webkit-transform: scale(1.05); transform: scale(1.05)}
  1784. 0% {-webkit-transform: scale(1); transform: scale(1);}
  1785. }
  1786. @keyframes layer-bounceOut {
  1787. 100% {opacity: 0; -webkit-transform: scale(.7); -ms-transform: scale(.7); transform: scale(.7);}
  1788. 30% {-webkit-transform: scale(1.05); -ms-transform: scale(1.05); transform: scale(1.05);}
  1789. 0% {-webkit-transform: scale(1); -ms-transform: scale(1);transform: scale(1);}
  1790. }
  1791. .layer-anim-close{-webkit-animation-name: layer-bounceOut; animation-name: layer-bounceOut; -webkit-animation-fill-mode: both; animation-fill-mode: both; -webkit-animation-duration:.2s; animation-duration:.2s;}
  1792.  
  1793. @media screen and (max-width: 1100px) {
  1794. .layui-layer-iframe{overflow-y: auto; -webkit-overflow-scrolling: touch;}
  1795. }
  1796. `);
  1797. }