mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix typedInput styling and allow option list to scroll
This commit is contained in:
parent
2bf9a353a6
commit
3a257e1e00
@ -172,7 +172,7 @@
|
|||||||
this.options.types = this.options.types||Object.keys(allOptions);
|
this.options.types = this.options.types||Object.keys(allOptions);
|
||||||
|
|
||||||
this.selectTrigger = $('<button class="red-ui-typedInput-type-select" tabindex="0"></button>').prependTo(this.uiSelect);
|
this.selectTrigger = $('<button class="red-ui-typedInput-type-select" tabindex="0"></button>').prependTo(this.uiSelect);
|
||||||
$('<i class="red-ui-typedInput-icon fa fa-sort-desc"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger);
|
$('<i class="red-ui-typedInput-icon fa fa-caret-down"></i>').toggle(this.options.types.length > 1).appendTo(this.selectTrigger);
|
||||||
|
|
||||||
this.selectLabel = $('<span class="red-ui-typedInput-type-label"></span>').appendTo(this.selectTrigger);
|
this.selectLabel = $('<span class="red-ui-typedInput-type-label"></span>').appendTo(this.selectTrigger);
|
||||||
|
|
||||||
@ -213,7 +213,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
// explicitly set optionSelectTrigger display to inline-block otherwise jQ sets it to 'inline'
|
// explicitly set optionSelectTrigger display to inline-block otherwise jQ sets it to 'inline'
|
||||||
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-sort-desc"></i></span></button>').appendTo(this.uiSelect);
|
this.optionSelectTrigger = $('<button tabindex="0" class="red-ui-typedInput-option-trigger" style="display:inline-block"><span class="red-ui-typedInput-option-caret"><i class="red-ui-typedInput-icon fa fa-caret-down"></i></span></button>').appendTo(this.uiSelect);
|
||||||
this.optionSelectLabel = $('<span class="red-ui-typedInput-option-label"></span>').prependTo(this.optionSelectTrigger);
|
this.optionSelectLabel = $('<span class="red-ui-typedInput-option-label"></span>').prependTo(this.optionSelectTrigger);
|
||||||
RED.popover.tooltip(this.optionSelectLabel,function() {
|
RED.popover.tooltip(this.optionSelectLabel,function() {
|
||||||
return that.optionValue;
|
return that.optionValue;
|
||||||
@ -241,7 +241,10 @@
|
|||||||
_showTypeMenu: function() {
|
_showTypeMenu: function() {
|
||||||
if (this.typeList.length > 1) {
|
if (this.typeList.length > 1) {
|
||||||
this._showMenu(this.menu,this.selectTrigger);
|
this._showMenu(this.menu,this.selectTrigger);
|
||||||
this.menu.find("[value='"+this.propertyType+"']").trigger("focus");
|
var selected = this.menu.find("[value='"+this.propertyType+"']");
|
||||||
|
setTimeout(function() {
|
||||||
|
selected.trigger("focus");
|
||||||
|
},120);
|
||||||
} else {
|
} else {
|
||||||
this.input.trigger("focus");
|
this.input.trigger("focus");
|
||||||
}
|
}
|
||||||
@ -262,8 +265,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_hideMenu: function(menu) {
|
_hideMenu: function(menu) {
|
||||||
$(document).off("mousedown.close-property-select");
|
$(document).off("mousedown.red-ui-typedInput-close-property-select");
|
||||||
menu.hide();
|
menu.hide();
|
||||||
|
menu.css({
|
||||||
|
height: "auto"
|
||||||
|
});
|
||||||
if (this.elementDiv.is(":visible")) {
|
if (this.elementDiv.is(":visible")) {
|
||||||
this.input.trigger("focus");
|
this.input.trigger("focus");
|
||||||
} else if (this.optionSelectTrigger.is(":visible")){
|
} else if (this.optionSelectTrigger.is(":visible")){
|
||||||
@ -305,18 +311,21 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
menu.css({
|
menu.css({
|
||||||
display: "none",
|
display: "none"
|
||||||
});
|
});
|
||||||
menu.appendTo(document.body);
|
menu.appendTo(document.body);
|
||||||
|
|
||||||
menu.on('keydown', function(evt) {
|
menu.on('keydown', function(evt) {
|
||||||
if (evt.keyCode === 40) {
|
if (evt.keyCode === 40) {
|
||||||
|
evt.preventDefault();
|
||||||
// DOWN
|
// DOWN
|
||||||
$(this).children(":focus").next().trigger("focus");
|
$(this).children(":focus").next().trigger("focus");
|
||||||
} else if (evt.keyCode === 38) {
|
} else if (evt.keyCode === 38) {
|
||||||
|
evt.preventDefault();
|
||||||
// UP
|
// UP
|
||||||
$(this).children(":focus").prev().trigger("focus");
|
$(this).children(":focus").prev().trigger("focus");
|
||||||
} else if (evt.keyCode === 27) {
|
} else if (evt.keyCode === 27) {
|
||||||
|
evt.preventDefault();
|
||||||
that._hideMenu(menu);
|
that._hideMenu(menu);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -339,6 +348,10 @@
|
|||||||
if (top+menuHeight > $(window).height()) {
|
if (top+menuHeight > $(window).height()) {
|
||||||
top -= (top+menuHeight)-$(window).height()+5;
|
top -= (top+menuHeight)-$(window).height()+5;
|
||||||
}
|
}
|
||||||
|
if (top < 0) {
|
||||||
|
menu.height(menuHeight+top)
|
||||||
|
top = 0;
|
||||||
|
}
|
||||||
menu.css({
|
menu.css({
|
||||||
top: top+"px",
|
top: top+"px",
|
||||||
left: (2+pos.left)+"px",
|
left: (2+pos.left)+"px",
|
||||||
@ -346,7 +359,7 @@
|
|||||||
menu.slideDown(100);
|
menu.slideDown(100);
|
||||||
this._delay(function() {
|
this._delay(function() {
|
||||||
that.uiSelect.addClass('red-ui-typedInput-focus');
|
that.uiSelect.addClass('red-ui-typedInput-focus');
|
||||||
$(document).on("mousedown.close-property-select", function(event) {
|
$(document).on("mousedown.red-ui-typedInput-close-property-select", function(event) {
|
||||||
if(!$(event.target).closest(menu).length) {
|
if(!$(event.target).closest(menu).length) {
|
||||||
that._hideMenu(menu);
|
that._hideMenu(menu);
|
||||||
}
|
}
|
||||||
@ -362,7 +375,7 @@
|
|||||||
if (labelWidth === 0) {
|
if (labelWidth === 0) {
|
||||||
var container = $('<div class="red-ui-typedInput-container"></div>').css({
|
var container = $('<div class="red-ui-typedInput-container"></div>').css({
|
||||||
position:"absolute",
|
position:"absolute",
|
||||||
top:0,
|
top:0
|
||||||
}).appendTo(document.body);
|
}).appendTo(document.body);
|
||||||
var newTrigger = label.clone().appendTo(container);
|
var newTrigger = label.clone().appendTo(container);
|
||||||
labelWidth = newTrigger.outerWidth();
|
labelWidth = newTrigger.outerWidth();
|
||||||
@ -464,7 +477,7 @@
|
|||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
this.selectTrigger.toggleClass("disabled", this.typeList.length === 1);
|
this.selectTrigger.toggleClass("disabled", this.typeList.length === 1);
|
||||||
this.selectTrigger.find(".fa-sort-desc").toggle(this.typeList.length > 1)
|
this.selectTrigger.find(".fa-caret-down").toggle(this.typeList.length > 1)
|
||||||
if (this.menu) {
|
if (this.menu) {
|
||||||
this.menu.remove();
|
this.menu.remove();
|
||||||
}
|
}
|
||||||
|
@ -67,15 +67,9 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
color: $form-text-color;
|
color: $form-text-color;
|
||||||
i.red-ui-typedInput-icon {
|
i.red-ui-typedInput-icon {
|
||||||
position: relative;
|
|
||||||
top: -3px;
|
|
||||||
margin-left: 1px;
|
margin-left: 1px;
|
||||||
margin-right: 2px;
|
margin-right: 2px;
|
||||||
margin-top: 1px;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
&.fa-ellipsis-h {
|
|
||||||
top: -1px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
&.disabled {
|
&.disabled {
|
||||||
cursor: default;
|
cursor: default;
|
||||||
@ -107,6 +101,12 @@
|
|||||||
border-top-right-radius: 4px;
|
border-top-right-radius: 4px;
|
||||||
border-bottom-right-radius: 4px;
|
border-bottom-right-radius: 4px;
|
||||||
}
|
}
|
||||||
|
&:before {
|
||||||
|
content:'';
|
||||||
|
display: inline-block;
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button.red-ui-typedInput-option-expand {
|
button.red-ui-typedInput-option-expand {
|
||||||
@ -135,15 +135,21 @@
|
|||||||
padding: 0 5px 0 8px;
|
padding: 0 5px 0 8px;
|
||||||
i.red-ui-typedInput-icon {
|
i.red-ui-typedInput-icon {
|
||||||
margin-right: 4px;
|
margin-right: 4px;
|
||||||
margin-top: 4px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.red-ui-typedInput-option-caret {
|
.red-ui-typedInput-option-caret {
|
||||||
top: 0;
|
top: 0;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
width: 17px;
|
width: 17px;
|
||||||
padding-left: 6px;
|
padding-left: 6px;
|
||||||
|
&:before {
|
||||||
|
content:'';
|
||||||
|
display: inline-block;
|
||||||
|
height: 100%;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
&:focus {
|
&:focus {
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
@ -159,6 +165,8 @@
|
|||||||
font-size: $primary-font-size;
|
font-size: $primary-font-size;
|
||||||
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
max-height: 350px;
|
||||||
|
overflow-y: auto;
|
||||||
border: 1px solid $primary-border-color;
|
border: 1px solid $primary-border-color;
|
||||||
background: $secondary-background;
|
background: $secondary-background;
|
||||||
z-index: 2000;
|
z-index: 2000;
|
||||||
|
Loading…
Reference in New Issue
Block a user