mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Set minimum size on workspace tab
This commit is contained in:
parent
8782bc5896
commit
00c2dae969
@ -21,6 +21,7 @@ RED.tabs = (function() {
|
|||||||
|
|
||||||
function createTabs(options) {
|
function createTabs(options) {
|
||||||
var tabs = {};
|
var tabs = {};
|
||||||
|
var currentTabWidth;
|
||||||
|
|
||||||
var ul = $("#"+options.id)
|
var ul = $("#"+options.id)
|
||||||
ul.addClass("red-ui-tabs");
|
ul.addClass("red-ui-tabs");
|
||||||
@ -45,10 +46,18 @@ RED.tabs = (function() {
|
|||||||
}
|
}
|
||||||
if (!link.parent().hasClass("active")) {
|
if (!link.parent().hasClass("active")) {
|
||||||
ul.children().removeClass("active");
|
ul.children().removeClass("active");
|
||||||
|
ul.children().css({"transition": "width 100ms"});
|
||||||
link.parent().addClass("active");
|
link.parent().addClass("active");
|
||||||
if (options.onchange) {
|
if (options.onchange) {
|
||||||
options.onchange(tabs[link.attr('href').slice(1)]);
|
options.onchange(tabs[link.attr('href').slice(1)]);
|
||||||
}
|
}
|
||||||
|
if (options.hasOwnProperty("minimumActiveTabWidth")) {
|
||||||
|
ul.children().css({"width":currentTabWidth+"%"});
|
||||||
|
link.parent().css({"width":options.minimumActiveTabWidth});
|
||||||
|
}
|
||||||
|
setTimeout(function() {
|
||||||
|
ul.children().css({"transition": ""});
|
||||||
|
},100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,8 +66,18 @@ RED.tabs = (function() {
|
|||||||
var width = ul.width();
|
var width = ul.width();
|
||||||
var tabCount = tabs.size();
|
var tabCount = tabs.size();
|
||||||
var tabWidth = (width-6-(tabCount*7))/tabCount;
|
var tabWidth = (width-6-(tabCount*7))/tabCount;
|
||||||
var pct = 100*tabWidth/width;
|
currentTabWidth = 100*tabWidth/width;
|
||||||
tabs.css({width:pct+"%"});
|
if (options.hasOwnProperty("minimumActiveTabWidth")) {
|
||||||
|
if (tabWidth < options.minimumActiveTabWidth) {
|
||||||
|
tabCount -= 1;
|
||||||
|
tabWidth = (width-7-options.minimumActiveTabWidth-(tabCount*7))/tabCount;
|
||||||
|
currentTabWidth = 100*tabWidth/width;
|
||||||
|
}
|
||||||
|
tabs.css({width:currentTabWidth+"%"});
|
||||||
|
ul.find("li.red-ui-tab.active").css({"width":options.minimumActiveTabWidth});
|
||||||
|
} else {
|
||||||
|
tabs.css({width:currentTabWidth+"%"});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.find("li.red-ui-tab a").on("click",onTabClick).on("dblclick",onTabDblClick);
|
ul.find("li.red-ui-tab a").on("click",onTabClick).on("dblclick",onTabDblClick);
|
||||||
|
@ -117,7 +117,8 @@ RED.workspaces = (function() {
|
|||||||
onremove: function(tab) {
|
onremove: function(tab) {
|
||||||
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() == 1);
|
RED.menu.setDisabled("menu-item-workspace-delete",workspace_tabs.count() == 1);
|
||||||
RED.menu.removeItem("menu-item-workspace-menu-"+tab.id.replace(".","-"));
|
RED.menu.removeItem("menu-item-workspace-menu-"+tab.id.replace(".","-"));
|
||||||
}
|
},
|
||||||
|
minimumActiveTabWidth: 150
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user