Sha256: 30d463599f0fa9d3214283881a7f15eeacd59c68fc65c17a21a86f6bd5e1b518
Contents?: true
Size: 1.48 KB
Versions: 9
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
9 entries across 9 versions & 1 rubygems