Sha256: ac259433de07483eea00cb480338bc2e8c03da59535414a97252a310142cfea1

Contents?: true

Size: 983 Bytes

Versions: 14

Compression:

Stored size: 983 Bytes

Contents

var RomoOnkey = RomoComponent(function(elem) {
  this.elem = elem;

  this.defaultTriggerOn = 'keydown';
  this.defaultDelayMs   = 0;
  this.delayTimeout     = undefined;

  this.doInit();

  this.triggerOn = Romo.data(this.elem, 'romo-onkey-on') || this.defaultTriggerOn;
  Romo.on(this.elem, this.triggerOn, Romo.proxy(this._onTrigger, this));

  Romo.trigger(this.elem, 'romoOnkey:ready', [this]);
});

// private

RomoOnkey.prototype._doTrigger = function(triggerEvent) {
  clearTimeout(this.delayTimeout);
  this.delayTimeout = setTimeout(
    Romo.proxy(function() {
      Romo.trigger(this.elem, 'romoOnkey:trigger', [triggerEvent, this]);
    }, this),
    Romo.data(this.elem, 'romo-onkey-delay-ms') || this.defaultDelayMs
  );
}

// event functions

RomoOnkey.prototype.romoEvFn._onTrigger = function(e) {
  if (Romo.hasClass(this.elem, 'disabled') === false) {
    this._doTrigger(e);
  }
}

// init

Romo.addElemsInitSelector('[data-romo-onkey-auto="true"]', RomoOnkey);

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
romo-0.20.13 assets/js/romo/onkey.js
romo-0.20.12 assets/js/romo/onkey.js
romo-0.20.11 assets/js/romo/onkey.js
romo-0.20.10 assets/js/romo/onkey.js
romo-0.20.9 assets/js/romo/onkey.js
romo-0.20.8 assets/js/romo/onkey.js
romo-0.20.7 assets/js/romo/onkey.js
romo-0.20.6 assets/js/romo/onkey.js
romo-0.20.5 assets/js/romo/onkey.js
romo-0.20.4 assets/js/romo/onkey.js
romo-0.20.3 assets/js/romo/onkey.js
romo-0.20.2 assets/js/romo/onkey.js
romo-0.20.1 assets/js/romo/onkey.js
romo-0.20.0 assets/js/romo/onkey.js