Files
Web_CRICS_Server_VS2010_Prod/WebSite/Scripts/easyui-panel-onMove.js
2025-12-11 09:17:16 +08:00

46 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* add by cgh
* 针对panel window dialog三个组件拖动时会超出父级元素的修正
* 如果父级元素的overflow属性为hidden则修复上下左右个方向
* 如果父级元素的overflow属性为非hidden则只修复上左两个方向
* @param left
* @param top
* @returns
*/
var easyuiPanelOnMove = function (left, top) {
try {
var parentObj = $(this).panel('panel').parent();
if (left < 0) {
$(this).window('move', {
left: 1
});
}
if (top < 0) {
$(this).window('move', {
top: 1
});
}
var width = $(this).panel('options').width;
var height = $(this).panel('options').height;
var right = left + width;
var buttom = top + height;
var parentWidth = parentObj.width();
var parentHeight = parentObj.height();
if (parentObj.css("overflow") == "hidden") {
if (left > parentWidth - width) {
$(this).window('move', {
"left": parentWidth - width
});
}
if (top > parentHeight - height) {
$(this).window('move', {
"top": parentHeight - height
});
}
}
}
catch (e) { }
};
$.fn.panel.defaults.onMove = easyuiPanelOnMove;
$.fn.window.defaults.onMove = easyuiPanelOnMove;
$.fn.dialog.defaults.onMove = easyuiPanelOnMove