打开新tab与弹窗样式

需求

在查看列表中某条数据的详情时,要么打开一个新的tab,要么弹出新窗口显示详情,下文代码展示两种实现方式:
在这里插入图片描述

样式一:弹出窗口

在这里插入图片描述

function trackLog() {
    var row = $('#data_table').datagrid('getSelected');
    if (null != row) {
        var url = "${basePath}/trackLog/totrackLogTab?fileName=" + row.fileName + "&fileId=" + row.id;
        var winName = "跟踪日志详情";
        var width = $(window).width() * 0.9;
        var height = $(window).height() * 0.9;
        openWindow(winName, url, width, height, true);
    } else {
        Notify('请选择要操作的数据', 'top-right', '3000', 'danger', 'fa-bolt', true);
    }
}

/**
 *打开弹出窗口
 *title 窗口名称
 *url 窗口的链接
 *width 窗口宽度
 *height 窗口的高度
 *modal 模态类型 true 模态窗口 false 非模态窗口
 **/
function openWindow(title, url, width, height, modal) {
    var $win = $("#" + title);
    if ($win.length == 0) {

    } else {
        $win.remove();
    }
    var ifm_html = "<iframe id=\"ifm_" + title + "\" class=\"tab-iframe\" width=\"100%\" height=\"" + (height - 40) + "\" frameborder=\"no\" border=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"auto\" allowtransparency=\"yes\"></iframe>";
    $("body").append("<div id=" + title + " class='easyui-window'>" + ifm_html + "</div>");
    $("#" + title).window({
        modal: modal,
        closed: true,
        maximizable: false,
        width: width,
        height: height,
        title: title,
        resizable: false,
        minimizable: false,
        collapsible: false,
        iconCls: 'fa fa-th-large padding-top-4',
        onClose: function () {
            $(this).window('destroy');
        }
    });

    $("#" + title).window("open");
    $("#ifm_" + title).attr("src", url);
}

样式二、

在这里插入图片描述

// 打开设置属性tab页
function trackLog() {
    var row = $('#data_table').datagrid('getSelected');
    if (null != row) {
        var url = "${basePath}/trackLog/totrackLogTab?fileName=" + row.fileName + "&fileId=" + row.id;
        openMenu(row.id + "type1", "跟踪日志详情", url);
    } else {
        Notify('请选择要操作的数据', 'top-right', '3000', 'danger', 'fa-bolt', true);
    }
}
/**
*打开菜单
*id 菜单标识
*label 菜单名称
*url 菜单URL
**/
function openMenu(id,label,url){
   MainTab.createTab(id,label,url);
   $(".sidebar-menu li").removeClass("active");
   if(id=='home'){
      $lis=$(".sidebar-menu").children();    
      for(var i=0;i<$lis.length-1;i++){
         var $li=$($lis[i]);
         if(!$li.hasClass("hidden")){
            $li.addClass("active");
            break;
         }
      }
   }else{
      $("#menu_"+id).addClass("active");
   }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的含有注册登录切换tab弹窗前端代码: HTML部分: ``` <div class="modal"> <div class="modal-content"> <ul class="tab-group"> <li class="tab active"><a href="#login">登录</a></li> <li class="tab"><a href="#signup">注册</a></li> </ul> <div class="tab-content"> <div id="login"> <h1>欢迎回来!</h1> <form> <div class="field-wrap"> <label> 邮箱<span class="req">*</span> </label> <input type="email" required autocomplete="off" /> </div> <div class="field-wrap"> <label> 密码<span class="req">*</span> </label> <input type="password" required autocomplete="off" /> </div> <p class="forgot"> 忘记密码了?<a href="#">重置密码</a> </p> <button class="button button-block">登录</button> </form> </div> <div id="signup"> <h1>欢迎加入我们!</h1> <form> <div class="top-row"> <div class="field-wrap"> <label> 姓名<span class="req">*</span> </label> <input type="text" required autocomplete="off" /> </div> <div class="field-wrap"> <label> 邮箱<span class="req">*</span> </label> <input type="email" required autocomplete="off" /> </div> </div> <div class="field-wrap"> <label> 密码<span class="req">*</span> </label> <input type="password" required autocomplete="off" /> </div> <button type="submit" class="button button-block">注册</button> </form> </div> </div> </div> </div> ``` CSS部分: ``` .modal { display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.4); padding-top: 60px; } .modal-content { background-color: #fefefe; margin: 5% auto 15% auto; border: 1px solid #888; width: 40%; max-width: 600px; padding: 30px 50px; } .tab-group { list-style: none; padding: 0; margin: 0 0 40px 0; } .tab-group:after { content: ""; display: table; clear: both; } .tab { float: left; } .tab a { display: block; text-decoration: none; padding: 15px; background-color: #eee; color: #888; margin-right: 1px; font-size: 20px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .tab.active a { background-color: #fff; color: #000; } .tab-content { display: none; padding: 15px; border-radius: 0 5px 5px 5px; border: 1px solid #888; overflow: hidden; } .tab-content.active { display: block; } .field-wrap { position: relative; margin-bottom: 25px; } label { font-size: 18px; font-weight: 400; display: block; margin-bottom: 5px; } input { font-size: 18px; display: block; width: 100%; height: 100%; padding: 10px 10px; background: none; background-image: none; border: 1px solid #a0b3b0; color: #545f58; border-radius: 0; transition: border-color 0.25s ease, box-shadow 0.25s ease; } input:focus { outline: 0; border-color: #33c3f0; box-shadow: 0 0 5px rgba(51, 204, 240, 0.5); } .forgot { color: #888; font-size: 13px; text-align: center; margin-top: 15px; } .button { border: 0; outline: none; border-radius: 5px; padding: 15px 0; font-size: 2rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; background-color: #33c3f0; color: #fff; transition: all 0.5s ease; -webkit-appearance: none; } .button:hover, .button:focus { background-color: #1cb3e8; } .button-block { display: block; width: 100%; } .top-row:after { content: ""; display: table; clear: both; } .top-row > div { float: left; width: 48%; margin-right: 4%; } .top-row > div:last-child { margin-right: 0; } ``` JavaScript部分: ``` document.addEventListener("DOMContentLoaded", function () { var tabs = document.querySelectorAll(".tab"); var contents = document.querySelectorAll(".tab-content"); for (var i = 0; i < tabs.length; i++) { tabs[i].addEventListener("click", function () { var activeTab = document.querySelector(".tab.active"); var activeContent = document.querySelector(".tab-content.active"); var currentTab = this; var currentContent = document.querySelector( currentTab.querySelector("a").getAttribute("href") ); activeTab.classList.remove("active"); currentTab.classList.add("active"); activeContent.classList.remove("active"); currentContent.classList.add("active"); }); } }); ``` 以上代码会在页面加载完毕后自动执行,监听tab的点击事件,实现注册登录切换的功能。当用户点击注册或登录按钮时,会弹出一个模态框,其中包含两个tab,分别对应注册和登录功能。用户可以在模态框中输入相关信息进行注册或登录操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值