Sha256: 98b7705949303e4e0918aef5f7ce9cb84940cdb256ff76f28a49c61d1c9268a7

Contents?: true

Size: 1.69 KB

Versions: 38

Compression:

Stored size: 1.69 KB

Contents

I"·(function() {
  var AbortButton,
    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

  AbortButton = (function() {
    var SELECTOR;

    SELECTOR = '[data-action="abort"]';

    AbortButton.listen = function() {
      return $(document).on('click', SELECTOR, this.handle);
    };

    AbortButton.handle = function(event) {
      var button;
      event.preventDefault();
      button = new AbortButton($(event.currentTarget));
      return button.trigger();
    };

    function AbortButton($button) {
      this.$button = $button;
      this.reenable = bind(this.reenable, this);
      this.waitForCompletion = bind(this.waitForCompletion, this);
      this.url = this.$button.attr('href');
      this.shouldRollback = this.$button.data('rollback');
    }

    AbortButton.prototype.trigger = function() {
      if (this.isDisabled()) {
        return false;
      }
      this.disable();
      this.waitForCompletion();
      return $.post(this.url).success(this.waitForCompletion).error(this.reenable);
    };

    AbortButton.prototype.waitForCompletion = function() {
      return setTimeout(this.reenable, 3000);
    };

    AbortButton.prototype.reenable = function() {
      this.$button.removeClass('pending btn-disabled');
      return this.$button.siblings(SELECTOR).removeClass('btn-disabled');
    };

    AbortButton.prototype.disable = function() {
      this.$button.addClass('pending btn-disabled');
      return this.$button.siblings(SELECTOR).addClass('btn-disabled');
    };

    AbortButton.prototype.isDisabled = function() {
      return this.$button.hasClass('btn-disabled');
    };

    return AbortButton;

  })();

  AbortButton.listen();

}).call(this);
:ET

Version data entries

38 entries across 17 versions & 1 rubygems

Version Path
shipit-engine-0.5.0 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.5.0 test/dummy/tmp/cache/assets/test/sprockets/v3.0/JQ8n4TH3kuPzDkGXdft77ktId3xDdNuPysNdAIrlVsw.cache
shipit-engine-0.5.0 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.5.0 test/dummy/tmp/cache/assets/development/sprockets/v3.0/JQ8n4TH3kuPzDkGXdft77ktId3xDdNuPysNdAIrlVsw.cache
shipit-engine-0.4.10 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.10 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.10 test/dummy/tmp/cache/assets/test/sprockets/v3.0/JQ8n4TH3kuPzDkGXdft77ktId3xDdNuPysNdAIrlVsw.cache
shipit-engine-0.4.9 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.9 test/dummy/tmp/cache/assets/test/sprockets/v3.0/JQ8n4TH3kuPzDkGXdft77ktId3xDdNuPysNdAIrlVsw.cache
shipit-engine-0.4.9 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.8 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.8 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.7 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.7 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.6 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.6 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.5 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.5 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.4 test/dummy/tmp/cache/assets/development/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache
shipit-engine-0.4.4 test/dummy/tmp/cache/assets/test/sprockets/v3.0/H-57H3_wQdiyyUNKshzgl2HTIyGPy3MDG01_w7CnqGc.cache