|
@@ -39,7 +39,7 @@ function Formatter(el, opts) { |
|
|
|
|
|
// Make sure we have an element. Make accesible to instance
|
|
|
self.el = el;
|
|
|
- if (!self.el) {
|
|
|
+ if (!self.el) {
|
|
|
throw new TypeError('Must provide an existing element');
|
|
|
}
|
|
|
|
|
@@ -95,8 +95,8 @@ function Formatter(el, opts) { |
|
|
// @public
|
|
|
// Add new char
|
|
|
//
|
|
|
-Formatter.addInptType = function (char, reg) {
|
|
|
- inptRegs[char] = reg;
|
|
|
+Formatter.addInptType = function (chr, reg) {
|
|
|
+ inptRegs[chr] = reg;
|
|
|
};
|
|
|
|
|
|
//
|
|
@@ -107,7 +107,7 @@ Formatter.addInptType = function (char, reg) { |
|
|
Formatter.prototype.resetPattern = function (str) {
|
|
|
// Update opts to hold new pattern
|
|
|
this.opts.pattern = str;
|
|
|
-
|
|
|
+
|
|
|
// Get current state
|
|
|
this.sel = inptSel.get(this.el);
|
|
|
this.val = this.el.value;
|
|
@@ -182,14 +182,14 @@ Formatter.prototype._paste = function (evt) { |
|
|
// @private
|
|
|
// Handle called on focus event.
|
|
|
//
|
|
|
-Formatter.prototype._focus = function (evt) {
|
|
|
+Formatter.prototype._focus = function () {
|
|
|
// Wrapped in timeout so that we can grab input selection
|
|
|
var self = this;
|
|
|
setTimeout(function () {
|
|
|
// Grab selection
|
|
|
var selection = inptSel.get(self.el);
|
|
|
// Char check
|
|
|
- var isAfterStart = selection.end > self.focus;
|
|
|
+ var isAfterStart = selection.end > self.focus,
|
|
|
isFirstChar = selection.end === 0;
|
|
|
// If clicked in front of start, refocus to start
|
|
|
if (isAfterStart || isFirstChar) {
|
|
@@ -286,7 +286,7 @@ Formatter.prototype._formatValue = function () { |
|
|
// Add formatted characters
|
|
|
this._addChars();
|
|
|
|
|
|
- // Set vakye and adhere to maxLength
|
|
|
+ // Set vakye and adhere to maxLength
|
|
|
this.el.value = this.val.substr(0, this.mLength);
|
|
|
|
|
|
// Set new caret position
|
|
@@ -362,7 +362,7 @@ Formatter.prototype._validateInpts = function () { |
|
|
// Loop over val and add formatted chars as necessary
|
|
|
//
|
|
|
Formatter.prototype._addChars = function () {
|
|
|
- if (this.opts.persistent) {
|
|
|
+ if (this.opts.persistent) {
|
|
|
// Loop over all possible characters
|
|
|
for (var i = 0; i <= this.mLength; i++) {
|
|
|
if (!this.val.charAt(i)) {
|
|
@@ -394,8 +394,8 @@ Formatter.prototype._addChars = function () { |
|
|
//
|
|
|
Formatter.prototype._addChar = function (i) {
|
|
|
// If char exists at position
|
|
|
- var char = this.chars[i];
|
|
|
- if (!char) { return true; }
|
|
|
+ var chr = this.chars[i];
|
|
|
+ if (!chr) { return true; }
|
|
|
|
|
|
// If chars are added in between the old pos and new pos
|
|
|
// we need to increment pos and delta
|
|
@@ -416,5 +416,5 @@ Formatter.prototype._addChar = function (i) { |
|
|
}
|
|
|
|
|
|
// Update value
|
|
|
- this.val = utils.addChars(this.val, char, i);
|
|
|
+ this.val = utils.addChars(this.val, chr, i);
|
|
|
};
|
0 comments on commit
317ab02