• Easyui 让Window弹出居中与最大化后居中


    easyui1.3.2版本,window的弹出不会居中了。而dialog是会居中的,我们必须为为window的open事件做扩展

    代码如下:只要加入以下代码即可.如果你是看了MVC项目系列的,把他放到jquery.easyui.plus.js里面就可以了

    //让window居中
    var easyuiPanelOnOpen = function (left, top) {
        var iframeWidth = $(this).parent().parent().width();
       
        var iframeHeight = $(this).parent().parent().height();
    
        var windowWidth = $(this).parent().width();
        var windowHeight = $(this).parent().height();
    
        var setWidth = (iframeWidth - windowWidth) / 2;
        var setHeight = (iframeHeight - windowHeight) / 2;
        $(this).parent().css({/* 修正面板位置 */
            left: setWidth,
            top: setHeight
        });
    
        if (iframeHeight < windowHeight)
        {
            $(this).parent().css({/* 修正面板位置 */
                left: setWidth,
                top: 0
            });
        }
        $(".window-shadow").hide();
    };
    $.fn.window.defaults.onOpen = easyuiPanelOnOpen;

    完美居中。

    点击最大化后,再次最小化时也会出现不居中现象,我们必须,扩展resize事件。

    var easyuiPanelOnResize = function (left, top) {
    
    
        var iframeWidth = $(this).parent().parent().width();
    
        var iframeHeight = $(this).parent().parent().height();
    
        var windowWidth = $(this).parent().width();
        var windowHeight = $(this).parent().height();
    
    
        var setWidth = (iframeWidth - windowWidth) / 2;
        var setHeight = (iframeHeight - windowHeight) / 2;
        $(this).parent().css({/* 修正面板位置 */
            left: setWidth-6,
            top: setHeight-6
        });
    
        if (iframeHeight < windowHeight) {
            $(this).parent().css({/* 修正面板位置 */
                left: setWidth,
                top: 0
            });
        }
        $(".window-shadow").hide();
        //$(".window-mask").hide().width(1).height(3000).show();
    };
    $.fn.window.defaults.onResize = easyuiPanelOnResize;

    window组件可以兼容了

  • 相关阅读:
    替换gitlab自带的Nginx,并修改仓库存储路径
    linux 内网scp 无密码传输
    centos7 安装docker及Hyperf
    VMware 安装centos 7 及自动挂载共享文件夹
    基于 Thrift + Laravel RPC 调用实现
    PHP计算两个经纬度地点之间的距离
    sql server 2008安装过程中服务器配置出错
    SQL Server2008如何设置开启远程连接
    向上下左右不间断无缝滚动图片的效果(兼容火狐和IE)
    彻底解决Google浏览器CSS居中问题
  • 原文地址:https://www.cnblogs.com/ymnets/p/3439302.html
Copyright © 2020-2023  润新知