Sha256: 9855c6af093583501ea28f89fb14538bd21790ad638f91bfcc3050db73932cca

Contents?: true

Size: 1.17 KB

Versions: 98

Compression:

Stored size: 1.17 KB

Contents

var Helpers = require("./helpers");



function Login(el) {
  this.$el = $(el);
  this.$tryout = this.$el.find(".text.tryout");

  this.bind_events();
  this.$el.find("input").trigger("change");
}



//
//  Events
//
Login.prototype.bind_events = function() {
  this.$el.on("change", "input", $.proxy(this.input_change_handler, this));
  this.$el.on("keyup", "input", Helpers.debounce($.proxy(this.input_keyup_handler, this), 250));
};


Login.prototype.input_change_handler = function(e) {
  var $trgt, text, width;

  // input element
  $trgt = $(e.currentTarget);

  // text
  text = $trgt.val();

  if ($trgt.attr("type") == "password") {
    text = new Array(text.length + 1).join("⦁");
  }

  this.$tryout.text(text);

  // width
  if (!e.currentTarget.original_width) {
    e.currentTarget.original_width = $trgt.width();
  }

  width = this.$tryout.width();
  if (width < e.currentTarget.original_width) {
    width = e.currentTarget.original_width;
  }

  $trgt.width(width);
};


Login.prototype.input_keyup_handler = function(e) {
  $(e.currentTarget).trigger("change");
};



//
//  Exports
//
exports.init = function() {
  $(".mod-login").each(function() {
    new Login(this);
  });
};

Version data entries

98 entries across 98 versions & 1 rubygems

Version Path
lalala-4.1.0.dev.359 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.358 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.357 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.356 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.355 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.354 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.351 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.350 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.349 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.344 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.343 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.342 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.341 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.340 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.339 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.336 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.334 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.332 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.331 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.329 app/assets/javascripts/lalala/modules/login.module.js