update okTab
parent
93ebbd1a56
commit
726259ac49
|
|
@ -46,17 +46,17 @@ layui.use(["element", "layer"], function () {
|
||||||
* @param path 路径
|
* @param path 路径
|
||||||
* @param tabId tabId必须唯一
|
* @param tabId tabId必须唯一
|
||||||
*/
|
*/
|
||||||
window.tabAdd = function (title, path, tabId) {
|
// window.tabAdd = function (title, path, tabId) {
|
||||||
if (self == top) {
|
// if (self == top) {
|
||||||
// console.log("不在iframe中")
|
// // console.log("不在iframe中")
|
||||||
tabAdd1(title, path, tabId)
|
// tabAdd1(title, path, tabId)
|
||||||
} else {
|
// } else {
|
||||||
// console.log("在iframe中")
|
// // console.log("在iframe中")
|
||||||
tabAdd2(title, path, tabId)
|
// tabAdd2(title, path, tabId)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
function tabAdd1(title, path, tabId) {
|
function tabAdd(title, path, tabId) {
|
||||||
// 参数校验
|
// 参数校验
|
||||||
parameterCheck(title, path, tabId);
|
parameterCheck(title, path, tabId);
|
||||||
// 去重复选项卡
|
// 去重复选项卡
|
||||||
|
|
@ -79,29 +79,29 @@ layui.use(["element", "layer"], function () {
|
||||||
element.tabChange("ok-tab", tabId);
|
element.tabChange("ok-tab", tabId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tabAdd2(title, path, tabId) {
|
// function tabAdd2(title, path, tabId) {
|
||||||
// 参数校验
|
// // 参数校验
|
||||||
parameterCheck(title, path, tabId);
|
// parameterCheck(title, path, tabId);
|
||||||
// 去重复选项卡
|
// // 去重复选项卡
|
||||||
var parentOkFrame = $(".ok-frame", parent.document);
|
// var parentOkFrame = $(".ok-frame", parent.document);
|
||||||
for (var i = 0; i < parentOkFrame.length; i++) {
|
// for (var i = 0; i < parentOkFrame.length; i++) {
|
||||||
var _tabId = parentOkFrame.eq(i).attr("tab-id");
|
// var _tabId = parentOkFrame.eq(i).attr("tab-id");
|
||||||
if (_tabId == tabId) {
|
// if (_tabId == tabId) {
|
||||||
console.warn("tabId=" + tabId + "有重复元素,请检查!")
|
// console.warn("tabId=" + tabId + "有重复元素,请检查!")
|
||||||
parent.layui.element.tabChange("ok-tab", tabId);
|
// parent.layui.element.tabChange("ok-tab", tabId);
|
||||||
event.stopPropagation();
|
// event.stopPropagation();
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// 添加选项卡
|
// // 添加选项卡
|
||||||
parent.layui.element.tabAdd("ok-tab", {
|
// parent.layui.element.tabAdd("ok-tab", {
|
||||||
title: title,
|
// title: title,
|
||||||
content: "<iframe src='" + path + "' tab-id='" + tabId + "' class='ok-frame' frameborder='0' scrolling='yes' width='100%' height='100%'></iframe>",
|
// content: "<iframe src='" + path + "' tab-id='" + tabId + "' class='ok-frame' frameborder='0' scrolling='yes' width='100%' height='100%'></iframe>",
|
||||||
id: tabId
|
// id: tabId
|
||||||
});
|
// });
|
||||||
// 切换选项卡
|
// // 切换选项卡
|
||||||
parent.layui.element.tabChange("ok-tab", tabId);
|
// parent.layui.element.tabChange("ok-tab", tabId);
|
||||||
}
|
// }
|
||||||
|
|
||||||
function parameterCheck(title, path, tabId) {
|
function parameterCheck(title, path, tabId) {
|
||||||
if (title == undefined || title == "") {
|
if (title == undefined || title == "") {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
layui.define(["element", "layer"], function (exports) {
|
layui.define(["element", "layer"], function (exports) {
|
||||||
var element = layui.element;
|
var element = parent.layui.element;
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
var $ = layui.jquery;
|
var $ = layui.jquery;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,8 @@
|
||||||
okTab.tabAdd("ok-tool", "http://www.xlbweb.cn", "11-1")
|
okTab.tabAdd("ok-tool", "http://www.xlbweb.cn", "11-1")
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<button class="layui-btn" id="addTab">打开一个新的Tab</button>
|
<button class="layui-btn" id="addTab1">打开一个新的Tab1</button>
|
||||||
|
<button class="layui-btn" id="addTab2">打开一个新的Tab2</button>
|
||||||
</div>
|
</div>
|
||||||
<!--js逻辑-->
|
<!--js逻辑-->
|
||||||
<script src="../../lib/layui/layui.js"></script>
|
<script src="../../lib/layui/layui.js"></script>
|
||||||
|
|
@ -80,9 +81,13 @@ okTab.tabAdd("ok-tool", "http://www.xlbweb.cn", "11-1")
|
||||||
|
|
||||||
layui.code({about: false});
|
layui.code({about: false});
|
||||||
|
|
||||||
$("#addTab").click(function () {
|
$("#addTab1").click(function () {
|
||||||
okTab.add("ok-tool", "http://tool.xlbweb.cn", "11-1");
|
okTab.add("ok-tool", "pages/use/use-okLayer.html", "11-1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#addTab2").click(function () {
|
||||||
|
okTab.add("ok-tool", "http://tool.xlbweb.cn", "11-2");
|
||||||
|
});
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue