UNPKG

3.45 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 /**
13 * @param {?} input
14 * @return {?}
15 */
16 Form.prototype.register = function (input) {
17 this._inputs.push(input);
18 };
19 /**
20 * @param {?} input
21 * @return {?}
22 */
23 Form.prototype.deregister = function (input) {
24 removeArrayItem(this._inputs, input);
25 this.unsetAsFocused(input);
26 };
27 /**
28 * @param {?} input
29 * @return {?}
30 */
31 Form.prototype.setAsFocused = function (input) {
32 this._focused = input;
33 };
34 /**
35 * @param {?} input
36 * @return {?}
37 */
38 Form.prototype.unsetAsFocused = function (input) {
39 if (input === this._focused) {
40 this._focused = null;
41 }
42 };
43 /**
44 * Focuses the next input element, if it exists.
45 * @param {?} currentInput
46 * @return {?}
47 */
48 Form.prototype.tabFocus = function (currentInput) {
49 var /** @type {?} */ inputs = this._inputs;
50 var /** @type {?} */ index = inputs.indexOf(currentInput) + 1;
51 if (index > 0 && index < inputs.length) {
52 var /** @type {?} */ nextInput = inputs[index];
53 if (nextInput !== this._focused) {
54 (void 0) /* console.debug */;
55 return nextInput.initFocus();
56 }
57 }
58 index = inputs.indexOf(this._focused);
59 if (index > 0) {
60 var /** @type {?} */ previousInput = inputs[index - 1];
61 if (previousInput) {
62 (void 0) /* console.debug */;
63 previousInput.initFocus();
64 }
65 }
66 };
67 /**
68 * @return {?}
69 */
70 Form.prototype.nextId = function () {
71 return ++this._ids;
72 };
73 return Form;
74}());
75export { Form };
76Form.decorators = [
77 { type: Injectable },
78];
79/**
80 * @nocollapse
81 */
82Form.ctorParameters = function () { return []; };
83function Form_tsickle_Closure_declarations() {
84 /** @type {?} */
85 Form.decorators;
86 /**
87 * @nocollapse
88 * @type {?}
89 */
90 Form.ctorParameters;
91 /** @type {?} */
92 Form.prototype._focused;
93 /** @type {?} */
94 Form.prototype._ids;
95 /** @type {?} */
96 Form.prototype._inputs;
97}
98/**
99 * @hidden
100 * @abstract
101 */
102var IonicTapInput = (function () {
103 function IonicTapInput() {
104 }
105 /**
106 * @abstract
107 * @return {?}
108 */
109 IonicTapInput.prototype.initFocus = function () { };
110 /**
111 * @abstract
112 * @return {?}
113 */
114 IonicTapInput.prototype.checked = function () { };
115 /**
116 * @abstract
117 * @param {?} val
118 * @return {?}
119 */
120 IonicTapInput.prototype.checked = function (val) { };
121 /**
122 * @abstract
123 * @return {?}
124 */
125 IonicTapInput.prototype.disabled = function () { };
126 /**
127 * @abstract
128 * @param {?} val
129 * @return {?}
130 */
131 IonicTapInput.prototype.disabled = function (val) { };
132 return IonicTapInput;
133}());
134export { IonicTapInput };
135/**
136 * @hidden
137 * @abstract
138 */
139var IonicFormInput = (function () {
140 function IonicFormInput() {
141 }
142 /**
143 * @abstract
144 * @return {?}
145 */
146 IonicFormInput.prototype.initFocus = function () { };
147 return IonicFormInput;
148}());
149export { IonicFormInput };
150//# sourceMappingURL=form.js.map
\No newline at end of file