a zip code crypto-currency system good for red ONLY

click-block.js 3.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. (function (factory) {
  2. if (typeof module === "object" && typeof module.exports === "object") {
  3. var v = factory(require, exports);
  4. if (v !== undefined) module.exports = v;
  5. }
  6. else if (typeof define === "function" && define.amd) {
  7. define(["require", "exports", "@angular/core", "../app/app", "../../config/config", "../../platform/platform"], factory);
  8. }
  9. })(function (require, exports) {
  10. "use strict";
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var core_1 = require("@angular/core");
  13. var app_1 = require("../app/app");
  14. var config_1 = require("../../config/config");
  15. var platform_1 = require("../../platform/platform");
  16. /**
  17. * @hidden
  18. */
  19. var ClickBlock = (function () {
  20. function ClickBlock(app, config, plt, elementRef, renderer) {
  21. this.plt = plt;
  22. this.elementRef = elementRef;
  23. this.renderer = renderer;
  24. this._showing = false;
  25. app._clickBlock = this;
  26. var enabled = this.isEnabled = config.getBoolean('clickBlock', true);
  27. if (enabled) {
  28. this._setElementClass('click-block-enabled', true);
  29. }
  30. }
  31. ClickBlock.prototype.activate = function (shouldShow, expire, minDuration) {
  32. if (expire === void 0) { expire = 100; }
  33. if (minDuration === void 0) { minDuration = 0; }
  34. if (this.isEnabled) {
  35. this.plt.cancelTimeout(this._tmr);
  36. if (shouldShow) {
  37. // remember when we started the click block
  38. this._start = Date.now();
  39. // figure out the minimum time it should be showing until
  40. // this is useful for transitions that are less than 300ms
  41. this._minEnd = this._start + (minDuration || 0);
  42. this._activate(true);
  43. }
  44. this._tmr = this.plt.timeout(this._activate.bind(this, false), expire);
  45. }
  46. };
  47. /** @internal */
  48. ClickBlock.prototype._activate = function (shouldShow) {
  49. if (this._showing !== shouldShow) {
  50. if (!shouldShow) {
  51. // check if it was enabled before the minimum duration
  52. // this is useful for transitions that are less than 300ms
  53. var now = Date.now();
  54. if (now < this._minEnd) {
  55. this._tmr = this.plt.timeout(this._activate.bind(this, false), this._minEnd - now);
  56. return;
  57. }
  58. }
  59. this._setElementClass('click-block-active', shouldShow);
  60. this._showing = shouldShow;
  61. }
  62. };
  63. ClickBlock.prototype._setElementClass = function (className, add) {
  64. this.renderer.setElementClass(this.elementRef.nativeElement, className, add);
  65. };
  66. ClickBlock.decorators = [
  67. { type: core_1.Directive, args: [{
  68. selector: '.click-block'
  69. },] },
  70. ];
  71. /** @nocollapse */
  72. ClickBlock.ctorParameters = function () { return [
  73. { type: app_1.App, decorators: [{ type: core_1.Inject, args: [core_1.forwardRef(function () { return app_1.App; }),] },] },
  74. { type: config_1.Config, },
  75. { type: platform_1.Platform, },
  76. { type: core_1.ElementRef, },
  77. { type: core_1.Renderer, },
  78. ]; };
  79. return ClickBlock;
  80. }());
  81. exports.ClickBlock = ClickBlock;
  82. });
  83. //# sourceMappingURL=click-block.js.map