From 7f644019a8eb1c0947bb6a31e7d21590e12fd383 Mon Sep 17 00:00:00 2001 From: Kane York Date: Thu, 9 Jul 2015 13:20:21 -0700 Subject: [PATCH] Add resizing --- .../discourse/components/query-result.js.es6 | 3 ++ .../templates/admin/plugins-explorer.hbs | 2 +- .../views/admin-plugins-explorer.js.es6 | 49 +++++++++++++++++++ assets/stylesheets/explorer.scss | 1 + 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 assets/javascripts/discourse/views/admin-plugins-explorer.js.es6 diff --git a/assets/javascripts/discourse/components/query-result.js.es6 b/assets/javascripts/discourse/components/query-result.js.es6 index b1d2971..ac748ee 100644 --- a/assets/javascripts/discourse/components/query-result.js.es6 +++ b/assets/javascripts/discourse/components/query-result.js.es6 @@ -133,6 +133,9 @@ const QueryResultComponent = Ember.Component.extend({ document.body.appendChild(form); form.submit(); + Em.run.next('afterRender', function() { + document.body.removeChild(form); + }) }); } }, diff --git a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs index 3a55a79..86f3053 100644 --- a/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs +++ b/assets/javascripts/discourse/templates/admin/plugins-explorer.hbs @@ -46,7 +46,7 @@
- {{ace-editor content=selectedItem.sql mode="sql"}} + {{ace-editor content=selectedItem.sql mode="sql" stashSelf=editor}}
diff --git a/assets/javascripts/discourse/views/admin-plugins-explorer.js.es6 b/assets/javascripts/discourse/views/admin-plugins-explorer.js.es6 new file mode 100644 index 0000000..a277a95 --- /dev/null +++ b/assets/javascripts/discourse/views/admin-plugins-explorer.js.es6 @@ -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') +}); diff --git a/assets/stylesheets/explorer.scss b/assets/stylesheets/explorer.scss index f2669be..62bc033 100644 --- a/assets/stylesheets/explorer.scss +++ b/assets/stylesheets/explorer.scss @@ -82,6 +82,7 @@ } .grippie { clear: both; + -webkit-user-select: none; } }