layuimini.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214
  1. /**
  2. * date:2019/06/10
  3. * author:Mr.Chung
  4. * description:layuimini 框架扩展
  5. */
  6. var _this = $(this)
  7. layui.define(["element", "jquery"], function (exports) {
  8. var element = layui.element,
  9. // $ = layui.$,
  10. layer = layui.layer;
  11. // 判断是否在web容器中打开
  12. if (!/http(s*):\/\//.test(location.href)) {
  13. return layer.alert("请先将项目部署至web容器(Apache/Tomcat/Nginx/IIS/等),否则部分数据将无法显示");
  14. }
  15. layuimini = new function () {
  16. /**
  17. * 系统配置
  18. * @param name
  19. * @returns {{BgColorDefault: number, urlSuffixDefault: boolean}|*}
  20. */
  21. this.config = function (name) {
  22. var config = {
  23. urlHashLocation: true, // URL地址hash定位
  24. urlSuffixDefault: true, // URL后缀
  25. BgColorDefault: 0, // 默认皮肤(0开始)
  26. checkUrlDefault: false, // 是否判断URL有效
  27. };
  28. if (name == undefined) {
  29. return config;
  30. } else {
  31. return config[name];
  32. }
  33. };
  34. /**
  35. * 初始化
  36. * @param url
  37. */
  38. this.init = function (data, tag) {
  39. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  40. layuimini.initBgColor();
  41. layuimini.initDevice();
  42. if (tag) {
  43. layuimini.initHome(data.homeInfo);
  44. layuimini.initLogo(data.logoInfo);
  45. layuimini.initClear(data.clearInfo);
  46. layuimini.initMenu(data.menuInfo);
  47. layuimini.initTab();
  48. } else {
  49. $.getJSON(data, function (data, status) {
  50. if (data == null) {
  51. layuimini.msg_error('暂无菜单信息');
  52. } else {
  53. layuimini.initHome(data.homeInfo);
  54. layuimini.initLogo(data.logoInfo);
  55. layuimini.initClear(data.clearInfo);
  56. layuimini.initMenu(data.menuInfo);
  57. layuimini.initTab();
  58. }
  59. }).fail(function () {
  60. layuimini.msg_error('菜单接口有误');
  61. });
  62. }
  63. layer.close(loading);
  64. };
  65. /**
  66. * 初始化设备端
  67. */
  68. this.initDevice = function () {
  69. if (layuimini.checkMobile()) {
  70. $('.layuimini-tool i').attr('data-side-fold', 0);
  71. $('.layuimini-tool i').attr('class', 'fa fa-indent');
  72. $('.layui-layout-body').attr('class', 'layui-layout-body layuimini-mini');
  73. }
  74. };
  75. /**
  76. * 初始化首页信息
  77. * @param data
  78. */
  79. this.initHome = function (data) {
  80. sessionStorage.setItem('layuiminiHomeHref', data.href);
  81. $('#layuiminiHomeTabId').html('<i class="' + data.icon + '"></i> <span>' + data.title + '</span>');
  82. $('#layuiminiHomeTabId').attr('lay-id', data.href);
  83. $('#layuiminiHomeTabIframe').html('<iframe width="100%" height="100%" frameborder="0" src="' + data.href + '"></iframe>');
  84. };
  85. /**
  86. * 初始化logo信息
  87. * @param data
  88. */
  89. this.initLogo = function (data) {
  90. var html = '<a href="' + data.href + '">\n' +
  91. '<img src="' + data.image + '" alt="logo">\n' +
  92. '<h1>' + data.title + '</h1>\n' +
  93. '</a>';
  94. $('.layui-layout-admin .layui-logo').html(html);
  95. };
  96. /**
  97. * 初始化清理缓存
  98. * @param data
  99. */
  100. this.initClear = function (data) {
  101. $('.layuimini-clear').attr('data-href', data.clearUrl);
  102. };
  103. /*搜索导航栏绑定事件*/
  104. this.bindFunction = function () {
  105. var selectList = []
  106. $('.layuimini-mini .searchEvent-mini').off('click').click(function () {
  107. $('.mc-hover-show').animate({ left: '60px' })
  108. $('.mc-hover-show input').focus()
  109. })
  110. $('.mc-hover-show input').blur(function () {
  111. $('.mc-hover-show').animate({ left: '-1000px' })
  112. })
  113. $('.mc-hover-show input').off('keydown').keydown(function (e) {
  114. console.log('adasdasdasd')
  115. selectList = []
  116. navList = []
  117. if (e.keyCode == 13) {
  118. var value = $(this).val()
  119. var navData = JSON.parse(sessionStorage.getItem('menu')).menuInfo.currency.child
  120. var navLsit = layuimini.getNavList(navData)
  121. if (value) {
  122. for (var i = 0; i < navLsit.length; i++) {
  123. if (navLsit[i].title.indexOf(value) != -1) {
  124. selectList.push(navLsit[i])
  125. }
  126. }
  127. var htmlStr = '<dl class="layui-nav-child tips-dd">{innerHTML}</dl>'
  128. var innerHTML = ''
  129. for (var i = 0; i < selectList.length; i++) {
  130. innerHTML += '<dd class="layui-this"><a href="javascript:;" class="layui-menu-tips" data-type="tabAdd" data-tab-mpi="m-p-i-1"data-tab="/views/login/loginInit.html" target="_self"><iclass="layui-icon layui-icon-ok-circle"></i><span class="layui-left-nav">' + selectList[i].title + '</span></a></dd>'
  131. }
  132. var html = htmlStr.replace('{innerHTML}', innerHTML)
  133. window.openTips = layer.tips(html, $(this), {
  134. tips: [2, '#2f4056'],
  135. time: 300000,
  136. skin: "popup-tips",
  137. success: function (el) {
  138. $(el).css({ left: 60, top: 30 });
  139. element.render();
  140. $('.mc-hover-show').animate({ left: '-1000px' })
  141. }
  142. });
  143. }
  144. }
  145. })
  146. $('#search').keydown(function (e) {
  147. selectList = []
  148. navList = []
  149. if (e.keyCode == 13) {
  150. var value = $('#search').val()
  151. var navData = JSON.parse(sessionStorage.getItem('menu')).menuInfo.currency.child
  152. var navLsit = layuimini.getNavList(navData)
  153. if (value) {
  154. for (var i = 0; i < navLsit.length; i++) {
  155. if (navLsit[i].title.indexOf(value) != -1) {
  156. selectList.push(navLsit[i])
  157. }
  158. }
  159. layuimini.initMenu({ currency: { child: selectList } });
  160. } else {
  161. layuimini.initMenu(JSON.parse(sessionStorage.getItem('menu')).menuInfo);
  162. }
  163. }
  164. })
  165. $('.searchEvent').click(function () {
  166. selectList = []
  167. navList = []
  168. var value = $('#search').val()
  169. var navData = JSON.parse(sessionStorage.getItem('menu')).menuInfo.currency.child
  170. var navLsit = layuimini.getNavList(navData)
  171. if (value) {
  172. for (var i = 0; i < navLsit.length; i++) {
  173. if (navLsit[i].title.indexOf(value) != -1) {
  174. selectList.push(navLsit[i])
  175. }
  176. }
  177. layuimini.initMenu({ currency: { child: selectList } });
  178. } else {
  179. layuimini.initMenu(JSON.parse(sessionStorage.getItem('menu')).menuInfo);
  180. }
  181. })
  182. }
  183. var navList = [];
  184. // 格式化导航栏数据
  185. this.getNavList = function (list) {
  186. for (var i = 0; i < list.length; i++) {
  187. if (list[i].href != '#') {
  188. navList.push({
  189. title: list[i].title,
  190. href: list[i].href,
  191. target: list[i].target
  192. })
  193. }
  194. if (list[i].child && list[i].child.length != 0) {
  195. this.getNavList(list[i].child)
  196. }
  197. }
  198. return navList
  199. }
  200. /**
  201. * 初始化背景色
  202. */
  203. this.initBgColor = function () {
  204. var bgcolorId = sessionStorage.getItem('layuiminiBgcolorId');
  205. if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') {
  206. bgcolorId = layuimini.config('BgColorDefault');
  207. }
  208. var bgcolorData = layuimini.bgColorConfig(bgcolorId);
  209. var styleHtml = '.layui-layout-admin .layui-header{background-color:' + bgcolorData.headerRight + '!important;}\n' +
  210. '.layui-header>ul>.layui-nav-item.layui-this,.layuimini-tool i:hover{background-color:' + bgcolorData.headerRightThis + '!important;}\n' +
  211. '.layui-layout-admin .layui-logo {background-color:' + bgcolorData.headerLogo + '!important;}\n' +
  212. '.layui-side.layui-bg-black,.layui-side.layui-bg-black>.layui-left-menu>ul {background-color:' + bgcolorData.menuLeft + '!important;}\n' +
  213. '.layui-left-menu .layui-nav .layui-nav-child a:hover:not(.layui-this) {background-color:' + bgcolorData.menuLeftHover + ';color:#fff !important}\n' +
  214. '.layui-layout-admin .layui-nav-tree .layui-this, .layui-layout-admin .layui-nav-tree .layui-this>a, .layui-layout-admin .layui-nav-tree .layui-nav-child dd.layui-this, .layui-layout-admin .layui-nav-tree .layui-nav-child dd.layui-this a {\n' +
  215. ' background-color: ' + bgcolorData.menuLeftThis + ' !important;color:#fff !important' +
  216. '}';
  217. if (bgcolorData.menuLeft == "#fff") {
  218. styleHtml += '.paperless .layui-left-menu .layui-nav .layui-nav-item > a:hover {'
  219. + ' background-color: #0b82ff !important;'
  220. + 'color: #fff !important; }.paperless .layui-left-menu .layui-nav .layui-nav-item > a:hover .layui-nav-more {'
  221. + 'border-color: #fff transparent transparent; }'
  222. + '.paperless .layui-nav-itemed > a:hover .layui-nav-more {'
  223. + 'border-color: transparent transparent #fff !important; }'
  224. + '.paperless .layui-nav-tree .layui-nav-child a, .paperless .paperless-v1 .layui-nav-item a {'
  225. + 'color: #333333 !important; }'
  226. + '.paperless .layui-nav-itemed > .layui-nav-child {'
  227. + 'background-color: #fff !important; }'
  228. + '.layui-layout-right .paperless .layui-nav .layui-nav-more {'
  229. + 'border-color: white transparent transparent;opacity:0.7 }'
  230. + '.paperless .layui-nav .layui-nav-mored, .paperless .layui-nav-itemed > a .layui-nav-more {'
  231. + 'border-color: transparent transparent white; }'
  232. }
  233. //全局按钮以及其他基础配色
  234. var baseHtml = '.ag-form .layui-form-select dl dd.layui-this {'
  235. + 'background-color: ' + bgcolorData.base + '; }'
  236. + '.layui-form-checked[lay-skin=primary] i {'
  237. + 'background-color: ' + bgcolorData.base + '; }'
  238. + '.layui-laypage .layui-laypage-curr .layui-laypage-em {'
  239. + 'background-color: ' + bgcolorData.base + '; }'
  240. + '.layui-btn{'
  241. + ' background-color:' + bgcolorData.base + ' ;'
  242. + ' }'
  243. + '.layui-btn-danger {'
  244. + ' background-color: #FF5722;'
  245. + ' }'
  246. + '.layui-form-radio>i:hover, .layui-form-radioed>i{'
  247. + 'color:' + bgcolorData.base + ';'
  248. + '}'
  249. var version = common.IEVersion();
  250. if (version == 8 || version == 9 || version == 7) {
  251. // var domStyle = document.getElementById("layuimini-bg-color");
  252. var cssStyle = document.createStyleSheet(); //兼容ie8
  253. cssStyle.cssText = styleHtml; //要添加的css
  254. setTimeout(function () {
  255. var agile = document.getElementsByTagName("iframe");
  256. var len = agile.length;
  257. for (var i = 0; i < len; i++) {
  258. // alert(agile[i].getAttribute("src"))
  259. var cssStyle2 = agile[i].contentWindow.document.createStyleSheet(); //兼容ie8
  260. cssStyle2.cssText = baseHtml; //要添加的css
  261. }
  262. }, 500)
  263. } else {
  264. setTimeout(function () {
  265. var agile = $("iframe").contents().find("#agile-color");
  266. agile.html(baseHtml)
  267. }, 500)
  268. $('#layuimini-bg-color').html(styleHtml);
  269. }
  270. };
  271. /**
  272. * 初始化菜单栏
  273. * @param data
  274. */
  275. this.initMenu = function (data) {
  276. var headerMenuHtml = '',
  277. headerMobileMenuHtml = '',
  278. leftMenuHtml = '',
  279. headerMenuCheckDefault = 'layui-this',
  280. leftMenuCheckDefault = 'layui-this';
  281. window.menuParameId = 1;
  282. console.log(data)
  283. $.each(data, function (key, val) {
  284. headerMenuHtml += '<li class="layui-nav-item ' + headerMenuCheckDefault + '" id="' + key + 'HeaderId" data-menu="' + key + '"> <a href="javascript:;"><i class="' + val.icon + '"></i> ' + val.title + '</a> </li>\n';
  285. headerMobileMenuHtml += '<dd><a href="javascript:;" id="' + key + 'HeaderId" data-menu="' + key + '"><i class="' + val.icon + '"></i> ' + val.title + '</a></dd>\n';
  286. leftMenuHtml += '<ul class="layui-nav layui-nav-tree layui-left-nav-tree ' + leftMenuCheckDefault + '" id="' + key + '"><li class="layui-nav-item search-li"><i class="layui-icon layui-icon-search searchEvent"></i><i class="layui-icon layui-icon-search searchEvent-mini"></i><input value="" id="search" placeholder="请输入搜索内容"><div class="mc-hover-show"><input value="" placeholder="请输入搜索内容"></div> </li>'
  287. ;
  288. var menuList = val.child;
  289. $.each(menuList, function (index, menu) {
  290. leftMenuHtml += '<li class="layui-nav-item menu-li">\n';
  291. menu.icon = menu.icon ? menu.icon : 'layui-icon layui-icon-ok-circle'
  292. if (menu.child != undefined && menu.child != []) {
  293. leftMenuHtml += '<a href="javascript:;" class="layui-menu-tips" ><i class="' + menu.icon + '"></i><span class="layui-left-nav"> ' + menu.title + '</span> </a>';
  294. var buildChildHtml = function (html, child, menuParameId) {
  295. html += '<dl class="layui-nav-child">\n';
  296. $.each(child, function (childIndex, childMenu) {
  297. html += '<dd>\n';
  298. childMenu.icon = childMenu.icon ? childMenu.icon : 'layui-icon layui-icon-ok-circle'
  299. if (childMenu.child != undefined && childMenu.child != []) {
  300. html += '<a href="javascript:;" class="layui-menu-tips" ><i class="' + childMenu.icon + '"></i><span class="layui-left-nav"> ' + childMenu.title + '</span></a>';
  301. html = buildChildHtml(html, childMenu.child, menuParameId);
  302. } else {
  303. html += '<a href="javascript:;" class="layui-menu-tips" data-type="tabAdd" data-tab-mpi="m-p-i-' + menuParameId + '" data-tab="' + childMenu.href + '" target="' + childMenu.target + '"><i class="' + childMenu.icon + '"></i><span class="layui-left-nav"> ' + childMenu.title + '</span></a>\n';
  304. menuParameId++;
  305. window.menuParameId = menuParameId;
  306. }
  307. html += '</dd>\n';
  308. });
  309. html += '</dl>\n';
  310. return html;
  311. };
  312. leftMenuHtml = buildChildHtml(leftMenuHtml, menu.child, menuParameId);
  313. } else {
  314. leftMenuHtml += '<a href="javascript:;" class="layui-menu-tips" data-type="tabAdd" data-tab-mpi="m-p-i-' + menuParameId + '" data-tab="' + menu.href + '" target="' + menu.target + '"><i class="' + menu.icon + '"></i><span class="layui-left-nav"> ' + menu.title + '</span></a>\n';
  315. menuParameId++;
  316. }
  317. leftMenuHtml += '</li>\n';
  318. });
  319. leftMenuHtml += '</ul>\n';
  320. headerMenuCheckDefault = '';
  321. leftMenuCheckDefault = 'layui-hide';
  322. });
  323. $('.layui-header-pc-menu').html(headerMenuHtml); //电脑
  324. $('.layui-header-mini-menu').html(headerMobileMenuHtml); //手机
  325. $('.layui-left-menu').html(leftMenuHtml);
  326. element.init();
  327. layuimini.bindFunction()
  328. };
  329. /**
  330. * 初始化选项卡
  331. */
  332. this.initTab = function () {
  333. var locationHref = window.location.href;
  334. var urlArr = locationHref.split("#");
  335. if (urlArr.length >= 2) {
  336. var href = urlArr.pop();
  337. // 判断链接是否有效
  338. var checkUrl = layuimini.checkUrl(href);
  339. if (checkUrl != true) {
  340. return layuimini.msg_error(checkUrl);
  341. }
  342. // 判断tab是否存在
  343. var checkTab = layuimini.checkTab(href);
  344. if (!checkTab) {
  345. var title = href,
  346. tabId = href;
  347. $("[data-tab]").each(function () {
  348. var checkHref = $(this).attr("data-tab");
  349. // 判断是否带参数了
  350. if (layuimini.config('urlSuffixDefault')) {
  351. if (href.indexOf("mpi=") > -1) {
  352. var menuParameId = $(this).attr('data-tab-mpi');
  353. if (checkHref.indexOf("?") > -1) {
  354. checkHref = checkHref + '&mpi=' + menuParameId;
  355. } else {
  356. checkHref = checkHref + '?mpi=' + menuParameId;
  357. }
  358. }
  359. }
  360. if (checkHref == tabId) {
  361. title = $(this).html();
  362. title = title.replace('style="display: none;"', '');
  363. // 自动展开菜单栏
  364. var addMenuClass = function ($element, type) {
  365. if (type == 1) {
  366. $element.addClass('layui-this');
  367. if ($element.attr('class') != 'layui-nav-item menu-li layui-this') {
  368. addMenuClass($element.parent().parent(), 2);
  369. } else {
  370. var moduleId = $element.parent().attr('id');
  371. $(".layui-header-menu li").attr('class', 'layui-nav-item');
  372. $("#" + moduleId + "HeaderId").addClass("layui-this");
  373. $(".layui-left-nav-tree").attr('class', 'layui-nav layui-nav-tree layui-hide');
  374. $("#" + moduleId).attr('class', 'layui-nav layui-nav-tree layui-this');
  375. }
  376. } else {
  377. $element.addClass('layui-nav-itemed');
  378. if ($element.attr('class') != 'layui-nav-item menu-li layui-nav-itemed') {
  379. addMenuClass($element.parent().parent(), 2);
  380. } else {
  381. var moduleId = $element.parent().attr('id');
  382. $(".layui-header-menu li").attr('class', 'layui-nav-item');
  383. $("#" + moduleId + "HeaderId").addClass("layui-this");
  384. $(".layui-left-nav-tree").attr('class', 'layui-nav layui-nav-tree layui-hide');
  385. $("#" + moduleId).attr('class', 'layui-nav layui-nav-tree layui-this');
  386. }
  387. }
  388. };
  389. addMenuClass($(this).parent(), 1);
  390. }
  391. });
  392. var layuiminiHomeTab = $('#layuiminiHomeTab').attr('lay-id'),
  393. layuiminiHomeHref = sessionStorage.getItem('layuiminiHomeHref');
  394. // 非菜单打开的tab窗口
  395. if (href == title) {
  396. var layuiminiTabInfo = JSON.parse(sessionStorage.getItem("layuiminiTabInfo"));
  397. if (layuiminiTabInfo != null) {
  398. var check = layuiminiTabInfo[tabId];
  399. if (check != undefined || check != null) {
  400. title = check['title'];
  401. }
  402. }
  403. }
  404. if (layuiminiHomeTab != href && layuiminiHomeHref != href) {
  405. layuimini.addTab(tabId, href, title, true);
  406. layuimini.changeTab(tabId);
  407. }
  408. }
  409. }
  410. if (layuimini.config('urlHashLocation')) {
  411. layuimini.hashTab();
  412. }
  413. };
  414. /**
  415. * 配色方案配置项(默认选中第一个方案)
  416. * @param bgcolorId
  417. */
  418. this.bgColorConfig = function (bgcolorId) {
  419. var bgColorConfig = [
  420. {
  421. headerRight: '#0081cc',
  422. headerRightThis: '#0069b7',
  423. headerLogo: '#fff',
  424. menuLeft: '#fff',
  425. menuLeftThis: '#0b82ff',
  426. menuLeftHover: '#0b82ff',
  427. base: '#0b82ff'
  428. },
  429. {
  430. headerRight: '#1aa094',
  431. headerRightThis: '#197971',
  432. headerLogo: '#243346',
  433. menuLeft: '#2f4056',
  434. menuLeftThis: '#1aa094',
  435. menuLeftHover: '#3b3f4b',
  436. base: '#243346'
  437. },
  438. {
  439. headerRight: '#23262e',
  440. headerRightThis: '#0c0c0c',
  441. headerLogo: '#0c0c0c',
  442. menuLeft: '#23262e',
  443. menuLeftThis: '#1aa094',
  444. menuLeftHover: '#3b3f4b',
  445. base: '#3b3f4b'
  446. },
  447. {
  448. headerRight: '#ffa4d1',
  449. headerRightThis: '#bf7b9d',
  450. headerLogo: '#e694bd',
  451. menuLeft: '#1f1f1f',
  452. menuLeftThis: '#ffa4d1',
  453. menuLeftHover: '#1f1f1f',
  454. base: '#ffa4d1'
  455. },
  456. {
  457. headerRight: '#1aa094',
  458. headerRightThis: '#197971',
  459. headerLogo: '#0c0c0c',
  460. menuLeft: '#23262e',
  461. menuLeftThis: '#1aa094',
  462. menuLeftHover: '#3b3f4b',
  463. base: '#197971'
  464. },
  465. {
  466. headerRight: '#1e9fff',
  467. headerRightThis: '#0069b7',
  468. headerLogo: '#0c0c0c',
  469. menuLeft: '#1f1f1f',
  470. menuLeftThis: '#1e9fff',
  471. menuLeftHover: '#3b3f4b',
  472. base: '#0069b7'
  473. },
  474. {
  475. headerRight: '#ffb800',
  476. headerRightThis: '#d09600',
  477. headerLogo: '#243346',
  478. menuLeft: '#2f4056',
  479. menuLeftThis: '#ffb800',
  480. menuLeftHover: '#3b3f4b',
  481. base: '#d09600'
  482. },
  483. {
  484. headerRight: '#e82121',
  485. headerRightThis: '#ae1919',
  486. headerLogo: '#0c0c0c',
  487. menuLeft: '#1f1f1f',
  488. menuLeftThis: '#e82121',
  489. menuLeftHover: '#3b3f4b',
  490. base: '#ae1919'
  491. },
  492. {
  493. headerRight: '#963885',
  494. headerRightThis: '#772c6a',
  495. headerLogo: '#243346',
  496. menuLeft: '#2f4056',
  497. menuLeftThis: '#963885',
  498. menuLeftHover: '#3b3f4b',
  499. base: '#772c6a'
  500. },
  501. {
  502. headerRight: '#ffb800',
  503. headerRightThis: '#d09600',
  504. headerLogo: '#d09600',
  505. menuLeft: '#2f4056',
  506. menuLeftThis: '#ffb800',
  507. menuLeftHover: '#3b3f4b',
  508. base: '#d09600'
  509. },
  510. {
  511. headerRight: '#e82121',
  512. headerRightThis: '#ae1919',
  513. headerLogo: '#d91f1f',
  514. menuLeft: '#1f1f1f',
  515. menuLeftThis: '#e82121',
  516. menuLeftHover: '#3b3f4b',
  517. base: '#ae1919'
  518. },
  519. {
  520. headerRight: '#963885',
  521. headerRightThis: '#772c6a',
  522. headerLogo: '#772c6a',
  523. menuLeft: '#2f4056',
  524. menuLeftThis: '#963885',
  525. menuLeftHover: '#3b3f4b',
  526. base: '#772c6a'
  527. }
  528. ];
  529. if (bgcolorId == undefined) {
  530. return bgColorConfig;
  531. } else {
  532. return bgColorConfig[bgcolorId];
  533. }
  534. };
  535. /**
  536. * 构建背景颜色选择
  537. * @returns {string}
  538. */
  539. this.buildBgColorHtml = function () {
  540. var html = '';
  541. var bgcolorId = sessionStorage.getItem('layuiminiBgcolorId');
  542. if (bgcolorId == null || bgcolorId == undefined || bgcolorId == '') {
  543. bgcolorId = 0;
  544. }
  545. var bgColorConfig = layuimini.bgColorConfig();
  546. $.each(bgColorConfig, function (key, val) {
  547. if (key == bgcolorId) {
  548. html += '<li class="layui-this" data-select-bgcolor="' + key + '">\n';
  549. } else {
  550. html += '<li data-select-bgcolor="' + key + '">\n';
  551. }
  552. html += '<a href="javascript:;" data-skin="skin-blue" style="" class="clearfix full-opacity-hover">\n' +
  553. '<div><span style="display:block; width: 20%; float: left; height: 12px; background: ' + val.headerLogo + ';"></span><span style="display:block; width: 80%; float: left; height: 12px; background: ' + val.headerRight + ';"></span></div>\n' +
  554. '<div><span style="display:block; width: 20%; float: left; height: 40px; background: ' + val.menuLeft + ';"></span><span style="display:block; width: 80%; float: left; height: 40px; background: #f4f5f7;"></span></div>\n' +
  555. '</a>\n' +
  556. '</li>';
  557. });
  558. return html;
  559. };
  560. /**
  561. * 判断窗口是否已打开
  562. * @param tabId
  563. **/
  564. this.checkTab = function (tabId, isIframe) {
  565. // 判断选项卡上是否有
  566. var checkTab = false;
  567. if (isIframe == undefined || isIframe == false) {
  568. $(".layui-tab-title li").each(function () {
  569. checkTabId = $(this).attr('lay-id');
  570. if (checkTabId != null && checkTabId == tabId) {
  571. checkTab = true;
  572. }
  573. });
  574. } else {
  575. parent.layui.$(".layui-tab-title li").each(function () {
  576. checkTabId = $(this).attr('lay-id');
  577. if (checkTabId != null && checkTabId == tabId) {
  578. checkTab = true;
  579. }
  580. });
  581. }
  582. if (checkTab == false) {
  583. return false;
  584. }
  585. // 判断sessionStorage是否有
  586. var layuiminiTabInfo = JSON.parse(sessionStorage.getItem("layuiminiTabInfo"));
  587. if (layuiminiTabInfo == null) {
  588. layuiminiTabInfo = {};
  589. }
  590. var check = layuiminiTabInfo[tabId];
  591. if (check == undefined || check == null) {
  592. return false;
  593. }
  594. return true;
  595. };
  596. /**
  597. * 打开新窗口
  598. * @param tabId
  599. * @param href
  600. * @param title
  601. */
  602. this.addTab = function (tabId, href, title, addSession) {
  603. if (addSession == undefined || addSession == true) {
  604. var layuiminiTabInfo = JSON.parse(sessionStorage.getItem("layuiminiTabInfo"));
  605. if (layuiminiTabInfo == null) {
  606. layuiminiTabInfo = {};
  607. }
  608. layuiminiTabInfo[tabId] = { href: href, title: title }
  609. sessionStorage.setItem("layuiminiTabInfo", JSON.stringify(layuiminiTabInfo));
  610. }
  611. var height = $('.layui-tab-item.layui-show').height() - 5;
  612. element.tabAdd('layuiminiTab', {
  613. title: title + '<i data-tab-close="" class="layui-icon layui-unselect layui-tab-close">ဆ</i>' //用于演示
  614. , content: '<iframe width="100%" height="' + height + '" frameborder="0" src="' + href + '"></iframe>'
  615. , id: tabId
  616. });
  617. };
  618. /**
  619. * 删除窗口
  620. * @param tabId
  621. * @param isParent
  622. */
  623. this.delTab = function (tabId, isParent) {
  624. var layuiminiTabInfo = JSON.parse(sessionStorage.getItem("layuiminiTabInfo"));
  625. if (layuiminiTabInfo != null) {
  626. delete layuiminiTabInfo[tabId];
  627. sessionStorage.setItem("layuiminiTabInfo", JSON.stringify(layuiminiTabInfo))
  628. }
  629. if (isParent === true) {
  630. parent.layui.element.tabDelete('layuiminiTab', tabId);
  631. } else {
  632. element.tabDelete('layuiminiTab', tabId);
  633. }
  634. };
  635. /**
  636. * 在iframe层关闭当前tab方法
  637. */
  638. this.closeCurrentTab = function () {
  639. var ele = $("#top_tabs li.layui-this", parent.document);
  640. if (ele.length > 0) {
  641. var layId = $(ele[0]).attr('lay-id');
  642. layuimini.delTab(layId, true);
  643. }
  644. };
  645. /**
  646. * 切换选项卡
  647. **/
  648. this.changeTab = function (tabId) {
  649. console.log(tabId)
  650. element.tabChange('layuiminiTab', tabId);
  651. };
  652. /**
  653. * Hash地址的定位
  654. */
  655. this.hashTab = function () {
  656. var layId = location.hash.replace(/^#/, '');
  657. element.tabChange('layuiminiTab', layId);
  658. element.on('tab(layuiminiTab)', function (elem) {
  659. location.hash = $(this).attr('lay-id');
  660. });
  661. };
  662. /**
  663. * 判断是否为手机
  664. */
  665. this.checkMobile = function () {
  666. var ua = navigator.userAgent.toLocaleLowerCase();
  667. var pf = navigator.platform.toLocaleLowerCase();
  668. var isAndroid = (/android/i).test(ua) || ((/iPhone|iPod|iPad/i).test(ua) && (/linux/i).test(pf))
  669. || (/ucweb.*linux/i.test(ua));
  670. var isIOS = (/iPhone|iPod|iPad/i).test(ua) && !isAndroid;
  671. var isWinPhone = (/Windows Phone|ZuneWP7/i).test(ua);
  672. var clientWidth = document.documentElement.clientWidth;
  673. if (!isAndroid && !isIOS && !isWinPhone && clientWidth > 768) {
  674. return false;
  675. } else {
  676. return true;
  677. }
  678. };
  679. /**
  680. * 判断链接是否有效
  681. * @param url
  682. * @returns {boolean}
  683. */
  684. this.checkUrl = function (url) {
  685. if (!layuimini.config('checkUrlDefault')) {
  686. return true;
  687. }
  688. var msg = true;
  689. $.ajax({
  690. url: url,
  691. type: 'get',
  692. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  693. async: false,
  694. error: function (xhr, textstatus, thrown) {
  695. msg = 'Status:' + xhr.status + ',' + xhr.statusText + ',请稍后再试!';
  696. }
  697. });
  698. return msg;
  699. };
  700. /**
  701. * 成功
  702. * @param title
  703. * @returns {*}
  704. */
  705. this.msg_success = function (title) {
  706. return layer.msg(title, { icon: 1, shade: this.shade, scrollbar: false, time: 2000, shadeClose: true });
  707. };
  708. /**
  709. * 失败
  710. * @param title
  711. * @returns {*}
  712. */
  713. this.msg_error = function (title) {
  714. return layer.msg(title, { icon: 2, shade: this.shade, scrollbar: false, time: 3000, shadeClose: true });
  715. };
  716. /**
  717. * 选项卡滚动
  718. */
  719. this.tabRoll = function () {
  720. $(window).on("resize", function (event) {
  721. var topTabsBox = $("#top_tabs_box"),
  722. topTabsBoxWidth = $("#top_tabs_box").width(),
  723. topTabs = $("#top_tabs"),
  724. topTabsWidth = $("#top_tabs").width(),
  725. tabLi = topTabs.find("li.layui-this"),
  726. top_tabs = document.getElementById("top_tabs"),
  727. event = event || window.event;
  728. if (topTabsWidth > topTabsBoxWidth) {
  729. if (tabLi.position().left > topTabsBoxWidth || tabLi.position().left + topTabsBoxWidth > topTabsWidth) {
  730. topTabs.css("left", topTabsBoxWidth - topTabsWidth);
  731. } else {
  732. topTabs.css("left", -tabLi.position().left);
  733. }
  734. //拖动效果
  735. var flag = false;
  736. var cur = {
  737. x: 0,
  738. y: 0
  739. }
  740. var nx, dx, x;
  741. function down(event) {
  742. flag = true;
  743. var touch;
  744. if (event.touches) {
  745. touch = event.touches[0];
  746. } else {
  747. touch = event;
  748. }
  749. cur.x = touch.clientX;
  750. dx = top_tabs.offsetLeft;
  751. }
  752. function move(event) {
  753. var self = this;
  754. if (flag) {
  755. window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
  756. var touch;
  757. if (event.touches) {
  758. touch = event.touches[0];
  759. } else {
  760. touch = event;
  761. }
  762. nx = touch.clientX - cur.x;
  763. x = dx + nx;
  764. if (x > 0) {
  765. x = 0;
  766. } else {
  767. if (x < topTabsBoxWidth - topTabsWidth) {
  768. x = topTabsBoxWidth - topTabsWidth;
  769. } else {
  770. x = dx + nx;
  771. }
  772. }
  773. top_tabs.style.left = x + "px";
  774. //阻止页面的滑动默认事件
  775. document.addEventListener("touchmove", function () {
  776. event.preventDefault();
  777. }, false);
  778. }
  779. }
  780. //鼠标释放时候的函数
  781. function end() {
  782. flag = false;
  783. }
  784. //pc端拖动效果
  785. topTabs.on("mousedown", down);
  786. topTabs.on("mousemove", move);
  787. $(document).on("mouseup", end);
  788. //移动端拖动效果
  789. topTabs.on("touchstart", down);
  790. topTabs.on("touchmove", move);
  791. topTabs.on("touchend", end);
  792. } else {
  793. //移除pc端拖动效果
  794. topTabs.off("mousedown", down);
  795. topTabs.off("mousemove", move);
  796. topTabs.off("mouseup", end);
  797. //移除移动端拖动效果
  798. topTabs.off("touchstart", down);
  799. topTabs.off("touchmove", move);
  800. topTabs.off("touchend", end);
  801. topTabs.removeAttr("style");
  802. return false;
  803. }
  804. }).resize();
  805. };
  806. /**
  807. * 进入全屏
  808. */
  809. this.fullScreen = function () {
  810. var el = document.documentElement;
  811. var rfs = el.requestFullScreen || el.webkitRequestFullScreen;
  812. if (typeof rfs != "undefined" && rfs) {
  813. rfs.call(el);
  814. } else if (typeof window.ActiveXObject != "undefined") {
  815. var wscript = new ActiveXObject("WScript.Shell");
  816. if (wscript != null) {
  817. wscript.SendKeys("{F11}");
  818. }
  819. } else if (el.msRequestFullscreen) {
  820. el.msRequestFullscreen();
  821. } else if (el.oRequestFullscreen) {
  822. el.oRequestFullscreen();
  823. } else {
  824. layuimini.msg_error('浏览器不支持全屏调用!');
  825. }
  826. };
  827. /**
  828. * 退出全屏
  829. */
  830. this.exitFullScreen = function () {
  831. var el = document;
  832. var cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.exitFullScreen;
  833. if (typeof cfs != "undefined" && cfs) {
  834. cfs.call(el);
  835. } else if (typeof window.ActiveXObject != "undefined") {
  836. var wscript = new ActiveXObject("WScript.Shell");
  837. if (wscript != null) {
  838. wscript.SendKeys("{F11}");
  839. }
  840. } else if (el.msExitFullscreen) {
  841. el.msExitFullscreen();
  842. } else if (el.oRequestFullscreen) {
  843. el.oCancelFullScreen();
  844. } else {
  845. layuimini.msg_error('浏览器不支持全屏调用!');
  846. }
  847. };
  848. };
  849. /**
  850. * 关闭选项卡
  851. **/
  852. $('body').on('click', '[data-tab-close]', function () {
  853. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  854. $parent = $(this).parent();
  855. tabId = $parent.attr('lay-id');
  856. if (tabId != undefined || tabId != null) {
  857. layuimini.delTab(tabId);
  858. }
  859. layuimini.tabRoll();
  860. layer.close(loading);
  861. });
  862. /**
  863. * 打开新窗口
  864. */
  865. $('body').on('click', '[data-tab]', function () {
  866. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  867. var tabId = $(this).attr('data-tab'),
  868. href = $(this).attr('data-tab'),
  869. title = $(this).html(),
  870. target = $(this).attr('target');
  871. if (target == '_blank') {
  872. layer.close(loading);
  873. window.open(href, "_blank");
  874. return false;
  875. }
  876. title = title.replace('style="display: none;"', '');
  877. // 拼接参数
  878. if (layuimini.config('urlSuffixDefault')) {
  879. var menuParameId = $(this).attr('data-tab-mpi');
  880. if (href.indexOf("?") > -1) {
  881. href = href + '&mpi=' + menuParameId;
  882. tabId = href;
  883. } else {
  884. href = href + '?mpi=' + menuParameId;
  885. tabId = href;
  886. }
  887. }
  888. // 判断链接是否有效
  889. var checkUrl = layuimini.checkUrl(href);
  890. if (checkUrl != true) {
  891. return layuimini.msg_error(checkUrl);
  892. }
  893. if (tabId == null || tabId == undefined) {
  894. tabId = new Date().getTime();
  895. }
  896. // 判断该窗口是否已经打开过
  897. var checkTab = layuimini.checkTab(tabId);
  898. if (!checkTab) {
  899. layuimini.addTab(tabId, href, title, true);
  900. }
  901. element.tabChange('layuiminiTab', tabId);
  902. layuimini.initDevice();
  903. layuimini.tabRoll();
  904. layer.close(loading);
  905. });
  906. /**
  907. * 在iframe子菜单上打开新窗口
  908. */
  909. $('body').on('click', '[data-iframe-tab]', function () {
  910. var loading = parent.layer.load(0, { shade: false, time: 2 * 1000 });
  911. var tabId = $(this).attr('data-iframe-tab'),
  912. href = $(this).attr('data-iframe-tab'),
  913. icon = $(this).attr('data-icon'),
  914. title = $(this).attr('data-title'),
  915. target = $(this).attr('target');
  916. if (target == '_blank') {
  917. parent.layer.close(loading);
  918. window.open(href, "_blank");
  919. return false;
  920. }
  921. title = '<i class="' + icon + '"></i><span class="layui-left-nav"> ' + title + '</span>';
  922. if (tabId == null || tabId == undefined) {
  923. tabId = new Date().getTime();
  924. }
  925. // 判断该窗口是否已经打开过
  926. var checkTab = layuimini.checkTab(tabId, true);
  927. if (!checkTab) {
  928. var layuiminiTabInfo = JSON.parse(sessionStorage.getItem("layuiminiTabInfo"));
  929. if (layuiminiTabInfo == null) {
  930. layuiminiTabInfo = {};
  931. }
  932. layuiminiTabInfo[tabId] = { href: href, title: title }
  933. sessionStorage.setItem("layuiminiTabInfo", JSON.stringify(layuiminiTabInfo));
  934. parent.layui.element.tabAdd('layuiminiTab', {
  935. title: title + '<i data-tab-close="" class="layui-icon layui-unselect layui-tab-close">ဆ</i>' //用于演示
  936. , content: '<iframe width="100%" height="100%" frameborder="0" src="' + href + '"></iframe>'
  937. , id: tabId
  938. });
  939. }
  940. parent.layui.element.tabChange('layuiminiTab', tabId);
  941. layuimini.tabRoll();
  942. parent.layer.close(loading);
  943. });
  944. /**
  945. * 左侧菜单的切换
  946. */
  947. $('body').on('click', '[data-menu]', function () {
  948. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  949. $parent = $(this).parent();
  950. menuId = $(this).attr('data-menu');
  951. // header
  952. $(".layui-header-menu .layui-nav-item.layui-this").removeClass('layui-this');
  953. $(this).addClass('layui-this');
  954. // left
  955. $(".layui-left-menu .layui-nav.layui-nav-tree.layui-this").addClass('layui-hide');
  956. $(".layui-left-menu .layui-nav.layui-nav-tree.layui-this.layui-hide").removeClass('layui-this');
  957. $("#" + menuId).removeClass('layui-hide');
  958. $("#" + menuId).addClass('layui-this');
  959. layer.close(loading);
  960. });
  961. /**
  962. * 清理
  963. */
  964. $('body').on('click', '[data-clear]', function () {
  965. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  966. sessionStorage.clear();
  967. // 判断是否清理服务端
  968. var clearUrl = $(this).attr('data-href');
  969. if (clearUrl != undefined && clearUrl != '' && clearUrl != null) {
  970. $.getJSON(clearUrl, function (data, status) {
  971. layer.close(loading);
  972. if (data.code != 1) {
  973. return layuimini.msg_error(data.msg);
  974. } else {
  975. return layuimini.msg_success(data.msg);
  976. }
  977. }).fail(function () {
  978. layer.close(loading);
  979. return layuimini.msg_error('清理缓存接口有误');
  980. });
  981. } else {
  982. layer.close(loading);
  983. return layuimini.msg_success('清除缓存成功');
  984. }
  985. });
  986. /**
  987. * 刷新
  988. */
  989. $('body').on('click', '[data-refresh]', function () {
  990. $(".layui-tab-item.layui-show").find("iframe")[0].contentWindow.location.reload();
  991. layuimini.msg_success('刷新成功');
  992. });
  993. /**
  994. * 选项卡操作
  995. */
  996. $('body').on('click', '[data-page-close]', function () {
  997. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  998. var closeType = $(this).attr('data-page-close');
  999. $(".layui-tab-title li").each(function () {
  1000. tabId = $(this).attr('lay-id');
  1001. var id = $(this).attr('id');
  1002. if (id != 'layuiminiHomeTabId') {
  1003. var tabClass = $(this).attr('class');
  1004. if (closeType == 'all') {
  1005. layuimini.delTab(tabId);
  1006. } else {
  1007. if (tabClass != 'layui-this') {
  1008. layuimini.delTab(tabId);
  1009. }
  1010. }
  1011. }
  1012. });
  1013. layuimini.tabRoll();
  1014. layer.close(loading);
  1015. });
  1016. /**
  1017. * 菜单栏缩放
  1018. */
  1019. $('body').on('click', '[data-side-fold]', function () {
  1020. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  1021. var isShow = $(this).attr('data-side-fold');
  1022. if (isShow == 1) { // 缩放
  1023. $(this).attr('data-side-fold', 0);
  1024. $('.layuimini-tool i').attr('class', 'fa fa-indent');
  1025. $('.layui-layout-body').attr('class', 'paperless layui-layout-body layuimini-mini');
  1026. } else { // 正常
  1027. $(this).attr('data-side-fold', 1);
  1028. $('.layuimini-tool i').attr('class', 'fa fa-outdent');
  1029. $('.layui-layout-body').attr('class', 'paperless layui-layout-body layuimini-all');
  1030. }
  1031. layuimini.tabRoll();
  1032. element.init();
  1033. layuimini.bindFunction()
  1034. layer.close(loading);
  1035. });
  1036. /**
  1037. * 监听提示信息
  1038. */
  1039. $("body").on("mouseenter", ".layui-nav-tree .menu-li", function () {
  1040. var classInfo = $(this).attr('class'),
  1041. tips = $(this).prop("innerHTML"),
  1042. isShow = $('.layuimini-tool i').attr('data-side-fold');
  1043. if (isShow == 0 && tips) {
  1044. tips = "<ul class='layuimini-menu-left-zoom layui-nav layui-nav-tree layui-this'><li class='layui-nav-item layui-nav-itemed'>" + tips + "</li></ul>";
  1045. window.openTips = layer.tips(tips, $(this), {
  1046. tips: [2, '#2f4056'],
  1047. time: 300000,
  1048. skin: "popup-tips",
  1049. success: function (el) {
  1050. var left = $(el).position().left - 10;
  1051. $(el).css({ left: left });
  1052. element.render();
  1053. }
  1054. });
  1055. }
  1056. });
  1057. $("body").on("mouseleave", ".popup-tips", function () {
  1058. var isShow = $('.layuimini-tool i').attr('data-side-fold');
  1059. if (isShow == 0) {
  1060. try {
  1061. layer.close(window.openTips);
  1062. } catch (e) {
  1063. console.log(e.message);
  1064. }
  1065. }
  1066. });
  1067. /**
  1068. * 弹出配色方案
  1069. */
  1070. $('body').on('click', '[data-bgcolor]', function () {
  1071. var loading = layer.load(0, { shade: false, time: 2 * 1000 });
  1072. var clientHeight = (document.documentElement.clientHeight) - 95;
  1073. var bgColorHtml = layuimini.buildBgColorHtml();
  1074. var html = '<div class="layuimini-color">\n' +
  1075. '<div class="color-title">\n' +
  1076. '<span>配色方案</span>\n' +
  1077. '</div>\n' +
  1078. '<div class="color-content">\n' +
  1079. '<ul>\n' + bgColorHtml + '</ul>\n' +
  1080. '</div>\n' +
  1081. '</div>';
  1082. layer.open({
  1083. type: 1,
  1084. title: false,
  1085. closeBtn: 0,
  1086. shade: 0.2,
  1087. anim: 2,
  1088. shadeClose: true,
  1089. id: 'layuiminiBgColor',
  1090. area: ['340px', clientHeight + 'px'],
  1091. offset: 'rb',
  1092. content: html,
  1093. end: function () {
  1094. $('.layuimini-select-bgcolor').removeClass('layui-this');
  1095. }
  1096. });
  1097. layer.close(loading);
  1098. });
  1099. /**
  1100. * 选择配色方案
  1101. */
  1102. $('body').on('click', '[data-select-bgcolor]', function () {
  1103. var bgcolorId = $(this).attr('data-select-bgcolor');
  1104. $('.layuimini-color .color-content ul .layui-this').attr('class', '');
  1105. $(this).attr('class', 'layui-this');
  1106. sessionStorage.setItem('layuiminiBgcolorId', bgcolorId);
  1107. layuimini.initBgColor();
  1108. });
  1109. /**
  1110. * 全屏
  1111. */
  1112. $('body').on('click', '[data-check-screen]', function () {
  1113. var check = $(this).attr('data-check-screen');
  1114. if (check == 'full') {
  1115. layuimini.fullScreen();
  1116. $(this).attr('data-check-screen', 'exit');
  1117. $(this).html('<i class="fa fa-compress"></i>');
  1118. } else {
  1119. layuimini.exitFullScreen();
  1120. $(this).attr('data-check-screen', 'full');
  1121. $(this).html('<i class="fa fa-arrows-alt"></i>');
  1122. }
  1123. });
  1124. exports("layuimini", layuimini);
  1125. });