Skip to content

Business intelligence made simple

Dynamically expand editor height as needed

Andrew Kane6ef1125a5076
diff --git a/app/views/blazer/queries/_form.html.erb b/app/views/blazer/queries/_form.html.erb
index 54f05a3d..d152048a 100644
--- a/app/views/blazer/queries/_form.html.erb
+++ b/app/views/blazer/queries/_form.html.erb
@@ -61,12 +61,25 @@
name: 'run',
bindKey: {win: 'Ctrl-Enter', mac: 'Command-Enter'},
exec: function(editor) {
- $("#run").click();
+ $("#run").click();
},
readOnly: false // false if this command should not apply in readOnly mode
});
- editor.resize();
+ // http://stackoverflow.com/questions/11584061/
+ function adjustHeight() {
+ var lines = editor.getSession().getScreenLength();
+ if (lines < 9) {
+ lines = 9;
+ }
+
+ var newHeight = (lines + 1) * 16;
+ $("#editor").height(newHeight.toString() + "px");
+ editor.resize();
+ };
+
+ editor.getSession().on("change", adjustHeight);
+ adjustHeight();
$("#editor").show();
editor.focus();