/* * @Descripttion : 通用js * @Author : liuzhifang * @Date : 2022-06-02 13:42:45 * @LastEditors : Please set LastEditors * @LastEditTime : 2022-12-24 00:18:35 */ // 导航服务和消息 foxui.tooltip({ el: '#barService', content: barServiceHtml(), className: 'bar-service-container', width: '324px', }); foxui.tooltip({ el: '#barBell', content: barBellHtml(), className: 'bar-bell-container', effect: 'light', width: '330px', }); // 导航折叠功能 $('.foxcms-menu-nav-fold').on('click', function () { let $this = $(this), $icon = $this.find('i'), $inner = $('.foxcms-menu-nav-inner'), isRotate = $icon.is('.rotate'); if (isRotate) { $icon.removeClass('rotate'); $inner.animate({ width: '148px' }); } else { $icon.addClass('rotate'); $inner.animate({ width: 0 }); } }); // 根据窗口宽度判断是否折叠 let foldTimer = null; $(window).on('resize', function () { if (foldTimer) { clearTimeout(foldTimer); foldTimer = null; } foldTimer = setTimeout(function () { let width = $(window).width(), $fold = $('.foxcms-menu-nav-fold'), $icon = $fold.find('i'), $inner = $('.foxcms-menu-nav-inner'), isRotate = $icon.is('.rotate'); if (width < 1440) { if (!isRotate) { $icon.addClass('rotate'); $inner.animate({ width: 0 }); } } else { if (isRotate) { $icon.removeClass('rotate'); $inner.animate({ width: '148px' }); } } clearTimeout(foldTimer); foldTimer = null; }, 300); }); // 收起/展开所有导航 $('.foxcms-menu-expand-all i').on('click', function () { let $container = $('.foxui-menu.foxui-type-vertical'), $this = $(this), isActive = $this.is('.is-active'); if (isActive) { let $openHandle = $container.find('.foxui-menu-handle.is-active'); $openHandle.click(); $this.removeClass('is-active'); } else { let $foldHandle = $container.find('.foxui-menu-handle:not(.is-active)'); $foldHandle.click(); $this.addClass('is-active'); } }); // 根据折叠转换全部折叠按钮状态 $(document).on('click', '.foxui-menu.foxui-type-vertical .foxui-menu-handle', function () { let count = $('.foxui-menu.foxui-type-vertical .foxui-menu-handle').length, openLen = $('.foxui-menu.foxui-type-vertical .foxui-menu-handle.is-active').length; if (count === openLen) { $('.foxcms-menu-expand-all i').addClass('is-active'); } else { $('.foxcms-menu-expand-all i').removeClass('is-active'); } }); // 表单字段调用 $(document).on('click', '.call-field .foxui-tag', function () { const text = $(this).text(), el = document.createElement('input'); el.value = text; el.setAttribute('readonly', ''); el.style.position = 'absolute'; el.style.opacity = 0; document.body.appendChild(el); el.select(); document.execCommand('copy'); document.body.removeChild(el); foxui.message({ text: '已复制到剪贴板' }); }); // 右侧浮动预览模板 $('.web-image-view .content-box .main-part').on('mouseover', function () { const viewHeight = $(this).height(); const imgHeight = $(this).find('img').height(); const mValue = viewHeight - imgHeight; $(this) .find('img') .css('marginTop', mValue + 'px'); }); $('.web-image-view .content-box .main-part').on('mouseout', function () { $(this).find('img').css('marginTop', 0); }); /* bar -> html *****************************************************************************************************/ function barServiceHtml() { return [ '
', ].join(''); } function barBellHtml() { return [ ' ', ].join(''); } // 标签调用 html function _callHtml(dataObj) { return [ '请将相应标签复制并粘贴到对应模板文件中!
', '