<commit_before>Monocle.Controls.Spinner = function (reader) {
  if (Monocle.Controls == this) {
    return new Monocle.Controls.Spinner(reader);
  }

  var API = { constructor: Monocle.Controls.Spinner }
  var k = API.constants = API.constructor;
  var p = API.properties = {
    reader: reader,
    divs: [],
    spinCount: 0
  }


  function createControlElements(cntr) {
    var anim = cntr.dom.make('div', 'controls_spinner_anim');
    p.divs.push(anim);
    return anim;
  }


  // Registers spin/spun event handlers for: loading,componentchanging,resizing.
  function listenForUsualDelays() {
    p.reader.listen('monocle:componentloading', spin);
    p.reader.listen('monocle:componentloaded', spun);
    p.reader.listen('monocle:componentchanging', spin);
    p.reader.listen('monocle:componentchange', spun);
    p.reader.listen('monocle:resizing', resizeSpin);
    p.reader.listen('monocle:resize', resizeSpun);
    //p.reader.listen('monocle:stylesheetchanging', spin);
    //p.reader.listen('monocle:stylesheetchange', spun);
  }


  function resizeSpin(evt) {
    if (p.resizing) {
      return;
    }
    spin(evt);
    p.resizing = true;
  }


  function resizeSpun(evt) {
    spun(evt);
    p.resizing = false;
  }


  function spin(evt) {
    //console.log('Spinning on ' + (evt ? evt.type : 'unknown'));
    p.spinCount += 1;
    p.reader.showControl(API);

    // If the delay is on a page other than the page we've been assigned to,
    // don't show the animation.
    var page = evt && evt.m.page ? evt.m.page : null;
    for (var i = 0; i < p.divs.length; ++i) {
      var owner = p.divs[i].parentNode.parentNode;
      p.divs[i].style.display = (!page || page == owner) ? 'block' : 'none';
    }
  }


  function spun(evt) {
    //console.log('Spun on ' + (evt ? evt.type : 'unknown'));
    p.spinCount -= 1;
    if (p.spinCount > 0) { return; }
    p.reader.hideControl(API);
  }


  API.createControlElements = createControlElements;
  API.listenForUsualDelays = listenForUsualDelays;<commit_msg>Better display logic for page-specific spinners. Spin on jump.<commit_after>Monocle.Controls.Spinner = function (reader) {
  if (Monocle.Controls == this) {
    return new Monocle.Controls.Spinner(reader);
  }

  var API = { constructor: Monocle.Controls.Spinner }
  var k = API.constants = API.constructor;
  var p = API.properties = {
    reader: reader,
    divs: [],
    spinCount: 0
  }


  function createControlElements(cntr) {
    var anim = cntr.dom.make('div', 'controls_spinner_anim');
    p.divs.push(anim);
    return anim;
  }


  // Registers spin/spun event handlers for: loading,componentchanging,resizing.
  function listenForUsualDelays() {
    p.reader.listen('monocle:componentloading', spin);
    p.reader.listen('monocle:componentloaded', spun);
    p.reader.listen('monocle:componentchanging', spin);
    p.reader.listen('monocle:componentchange', spun);
    p.reader.listen('monocle:resizing', resizeSpin);
    p.reader.listen('monocle:resize', resizeSpun);
    p.reader.listen('monocle:jumping', spin);
    p.reader.listen('monocle:jump', spun);
    //p.reader.listen('monocle:stylesheetchanging', spin);
    //p.reader.listen('monocle:stylesheetchange', spun);
  }


  function resizeSpin(evt) {
    if (p.resizing) {
      return;
    }
    spin(evt);
    p.resizing = true;
  }


  function resizeSpun(evt) {
    spun(evt);
    p.resizing = false;
  }


  function spin(evt) {
    //console.log('Spinning on ' + (evt ? evt.type : 'unknown'));
    p.spinCount += 1;
    p.reader.showControl(API);

    // If the delay is on a page other than the page we've been assigned to,
    // don't show the animation. p.global ensures that if an event affects
    // all pages, the animation is always shown, even if other events in this
    // spin cycle are page-specific.
    var page = evt && evt.m.page ? evt.m.page : null;
    if (!page) {
      p.global = true;
    }
    for (var i = 0; i < p.divs.length; ++i) {
      var owner = p.divs[i].parentNode.parentNode;
      p.divs[i].style.display = (p.global || page == owner) ? 'block' : 'none';
    }
  }


  function spun(evt) {
    //console.log('Spun on ' + (evt ? evt.type : 'unknown'));
    p.spinCount -= 1;
    if (p.spinCount > 0) { return; }
    p.spinCount = 0;
    p.global = false;
    p.reader.hideControl(API);
  }


  API.createControlElements = createControlElements;
  API.listenForUsualDelays = listenForUsualDelays;
{'fraction_non_alphanumeric': 0.14804784473030919, 'fraction_numerical': 0.002482509591514331, 'mean_word_length': 3.0961182994454712, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5413737', 'n_tokens_mistral': 1559, 'n_tokens_neox': 1524, 'n_words': 323}