diff --git a/datamodels/2.x/itop-config/config.php b/datamodels/2.x/itop-config/config.php index 00a193628..8db06c29c 100644 --- a/datamodels/2.x/itop-config/config.php +++ b/datamodels/2.x/itop-config/config.php @@ -92,7 +92,6 @@ $oP->add_linked_script(utils::GetCurrentModuleUrl().'/js/ace.js'); $oP->add_linked_script(utils::GetCurrentModuleUrl().'/js/mode-php.js'); $oP->add_linked_script(utils::GetCurrentModuleUrl().'/js/theme-eclipse.js'); $oP->add_linked_script(utils::GetCurrentModuleUrl().'/js/ext-searchbox.js'); -//$oP->add_linked_script(utils::GetCurrentModuleUrl().'/js/ext-textarea.js'); try { @@ -191,31 +190,93 @@ try $sConfirmCancel = addslashes(Dict::S('config-confirm-cancel')); $oP->add_script( - <<add_ready_script( + $oP->add_ready_script( <<<'EOF' var editor = ace.edit("new_config"); + var $configurationSource = $('input[name="new_config"]'); editor.getSession().setValue($configurationSource.val()); editor.getSession().on('change', function() { $configurationSource.val(editor.getSession().getValue()); - UpdateConfigEditorButtonState(); + EditorUtils.updateConfigEditorButtonState(editor); }); editor.getSession().on("changeAnnotation", function() { - UpdateConfigEditorButtonState(); + EditorUtils.updateConfigEditorButtonState(editor); }); editor.setTheme("ace/theme/eclipse"); @@ -224,16 +285,23 @@ editor.commands.addCommand({ name: 'save', bindKey: {win: "Ctrl-S", "mac": "Cmd-S"}, exec: function(editor) { - $editorContainer = $(editor.container); - $editorForm = $editorContainer.closest("form"); + $editorForm = EditorUtils.getEditorForm(editor); $submitButton = $('#submit_button'); if ($submitButton.is(":enabled")) { $editorForm.submit(); } } -}) +}); + +var $editorForm = EditorUtils.getEditorForm(editor); +$editorForm.submit(function() { + EditorUtils.saveEditorDisplay(editor); +}); + + +EditorUtils.restoreEditorDisplay(editor); editor.focus(); EOF );