EasyUI
Home
Demo
Tutorial
Documentation
Download
Extension
Contact
Forum
EasyUI Forum
May 13, 2024, 01:41:47 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News
:
Home
Help
Search
Login
Register
EasyUI Forum
>
General Category
>
EasyUI for jQuery
>
show window or dialog or messager center to browser window,not to document windo
Pages: [
1
]
« previous
next »
Print
Author
Topic: show window or dialog or messager center to browser window,not to document windo (Read 2700 times)
samuelzhu001
Newbie
Posts: 11
show window or dialog or messager center to browser window,not to document windo
«
on:
April 16, 2020, 11:30:55 AM »
I use layout in my project and almost all pages are shown in center region with iframe, when window,dialog or messager are shown in pages, they are centered to the page window , but not the browser window. I don't want to realize it by setting top/left or moving every time the window or dialog are open. Allthough
parent.$.messager
can be a good method for messagers, but I don't want its modal property applying to whole window.
How can I easily realize it?
«
Last Edit: April 16, 2020, 08:06:58 PM by samuelzhu001
»
Logged
samuelzhu001
Newbie
Posts: 11
Re: show window or dialog or messager center to browser window,not to document windo
«
Reply #1 on:
April 17, 2020, 03:31:56 AM »
I found a solution:
function centerOverall(target, offset) {
let jq = $(target);
let opts = jq.data('window').options;
let offsetTop = opts.top - (window.parent.innerHeight - window.innerHeight) / 2 + ((offset && offset.y) ? offset.y : 0);
let offsetLeft = opts.left - (window.parent.innerWidth - window.innerWidth) / 2 + ((offset && offset.x) ? offset.x : 0);
if (offsetTop < 0) offsetTop = 0;
if (offsetLeft < 0) offsetLeft = 0;
jq.window("move", { top: offsetTop, left: offsetLeft });
}
//extend easyui window
$.extend($.fn.window.methods, {
centerOverall: function (jq, offset) {
return jq.each(function () {
centerOverall(this, offset);
});
},
});
«
Last Edit: April 19, 2020, 07:38:39 AM by samuelzhu001
»
Logged
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Category
-----------------------------
=> News
=> General Discussion
=> EasyUI for jQuery
=> EasyUI for Angular
=> EasyUI for Vue
=> EasyUI for React
=> Bug Report
Loading...