/**
* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
RED.library = (function() {
var loadLibraryBrowser;
var saveLibraryBrowser;
var libraryEditor;
var activeLibrary;
var _libraryLookup = '
'+
''+
'
'
var _librarySave = '
'+
''+
'
'
function saveToLibrary() {
var elementPrefix = activeLibrary.elementPrefix || "node-input-";
var name = $("#"+elementPrefix+"name").val().trim();
if (name === "") {
name = RED._("library.unnamedType",{type:activeLibrary.type});
}
var filename = $("#node-dialog-library-save-filename").val().trim()
var selectedPath = saveLibraryBrowser.getSelected();
if (!selectedPath.children) {
selectedPath = selectedPath.parent;
}
var queryArgs = [];
var data = {};
for (var i=0; i 0 && !/[\/\\]/.test(filename);
if (valid) {
filenameInput.removeClass("input-error");
$("#node-dialog-library-save-button").button("enable");
} else {
filenameInput.addClass("input-error");
$("#node-dialog-library-save-button").button("disable");
}
},100);
}
function createUI(options) {
var libraryData = {};
var elementPrefix = options.elementPrefix || "node-input-";
// Orion editor has set/getText
// ACE editor has set/getValue
// normalise to set/getValue
if (options.editor.setText) {
// Orion doesn't like having pos passed in, so proxy the call to drop it
options.editor.setValue = function(text,pos) {
options.editor.setText.call(options.editor,text);
}
}
if (options.editor.getText) {
options.editor.getValue = options.editor.getText;
}
// Add the library button to the name in the edit dialog
$('#'+elementPrefix+"name").css("width","calc(100% - 52px)").after(
'