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

goog.provide('org.apache.royale.jewel.beads.views.SliderView');

goog.require('org.apache.royale.core.BeadViewBase');
goog.require('org.apache.royale.core.IBeadModel');
goog.require('org.apache.royale.core.IRangeModel');
goog.require('org.apache.royale.core.IStrand');
goog.require('org.apache.royale.core.IUIBase');
goog.require('org.apache.royale.core.UIBase');
goog.require('org.apache.royale.events.Event');
goog.require('org.apache.royale.events.IEventDispatcher');
goog.require('org.apache.royale.jewel.Button');
goog.require('org.apache.royale.core.IBeadView');
goog.require('org.apache.royale.jewel.beads.controls.slider.ISliderView');
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.core.BeadViewBase}
 * @implements {org.apache.royale.jewel.beads.controls.slider.ISliderView}
 * @implements {org.apache.royale.core.IBeadView}
 */
org.apache.royale.jewel.beads.views.SliderView = function() {
  org.apache.royale.jewel.beads.views.SliderView.base(this, 'constructor');
};
goog.inherits(org.apache.royale.jewel.beads.views.SliderView, org.apache.royale.core.BeadViewBase);


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


/**
 * @private
 * @type {org.apache.royale.core.IRangeModel}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView_rangeModel;


/**
 * @private
 * @type {org.apache.royale.jewel.Button}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView__track;


/**
 * @private
 * @type {org.apache.royale.jewel.Button}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView__thumb;


/**
 * @private
 * @type {HTMLDivElement}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView__sliderTrackFill;


/**
 * @private
 * @type {HTMLDivElement}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView__sliderTrack;


/**
 * @export
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.redraw = function() {
  var /** @type {number} */ barsize = (this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.value - this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.minimum) / (this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.maximum - this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.minimum);
  this.sliderTrack.style.flex = (1 - barsize).toString();
  this.sliderTrackFill.style.flex = barsize.toString();
};


/**
 * @asprivate
 *
 * @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.views.SliderView.prototype.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler = function(event) {
  var /** @type {HTMLInputElement} */ inputElement = org.apache.royale.utils.Language.as(org.apache.royale.utils.Language.as(this._strand, org.apache.royale.core.UIBase, true).element, HTMLInputElement);
  inputElement.step = String(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.stepSize);
  inputElement.min = String(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.minimum);
  inputElement.max = String(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.maximum);
  inputElement.value = this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.value.toString();
};


org.apache.royale.jewel.beads.views.SliderView.prototype.get__track = function() {
  return this.org_apache_royale_jewel_beads_views_SliderView__track;
};


org.apache.royale.jewel.beads.views.SliderView.prototype.get__thumb = function() {
  return this.org_apache_royale_jewel_beads_views_SliderView__thumb;
};


org.apache.royale.jewel.beads.views.SliderView.prototype.set__strand = function(value) {
  org.apache.royale.jewel.beads.views.SliderView.superClass_.set__strand.apply(this, [ value] );
  var /** @type {org.apache.royale.core.UIBase} */ host = org.apache.royale.utils.Language.as(this._strand, org.apache.royale.core.UIBase, true);
  this.org_apache_royale_jewel_beads_views_SliderView_rangeModel = org.apache.royale.utils.Language.as(this._strand.getBeadByType(org.apache.royale.core.IBeadModel), org.apache.royale.core.IRangeModel);
  
  var /** @type {HTMLInputElement} */ htmlSliderElement = org.apache.royale.utils.Language.as(host.element, HTMLInputElement);
  htmlSliderElement.value = String(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel.value);
  var /** @type {HTMLDivElement} */ sliderTrackContainer = document.createElement('div');
  sliderTrackContainer.className = "slider-track-container";
  this.sliderTrackFill = document.createElement('div');
  this.sliderTrackFill.className = "slider-track-fill";
  this.sliderTrack = document.createElement('div');
  this.sliderTrack.className = "slider-track";
  sliderTrackContainer.appendChild(this.sliderTrackFill);
  sliderTrackContainer.appendChild(this.sliderTrack);
  host.positioner.appendChild(sliderTrackContainer);
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel, org.apache.royale.events.IEventDispatcher, true).addEventListener("stepSizeChange", org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler, this, 'modelChangeHandler'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel, org.apache.royale.events.IEventDispatcher, true).addEventListener("minimumChange", org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler, this, 'modelChangeHandler'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel, org.apache.royale.events.IEventDispatcher, true).addEventListener("maximumChange", org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler, this, 'modelChangeHandler'));
  org.apache.royale.utils.Language.as(this.org_apache_royale_jewel_beads_views_SliderView_rangeModel, org.apache.royale.events.IEventDispatcher, true).addEventListener("valueChange", org.apache.royale.utils.Language.closure(this.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler, this, 'modelChangeHandler'));
  this.org_apache_royale_jewel_beads_views_SliderView_modelChangeHandler(null);
};


org.apache.royale.jewel.beads.views.SliderView.prototype.get__sliderTrackFill = function() {
  return this.org_apache_royale_jewel_beads_views_SliderView__sliderTrackFill;
};


org.apache.royale.jewel.beads.views.SliderView.prototype.set__sliderTrackFill = function(value) {
  this.org_apache_royale_jewel_beads_views_SliderView__sliderTrackFill = value;
};


org.apache.royale.jewel.beads.views.SliderView.prototype.get__sliderTrack = function() {
  return this.org_apache_royale_jewel_beads_views_SliderView__sliderTrack;
};


org.apache.royale.jewel.beads.views.SliderView.prototype.set__sliderTrack = function(value) {
  this.org_apache_royale_jewel_beads_views_SliderView__sliderTrack = value;
};


Object.defineProperties(org.apache.royale.jewel.beads.views.SliderView.prototype, /** @lends {org.apache.royale.jewel.beads.views.SliderView.prototype} */ {
/**
  * @export
  * @type {org.apache.royale.core.IUIBase} */
track: {
get: org.apache.royale.jewel.beads.views.SliderView.prototype.get__track},
/**
  * @export
  * @type {org.apache.royale.core.IUIBase} */
thumb: {
get: org.apache.royale.jewel.beads.views.SliderView.prototype.get__thumb},
/**
  * @export
  * @type {org.apache.royale.core.IStrand} */
strand: {
set: org.apache.royale.jewel.beads.views.SliderView.prototype.set__strand},
/**
  * @export
  * @type {HTMLDivElement} */
sliderTrackFill: {
get: org.apache.royale.jewel.beads.views.SliderView.prototype.get__sliderTrackFill,
set: org.apache.royale.jewel.beads.views.SliderView.prototype.set__sliderTrackFill},
/**
  * @export
  * @type {HTMLDivElement} */
sliderTrack: {
get: org.apache.royale.jewel.beads.views.SliderView.prototype.get__sliderTrack,
set: org.apache.royale.jewel.beads.views.SliderView.prototype.set__sliderTrack}}
);


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



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.royale.jewel.beads.views.SliderView.prototype.ROYALE_REFLECTION_INFO = function () {
  return {
    variables: function () {return {};},
    accessors: function () {
      return {
        'track': { type: 'org.apache.royale.core.IUIBase', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'},
        'thumb': { type: 'org.apache.royale.core.IUIBase', access: 'readonly', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'},
        'strand': { type: 'org.apache.royale.core.IStrand', access: 'writeonly', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'},
        'sliderTrackFill': { type: 'HTMLDivElement', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'},
        'sliderTrack': { type: 'HTMLDivElement', access: 'readwrite', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'}
      };
    },
    methods: function () {
      return {
        'SliderView': { type: '', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'},
        'redraw': { type: 'void', declaredBy: 'org.apache.royale.jewel.beads.views.SliderView'}
      };
    }
  };
};