<commit_before>
// @require core/colors/colors.js
// @require widgets/overlay/overlay.js

(function ( $, _, Svelto, Widgets, Factory, Colors ) {

  /* CONFIG */

  let config = {
    name: 'spinnerOverlay',
    plugin: true,
    templates: {
      overlay: _.template ( `
        <div class="overlay spinner-overlay <%= o.dimmer ? 'dimmer' : '' %>">
          <% if ( o.labeled ) { %>
            <div class="spinner-label <%= o.colors.labeled %>">
          <% } %>
            <svg class="spinner <%= ( o.multicolor ? 'multicolor' : ( o.labeled ? '' : o.unlabeled ) ) %>">
              <circle cx="1.625em" cy="1.625em" r="1.25em">
            </svg>
          <% if ( o.labeled ) { %>
            </div>
          <% } %>
        </div>
      ` )
    },
    options: {
      labeled: true,
      dimmer: true,
      multicolor: false,
      colors: {
        labeled: Colors.white,
        unlabeled: Colors.secondary
      },
      callbacks: {
        open: _.noop,
        close: _.noop
      }
    }
  };

  /* SPINNER OVERLAY */

  class SpinnerOverlay extends Widgets.Widget {

    /* SPECIAL */

    _variables () {

      this.$overlayed = this.$element;
      this.$overlay = $(this._template ( 'overlay', this.options ));

      this.instance = this.$overlay.overlay ( 'instance' );

    }

    /* API */

    isOpen () {

      return this.instance.isOpen ();

    }

    toggle ( force = !this.isOpen () ) {

      return this[force ? 'open' : 'close']();

    }

    open () {

      if ( this.isOpen () ) return null;

      if ( this.isLocked () ) return this.whenUnlocked ( this.open.bind ( this ) );

      if ( this.instance.isLocked () ) return this.instance.whenUnlocked ( this.open.bind ( this ) );

      this.$overlay.prependTo ( this.$overlayed );

      this.instance.open ();

      this._trigger ( 'open' );

    }

    close () {

      if ( !this.isOpen () ) return null;

      if ( this.isLocked () ) return this.whenUnlocked ( this.close.bind ( this ) );

      if ( this.instance.isLocked () ) return this.instance.whenUnlocked ( this.close.bind ( this ) );

      this.lock ();

      this.instance.close ();

      this._delay ( function () {

        this.$overlay.detach ();

        this.unlock ();

        this._trigger ( 'close' );

      }, Widgets.Overlay.config.options.animations.close );

    }

  }

  /* FACTORY */

  Factory.make ( SpinnerOverlay, config );

}( Svelto.$, Svelto._, Svelto, Svelto.Widgets, Svelto.Factory, Svelto.Colors ));
<commit_msg>SpinnerOverlay: added support for a `blurrer` variant<commit_after>
// @require core/colors/colors.js
// @require widgets/overlay/overlay.js

(function ( $, _, Svelto, Widgets, Factory, Colors ) {

  /* CONFIG */

  let config = {
    name: 'spinnerOverlay',
    plugin: true,
    templates: {
      overlay: _.template ( `
        <div class="overlay spinner-overlay <%= o.dimmer ? 'dimmer' : '' %> <%= o.blurrer ? 'blurrer' : '' %>">
          <% if ( o.labeled ) { %>
            <div class="spinner-label <%= o.colors.labeled %>">
          <% } %>
            <svg class="spinner <%= ( o.multicolor ? 'multicolor' : ( o.labeled ? '' : o.unlabeled ) ) %>">
              <circle cx="1.625em" cy="1.625em" r="1.25em">
            </svg>
          <% if ( o.labeled ) { %>
            </div>
          <% } %>
        </div>
      ` )
    },
    options: {
      labeled: true,
      blurrer: false,
      dimmer: true,
      multicolor: false,
      colors: {
        labeled: Colors.white,
        unlabeled: Colors.secondary
      },
      callbacks: {
        open: _.noop,
        close: _.noop
      }
    }
  };

  /* SPINNER OVERLAY */

  class SpinnerOverlay extends Widgets.Widget {

    /* SPECIAL */

    _variables () {

      this.$overlayed = this.$element;
      this.$overlay = $(this._template ( 'overlay', this.options ));

      this.instance = this.$overlay.overlay ( 'instance' );

    }

    /* API */

    isOpen () {

      return this.instance.isOpen ();

    }

    toggle ( force = !this.isOpen () ) {

      return this[force ? 'open' : 'close']();

    }

    open () {

      if ( this.isOpen () ) return null;

      if ( this.isLocked () ) return this.whenUnlocked ( this.open.bind ( this ) );

      if ( this.instance.isLocked () ) return this.instance.whenUnlocked ( this.open.bind ( this ) );

      this.$overlay.prependTo ( this.$overlayed );

      this.instance.open ();

      this._trigger ( 'open' );

    }

    close () {

      if ( !this.isOpen () ) return null;

      if ( this.isLocked () ) return this.whenUnlocked ( this.close.bind ( this ) );

      if ( this.instance.isLocked () ) return this.instance.whenUnlocked ( this.close.bind ( this ) );

      this.lock ();

      this.instance.close ();

      this._delay ( function () {

        this.$overlay.detach ();

        this.unlock ();

        this._trigger ( 'close' );

      }, Widgets.Overlay.config.options.animations.close );

    }

  }

  /* FACTORY */

  Factory.make ( SpinnerOverlay, config );

}( Svelto.$, Svelto._, Svelto, Svelto.Widgets, Svelto.Factory, Svelto.Colors ));

{'fraction_non_alphanumeric': 0.16705836271053662, 'fraction_numerical': 0.004308656482569526, 'mean_word_length': 1.919954259576901, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4724952', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1611, 'n_words': 306}