ampersand-input-view
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -24,2 +24,3 @@ var domify = require('domify'); | ||
this.value = opts.value || ''; | ||
this.originalValue = opts.value || ''; | ||
this.el = opts.el; | ||
@@ -42,5 +43,5 @@ this.template = opts.template || template; | ||
this.handleBlur = this.handleBlur.bind(this); | ||
this.handleInputEvent = this.handleInputEvent.bind(this); | ||
this.handleInputChanged = this.handleInputChanged.bind(this); | ||
this.input.addEventListener('blur', this.handleBlur, false); | ||
this.input.addEventListener('input', this.handleInputEvent, false); | ||
this.input.addEventListener('input', this.handleInputChanged, false); | ||
@@ -55,3 +56,3 @@ // tests for validity | ||
TextInputView.prototype.remove = function () { | ||
this.input.removeEventListener('input', this.handleInputEvent, false); | ||
this.input.removeEventListener('input', this.handleInputChanged, false); | ||
this.input.removeEventListener('blur', this.handleBlur, false); | ||
@@ -63,3 +64,5 @@ var parent = this.el.parentNode; | ||
// handle input events and show appropriate errors | ||
TextInputView.prototype.handleInputEvent = function () { | ||
TextInputView.prototype.handleInputChanged = function () { | ||
// track whether user has edited directly | ||
if (document.activeElement === this.input) this.directlyEdited = true; | ||
this.value = this.input.value; | ||
@@ -71,2 +74,8 @@ this.edited = true; | ||
// Expose a method for explicitly setting the value | ||
TextInputView.prototype.setValue = function (value, runValidation) { | ||
this.input.value = value; | ||
this.handleInputChanged(); | ||
}; | ||
// set the error message if exists | ||
@@ -73,0 +82,0 @@ // hides the message container entirely otherwise |
{ | ||
"name": "ampersand-input-view", | ||
"description": "A view module for intelligently rendering and validating input. Works well with ampersand-form-view.", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9003
146