import $ from 'jquery';
/**
 * 画面処理中のLoadding表示
 */
export class Snipper {
    private spinnerElement: JQuery<HTMLElement>;;
    private container :JQuery<HTMLElement>;
    constructor(selector: string) {
      this.container = $(selector??'body');
      this.spinnerElement=this.createSpinner();
    }
  
    createSpinner() {
      const html =[
        '<div class="bs-scope alc-loading alc-dnone">',
        '<div class="spinner-border" style="width: 3rem; height: 3rem;" role="status">',
        '<span class="visually-hidden"></span>',
        '</div></div>'
        ].join("");
      const spinner = $(html);
      this.container.append(spinner);
      return spinner;
    }
  
    removeSpinner() {
        this.spinnerElement.remove();
    }
  
    showSpinner() {
        this.spinnerElement.removeClass('alc-dnone');
    }
  
    hideSpinner() {
        this.spinnerElement.addClass('alc-dnone');
    }
  }
  