EasyUI Forum
May 13, 2024, 01:41:47 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: show window or dialog or messager center to browser window,not to document windo  (Read 2700 times)
samuelzhu001
Newbie
*
Posts: 11


View Profile
« 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


View Profile
« 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  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!