新增页签右键操作

This commit is contained in:
RuoYi
2019-05-23 12:33:09 +08:00
parent 7d7c052771
commit 8076277497
7 changed files with 107 additions and 34 deletions

View File

@ -338,16 +338,6 @@ $(function() {
$('.menuTabs').on('click', '.menuTab i', closeTab);
//关闭其他选项卡
function closeOtherTabs() {
$('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove();
$(this).remove();
});
$('.page-tabs-content').css("margin-left", "0");
}
$('.tabCloseOther').on('click', closeOtherTabs);
//滚动到已激活的选项卡
function showActiveTab() {
scrollToTab($('.menuTab.active'));
@ -373,7 +363,7 @@ $(function() {
// 点击选项卡菜单
$('.menuTabs').on('click', '.menuTab', activeTab);
//刷新iframe
// 刷新iframe
function refreshTab() {
var currentId = $('.page-tabs-content').find('.active').attr('data-id');
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]');
@ -381,6 +371,34 @@ $(function() {
target.attr('src', url).ready();
}
// 关闭当前选项卡
function tabCloseCurrent() {
$('.page-tabs-content').find('.active i').trigger("click");
}
//关闭其他选项卡
function tabCloseOther() {
$('.page-tabs-content').children("[data-id]").not(":first").not(".active").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove();
$(this).remove();
});
$('.page-tabs-content').css("margin-left", "0");
}
// 关闭全部选项卡
function tabCloseAll() {
$('.page-tabs-content').children("[data-id]").not(":first").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove();
$(this).remove();
});
$('.page-tabs-content').children("[data-id]:first").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').show();
$(this).addClass("active");
});
$('.page-tabs-content').css("margin-left", "0");
}
// 全屏显示
$('#fullScreen').on('click', function () {
$('#wrapper').fullScreen();
@ -399,22 +417,13 @@ $(function() {
$('.tabRight').on('click', scrollTabRight);
// 关闭当前
$('.tabCloseCurrent').on('click', function () {
$('.page-tabs-content').find('.active i').trigger("click");
});
$('.tabCloseCurrent').on('click', tabCloseCurrent);
// 关闭其他
$('.tabCloseOther').on('click', tabCloseOther);
// 关闭全部
$('.tabCloseAll').on('click', function() {
$('.page-tabs-content').children("[data-id]").not(":first").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').remove();
$(this).remove();
});
$('.page-tabs-content').children("[data-id]:first").each(function() {
$('.RuoYi_iframe[data-id="' + $(this).data('id') + '"]').show();
$(this).addClass("active");
});
$('.page-tabs-content').css("margin-left", "0");
});
$('.tabCloseAll').on('click', tabCloseAll);
// tab全屏显示
$('.tabMaxCurrent').on('click', function () {
@ -439,4 +448,48 @@ $(function() {
$('#ax_close_max').hide();
}
});
// 右键菜单实现
$.contextMenu({
selector: ".page-tabs-content",
trigger: 'right',
autoHide: true,
items: {
"close_current": {
name: "关闭当前",
icon: "fa-close",
callback: function(key, opt) {
tabCloseCurrent();
}
},
"close_other": {
name: "关闭其他",
icon: "fa-close",
callback: function(key, opt) {
tabCloseOther();
}
},
"close_all": {
name: "全部关闭",
icon: "fa-close",
callback: function(key, opt) {
tabCloseAll();
}
},
"full": {
name: "全屏显示",
icon: "fa-arrows-alt",
callback: function(key, opt) {
activeTabMax();
}
},
"refresh": {
name: "刷新页面",
icon: "fa-refresh",
callback: function(key, opt) {
refreshTab();
}
},
}
})
});