import Ember from 'ember';
import config from '../config/environment';

export default Ember.Component.extend({

  foundation: null,
  isMobileApp: config.cordova.enabled,

  currentClassName: Ember.computed("className", function(){
    return this.get("className") ? `.${this.get('className')}` : document;
  }),

  click() {
    Ember.run.later(function() {
      let mobileApp = this.get("isMobileApp");
      if($('.off-canvas-wrap.move-right')[0]) {
        mobileApp ? $('body').css('overflow', 'hidden') : $('html').css('overflow', 'hidden');
      } else {
        mobileApp ? $('body').css('overflow', 'auto') : $('html').css('overflow', 'auto');
      }
    }, 100);
  },

  didInsertElement() {
    var className = this.get("currentClassName");
    var _this = this;

    this._super();

    Ember.run.debounce(this, function(){
      var clientHeight = $( window ).height();
      $('.inner-wrap').css('min-height', clientHeight);
    }, 1000);

    Ember.run.scheduleOnce('afterRender', this, function(){
      var initFoundation = Ember.$(className).foundation({
        offcanvas: { close_on_click: true }
      });
      _this.set("foundation", initFoundation);
    });
  }

  // TODO: Breaks sometime on menu-bar
  // willDestroyElement() {
  //   this.get("foundation").foundation("destroy");
  // }

});

import Ember from 'ember';

export default Ember.Component.extend({

  foundation: null,

  currentClassName: Ember.computed("className", function(){
    return this.get("className") ? `.${this.get('className')}` : document;
  }),

  click() {
    Ember.run.later(function() {
      if($('.off-canvas-wrap.move-right')[0]) {
        $('html').css('overflow', 'hidden');
      } else {
        $('html').css('overflow', 'auto');
      }
    }, 100);
  },

  didInsertElement() {
    var className = this.get("currentClassName");
    var _this = this;

    this._super();

    Ember.run.debounce(this, function(){
      var clientHeight = $( window ).height();
      $('.inner-wrap').css('min-height', clientHeight);
    }, 1000);

    Ember.run.scheduleOnce('afterRender', this, function(){
      var initFoundation = Ember.$(className).foundation({
        offcanvas: { close_on_click: true }
      });
      _this.set("foundation", initFoundation);
    });
  }

  // TODO: Breaks sometime on menu-bar
  // willDestroyElement() {
  //   this.get("foundation").foundation("destroy");
  // }

});

Revert "GCW-1826 Disable scroll when menu is open"
Revert "GCW-1826 Disable scroll when menu is open"

This reverts commit 18e774eb4e8a0033727c0a16e494ed04c60c8abb.
