Sha256: d4774a70351454495110df67b52e359dfc0af4bb5e3edd1fcf94b255d1bb71be
Contents?: true
Size: 1.48 KB
Versions: 18
Compression:
Stored size: 1.48 KB
Contents
I"ß(function() { var AbortButton, bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; AbortButton = (function() { AbortButton.listen = function(selector) { 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.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; })(); AbortButton.listen('[data-action="abort"]'); }).call(this); :ET
Version data entries
18 entries across 9 versions & 1 rubygems