fix: Ability to resize expand/collapse code field

This commit is contained in:
Faris Ansari 2020-04-18 13:47:06 +05:30
parent 47a19ce6e5
commit 8f21ca4997

View file

@ -9,6 +9,12 @@ frappe.ui.form.ControlCode = frappe.ui.form.ControlText.extend({
this.ace_editor_target = $('<div class="ace-editor-target"></div>')
.appendTo(this.input_area);
this.expanded = false;
this.$expand_button = $(`<button class="margin-top btn btn-xs btn-default">${__('Expand / Collapse')}</button>`).click(() => {
this.expanded = !this.expanded;
this.refresh_height();
}).insertAfter(this.ace_editor_target);
// styling
this.ace_editor_target.addClass('border rounded');
this.ace_editor_target.css('height', 300);
@ -26,6 +32,11 @@ frappe.ui.form.ControlCode = frappe.ui.form.ControlText.extend({
}, 300));
},
refresh_height() {
this.ace_editor_target.css('height', this.expanded ? 600 : 300);
this.editor.resize();
},
set_language() {
const language_map = {
'Javascript': 'ace/mode/javascript',