/*
 * Copyright (c) 2018, FusionAuth, All Rights Reserved
 */
'use strict';

var FusionAuth = FusionAuth || {};
FusionAuth.Admin = FusionAuth.Admin || {};

/**
 * Constructs a OAuthConfiguration object.
 *
 * @param {Prime.Document.Element} element The form element.
 * @constructor
 */
FusionAuth.Admin.OAuthConfiguration = function(element) {
  Prime.Utils.bindAll(this);

  if (element.is('form')) {
    this.element = element;
  } else {
    this.element = element.queryFirst('form');
  }

  this.redirectURLs = Prime.Document.queryById('redirectURLs');
  this.origins = Prime.Document.queryById('origins');

  if (this.redirectURLs !== null) {
    new Prime.Widgets.MultipleSelect(this.redirectURLs)
        .withPlaceholder('e.g. http://www.example.com/oauth2callback')
        .withRemoveIcon('')
        .withCustomAddLabel('Add URL ')
        .initialize();
  }

  if (this.origins !== null) {
    new Prime.Widgets.MultipleSelect(this.origins)
        .withPlaceholder('e.g. http://www.example.com')
        .withRemoveIcon('')
        .withCustomAddLabel('Add URL ')
        .initialize();
  }
};

FusionAuth.Admin.OAuthConfiguration.constructor = FusionAuth.Admin.OAuthConfiguration;

FusionAuth.Admin.OAuthConfiguration.prototype = {

  /* ===================================================================================================================
   * Private methods
   * ===================================================================================================================*/

};
