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.425 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.420 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.419 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.418 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.417 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.416 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.415 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.414 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.413 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.412 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.411 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.410 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.409 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.407 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.408 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.398 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.397 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.396 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.0.0.dev.395 app/assets/javascripts/lalala/modules/login.module.js
lalala-4.1.0.dev.394 app/assets/javascripts/lalala/modules/login.module.js