|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
// Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
var CodeMirror = require('codemirror/lib/codemirror');
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A wrapper around bootstrap modal for easier use
|
|
|
|
|
@ -159,43 +160,41 @@
|
|
|
|
|
.append(textarea)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
requirejs(['codemirror/lib/codemirror'], function(CodeMirror) {
|
|
|
|
|
var editor = CodeMirror.fromTextArea(textarea[0], {
|
|
|
|
|
lineNumbers: true,
|
|
|
|
|
matchBrackets: true,
|
|
|
|
|
indentUnit: 2,
|
|
|
|
|
autoIndent: true,
|
|
|
|
|
mode: 'application/json',
|
|
|
|
|
});
|
|
|
|
|
var modal_obj = modal({
|
|
|
|
|
title: "Edit " + options.name + " Metadata",
|
|
|
|
|
body: dialogform,
|
|
|
|
|
buttons: {
|
|
|
|
|
OK: { class : "btn-primary",
|
|
|
|
|
click: function() {
|
|
|
|
|
/**
|
|
|
|
|
* validate json and set it
|
|
|
|
|
*/
|
|
|
|
|
var new_md;
|
|
|
|
|
try {
|
|
|
|
|
new_md = JSON.parse(editor.getValue());
|
|
|
|
|
} catch(e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
error_div.text('WARNING: Could not save invalid JSON.');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
options.callback(new_md);
|
|
|
|
|
var editor = CodeMirror.fromTextArea(textarea[0], {
|
|
|
|
|
lineNumbers: true,
|
|
|
|
|
matchBrackets: true,
|
|
|
|
|
indentUnit: 2,
|
|
|
|
|
autoIndent: true,
|
|
|
|
|
mode: 'application/json',
|
|
|
|
|
});
|
|
|
|
|
var modal_obj = modal({
|
|
|
|
|
title: "Edit " + options.name + " Metadata",
|
|
|
|
|
body: dialogform,
|
|
|
|
|
buttons: {
|
|
|
|
|
OK: { class : "btn-primary",
|
|
|
|
|
click: function() {
|
|
|
|
|
/**
|
|
|
|
|
* validate json and set it
|
|
|
|
|
*/
|
|
|
|
|
var new_md;
|
|
|
|
|
try {
|
|
|
|
|
new_md = JSON.parse(editor.getValue());
|
|
|
|
|
} catch(e) {
|
|
|
|
|
console.log(e);
|
|
|
|
|
error_div.text('WARNING: Could not save invalid JSON.');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
Cancel: {}
|
|
|
|
|
options.callback(new_md);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
notebook: options.notebook,
|
|
|
|
|
keyboard_manager: options.keyboard_manager,
|
|
|
|
|
});
|
|
|
|
|
Cancel: {}
|
|
|
|
|
},
|
|
|
|
|
notebook: options.notebook,
|
|
|
|
|
keyboard_manager: options.keyboard_manager,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
|
|
|
|
modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|