/**
 * Generated by Apache Royale Compiler from org\apache\royale\jewel\Drawer.as
 * org.apache.royale.jewel.Drawer
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.jewel.Drawer');

goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.MouseEvent');
goog.require('org.apache.royale.events.ValueChangeEvent');
goog.require('org.apache.royale.jewel.supportClasses.drawer.DrawerBase');
goog.require('org.apache.royale.utils.StringUtil');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @constructor
 * @extends {org.apache.royale.jewel.supportClasses.drawer.DrawerBase}
 */
org.apache.royale.jewel.Drawer = function() {
  org.apache.royale.jewel.Drawer.base(this, 'constructor');
  this.typeNames = "jewel drawer " + org.apache.royale.jewel.Drawer.FLOAT;
  this.addEventListener(org.apache.royale.events.MouseEvent.CLICK, org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_Drawer_internalMouseHandler, this, 'internalMouseHandler'));
};
goog.inherits(org.apache.royale.jewel.Drawer, org.apache.royale.jewel.supportClasses.drawer.DrawerBase);


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.jewel.Drawer', org.apache.royale.jewel.Drawer);


/**
 * @export
 * @const
 * @type {string}
 */
org.apache.royale.jewel.Drawer.FLOAT = "float";


/**
 * @export
 * @const
 * @type {string}
 */
org.apache.royale.jewel.Drawer.FIXED = "fixed";


/**
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.jewel.Drawer.prototype.org_apache_royale_jewel_Drawer_internalMouseHandler = function(event) {
  var /** @type {org.apache.royale.core.UIBase} */ hostComponent = org.apache.royale.utils.Language.as(event.target, org.apache.royale.core.UIBase);
  var /** @type {DOMTokenList} */ hostClassList = hostComponent.positioner.classList;
  if (hostClassList.contains("drawer")) {
    this.close();
  }
};


/**
 * @private
 * @type {boolean}
 */
org.apache.royale.jewel.Drawer.prototype.org_apache_royale_jewel_Drawer__isOpen;


/**
 * @protected
 */
org.apache.royale.jewel.Drawer.prototype.adjustAppScroll = function() {
  if (this.fixed) {
    document.body.classList.remove("viewport");
  } else {
    this.org_apache_royale_jewel_Drawer__isOpen ? document.body.classList.add("viewport") : document.body.classList.remove("viewport");
  }
};


/**
 * @export
 */
org.apache.royale.jewel.Drawer.prototype.open = function() {
  this.isOpen = true;
};


/**
 * @export
 */
org.apache.royale.jewel.Drawer.prototype.close = function() {
  this.isOpen = false;
};


/**
 * @protected
 * @type {boolean}
 */
org.apache.royale.jewel.Drawer.prototype._fixed = false;


org.apache.royale.jewel.Drawer.prototype.get__isOpen = function() {
  return this.org_apache_royale_jewel_Drawer__isOpen;
};


org.apache.royale.jewel.Drawer.prototype.bindable__set__isOpen = function(value) {
  if (this.org_apache_royale_jewel_Drawer__isOpen != value) {
    this.org_apache_royale_jewel_Drawer__isOpen = value;
    this.toggleClass("open", this.org_apache_royale_jewel_Drawer__isOpen);
    this.adjustAppScroll();
    this.org_apache_royale_jewel_Drawer__isOpen ? this.dispatchEvent(new org.apache.royale.events.Event("openDrawer")) : this.dispatchEvent(new org.apache.royale.events.Event("closeDrawer"));
  }
};


org.apache.royale.jewel.Drawer.prototype.set__isOpen = function(value) {
var oldValue = this.get__isOpen();
if (oldValue != value) {
this.bindable__set__isOpen(value);
    this.dispatchEvent(org.apache.royale.events.ValueChangeEvent.createUpdateEvent(
         this, "isOpen", oldValue, value));
}
};


org.apache.royale.jewel.Drawer.prototype.get__fixed = function() {
  return this._fixed;
};


org.apache.royale.jewel.Drawer.prototype.bindable__set__fixed = function(value) {
  if (this._fixed != value) {
    this._fixed = value;
    if (this._fixed) {
      this.typeNames = org.apache.royale.utils.StringUtil.removeWord(this.typeNames, " " + org.apache.royale.jewel.Drawer.FLOAT);
      this.typeNames += " " + org.apache.royale.jewel.Drawer.FIXED;
    } else {
      this.typeNames = org.apache.royale.utils.StringUtil.removeWord(this.typeNames, " " + org.apache.royale.jewel.Drawer.FIXED);
      this.typeNames += " " + org.apache.royale.jewel.Drawer.FLOAT;
    }
    if (this.parent)
      this.setClassName(this.computeFinalClassNames());
    this.toggleClass("open", this.org_apache_royale_jewel_Drawer__isOpen);
  }
};


org.apache.royale.jewel.Drawer.prototype.set__fixed = function(value) {
var oldValue = this.get__fixed();
if (oldValue != value) {
this.bindable__set__fixed(value);
    this.dispatchEvent(org.apache.royale.events.ValueChangeEvent.createUpdateEvent(
         this, "fixed", oldValue, value));
}
};


Object.defineProperties(org.apache.royale.jewel.Drawer.prototype, /** @lends {org.apache.royale.jewel.Drawer.prototype} */ {
/**
  * @export
  * @type {boolean} */
isOpen: {
get: org.apache.royale.jewel.Drawer.prototype.get__isOpen,
set: org.apache.royale.jewel.Drawer.prototype.set__isOpen},
/**
  * @export
  * @type {boolean} */
fixed: {
get: org.apache.royale.jewel.Drawer.prototype.get__fixed,
set: org.apache.royale.jewel.Drawer.prototype.set__fixed}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.jewel.Drawer.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'Drawer', qName: 'org.apache.royale.jewel.Drawer', kind: 'class' }] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.Drawer.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'isOpen': { type: 'Boolean', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.Drawer', metadata: function () { return [ { name: 'Bindable' } ]; }},
        'fixed': { type: 'Boolean', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.Drawer', metadata: function () { return [ { name: 'Bindable' } ]; }}
      };
    },
    methods: function () {
      return {
        'Drawer': { type: '', declaredBy: 'org.apache.royale.jewel.Drawer'},
        'open': { type: 'void', declaredBy: 'org.apache.royale.jewel.Drawer'},
        'close': { type: 'void', declaredBy: 'org.apache.royale.jewel.Drawer'}
      };
    }
  };
};