Merge pull request #9995 from netchampfaris/code-resize

feat: Ability to resize expand/collapse code field
This commit is contained in:
mergify[bot] 2020-04-20 06:07:37 +00:00 committed by GitHub
commit 30705290fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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',