text: /*
   * Created on: 30/10/2018
   * Author:     Esteban Cabezudo
   */
  
  /* global Core */
  
  
  class Link {
    constructor( { onClick = null, target = null, id = null, element = null, text = true, key = null, parameters = null, disable = false } = {}) {
      console.log(`Create Link`);
      this.key = key;
      this.parameters = parameters;
      this.id = id;
      this.element = element;
  
      const validateOptions = () => {
        if (id !== null) {
          this.element = Core.validateById(id);
          this.id = id;
        } else {
          if (element === null) {
            throw Error('You must define a property id or a property element.');
          }
          this.id = this.element.id;
        }
        if (onClick === null) {
          throw Error('You must define a url or function in a property onClick.');
        }
      };
      const createGUI = () => {
        console.log('Link :: createGUI :: Using element ', element);
        if (disable) {
          this.element.classList.add('linkToDisable');
        } else {
          this.element.classList.add('linkTo');
        }
        if (text) {
          const html = this.element.innerHTML;
          this.setText(html);
        }
  
        if (!disable) {
          this.element.addEventListener('mouseup', e => {
            e.preventDefault();
            if (typeof onClick === 'function') {
              onClick(this);
            } else {
              if (target === '_blank' || (e && (e.which === 2 || e.button === 4))) {
                window.open(onClick, '_blank');
              } else {
                document.location.href = onClick;
              }
            }
          });
        }
      };
      const setLanguage = () => {
        if (this.key !== null && this.key.length > 0) {
          const value = Core.getText(this.key, this.parameters);
          console.log(`Link :: setLanguage :: Set text ${value} for`, this.element);
          this.setText(value);
          return;
        }
        if (text && this.id !== null && this.id.length > 0) {
          const value = Core.getText(this.id, this.parameters);
          console.log(`Link :: setLanguage :: Set text ${value} for`, this.element);
          this.setText(value);
          return;
        }
        console.log('Link :: setLanguage :: No key nor id to set text for link.', this.element);
      };
      const assignTriggers = () => {
      };
      validateOptions();
      createGUI();
      assignTriggers();
      Core.addOnSetLanguageFunction(setLanguage);
      return this;
    }
  
    setText(value) {
      this.element.innerHTML = `<div>${value}</div>`;
    }
  
    getId() {
      return this.element.id;
    }
  }
  ;