HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/share/nodejs/turbolinks/src/turbolinks/progress_bar.js
// Generated by CoffeeScript 1.12.8
(function() {
  var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  Turbolinks.ProgressBar = (function() {
    var ANIMATION_DURATION;

    ANIMATION_DURATION = 300;

    ProgressBar.defaultCSS = ".turbolinks-progress-bar {\n  position: fixed;\n  display: block;\n  top: 0;\n  left: 0;\n  height: 3px;\n  background: #0076ff;\n  z-index: 9999;\n  transition: width " + ANIMATION_DURATION + "ms ease-out, opacity " + (ANIMATION_DURATION / 2) + "ms " + (ANIMATION_DURATION / 2) + "ms ease-in;\n  transform: translate3d(0, 0, 0);\n}";

    function ProgressBar() {
      this.trickle = bind(this.trickle, this);
      this.stylesheetElement = this.createStylesheetElement();
      this.progressElement = this.createProgressElement();
    }

    ProgressBar.prototype.show = function() {
      if (!this.visible) {
        this.visible = true;
        this.installStylesheetElement();
        this.installProgressElement();
        return this.startTrickling();
      }
    };

    ProgressBar.prototype.hide = function() {
      if (this.visible && !this.hiding) {
        this.hiding = true;
        return this.fadeProgressElement((function(_this) {
          return function() {
            _this.uninstallProgressElement();
            _this.stopTrickling();
            _this.visible = false;
            return _this.hiding = false;
          };
        })(this));
      }
    };

    ProgressBar.prototype.setValue = function(value) {
      this.value = value;
      return this.refresh();
    };

    ProgressBar.prototype.installStylesheetElement = function() {
      return document.head.insertBefore(this.stylesheetElement, document.head.firstChild);
    };

    ProgressBar.prototype.installProgressElement = function() {
      this.progressElement.style.width = 0;
      this.progressElement.style.opacity = 1;
      document.documentElement.insertBefore(this.progressElement, document.body);
      return this.refresh();
    };

    ProgressBar.prototype.fadeProgressElement = function(callback) {
      this.progressElement.style.opacity = 0;
      return setTimeout(callback, ANIMATION_DURATION * 1.5);
    };

    ProgressBar.prototype.uninstallProgressElement = function() {
      if (this.progressElement.parentNode) {
        return document.documentElement.removeChild(this.progressElement);
      }
    };

    ProgressBar.prototype.startTrickling = function() {
      return this.trickleInterval != null ? this.trickleInterval : this.trickleInterval = setInterval(this.trickle, ANIMATION_DURATION);
    };

    ProgressBar.prototype.stopTrickling = function() {
      clearInterval(this.trickleInterval);
      return this.trickleInterval = null;
    };

    ProgressBar.prototype.trickle = function() {
      return this.setValue(this.value + Math.random() / 100);
    };

    ProgressBar.prototype.refresh = function() {
      return requestAnimationFrame((function(_this) {
        return function() {
          return _this.progressElement.style.width = (10 + (_this.value * 90)) + "%";
        };
      })(this));
    };

    ProgressBar.prototype.createStylesheetElement = function() {
      var element;
      element = document.createElement("style");
      element.type = "text/css";
      element.textContent = this.constructor.defaultCSS;
      return element;
    };

    ProgressBar.prototype.createProgressElement = function() {
      var element;
      element = document.createElement("div");
      element.className = "turbolinks-progress-bar";
      return element;
    };

    return ProgressBar;

  })();

}).call(this);