/**
 * * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Generated by Apache Flex Cross-Compiler from org/apache/flex/html/ToggleTextButton.as
 * org.apache.flex.html.ToggleTextButton
 *
 * @fileoverview
 *
 * @suppress {checkTypes|accessControls}
 */

goog.provide('org.apache.flex.html.ToggleTextButton');

goog.require('org.apache.flex.html.TextButton');
goog.require('org.apache.flex.core.IStrand');
goog.require('org.apache.flex.core.IUIBase');
goog.require('org.apache.flex.events.IEventDispatcher');
goog.require('org.apache.flex.utils.Language');



/**
 *  Constructor.
 *
 *  @langversion 3.0
 *  @playerversion Flash 10.2
 *  @playerversion AIR 2.6
 *  @productversion FlexJS 0.0
 * @constructor
 * @extends {org.apache.flex.html.TextButton}
 * @implements {org.apache.flex.core.IStrand}
 * @implements {org.apache.flex.events.IEventDispatcher}
 * @implements {org.apache.flex.core.IUIBase}
 */
org.apache.flex.html.ToggleTextButton = function() {
  org.apache.flex.html.ToggleTextButton.base(this, 'constructor');
  this.typeNames = 'toggleTextButton';
};
goog.inherits(org.apache.flex.html.ToggleTextButton, org.apache.flex.html.TextButton);


/**
 * @private
 * @type {boolean}
 */
org.apache.flex.html.ToggleTextButton.prototype._selected;


/**
 * @private
 * @type {string}
 */
org.apache.flex.html.ToggleTextButton.prototype.SELECTED = "selected";


/**
 * @protected
 * @override
 */
org.apache.flex.html.ToggleTextButton.prototype.createElement = function() {
  org.apache.flex.html.ToggleTextButton.base(this, 'createElement');
  this.element.addEventListener("click", org.apache.flex.utils.Language.closure(this.clickHandler, this, 'clickHandler'), false);
  return this.element;
};


/**
 * @private
 * @param {Event} event
 */
org.apache.flex.html.ToggleTextButton.prototype.clickHandler = function(event) {
  this.selected = !this.selected;
};


Object.defineProperties(org.apache.flex.html.ToggleTextButton.prototype, /** @lends {org.apache.flex.html.ToggleTextButton.prototype} */ {
/** @export */
selected: {
get: /** @this {org.apache.flex.html.ToggleTextButton} */ function() {
  
  return this._selected;
},
set: /** @this {org.apache.flex.html.ToggleTextButton} */ function(value) {
  
  if (this._selected != value) {
    this._selected = value;
    var /** @type {string} */ className = this.className;
    var /** @type {string} */ typeNames = this.typeNames;
    if (value) {
      if (typeNames.indexOf(this.SELECTED) == -1) {
        typeNames = typeNames + this.SELECTED;
        if (className)
          this.element.className = typeNames + ' ' + className;
        else
          this.element.className = typeNames;
      }
    } else {
      if (typeNames.indexOf(this.SELECTED) == typeNames.length - this.SELECTED.length) {
        typeNames = typeNames.substring(0, typeNames.length - this.SELECTED.length);
        if (className)
          this.element.className = typeNames + ' ' + className;
        else
          this.element.className = typeNames;
      }
    }
  }
}},
/** @export */
className: {
get: /** @this {org.apache.flex.html.ToggleTextButton} */ function() {
  if (!this.parent)
    return org.apache.flex.utils.Language.superGetter(org.apache.flex.html.ToggleTextButton, this, 'className');
  var /** @type {string} */ name = org.apache.flex.utils.Language.superGetter(org.apache.flex.html.ToggleTextButton, this, 'className');
  if (this.selected)
    return "toggleTextButton_Selected" + (name ? " " + name : "");
  else
    return "toggleTextButton" + (name ? " " + name : "");
},
set: /** @this {org.apache.flex.html.ToggleTextButton} */ function(value) {
org.apache.flex.utils.Language.superSetter(org.apache.flex.html.ToggleTextButton, this, 'className', value);
}}}
);


/**
 * Metadata
 *
 * @type {Object.<string, Array.<Object>>}
 */
org.apache.flex.html.ToggleTextButton.prototype.FLEXJS_CLASS_INFO = { names: [{ name: 'ToggleTextButton', qName: 'org.apache.flex.html.ToggleTextButton'}], interfaces: [org.apache.flex.core.IStrand, org.apache.flex.events.IEventDispatcher, org.apache.flex.core.IUIBase] };


/**
 * Prevent renaming of class. Needed for reflection.
 */
goog.exportSymbol('org.apache.flex.html.ToggleTextButton', org.apache.flex.html.ToggleTextButton);



/**
 * Reflection
 *
 * @return {Object.<string, Function>}
 */
org.apache.flex.html.ToggleTextButton.prototype.FLEXJS_REFLECTION_INFO = function () {
  return {
    variables: function () {
      return {
      };
    },
    accessors: function () {
      return {
        'selected': { type: 'Boolean', declaredBy: 'org.apache.flex.html.ToggleTextButton'},
        'className': { type: 'String', declaredBy: 'org.apache.flex.html.ToggleTextButton'}
      };
    },
    methods: function () {
      return {
        'ToggleTextButton': { type: '', declaredBy: 'org.apache.flex.html.ToggleTextButton'}
      };
    },
    metadata: function () { return [ ]; }
  };
};