2015-07-09 16:20:21 -04:00
|
|
|
|
|
|
|
export default Ember.View.extend({
|
|
|
|
_bindGrippie: function() {
|
|
|
|
const $editPane = this.$().find('.query-editor');
|
|
|
|
if (!$editPane.length) {
|
|
|
|
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);
|
2015-07-09 17:10:45 -04:00
|
|
|
self.appEvents.trigger('ace:resize');
|
2015-07-09 16:20:21 -04:00
|
|
|
}, 5);
|
|
|
|
|
|
|
|
const mouseup = function(e) {
|
|
|
|
//mousemove(e);
|
|
|
|
$body.off('mousemove', mousemove);
|
|
|
|
$body.off('mouseup', mouseup);
|
|
|
|
self.set('startY', null);
|
|
|
|
self.set('startSize', null);
|
2015-07-09 17:10:45 -04:00
|
|
|
};
|
2015-07-09 16:20:21 -04:00
|
|
|
|
|
|
|
$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();
|
|
|
|
});
|
|
|
|
|
2015-07-09 17:10:45 -04:00
|
|
|
}.on('didInsertElement'),
|
|
|
|
|
|
|
|
_cleanup: function() {
|
|
|
|
this.set('grippie', null);
|
|
|
|
}.on('willDestroyElement')
|
2015-07-09 16:20:21 -04:00
|
|
|
});
|