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

goog.provide('org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer');

goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.jewel.Drawer');
goog.require('org.apache.royale.jewel.supportClasses.ResponsiveSizes');
goog.require('org.apache.royale.core.IBead');
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
 * @implements {org.apache.royale.core.IBead}
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer = function() {
};


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


/**
 * @private
 * @type {org.apache.royale.jewel.Drawer}
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer;


/**
 * @protected
 * @type {boolean}
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype._auto = false;


/**
 * @private
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_updateDrawer = function() {
  if (this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer) {
    if (this._auto) {
      window.addEventListener('resize', org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_autoResizeHandler, this, 'autoResizeHandler'), false);
    } else {
      window.removeEventListener('resize', org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_autoResizeHandler, this, 'autoResizeHandler'), false);
    }
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.toggleClass("auto", this._auto);
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_autoResizeHandler();
  }
};


/**
 *  When set to "auto" this resize handler monitors the width of the app window
 *  and switch between fixed and float modes.
 * 
 *  Note:This could be done with media queries, but since it handles open/close
 *  maybe this is the right way
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.9.4
 * @private
 * @param {org.apache.royale.events.Event=} event
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_autoResizeHandler = function(event) {
  event = typeof event !== 'undefined' ? event : null;
  var /** @type {number} */ outerWidth = document.body.getBoundingClientRect().width;
  var /** @type {boolean} */ tmpFixed = this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.fixed;
  if (outerWidth > org.apache.royale.jewel.supportClasses.ResponsiveSizes.DESKTOP_BREAKPOINT) {
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.fixed = true;
    if (tmpFixed != this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.fixed) {
      this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.open();
    }
  } else {
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.fixed = false;
    if (tmpFixed != this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.fixed) {
      this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer.close();
    }
  }
};


org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.set__strand = function(value) {
  this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer = org.apache.royale.utils.Language.as(value, org.apache.royale.jewel.Drawer);
  if (this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_drawer) {
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_updateDrawer();
  } else {
    throw new Error("ResponsiveDrawer must be used with Drawer class");
  }
};


org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.get__auto = function() {
  return this._auto;
};


org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.set__auto = function(value) {
  if (this._auto != value) {
    this._auto = value;
    this.org_apache_royale_jewel_beads_controls_drawer_ResponsiveDrawer_updateDrawer();
  }
};


Object.defineProperties(org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype, /** @lends {org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.set__strand},
/**
  * @export
  * @type {boolean} */
auto: {
get: org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.get__auto,
set: org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.set__auto}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'ResponsiveDrawer', qName: 'org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer', kind: 'class' }], interfaces: [org.apache.royale.core.IBead] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer'},
        'auto': { type: 'Boolean', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer'}
      };
    },
    methods: function () {
      return {
        'ResponsiveDrawer': { type: '', declaredBy: 'org.apache.royale.jewel.beads.controls.drawer.ResponsiveDrawer'}
      };
    }
  };
};