UNPKG

2.04 kBJavaScriptView Raw
1import { Injectable } from '@angular/core';
2import { removeArrayItem } from './util';
3/**
4 * @hidden
5 */
6var Form = (function () {
7 function Form() {
8 this._focused = null;
9 this._ids = -1;
10 this._inputs = [];
11 }
12 Form.prototype.register = function (input) {
13 this._inputs.push(input);
14 };
15 Form.prototype.deregister = function (input) {
16 removeArrayItem(this._inputs, input);
17 this.unsetAsFocused(input);
18 };
19 Form.prototype.setAsFocused = function (input) {
20 this._focused = input;
21 };
22 Form.prototype.unsetAsFocused = function (input) {
23 if (input === this._focused) {
24 this._focused = null;
25 }
26 };
27 /**
28 * Focuses the next input element, if it exists.
29 */
30 Form.prototype.tabFocus = function (currentInput) {
31 var inputs = this._inputs;
32 var index = inputs.indexOf(currentInput) + 1;
33 if (index > 0 && index < inputs.length) {
34 var nextInput = inputs[index];
35 if (nextInput !== this._focused) {
36 (void 0) /* console.debug */;
37 return nextInput.initFocus();
38 }
39 }
40 index = inputs.indexOf(this._focused);
41 if (index > 0) {
42 var previousInput = inputs[index - 1];
43 if (previousInput) {
44 (void 0) /* console.debug */;
45 previousInput.initFocus();
46 }
47 }
48 };
49 Form.prototype.nextId = function () {
50 return ++this._ids;
51 };
52 Form.decorators = [
53 { type: Injectable },
54 ];
55 /** @nocollapse */
56 Form.ctorParameters = function () { return []; };
57 return Form;
58}());
59export { Form };
60/**
61 * @hidden
62 */
63var IonicTapInput = (function () {
64 function IonicTapInput() {
65 }
66 return IonicTapInput;
67}());
68export { IonicTapInput };
69/**
70 * @hidden
71 */
72var IonicFormInput = (function () {
73 function IonicFormInput() {
74 }
75 return IonicFormInput;
76}());
77export { IonicFormInput };
78//# sourceMappingURL=form.js.map
\No newline at end of file