mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3603 from node-red-hitachi/fix-select-width-of-switch-node-rule
use text width instead of number of characters for deciding select fi…
This commit is contained in:
commit
d549a9ad92
@ -247,6 +247,8 @@
|
|||||||
var row2 = $('<div/>',{style:"display: flex; padding-top: 5px; padding-left: 175px;"}).appendTo(inputRows);
|
var row2 = $('<div/>',{style:"display: flex; padding-top: 5px; padding-left: 175px;"}).appendTo(inputRows);
|
||||||
var row3 = $('<div/>',{style:"display: flex; padding-top: 5px; align-items: center"}).appendTo(inputRows);
|
var row3 = $('<div/>',{style:"display: flex; padding-top: 5px; align-items: center"}).appendTo(inputRows);
|
||||||
|
|
||||||
|
var row4 = $('<div/>',{style:"visibility: hidden; height: 0px;"}).appendTo(inputRows);
|
||||||
|
var textSpan = $("<span/>").appendTo(row4);
|
||||||
var selectField = $('<select/>',{style:"width:120px; text-align: center;"}).appendTo(row);
|
var selectField = $('<select/>',{style:"width:120px; text-align: center;"}).appendTo(row);
|
||||||
var group0 = $('<optgroup/>', { label: RED._("node-red:switch.label.value-rules") }).appendTo(selectField);
|
var group0 = $('<optgroup/>', { label: RED._("node-red:switch.label.value-rules") }).appendTo(selectField);
|
||||||
for (var d in operators) {
|
for (var d in operators) {
|
||||||
@ -340,9 +342,12 @@
|
|||||||
row3.hide();
|
row3.hide();
|
||||||
}
|
}
|
||||||
var selectedLabel = selectField.find("option:selected").text();
|
var selectedLabel = selectField.find("option:selected").text();
|
||||||
if (selectedLabel.length <= 5) {
|
|
||||||
|
textSpan.text(selectedLabel);
|
||||||
|
var width = textSpan.width();
|
||||||
|
if (width <= 30) {
|
||||||
selectField.outerWidth(60);
|
selectField.outerWidth(60);
|
||||||
} else if (selectedLabel.length < 12) {
|
} else if (width <= 85) {
|
||||||
selectField.outerWidth(120);
|
selectField.outerWidth(120);
|
||||||
} else {
|
} else {
|
||||||
selectField.width("auto")
|
selectField.width("auto")
|
||||||
|
Loading…
Reference in New Issue
Block a user