新增autocontent

新增autocontent
优化Fast.api.open
pull/456/MERGE
Karson 2023-11-23 16:31:16 +08:00
parent 3831955b9b
commit d7302f2602
3 changed files with 42 additions and 1 deletions

View File

@ -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'}};
}
},
]
],

View File

@ -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)) {

View File

@ -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("<div class='autocontent-caret'><i class='fa fa-chevron-down'></div>");
}
} 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) {