admin.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  1. /**
  2. @Name:layuiAdmin iframe版核心模块
  3. @Author:贤心
  4. @Site:http://www.layui.com/admin/
  5. @License:LPPL
  6. */
  7. layui.define('view', function(exports){
  8. var $ = layui.jquery
  9. ,laytpl = layui.laytpl
  10. ,element = layui.element
  11. ,setter = layui.setter
  12. ,view = layui.view
  13. ,device = layui.device()
  14. ,$win = $(window), $body = $('body')
  15. ,container = $('#'+ setter.container)
  16. ,SHOW = 'layui-show', HIDE = 'layui-hide', THIS = 'layui-this', DISABLED = 'layui-disabled', TEMP = 'template'
  17. ,APP_BODY = '#LAY_app_body', APP_FLEXIBLE = 'LAY_app_flexible'
  18. ,FILTER_TAB_TBAS = 'layadmin-layout-tabs'
  19. ,APP_SPREAD_SM = 'layadmin-side-spread-sm', TABS_BODY = 'layadmin-tabsbody-item'
  20. ,ICON_SHRINK = 'layui-icon-shrink-right', ICON_SPREAD = 'layui-icon-spread-left'
  21. ,SIDE_SHRINK = 'layadmin-side-shrink', SIDE_MENU = 'LAY-system-side-menu'
  22. //通用方法
  23. ,admin = {
  24. v: '1.0.0-beta9 std'
  25. //数据的异步请求
  26. ,req: view.req
  27. //发送验证码
  28. ,sendAuthCode: function(options){
  29. options = $.extend({
  30. seconds: 60
  31. ,elemPhone: '#LAY_phone'
  32. ,elemVercode: '#LAY_vercode'
  33. }, options);
  34. var seconds = options.seconds
  35. ,btn = $(options.elem)
  36. ,token = null
  37. ,timer, countDown = function(loop){
  38. seconds--;
  39. if(seconds < 0){
  40. btn.removeClass(DISABLED).html('获取验证码');
  41. seconds = options.seconds;
  42. clearInterval(timer);
  43. } else {
  44. btn.addClass(DISABLED).html(seconds + '秒后重获');
  45. }
  46. if(!loop){
  47. timer = setInterval(function(){
  48. countDown(true);
  49. }, 1000);
  50. }
  51. };
  52. options.elemPhone = $(options.elemPhone);
  53. options.elemVercode = $(options.elemVercode);
  54. btn.on('click', function(){
  55. var elemPhone = options.elemPhone
  56. ,value = elemPhone.val();
  57. if(seconds !== options.seconds || $(this).hasClass(DISABLED)) return;
  58. if(!/^1\d{10}$/.test(value)){
  59. elemPhone.focus();
  60. return layer.msg('请输入正确的手机号')
  61. };
  62. if(typeof options.ajax === 'object'){
  63. var success = options.ajax.success;
  64. delete options.ajax.success;
  65. }
  66. admin.req($.extend(true, {
  67. url: '/auth/code'
  68. ,type: 'get'
  69. ,data: {
  70. phone: value
  71. }
  72. ,success: function(res){
  73. layer.msg('验证码已发送至你的手机,请注意查收', {
  74. icon: 1
  75. ,shade: 0
  76. });
  77. options.elemVercode.focus();
  78. countDown();
  79. success && success(res);
  80. }
  81. }, options.ajax));
  82. });
  83. }
  84. //屏幕类型
  85. ,screen: function(){
  86. var width = $win.width()
  87. if(width >= 1200){
  88. return 3; //大屏幕
  89. } else if(width >= 992){
  90. return 2; //中屏幕
  91. } else if(width >= 768){
  92. return 1; //小屏幕
  93. } else {
  94. return 0; //超小屏幕
  95. }
  96. }
  97. //清除本地 token,并跳转到登入页
  98. ,exit: view.exit
  99. //侧边伸缩
  100. ,sideFlexible: function(status){
  101. var app = container
  102. ,iconElem = $('#'+ APP_FLEXIBLE)
  103. ,screen = admin.screen();
  104. //设置状态,PC:默认展开、移动:默认收缩
  105. if(status === 'spread'){
  106. //切换到展开状态的 icon,箭头:←
  107. iconElem.removeClass(ICON_SPREAD).addClass(ICON_SHRINK);
  108. //移动:从左到右位移;PC:清除多余选择器恢复默认
  109. if(screen < 2){
  110. app.addClass(APP_SPREAD_SM);
  111. } else {
  112. app.removeClass(APP_SPREAD_SM);
  113. }
  114. app.removeClass(SIDE_SHRINK)
  115. } else {
  116. //切换到搜索状态的 icon,箭头:→
  117. iconElem.removeClass(ICON_SHRINK).addClass(ICON_SPREAD);
  118. //移动:清除多余选择器恢复默认;PC:从右往左收缩
  119. if(screen < 2){
  120. app.removeClass(SIDE_SHRINK);
  121. } else {
  122. app.addClass(SIDE_SHRINK);
  123. }
  124. app.removeClass(APP_SPREAD_SM)
  125. }
  126. layui.event.call(this, setter.MOD_NAME, 'side({*})', {
  127. status: status
  128. });
  129. }
  130. //事件监听
  131. ,on: function(events, callback){
  132. return layui.onevent.call(this, setter.MOD_NAME, events, callback);
  133. }
  134. //弹出面板
  135. ,popup: view.popup
  136. //右侧面板
  137. ,popupRight: function(options){
  138. //layer.close(admin.popup.index);
  139. return admin.popup.index = layer.open($.extend({
  140. type: 1
  141. ,id: 'LAY_adminPopupR'
  142. ,anim: -1
  143. ,title: false
  144. ,closeBtn: false
  145. ,offset: 'r'
  146. ,shade: 0.1
  147. ,shadeClose: true
  148. ,skin: 'layui-anim layui-anim-rl layui-layer-adminRight'
  149. ,area: '300px'
  150. }, options));
  151. }
  152. //主题设置
  153. ,theme: function(options){
  154. var theme = setter.theme
  155. ,local = layui.data(setter.tableName)
  156. ,id = 'LAY_layadmin_theme'
  157. ,style = document.createElement('style')
  158. ,styleText = laytpl([
  159. //主题色
  160. '.layui-side-menu,'
  161. ,'.layadmin-pagetabs .layui-tab-title li:after,'
  162. ,'.layadmin-pagetabs .layui-tab-title li.layui-this:after,'
  163. ,'.layui-layer-admin .layui-layer-title,'
  164. ,'.layadmin-side-shrink .layui-side-menu .layui-nav>.layui-nav-item>.layui-nav-child'
  165. ,'{background-color:{{d.color.layuiadmin}} !important;}'
  166. //选中色
  167. ,'.layui-nav-tree .layui-this,'
  168. ,'.layui-nav-tree .layui-this>a,'
  169. ,'.layui-nav-tree .layui-nav-child dd.layui-this,'
  170. ,'.layui-nav-tree .layui-nav-child dd.layui-this a'
  171. ,'{background-color:{{d.color.selected}} !important;}'
  172. //logo
  173. ,'.layui-layout-admin .layui-logo{background-color:{{d.color.logo || d.color.layuiadmin}} !important;}}'
  174. ].join('')).render(options = $.extend({}, local.theme, options))
  175. ,styleElem = document.getElementById(id);
  176. //添加主题样式
  177. if('styleSheet' in style){
  178. style.setAttribute('type', 'text/css');
  179. style.styleSheet.cssText = styleText;
  180. } else {
  181. style.innerHTML = styleText;
  182. }
  183. style.id = id;
  184. styleElem && $body[0].removeChild(styleElem);
  185. $body[0].appendChild(style);
  186. $body.attr('layadmin-themealias', options.color.alias);
  187. //本地存储记录
  188. local.theme = local.theme || {};
  189. layui.each(options, function(key, value){
  190. local.theme[key] = value;
  191. });
  192. layui.data(setter.tableName, {
  193. key: 'theme'
  194. ,value: local.theme
  195. });
  196. }
  197. //记录最近一次点击的页面标签数据
  198. ,tabsPage: {}
  199. //获取页面标签主体元素
  200. ,tabsBody: function(index){
  201. return $(APP_BODY).find('.'+ TABS_BODY).eq(index || 0);
  202. }
  203. //切换页面标签主体
  204. ,tabsBodyChange: function(index, options){
  205. options = options || {};
  206. admin.tabsBody(index).addClass(SHOW).siblings().removeClass(SHOW);
  207. events.rollPage('auto', index);
  208. //执行 {setter.MOD_NAME}.tabsPage 下的事件
  209. layui.event.call(this, setter.MOD_NAME, 'tabsPage({*})', {
  210. url: options.url
  211. ,text: options.text
  212. });
  213. }
  214. //resize事件管理
  215. ,resize: function(fn){
  216. var router = layui.router()
  217. ,key = router.path.join('-');
  218. $win.off('resize', admin.resizeFn[key]);
  219. fn(), admin.resizeFn[key] = fn;
  220. $win.on('resize', admin.resizeFn[key]);
  221. }
  222. ,resizeFn: {}
  223. ,runResize: function(){
  224. var router = layui.router()
  225. ,key = router.path.join('-');
  226. admin.resizeFn[key] && admin.resizeFn[key]();
  227. }
  228. ,delResize: function(){
  229. var router = layui.router()
  230. ,key = router.path.join('-');
  231. $win.off('resize', admin.resizeFn[key])
  232. delete admin.resizeFn[key];
  233. }
  234. //关闭当前 pageTabs
  235. ,closeThisTabs: function(){
  236. if(!admin.tabsPage.index) return;
  237. $(TABS_HEADER).eq(admin.tabsPage.index).find('.layui-tab-close').trigger('click');
  238. }
  239. //……
  240. };
  241. //事件
  242. var events = admin.events = {
  243. //伸缩
  244. flexible: function(othis){
  245. var iconElem = othis.find('#'+ APP_FLEXIBLE)
  246. ,isSpread = iconElem.hasClass(ICON_SPREAD);
  247. admin.sideFlexible(isSpread ? 'spread' : null);
  248. }
  249. //刷新
  250. ,refresh: function(){
  251. var iframe = admin.tabsBody(admin.tabsPage.index).find('.layadmin-iframe');
  252. iframe[0].contentWindow.location.reload(true);
  253. }
  254. //点击消息
  255. ,message: function(othis){
  256. othis.find('.layui-badge-dot').remove();
  257. }
  258. //弹出主题面板
  259. ,theme: function(){
  260. admin.popupRight({
  261. id: 'LAY_adminPopupTheme'
  262. ,success: function(){
  263. view(this.id).render('system/theme')
  264. }
  265. });
  266. }
  267. //便签
  268. ,note: function(othis){
  269. var mobile = admin.screen() < 2
  270. ,note = layui.data(setter.tableName).note;
  271. events.note.index = admin.popup({
  272. title: '便签'
  273. ,shade: 0
  274. ,offset: [
  275. '41px'
  276. ,(mobile ? null : (othis.offset().left - 250) + 'px')
  277. ]
  278. ,anim: -1
  279. ,id: 'LAY_adminNote'
  280. ,skin: 'layadmin-note layui-anim layui-anim-upbit'
  281. ,content: '<textarea placeholder="内容"></textarea>'
  282. ,resize: false
  283. ,success: function(layero, index){
  284. var textarea = layero.find('textarea')
  285. ,value = note === undefined ? '便签中的内容会存储在本地,这样即便你关掉了浏览器,在下次打开时,依然会读取到上一次的记录。是个非常小巧实用的本地备忘录' : note;
  286. textarea.val(value).focus().on('keyup', function(){
  287. layui.data(setter.tableName, {
  288. key: 'note'
  289. ,value: this.value
  290. });
  291. });
  292. }
  293. })
  294. }
  295. //弹出关于面板
  296. ,about: function(){
  297. admin.popupRight({
  298. id: 'LAY_adminPopupAbout'
  299. ,success: function(){
  300. view(this.id).render('system/about')
  301. }
  302. });
  303. }
  304. //弹出更多面板
  305. ,more: function(){
  306. admin.popupRight({
  307. id: 'LAY_adminPopupMore'
  308. ,success: function(){
  309. view(this.id).render('system/more')
  310. }
  311. });
  312. }
  313. //返回上一页
  314. ,back: function(){
  315. history.back();
  316. }
  317. //主题设置
  318. ,setTheme: function(othis){
  319. var theme = setter.theme
  320. ,index = othis.data('index')
  321. ,nextIndex = othis.siblings('.layui-this').data('index');
  322. if(othis.hasClass(THIS)) return;
  323. othis.addClass(THIS).siblings('.layui-this').removeClass(THIS);
  324. if(theme.color[index]){
  325. theme.color[index].index = index
  326. admin.theme({
  327. color: theme.color[index]
  328. });
  329. }
  330. }
  331. //左右滚动页面标签
  332. ,rollPage: function(type, index){
  333. var tabsHeader = $('#LAY_app_tabsheader')
  334. ,liItem = tabsHeader.children('li')
  335. ,scrollWidth = tabsHeader.prop('scrollWidth')
  336. ,outerWidth = tabsHeader.outerWidth()
  337. ,tabsLeft = parseFloat(tabsHeader.css('left'));
  338. //右左往右
  339. if(type === 'left'){
  340. if(!tabsLeft && tabsLeft <=0) return;
  341. //当前的left减去可视宽度,用于与上一轮的页标比较
  342. var prefLeft = -tabsLeft - outerWidth;
  343. liItem.each(function(index, item){
  344. var li = $(item)
  345. ,left = li.position().left;
  346. if(left >= prefLeft){
  347. tabsHeader.css('left', -left);
  348. return false;
  349. }
  350. });
  351. } else if(type === 'auto'){ //自动滚动
  352. (function(){
  353. var thisLi = liItem.eq(index), thisLeft;
  354. if(!thisLi[0]) return;
  355. thisLeft = thisLi.position().left;
  356. //当目标标签在可视区域左侧时
  357. if(thisLeft < -tabsLeft){
  358. return tabsHeader.css('left', -thisLeft);
  359. }
  360. //当目标标签在可视区域右侧时
  361. if(thisLeft + thisLi.outerWidth() >= outerWidth - tabsLeft){
  362. var subLeft = thisLeft + thisLi.outerWidth() - (outerWidth - tabsLeft);
  363. liItem.each(function(i, item){
  364. var li = $(item)
  365. ,left = li.position().left;
  366. //从当前可视区域的最左第二个节点遍历,如果减去最左节点的差 > 目标在右侧不可见的宽度,则将该节点放置可视区域最左
  367. if(left + tabsLeft > 0){
  368. if(left - tabsLeft > subLeft){
  369. tabsHeader.css('left', -left);
  370. return false;
  371. }
  372. }
  373. });
  374. }
  375. }());
  376. } else {
  377. //默认向左滚动
  378. liItem.each(function(i, item){
  379. var li = $(item)
  380. ,left = li.position().left;
  381. if(left + li.outerWidth() >= outerWidth - tabsLeft){
  382. tabsHeader.css('left', -left);
  383. return false;
  384. }
  385. });
  386. }
  387. }
  388. //向右滚动页面标签
  389. ,leftPage: function(){
  390. events.rollPage('left');
  391. }
  392. //向左滚动页面标签
  393. ,rightPage: function(){
  394. events.rollPage();
  395. }
  396. //关闭当前标签页
  397. ,closeThisTabs: function(){
  398. admin.closeThisTabs();
  399. }
  400. //关闭其它标签页
  401. ,closeOtherTabs: function(type){
  402. var TABS_REMOVE = 'LAY-system-pagetabs-remove';
  403. if(type === 'all'){
  404. $(TABS_HEADER+ ':gt(0)').remove();
  405. $(APP_BODY).find('.'+ TABS_BODY+ ':gt(0)').remove();
  406. $(TABS_HEADER).eq(0).trigger('click');
  407. } else {
  408. $(TABS_HEADER).each(function(index, item){
  409. if(index && index != admin.tabsPage.index){
  410. $(item).addClass(TABS_REMOVE);
  411. admin.tabsBody(index).addClass(TABS_REMOVE);
  412. }
  413. });
  414. $('.'+ TABS_REMOVE).remove();
  415. }
  416. }
  417. //关闭全部标签页
  418. ,closeAllTabs: function(){
  419. events.closeOtherTabs('all');
  420. //location.hash = '';
  421. }
  422. //遮罩
  423. ,shade: function(){
  424. admin.sideFlexible();
  425. }
  426. //呼出IM 示例
  427. ,im: function(){
  428. admin.popup({
  429. id: 'LAY-popup-layim-demo' //定义唯一ID,防止重复弹出
  430. ,shade: 0
  431. ,area: ['800px', '300px']
  432. ,title: '面板外的操作示例'
  433. ,offset: 'lb'
  434. ,success: function(){
  435. //将 views 目录下的某视图文件内容渲染给该面板
  436. layui.view(this.id).render('layim/demo').then(function(){
  437. layui.use('im');
  438. });
  439. }
  440. })
  441. }
  442. };
  443. //初始
  444. !function(){
  445. //Ajax Setup
  446. view.reqSetup();
  447. //主题初始化
  448. var local = layui.data(setter.tableName);
  449. local.theme && admin.theme(local.theme);
  450. //常规版默认开启多标签页
  451. if(!('pageTabs' in layui.setter)) layui.setter.pageTabs = true;
  452. //不开启页面标签时
  453. if(!setter.pageTabs){
  454. $('#LAY_app_tabs').addClass(HIDE);
  455. container.addClass('layadmin-tabspage-none');
  456. }
  457. //低版本IE提示
  458. if(device.ie && device.ie < 10){
  459. view.error('IE'+ device.ie + '下访问可能不佳,推荐使用:Chrome / Firefox / Edge 等高级浏览器', {
  460. offset: 'auto'
  461. ,id: 'LAY_errorIE'
  462. });
  463. }
  464. }();
  465. //admin.prevRouter = {}; //上一个路由
  466. //监听 tab 组件切换,同步 index
  467. element.on('tab('+ FILTER_TAB_TBAS +')', function(data){
  468. admin.tabsPage.index = data.index;
  469. });
  470. //监听选项卡切换,改变菜单状态
  471. admin.on('tabsPage(setMenustatus)', function(router){
  472. var pathURL = router.url, getData = function(item){
  473. return {
  474. list: item.children('.layui-nav-child')
  475. ,a: item.children('*[lay-href]')
  476. }
  477. }
  478. ,sideMenu = $('#'+ SIDE_MENU)
  479. ,SIDE_NAV_ITEMD = 'layui-nav-itemed'
  480. //捕获对应菜单
  481. ,matchMenu = function(list){
  482. list.each(function(index1, item1){
  483. var othis1 = $(item1)
  484. ,data1 = getData(othis1)
  485. ,listChildren1 = data1.list.children('dd')
  486. ,matched1 = pathURL === data1.a.attr('lay-href');
  487. listChildren1.each(function(index2, item2){
  488. var othis2 = $(item2)
  489. ,data2 = getData(othis2)
  490. ,listChildren2 = data2.list.children('dd')
  491. ,matched2 = pathURL === data2.a.attr('lay-href');
  492. listChildren2.each(function(index3, item3){
  493. var othis3 = $(item3)
  494. ,data3 = getData(othis3)
  495. ,matched3 = pathURL === data3.a.attr('lay-href');
  496. if(matched3){
  497. var selected = data3.list[0] ? SIDE_NAV_ITEMD : THIS;
  498. othis3.addClass(selected).siblings().removeClass(selected); //标记选择器
  499. return false;
  500. }
  501. });
  502. if(matched2){
  503. var selected = data2.list[0] ? SIDE_NAV_ITEMD : THIS;
  504. othis2.addClass(selected).siblings().removeClass(selected); //标记选择器
  505. return false
  506. }
  507. });
  508. if(matched1){
  509. var selected = data1.list[0] ? SIDE_NAV_ITEMD : THIS;
  510. othis1.addClass(selected).siblings().removeClass(selected); //标记选择器
  511. return false;
  512. }
  513. });
  514. }
  515. //重置状态
  516. sideMenu.find('.'+ THIS).removeClass(THIS);
  517. //移动端点击菜单时自动收缩
  518. if(admin.screen() < 2) admin.sideFlexible();
  519. //开始捕获
  520. matchMenu(sideMenu.children('li'));
  521. });
  522. //监听侧边导航点击事件
  523. element.on('nav(layadmin-system-side-menu)', function(elem){
  524. if(elem.siblings('.layui-nav-child')[0] && container.hasClass(SIDE_SHRINK)){
  525. admin.sideFlexible('spread');
  526. layer.close(elem.data('index'));
  527. };
  528. admin.tabsPage.type = 'nav';
  529. });
  530. //监听选项卡的更多操作
  531. element.on('nav(layadmin-pagetabs-nav)', function(elem){
  532. var dd = elem.parent();
  533. dd.removeClass(THIS);
  534. dd.parent().removeClass(SHOW);
  535. });
  536. //同步路由
  537. var setThisRouter = function(othis){
  538. var layid = othis.attr('lay-id')
  539. ,attr = othis.attr('lay-attr')
  540. ,index = othis.index();
  541. admin.tabsBodyChange(index);
  542. location.hash = layid === setter.entry ? '/' : attr;
  543. }
  544. ,TABS_HEADER = '#LAY_app_tabsheader>li';
  545. //标签页标题点击
  546. $body.on('click', TABS_HEADER, function(){
  547. var othis = $(this)
  548. ,index = othis.index();
  549. admin.tabsPage.type = 'tab';
  550. admin.tabsPage.index = index;
  551. //单页标签页
  552. setThisRouter(othis);
  553. });
  554. //监听 tabspage 删除
  555. element.on('tabDelete('+ FILTER_TAB_TBAS +')', function(obj){
  556. var othis = $(TABS_HEADER+ '.layui-this');
  557. obj.index && admin.tabsBody(obj.index).remove();
  558. setThisRouter(othis);
  559. //移除resize事件
  560. admin.delResize();
  561. });
  562. //页面跳转
  563. $body.on('click', '*[lay-href]', function(){
  564. var othis = $(this)
  565. ,href = othis.attr('lay-href')
  566. ,text = othis.attr('lay-text')
  567. ,router = layui.router();
  568. admin.tabsPage.elem = othis;
  569. //admin.prevRouter[router.path[0]] = router.href; //记录上一次各菜单的路由信息
  570. //执行跳转
  571. var topLayui = parent === self ? layui : top.layui;
  572. topLayui.index.openTabsPage(href, text || othis.text());
  573. });
  574. //点击事件
  575. $body.on('click', '*[layadmin-event]', function(){
  576. var othis = $(this)
  577. ,attrEvent = othis.attr('layadmin-event');
  578. events[attrEvent] && events[attrEvent].call(this, othis);
  579. });
  580. //tips
  581. $body.on('mouseenter', '*[lay-tips]', function(){
  582. var othis = $(this);
  583. if(othis.parent().hasClass('layui-nav-item') && !container.hasClass(SIDE_SHRINK)) return;
  584. var tips = othis.attr('lay-tips')
  585. ,offset = othis.attr('lay-offset')
  586. ,direction = othis.attr('lay-direction')
  587. ,index = layer.tips(tips, this, {
  588. tips: direction || 1
  589. ,time: -1
  590. ,success: function(layero, index){
  591. if(offset){
  592. layero.css('margin-left', offset + 'px');
  593. }
  594. }
  595. });
  596. othis.data('index', index);
  597. }).on('mouseleave', '*[lay-tips]', function(){
  598. layer.close($(this).data('index'));
  599. });
  600. //窗口resize事件
  601. var resizeSystem = layui.data.resizeSystem = function(){
  602. //layer.close(events.note.index);
  603. layer.closeAll('tips');
  604. if(!resizeSystem.lock){
  605. setTimeout(function(){
  606. admin.sideFlexible(admin.screen() < 2 ? '' : 'spread');
  607. delete resizeSystem.lock;
  608. }, 100);
  609. }
  610. resizeSystem.lock = true;
  611. }
  612. $win.on('resize', layui.data.resizeSystem);
  613. //接口输出
  614. exports('admin', admin);
  615. });