Simplify index.mst to a single div to insert the editor

This commit is contained in:
Nick O'Leary
2019-05-02 16:09:13 +01:00
parent 8dc1ad8168
commit 5b1defad9f
15 changed files with 171 additions and 148 deletions

View File

@@ -150,13 +150,29 @@ RED.menu = (function() {
}
function createMenu(options) {
var topMenu = $("<ul/>",{class:"dropdown-menu pull-right"});
var topMenu = $("<ul/>",{class:"red-ui-menu dropdown-menu pull-right"});
if (options.id) {
topMenu.attr({id:options.id+"-submenu"});
var menuParent = $("#"+options.id);
if (menuParent.length === 1) {
topMenu.insertAfter(menuParent);
menuParent.on("click", function(evt) {
evt.stopPropagation();
evt.preventDefault();
if (topMenu.is(":visible")) {
$(document).off("click.red-ui-menu");
topMenu.hide();
} else {
$(document).on("click.red-ui-menu", function(evt) {
$(document).off("click.red-ui-menu");
activeMenu = null;
topMenu.hide();
});
$(".red-ui-menu").hide();
topMenu.show();
}
})
}
}

View File

@@ -136,7 +136,7 @@ RED.tabs = (function() {
}
});
options = pinnedOptions.concat(options);
collapsibleMenu = RED.menu.init({id:"debug-message-option-menu",options: options});
collapsibleMenu = RED.menu.init({options: options});
collapsibleMenu.css({
position: "absolute"
})
@@ -150,6 +150,7 @@ RED.tabs = (function() {
if (collapsibleMenu.is(":visible")) {
$(document).off("click.tabmenu");
} else {
$(".red-ui-menu").hide();
$(document).on("click.tabmenu", function(evt) {
$(document).off("click.tabmenu");
collapsibleMenu.hide();
@@ -448,7 +449,10 @@ RED.tabs = (function() {
}
delete tabs[id];
updateTabWidths();
collapsibleMenu = null;
if (collapsibleMenu) {
collapsibleMenu.remove();
collapsibleMenu = null;
}
}
return {
@@ -626,7 +630,10 @@ RED.tabs = (function() {
setTimeout(function() {
updateTabWidths();
},10);
collapsibleMenu = null;
if (collapsibleMenu) {
collapsibleMenu.remove();
collapsibleMenu = null;
}
},
removeTab: removeTab,
activateTab: activateTab,

View File

@@ -61,7 +61,7 @@ RED.deploy = (function() {
'<img src="red/images/spin.svg"/>'+
'</span>'+
'</a>'+
'<a id="btn-deploy-options" data-toggle="dropdown" class="deploy-button" href="#"><i class="fa fa-caret-down"></i></a>'+
'<a id="btn-deploy-options" class="deploy-button" href="#"><i class="fa fa-caret-down"></i></a>'+
'</span></li>').prependTo(".red-ui-header-toolbar");
RED.menu.init({id:"btn-deploy-options",
options: [

View File

@@ -202,86 +202,89 @@ RED.library = (function() {
// Add the library button to the name <input> in the edit dialog
$('#'+elementPrefix+"name").css("width","calc(100% - 52px)").after(
'<div class="btn-group" style="margin-left:5px;">'+
'<a id="node-input-'+options.type+'-lookup" class="editor-button" data-toggle="dropdown"><i class="fa fa-book"></i> <i class="fa fa-caret-down"></i></a>'+
'<ul class="dropdown-menu pull-right" role="menu">'+
'<li><a id="node-input-'+options.type+'-menu-open-library" tabindex="-1" href="#">'+RED._("library.openLibrary")+'</a></li>'+
'<li><a id="node-input-'+options.type+'-menu-save-library" tabindex="-1" href="#">'+RED._("library.saveToLibrary")+'</a></li>'+
'</ul></div>'
'<a id="node-input-'+options.type+'-lookup" class="editor-button"><i class="fa fa-book"></i> <i class="fa fa-caret-down"></i></a>'+
'</div>'
// '<ul class="dropdown-menu pull-right" role="menu">'+
// '<li><a id="node-input-'+options.type+'-menu-open-library" tabindex="-1" href="#">'+RED._("library.openLibrary")+'</a></li>'+
// '<li><a id="node-input-'+options.type+'-menu-save-library" tabindex="-1" href="#">'+RED._("library.saveToLibrary")+'</a></li>'+
// '</ul></div>'
);
RED.menu.init({id:'node-input-'+options.type+'-lookup', options: [
{ id:'node-input-'+options.type+'-menu-open-library',
label: RED._("library.openLibrary"),
onselect: function() {
activeLibrary = options;
loadLibraryFolder("local",options.url, "", function(items) {
var listing = [{
library: "local",
type: options.url,
icon: 'fa fa-hdd-o',
label: RED._("library.types.local"),
path: "",
expanded: true,
writable: false,
children: [{
icon: 'fa fa-cube',
label: options.type,
path: options.type+"/",
expanded: true,
children: items
}]
}]
loadLibraryBrowser.data(listing);
});
libraryEditor = ace.edit('node-dialog-library-load-preview-text',{
useWorker: false
});
libraryEditor.setTheme("ace/theme/tomorrow");
if (options.mode) {
libraryEditor.getSession().setMode(options.mode);
}
libraryEditor.setOptions({
readOnly: true,
highlightActiveLine: false,
highlightGutterLine: false
});
libraryEditor.renderer.$cursorLayer.element.style.opacity=0;
libraryEditor.$blockScrolling = Infinity;
$('#node-input-'+options.type+'-menu-open-library').on("click", function(e) {
activeLibrary = options;
loadLibraryFolder("local",options.url, "", function(items) {
var listing = [{
library: "local",
type: options.url,
icon: 'fa fa-hdd-o',
label: RED._("library.types.local"),
path: "",
expanded: true,
writable: false,
children: [{
icon: 'fa fa-cube',
label: options.type,
path: options.type+"/",
expanded: true,
children: items
}]
}]
loadLibraryBrowser.data(listing);
});
libraryEditor = ace.edit('node-dialog-library-load-preview-text',{
useWorker: false
});
libraryEditor.setTheme("ace/theme/tomorrow");
if (options.mode) {
libraryEditor.getSession().setMode(options.mode);
$( "#node-dialog-library-load" ).dialog("option","title",RED._("library.typeLibrary", {type:options.type})).dialog( "open" );
}
},
{ id:'node-input-'+options.type+'-menu-save-library',
label: RED._("library.saveToLibrary"),
onselect: function() {
activeLibrary = options;
//var found = false;
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
var filename = name.replace(/[^\w-]/g,"-");
if (filename === "") {
filename = "unnamed-"+options.type;
}
$("#node-dialog-library-save-filename").attr("value",filename+".js");
loadLibraryFolder("local",options.url, "", function(items) {
var listing = [{
icon: 'fa fa-archive',
label: RED._("library.types.local"),
path: "",
expanded: true,
writable: false,
children: [{
icon: 'fa fa-cube',
label: options.type,
path: options.type+"/",
expanded: true,
children: items
}]
}]
saveLibraryBrowser.data(listing);
});
$( "#node-dialog-library-save" ).dialog( "open" );
}
}
libraryEditor.setOptions({
readOnly: true,
highlightActiveLine: false,
highlightGutterLine: false
});
libraryEditor.renderer.$cursorLayer.element.style.opacity=0;
libraryEditor.$blockScrolling = Infinity;
$( "#node-dialog-library-load" ).dialog("option","title",RED._("library.typeLibrary", {type:options.type})).dialog( "open" );
e.preventDefault();
});
$('#node-input-'+options.type+'-menu-save-library').on("click", function(e) {
activeLibrary = options;
//var found = false;
var name = $("#"+elementPrefix+"name").val().replace(/(^\s*)|(\s*$)/g,"");
var filename = name.replace(/[^\w-]/g,"-");
if (filename === "") {
filename = "unnamed-"+options.type;
}
$("#node-dialog-library-save-filename").attr("value",filename+".js");
loadLibraryFolder("local",options.url, "", function(items) {
var listing = [{
icon: 'fa fa-archive',
label: RED._("library.types.local"),
path: "",
expanded: true,
writable: false,
children: [{
icon: 'fa fa-cube',
label: options.type,
path: options.type+"/",
expanded: true,
children: items
}]
}]
saveLibraryBrowser.data(listing);
});
$( "#node-dialog-library-save" ).dialog( "open" );
e.preventDefault();
});
]})
}
function exportFlow() {

View File

@@ -16,7 +16,7 @@
RED.tray = (function() {
var stack = [];
var editorStack = $("#red-ui-editor-stack");
var editorStack;
var openingTray = false;
function resize() {
@@ -203,6 +203,7 @@ RED.tray = (function() {
return {
init: function init() {
editorStack = $("#red-ui-editor-stack");
$(window).on("resize", handleWindowResize);
RED.events.on("sidebar:resize",handleWindowResize);
$("#editor-shade").on("click", function() {

View File

@@ -107,8 +107,8 @@ RED.workspaces = (function() {
changed = true;
workspace.info = info;
}
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('workspace-disabled',!!workspace.disabled);
$("#red-ui-workspace").toggleClass("workspace-disabled",!!workspace.disabled);
$("#red-ui-tab-"+(workspace.id.replace(".","-"))).toggleClass('red-ui-workspace-disabled',!!workspace.disabled);
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!workspace.disabled);
if (changed) {
var historyEvent = {
@@ -250,7 +250,7 @@ RED.workspaces = (function() {
event.workspace = activeWorkspace;
RED.events.emit("workspace:change",event);
window.location.hash = 'flow/'+tab.id;
$("#red-ui-workspace").toggleClass("workspace-disabled",!!tab.disabled);
$("#red-ui-workspace").toggleClass("red-ui-workspace-disabled",!!tab.disabled);
RED.sidebar.config.refresh();
RED.view.focus();
},
@@ -268,9 +268,9 @@ RED.workspaces = (function() {
if (tab.type === "tab") {
workspaceTabCount++;
}
$('<span class="workspace-disabled-icon"><i class="fa fa-ban"></i> </span>').prependTo("#red-ui-tab-"+(tab.id.replace(".","-"))+" .red-ui-tab-label");
$('<span class="red-ui-workspace-disabled-icon"><i class="fa fa-ban"></i> </span>').prependTo("#red-ui-tab-"+(tab.id.replace(".","-"))+" .red-ui-tab-label");
if (tab.disabled) {
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('workspace-disabled');
$("#red-ui-tab-"+(tab.id.replace(".","-"))).addClass('red-ui-workspace-disabled');
}
RED.menu.setDisabled("menu-item-workspace-delete",workspaceTabCount <= 1);
if (workspaceTabCount === 1) {