From d7302f26024bfdee977719a40e9c58e69b2c6109 Mon Sep 17 00:00:00 2001 From: Karson Date: Thu, 23 Nov 2023 16:31:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eautocontent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增autocontent 优化Fast.api.open --- public/assets/js/backend/addon.js | 5 ++++- public/assets/js/fast.js | 5 +++++ public/assets/js/require-table.js | 33 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/public/assets/js/backend/addon.js b/public/assets/js/backend/addon.js index c3d56735..95c51f85 100644 --- a/public/assets/js/backend/addon.js +++ b/public/assets/js/backend/addon.js @@ -156,7 +156,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'cookie'] title: __('Operate'), table: table, formatter: Controller.api.formatter.operate, - align: 'right' + align: 'right', + cellStyle: function (value, row, index) { + return {css: {'min-width': '158px'}}; + } }, ] ], diff --git a/public/assets/js/fast.js b/public/assets/js/fast.js index f963e9b4..6f07964d 100644 --- a/public/assets/js/fast.js +++ b/public/assets/js/fast.js @@ -133,6 +133,10 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine url = Fast.api.fixurl(url); url = url + (url.indexOf("?") > -1 ? "&" : "?") + "dialog=1"; var area = Fast.config.openArea != undefined ? Fast.config.openArea : [$(window).width() > 800 ? '800px' : '95%', $(window).height() > 600 ? '600px' : '95%']; + var success = options && typeof options.success === 'function' ? options.success : $.noop; + if (options && typeof options.success === 'function') { + delete options.success; + } options = $.extend({ type: 2, title: title, @@ -186,6 +190,7 @@ define(['jquery', 'bootstrap', 'toastr', 'layer', 'lang'], function ($, undefine height: $(window).height() }); } + success.call(this, layero, index); } }, options ? options : {}); if ($(window).width() < 480 || (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream && top.$(".tab-pane.active").length > 0)) { diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index d0b7a781..ce75cdb2 100755 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -504,6 +504,39 @@ define(['jquery', 'bootstrap'], function ($, undefined) { } ); }); + table.on("mouseenter mouseleave", ".autocontent", function (e) { + var target = $(".autocontent-item", this).get(0); + if (!target) return; + if (e.type === 'mouseenter') { + if (target.scrollWidth > target.offsetWidth && $(".autocontent-caret", this).length === 0) { + $(this).append("
"); + } + } else { + $(".autocontent-caret", this).remove(); + } + }); + table.on("click mouseenter", ".autocontent-caret", function (e) { + var hover = $(this).prev().hasClass("autocontent-hover"); + if (!hover && e.type === 'mouseenter') { + return; + } + var text = $(this).prev().text(); + var tdrect = $(this).parent().get(0).getBoundingClientRect(); + var index = Layer.open({id: 'autocontent', skin: 'layui-layer-fast layui-layer-autocontent', title: false, content: text, btn: false, anim: false, shade: 0, isOutAnim: false, area: 'auto', maxWidth: 450, maxHeight: 350, offset: [tdrect.y, tdrect.x]}); + + if (hover) { + $(document).one("mouseleave", "#layui-layer" + index, function () { + Layer.close(index); + }); + } + var mousedown = function (e) { + if ($(e.target).closest(".layui-layer").length === 0) { + Layer.close(index); + $(document).off("mousedown", mousedown); + } + }; + $(document).off("mousedown", mousedown).on("mousedown", mousedown); + }); //修复dropdown定位溢出的情况 if (options.fixDropdownPosition) {