Sha256: 350051d46c6d351afeb74267fee6ba5d695fc03fdf96ec7358398318bbc8a66c
Contents?: true
Size: 1.63 KB
Versions: 9
Compression:
Stored size: 1.63 KB
Contents
I"x(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.find('a[href]').attr('href'); this.shouldRollback = this.$button.data('rollback'); } AbortButton.prototype.trigger = function() { if (this.isDisabled()) { return false; } this.disable(); return this.waitForCompletion(); }; AbortButton.prototype.waitForCompletion = function() { return setTimeout(this.reenable, 3000); }; AbortButton.prototype.reenable = function() { this.$button.removeClass('pending'); return this.$button.siblings(SELECTOR).removeClass('disabled'); }; AbortButton.prototype.disable = function() { this.$button.addClass('pending'); return this.$button.siblings(SELECTOR).addClass('disabled'); }; AbortButton.prototype.isDisabled = function() { return this.$button.hasClass('pending') || this.$button.hasClass('disabled'); }; return AbortButton; })(); AbortButton.listen(); }).call(this); :ET
Version data entries
9 entries across 9 versions & 1 rubygems