Skip to content

Commit

Permalink
Maintenance (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
msafi committed Jul 23, 2016
1 parent 0f45f9c commit 7e443a0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion angular2/dist/angular2TextMask.d.ts
Expand Up @@ -2,8 +2,8 @@ import { ElementRef } from '@angular/core';
import { NgControl } from '@angular/forms';
export default class MaskedInputDirective {
private ngControl;
private control;
private inputElement;
control: any;
textMaskConfig: {
mask: string;
guide: boolean;
Expand Down
2 changes: 1 addition & 1 deletion angular2/dist/angular2TextMask.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions angular2/example/app.ts
Expand Up @@ -3,7 +3,7 @@ import 'es6-promise'
import 'zone.js/dist/zone'
import 'reflect-metadata'

import {Component} from '@angular/core';
import {Component} from '@angular/core'
import {disableDeprecatedForms, provideForms} from '@angular/forms'
import {bootstrap} from '@angular/platform-browser-dynamic'
import MaskedInput from '../src/angular2TextMask'
Expand All @@ -21,7 +21,7 @@ class AppComponent {
}
}

//noinspection TypeScriptValidateTypes
// noinspection TypeScriptValidateTypes
bootstrap(AppComponent, [
provideForms(),
disableDeprecatedForms()
Expand Down
26 changes: 12 additions & 14 deletions angular2/src/angular2TextMask.ts
Expand Up @@ -3,42 +3,40 @@ import {NgControl} from '@angular/forms'
import createTextMaskInputElement from '../../core/src/createTextMaskInputElement'

@Directive({
selector: 'input[textMask]',
host: {
'(input)': 'onInput()'
}
},
selector: 'input[textMask]'
})
export default class MaskedInputDirective {
private inputElement:HTMLInputElement;
public control: any;
private control: any
private inputElement:HTMLInputElement

@Input('textMask') textMaskConfig = {
@Input('textMask')
textMaskConfig = {
mask: '',
guide: true,
placeholderChar: '_',
pipe: undefined,
keepCharPositions: false,
onReject: undefined,
onAccept: undefined
};
}

constructor(inputElement: ElementRef, private ngControl: NgControl) {
this.inputElement = inputElement.nativeElement
}

ngOnInit() {
const {placeholderChar} = this.textMaskConfig;
this.control = createTextMaskInputElement(Object.assign({
inputElement: this.inputElement,
placeholderChar,
}, this.textMaskConfig));
this.control = createTextMaskInputElement(Object.assign({inputElement: this.inputElement, }, this.textMaskConfig))

setTimeout(() => this.onInput());
// This ensures that initial model value gets masked
setTimeout(() => this.onInput())
}

onInput() {
this.control.update();
this.ngControl.viewToModelUpdate(this.inputElement.value);
this.control.update()
this.ngControl.viewToModelUpdate(this.inputElement.value)
}
}

Expand Down
7 changes: 7 additions & 0 deletions angular2/tslint.json
@@ -0,0 +1,7 @@
{
"rules": {
"semicolon": [true, "never"],
"quotemark": [true, "single"],
"indent": [true, "spaces"]
}
}
1 change: 0 additions & 1 deletion core/src/utilities.d.ts

This file was deleted.

0 comments on commit 7e443a0

Please sign in to comment.