From 4ab5724f2e9fe0b292161000b77608c1db392e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E4=BB=AA=E5=BC=8F?= <854085467@qq.com> Date: Thu, 2 Jul 2020 20:31:15 +0800 Subject: [PATCH] =?UTF-8?q?Tab=20=E8=A7=86=E5=9B=BE=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/layui/lay/extends/pearTab.js | 35 ++++++++++---------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/component/layui/lay/extends/pearTab.js b/component/layui/lay/extends/pearTab.js index a9314d4..09c9436 100644 --- a/component/layui/lay/extends/pearTab.js +++ b/component/layui/lay/extends/pearTab.js @@ -37,8 +37,6 @@ layui.define(['jquery', 'element'], function(exports) { element.init(); - closeEvent(option); - toolEvent(option); $("#" + option.elem).width(opt.width); @@ -47,6 +45,8 @@ layui.define(['jquery', 'element'], function(exports) { position: "relative" }); + closeEvent(option); + return new pearTab(option); } @@ -63,7 +63,6 @@ layui.define(['jquery', 'element'], function(exports) { }); } - pearTab.prototype.positionTab = function() { var $tabTitle = $('.layui-tab[lay-filter=' + this.option.elem + '] .layui-tab-title'); var autoLeft = 0; @@ -371,22 +370,26 @@ layui.define(['jquery', 'element'], function(exports) { //根据 elem id 来删除指定的 layui title li + console.log("进入"); + var tabTitle = $(".layui-tab[lay-filter='" + elem + "']").find(".layui-tab-title"); // 删除指定 id 的 title var removeTab = tabTitle.find("li[lay-id='" + id + "']"); - // 查 找 下 方 是 否 存 在 li - var nextNode = removeTab.next("li"); - if (nextNode.length) { + console.log(nextNode.length); + if (nextNode.length) { + nextNode.addClass("layui-this"); var currId = nextNode.attr("lay-id"); + console.log("下:"+currId); + $("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show"); } else { @@ -397,16 +400,14 @@ layui.define(['jquery', 'element'], function(exports) { var currId = prevNode.attr("lay-id"); + console.log("上:"+currId); + $("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show"); } removeTab.remove(); // 删除 content - - - - var tabContent = $(".layui-tab[lay-filter='" + elem + "']").find("iframe[id='" + id + "']").parent(); tabContent.remove(); @@ -486,9 +487,7 @@ layui.define(['jquery', 'element'], function(exports) { '" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;">' } - index++; - }); title += ''; @@ -499,7 +498,6 @@ layui.define(['jquery', 'element'], function(exports) { control += '
关 闭 当 前
' control += '
关 闭 其 他
' control += '
关 闭 全 部
' - control += ''; tab += title; @@ -532,8 +530,8 @@ layui.define(['jquery', 'element'], function(exports) { function closeEvent(option) { $(".layui-tab[lay-filter='" + option.elem + "']").on("click", ".layui-tab-close", function() { - var layid = $(this).parent().attr("lay-id") - element.tabDelete(option.elem, layid); + var layid = $(this).parent().attr("lay-id"); + tabDelete(option.elem, layid); }) } @@ -541,12 +539,8 @@ layui.define(['jquery', 'element'], function(exports) { $("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeThis", function() { var currentTab = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this"); - if (currentTab.find("span").is(".able-close")) { - var currentId = currentTab.attr("lay-id"); - - tabDelete(option.elem, currentId); } @@ -570,12 +564,9 @@ layui.define(['jquery', 'element'], function(exports) { var currentId = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this").attr("lay-id"); var tabtitle = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title li"); $.each(tabtitle, function(i) { - if ($(this).find("span").is(".able-close")) { tabDelete(option.elem, $(this).attr("lay-id")); - } - }) }) }