Add resizing

This commit is contained in:
Kane York 2015-07-09 13:20:21 -07:00
parent d748e0dae5
commit 7f644019a8
4 changed files with 54 additions and 1 deletions

View File

@ -133,6 +133,9 @@ const QueryResultComponent = Ember.Component.extend({
document.body.appendChild(form);
form.submit();
Em.run.next('afterRender', function() {
document.body.removeChild(form);
})
});
}
},

View File

@ -46,7 +46,7 @@
<div class="query-editor">
<div class="editor-panel">
{{ace-editor content=selectedItem.sql mode="sql"}}
{{ace-editor content=selectedItem.sql mode="sql" stashSelf=editor}}
</div>
<div class="right-panel">
<div class="schema grippie-target">

View File

@ -0,0 +1,49 @@
export default Ember.View.extend({
_bindGrippie: function() {
const $editPane = this.$().find('.query-editor');
if (!$editPane.length) {
return;
}
const aceComponent = this.get('controller.editor');
if (!aceComponent) {
return;
}
const oldGrippie = this.get('grippie');
if (oldGrippie) {
oldGrippie.off('mousedown mousemove mouseup');
$editPane.off('mousemove mouseup');
}
const $grippie = $editPane.find('.grippie');
const $targets = $editPane.find('.ace-wrapper,.grippie-target');
const $body = $('body');
const self = this;
this.set('grippie', $grippie);
const mousemove = Discourse.debounce(function(e) {
const diff = self.get('startY') - e.screenY;
$targets.height(self.get('startSize') - diff);
aceComponent.trigger('resize');
}, 5);
const mouseup = function(e) {
//mousemove(e);
$body.off('mousemove', mousemove);
$body.off('mouseup', mouseup);
self.set('startY', null);
self.set('startSize', null);
}
$grippie.on('mousedown', function(e) {
self.set('startY', e.screenY);
self.set('startSize', $targets.height());
$body.on('mousemove', mousemove);
$body.on('mouseup', mouseup);
e.preventDefault();
});
}.observes('controller.editor')
});

View File

@ -82,6 +82,7 @@
}
.grippie {
clear: both;
-webkit-user-select: none;
}
}