aboutsummaryrefslogtreecommitdiff
path: root/javascript/app/components/bottom-panel.js
blob: 5d8b5bce7e1ee4342eb014736d1bc73d13779313 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import Ember from 'ember';

function show(component) {  
  const height = Math.floor(component.$containerElement.height() /2);
  component.$().css({
    "display":"block",
    "top" : height+"px"
  });
  component.$topPanelElement.css({
    "height":height+"px"
  });
}

function hide(component) {
  const height = Math.floor(component.$containerElement.height()/2);
  component.$().css({
    "display":"none",
    "height":height+"px"
  });
  component.$topPanelElement.css({
    "height":"100%"
  });
}

export default Ember.Component.extend({
  classNames:["bottom-panel"],
  didInsertElement : function () {
    this._super(...arguments);
    this.$topPanelElement = Ember.$(this.get('topPanelElementId'));
    this.$containerElement = Ember.$(this.get('containerElementId'));
    Ember.run.next(this,() => {
      Ember.$(this.element).resizable({
        handles:"n",
        maxHeight:700,
        minHeight:200,
        resize: (event,ui) => {
          Ember.run.next(this,() => {
            this.$topPanelElement.css({"height": this.$containerElement.height() - ui.size.height});
          });
        }
      });
    });
  },  
  visibilityObserver : Ember.observer('visible',function () {
    this.get('visible') ? show(this) : hide(this);
  }),
  actions : {
    close () {
      this.set('visible',false);      
    }
  }
});