/**
 * Generated by Apache Royale Compiler from org\apache\royale\html\beads\controllers\DateChooserMouseController.as
 * org.apache.royale.html.beads.controllers.DateChooserMouseController
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.royale.html.beads.controllers.DateChooserMouseController');

goog.require('org.apache.royale.core.IBeadModel');
goog.require('org.apache.royale.core.IBeadView');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.events.MouseEvent');
goog.require('org.apache.royale.html.beads.DateChooserView');
goog.require('org.apache.royale.html.beads.models.DateChooserModel');
goog.require('org.apache.royale.html.supportClasses.DateChooserList');
goog.require('org.apache.royale.core.IBeadController');
goog.require('org.apache.royale.utils.Language');



/**
 *  constructor.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion Royale 0.0
 * @constructor
 * @implements {org.apache.royale.core.IBeadController}
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController = function() {
};


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.royale.html.beads.controllers.DateChooserMouseController', org.apache.royale.html.beads.controllers.DateChooserMouseController);


/**
 * @private
 * @type {org.apache.royale.core.IStrand}
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_html_beads_controllers_DateChooserMouseController__strand;


/**
 * @private
 * @param {org.apache.royale.events.Event} event
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_html_beads_controllers_DateChooserMouseController_listHandler = function(event) {
  var /** @type {org.apache.royale.html.supportClasses.DateChooserList} */ list = org.apache.royale.utils.Language.as(event.target, org.apache.royale.html.supportClasses.DateChooserList);
  var /** @type {org.apache.royale.html.beads.models.DateChooserModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.html.beads.models.DateChooserModel);
  model.selectedDate = org.apache.royale.utils.Language.as(list.selectedItem, Date);
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_html_beads_controllers_DateChooserMouseController_prevMonthClickHandler = function(event) {
  event.preventDefault();
  var /** @type {org.apache.royale.html.beads.models.DateChooserModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.html.beads.models.DateChooserModel);
  var /** @type {number} */ month = model.displayedMonth - 1;
  var /** @type {number} */ year = model.displayedYear;
  if (month < 0) {
    month = 11;
    year--;
  }
  model.displayedMonth = month;
  model.displayedYear = year;
};


/**
 * @asprivate
 * @private
 * @param {org.apache.royale.events.MouseEvent} event
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.org_apache_royale_html_beads_controllers_DateChooserMouseController_nextMonthClickHandler = function(event) {
  event.preventDefault();
  var /** @type {org.apache.royale.html.beads.models.DateChooserModel} */ model = org.apache.royale.utils.Language.as(this.org_apache_royale_html_beads_controllers_DateChooserMouseController__strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.html.beads.models.DateChooserModel);
  var /** @type {number} */ month = model.displayedMonth + 1;
  var /** @type {number} */ year = model.displayedYear;
  if (month >= 12) {
    month = 0;
    year++;
  }
  model.displayedMonth = month;
  model.displayedYear = year;
};


org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.set__strand = function(value) {
  this.org_apache_royale_html_beads_controllers_DateChooserMouseController__strand = value;
  var /** @type {org.apache.royale.html.beads.DateChooserView} */ view = org.apache.royale.utils.Language.as(value.getBeadByType(org.apache.royale.core.IBeadView), org.apache.royale.html.beads.DateChooserView);
  view.prevMonthButton.addEventListener("click", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_DateChooserMouseController_prevMonthClickHandler, this, 'prevMonthClickHandler'));
  view.nextMonthButton.addEventListener("click", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_DateChooserMouseController_nextMonthClickHandler, this, 'nextMonthClickHandler'));
  org.apache.royale.utils.Language.as(view.dayList, org.apache.royale.events.IEventDispatcher, true).addEventListener("change", org.apache.royale.utils.Language.closure(this.org_apache_royale_html_beads_controllers_DateChooserMouseController_listHandler, this, 'listHandler'));
};


Object.defineProperties(org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype, /** @lends {org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.set__strand}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.prototype.ROYALE_CLASS_INFO = { names: [{ name: 'DateChooserMouseController', qName: 'org.apache.royale.html.beads.controllers.DateChooserMouseController', kind: 'class' }], interfaces: [org.apache.royale.core.IBeadController] };



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.html.beads.controllers.DateChooserMouseController.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.html.beads.controllers.DateChooserMouseController'}
      };
    },
    methods: function () {
      return {
        'DateChooserMouseController': { type: '', declaredBy: 'org.apache.royale.html.beads.controllers.DateChooserMouseController'}
      };
    }
  };
};