/*
EnumBasic.php
public static function getTypeForJs() {
  $ancestral = get_called_class();
  $name = substr($ancestral, strripos($ancestral, '\\') + 1);

  $return = array('name' => $name, 'constants' => self::getEnumListConst(), 'nickname' => $ancestral::$nickname);
  if (isset($ancestral::$others)) {
    $return['others'] = $ancestral::$others;
  }

  return $return;
}

Controller.php
$this->document->addTypesForJs(Type_ModulePosition::getTypeForJs());

ou

$this->document->addTypesForJs(array(
  Type_ModulePosition::getTypeForJs(),
  Type_PerfilCustomerJuridico::getTypeForJs()
));


=================================== JS ======================================
var html = '';
for (var key in Type_Tamanho.getEnumList()) {
  html += '<option value="' + key + '"' + ftr_geral.isSelected(KEY, 'content_bottom', Type_ModulePosition.Tp_ContentTop) + '>' + Type_Tamanho.getEnumList()[key] + '</option>';
}
console.log(html);


*/
(function(window) {
  function Ftr_Geral() {}

  Ftr_Geral.prototype.isSelected = function(value, baseValue, defaultValue) {
    defaultValue = typeof defaultValue !== 'undefined' ? defaultValue : '';
    baseValue = baseValue !== '' && baseValue != null ? baseValue : defaultValue;

    if (baseValue !== '' && baseValue != null) {
      if (value == baseValue) {
        return ' selected="selected"';
      } else {
        return '';
      }
    }
  };

  Ftr_Geral.prototype.isChecked = function(value, baseValue, defaultValue) {
    defaultValue = typeof defaultValue !== 'undefined' ? defaultValue : '';
    baseValue = baseValue !== '' && baseValue != null ? baseValue : defaultValue;

    if (baseValue !== '' && baseValue != null) {
      if (value == baseValue) {
        return ' checked="checked"';
      } else {
        return '';
      }
    }
  };

  window.ftr_geral = new Ftr_Geral();
})(window);

(function(window) {
  function Enumbasic() {}

  Enumbasic.prototype.getEnumList = function(other) {
    other = typeof other !== 'undefined' ? other : false;
    if (other) {
      return Object.assign(this.nickname, this.others);
    } else {
      return this.nickname;
    }
  };

  Enumbasic.prototype.getNickFromValue = function(value, other) {
    other = typeof other !== 'undefined' ? other : false;
    var enumlist = this.getEnumList(other);

    if (typeof enumlist == 'object' && typeof enumlist[value] != 'undefined') {
      return enumlist[value];
    } else {
      return null;
    }
  };

  Enumbasic.prototype.getRemoveArray = function(indices, other) {
    indices = typeof indices !== 'undefined' ? indices : [];
    other = typeof other !== 'undefined' ? other : false;
    var enumlist = this.getEnumList(other);
    for (var i = 0; i < indices.length; i++) {
      delete enumlist[indices[i]];
    }

    return enumlist;
  };

  function Type(type) {
    if (!type) return false;

    for (var KEY in type.constants) {
      if (type.constants.hasOwnProperty(KEY)) {
        this[KEY] = type.constants[KEY];
      }
    }

    this.nickname = type.nickname;
    if (typeof type.others != 'undefined') {
      this.others = type.others;
    }

    window[type.name] = this;
  }

  Type.prototype = Enumbasic.prototype;
  Type.prototype.constructor = Type;

  Type.prototype.forEach = function(func) {
    var object = this.getEnumList();

    for (var KEY in object) {
      if (object.hasOwnProperty(KEY)) {
        var PARAMETERS = [object[KEY], KEY, object];
        func.apply(this, PARAMETERS);
      }
    }
  };

  module = typeof module !== 'undefined' ? module : {};
  module.exports = Type;

  window.Type = Type;
})(window);
