Sha256: e6aea4d15140cbdd8beb1ea69acc24e781a43dd11fd7c4f3359aa9f871197b27

Contents?: true

Size: 1.5 KB

Versions: 18

Compression:

Stored size: 1.5 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.handle = function(event) {
      var $element, button;
      event.preventDefault();
      $element = $(event.currentTarget).closest(SELECTOR);
      button = new AbortButton($element);
      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.find('a[href]').attr('href');
      this.shouldRollback = this.$button.data('rollback');
    }

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

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

    AbortButton.prototype.reenable = function() {
      return this.$button.removeClass('pending');
    };

    AbortButton.prototype.disable = function() {
      return this.$button.addClass('pending');
    };

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

    return AbortButton;

  })();

  $(document).on('click', '[data-action=abort]', AbortButton.handle);

}).call(this);
:ET

Version data entries

18 entries across 9 versions & 1 rubygems

Version Path
shipit-engine-0.4.2 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.4.2 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.4.1 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.4.1 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.4.0 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.4.0 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.3.1 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.3.1 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.3.0 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.3.0 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.3 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.3 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.2 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.2 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.1 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.1 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.0 test/dummy/tmp/cache/assets/test/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache
shipit-engine-0.2.0 test/dummy/tmp/cache/assets/development/sprockets/v3.0/oUZ-OUvdfQz-qAflqpsQ9kscC8msRQvQ4JzM1mB3lIY.cache