Skip to content

Commit

Permalink
Merge branch 'pr_2033' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
knolleary committed Jan 23, 2019
2 parents 888e7ee + aa9a37d commit 3c8e4f8
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RED.typeSearch = (function() {
//shade = $('<div>',{class:"red-ui-type-search-shade"}).appendTo("#main-container");
dialog = $("<div>",{id:"red-ui-type-search",class:"red-ui-search red-ui-type-search"}).appendTo("#main-container");
var searchDiv = $("<div>",{class:"red-ui-search-container"}).appendTo(dialog);
searchInput = $('<input type="text">').attr("placeholder",RED._("search.addNode")).appendTo(searchDiv).searchBox({
searchInput = $('<input type="text" id="red-ui-type-search-input">').attr("placeholder",RED._("search.addNode")).appendTo(searchDiv).searchBox({
delay: 50,
change: function() {
search($(this).val());
Expand Down Expand Up @@ -79,6 +79,19 @@ RED.typeSearch = (function() {
$(children[selected]).addClass('selected');
ensureSelectedIsVisible();
evt.preventDefault();
} else if ((evt.metaKey || evt.ctrlKey) && evt.keyCode === 13 ) {
// (ctrl or cmd) and enter
var index = Math.max(0,selected);
if (index < children.length) {
var n = $(children[index]).find(".red-ui-editableList-item-content").data('data');
typesUsed[n.type] = Date.now();
if (n.def.outputs === 0) {
confirm(n);
} else {
addCallback(n.type,true);
}
$("#red-ui-type-search-input").val("").keyup();
}
} else if (evt.keyCode === 13) {
// Enter
var index = Math.max(0,selected);
Expand Down Expand Up @@ -191,20 +204,27 @@ RED.typeSearch = (function() {
createDialog();
}
visible = true;
setTimeout(function() {
$(document).on('mousedown.type-search',handleMouseActivity);
$(document).on('mouseup.type-search',handleMouseActivity);
$(document).on('click.type-search',handleMouseActivity);
},200);
} else {
dialog.hide();
searchResultsDiv.hide();
}
$(document).off('mousedown.type-search');
$(document).off('mouseup.type-search');
$(document).off('click.type-search');
setTimeout(function() {
$(document).on('mousedown.type-search',handleMouseActivity);
$(document).on('mouseup.type-search',handleMouseActivity);
$(document).on('click.type-search',handleMouseActivity);
},200);

refreshTypeList(opts);
addCallback = opts.add;
closeCallback = opts.close;
cancelCallback = opts.cancel;
RED.events.emit("type-search:open");
//shade.show();
if ($("#main-container").height() - opts.y - 150 < 0) {
opts.y = opts.y - 235;
}
dialog.css({left:opts.x+"px",top:opts.y+"px"}).show();
searchResultsDiv.slideDown(300);
setTimeout(function() {
Expand All @@ -230,7 +250,6 @@ RED.typeSearch = (function() {
$(document).off('click.type-search');
}
}

function getTypeLabel(type, def) {
var label = type;
if (typeof def.paletteLabel !== "undefined") {
Expand Down Expand Up @@ -334,6 +353,7 @@ RED.typeSearch = (function() {

return {
show: show,
refresh: refreshTypeList,
hide: hide
};

Expand Down
Loading

0 comments on commit 3c8e4f8

Please sign in to comment.