mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
chore(): fix typescript errors
This commit is contained in:
@ -17,6 +17,8 @@ export class TextInput {
|
|||||||
@Input() ngModel: any;
|
@Input() ngModel: any;
|
||||||
@Output() valueChange: EventEmitter<string> = new EventEmitter();
|
@Output() valueChange: EventEmitter<string> = new EventEmitter();
|
||||||
@Output() focusChange: EventEmitter<boolean> = new EventEmitter();
|
@Output() focusChange: EventEmitter<boolean> = new EventEmitter();
|
||||||
|
public type: string;
|
||||||
|
private _relocated: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Attribute('type') type: string,
|
@Attribute('type') type: string,
|
||||||
|
@ -50,7 +50,7 @@ import {pointerCoord} from '../../util/dom';
|
|||||||
'role': 'checkbox',
|
'role': 'checkbox',
|
||||||
'class': 'item',
|
'class': 'item',
|
||||||
'tappable': '',
|
'tappable': '',
|
||||||
'tabindex': 0,
|
'tabindex': '0',
|
||||||
'[attr.aria-disabled]': 'disabled',
|
'[attr.aria-disabled]': 'disabled',
|
||||||
'(touchstart)': 'pointerDown($event)',
|
'(touchstart)': 'pointerDown($event)',
|
||||||
'(mousedown)': 'pointerDown($event)',
|
'(mousedown)': 'pointerDown($event)',
|
||||||
@ -70,9 +70,16 @@ import {pointerCoord} from '../../util/dom';
|
|||||||
})
|
})
|
||||||
export class Toggle {
|
export class Toggle {
|
||||||
@Input() value: string = '';
|
@Input() value: string = '';
|
||||||
@Input() public checked: any = false;
|
|
||||||
@Input() disabled: boolean = false;
|
@Input() disabled: boolean = false;
|
||||||
@Input() id: string;
|
@Input() id: string;
|
||||||
|
private _checked: boolean;
|
||||||
|
private _touched: number = 0;
|
||||||
|
private _mode: string;
|
||||||
|
private _startX: any;
|
||||||
|
private addMoveListener: any;
|
||||||
|
private removeMoveListener: any;
|
||||||
|
public labelId: string;
|
||||||
|
public isActivated: boolean;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _form: Form,
|
private _form: Form,
|
||||||
@ -88,8 +95,7 @@ export class Toggle {
|
|||||||
|
|
||||||
_form.register(this);
|
_form.register(this);
|
||||||
|
|
||||||
this.lastTouch = 0;
|
this._mode = config.get('mode');
|
||||||
this.mode = config.get('mode');
|
|
||||||
|
|
||||||
if (ngControl) {
|
if (ngControl) {
|
||||||
ngControl.valueAccessor = this;
|
ngControl.valueAccessor = this;
|
||||||
@ -100,13 +106,13 @@ export class Toggle {
|
|||||||
let currentX = pointerCoord(ev).x;
|
let currentX = pointerCoord(ev).x;
|
||||||
|
|
||||||
if (self.checked) {
|
if (self.checked) {
|
||||||
if (currentX + 15 < self.startX) {
|
if (currentX + 15 < self._startX) {
|
||||||
self.toggle();
|
self.toggle();
|
||||||
self.startX = currentX;
|
self._startX = currentX;
|
||||||
}
|
}
|
||||||
} else if (currentX - 15 > self.startX) {
|
} else if (currentX - 15 > self._startX) {
|
||||||
self.toggle();
|
self.toggle();
|
||||||
self.startX = currentX;
|
self._startX = currentX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,13 +157,14 @@ export class Toggle {
|
|||||||
this.checked = !this.checked;
|
this.checked = !this.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
get checked() {
|
get checked(): boolean {
|
||||||
return !!this._checked;
|
return !!this._checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
set checked(val) {
|
@Input()
|
||||||
|
set checked(val: boolean) {
|
||||||
this._checked = !!val;
|
this._checked = !!val;
|
||||||
this._renderer.setElementAttribute(this._elementRef, 'aria-checked', this._checked);
|
this._renderer.setElementAttribute(this._elementRef, 'aria-checked', this._checked.toString());
|
||||||
this.onChange(this._checked);
|
this.onChange(this._checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,12 +173,12 @@ export class Toggle {
|
|||||||
*/
|
*/
|
||||||
pointerDown(ev) {
|
pointerDown(ev) {
|
||||||
if (/touch/.test(ev.type)) {
|
if (/touch/.test(ev.type)) {
|
||||||
this.lastTouch = Date.now();
|
this._touched = Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isDisabled(ev)) return;
|
if (this.isDisabled(ev)) return;
|
||||||
|
|
||||||
this.startX = pointerCoord(ev).x;
|
this._startX = pointerCoord(ev).x;
|
||||||
|
|
||||||
this.removeMoveListener();
|
this.removeMoveListener();
|
||||||
this.addMoveListener();
|
this.addMoveListener();
|
||||||
@ -188,11 +195,11 @@ export class Toggle {
|
|||||||
let endX = pointerCoord(ev).x;
|
let endX = pointerCoord(ev).x;
|
||||||
|
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
if (this.startX + 4 > endX) {
|
if (this._startX + 4 > endX) {
|
||||||
this.toggle(ev);
|
this.toggle();
|
||||||
}
|
}
|
||||||
} else if (this.startX - 4 < endX) {
|
} else if (this._startX - 4 < endX) {
|
||||||
this.toggle(ev);
|
this.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeMoveListener();
|
this.removeMoveListener();
|
||||||
@ -235,7 +242,7 @@ export class Toggle {
|
|||||||
*/
|
*/
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.removeMoveListener();
|
this.removeMoveListener();
|
||||||
this.toggleEle = this.addMoveListener = this.removeMoveListener = null;
|
this.addMoveListener = this.removeMoveListener = null;
|
||||||
this._form.deregister(this);
|
this._form.deregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +250,7 @@ export class Toggle {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
isDisabled(ev) {
|
isDisabled(ev) {
|
||||||
return (this.lastTouch + 999 > Date.now() && /mouse/.test(ev.type)) || (this.mode == 'ios' && ev.target.tagName == 'ION-TOGGLE');
|
return (this._touched + 999 > Date.now() && /mouse/.test(ev.type)) || (this._mode == 'ios' && ev.target.tagName == 'ION-TOGGLE');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import {Component, Directive, Host, ElementRef, Optional, forwardRef, Inject, ContentChildren, ContentChild, QueryList} from 'angular2/core';
|
import {Component, Directive, Host, ElementRef, Optional, forwardRef, Inject, ContentChildren, ContentChild, QueryList} from 'angular2/core';
|
||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
import {Config} from '../../config/config';
|
|
||||||
import {MenuToggle} from '../menu/menu-toggle';
|
import {MenuToggle} from '../menu/menu-toggle';
|
||||||
import {Navbar} from '../navbar/navbar';
|
import {Navbar} from '../navbar/navbar';
|
||||||
import {Button} from '../button/button';
|
import {Button} from '../button/button';
|
||||||
@ -15,11 +14,8 @@ export class ToolbarBase extends Ion {
|
|||||||
titleRef = null;
|
titleRef = null;
|
||||||
titleCmp: any;
|
titleCmp: any;
|
||||||
|
|
||||||
constructor(
|
constructor(elementRef: ElementRef) {
|
||||||
elementRef: ElementRef,
|
super(elementRef);
|
||||||
config: Config
|
|
||||||
) {
|
|
||||||
super(elementRef, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,11 +91,8 @@ export class ToolbarBase extends Ion {
|
|||||||
})
|
})
|
||||||
export class Toolbar extends ToolbarBase {
|
export class Toolbar extends ToolbarBase {
|
||||||
|
|
||||||
constructor(
|
constructor(elementRef: ElementRef) {
|
||||||
elementRef: ElementRef,
|
super(elementRef);
|
||||||
config: Config
|
|
||||||
) {
|
|
||||||
super(elementRef, config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -137,7 +130,7 @@ export class ToolbarTitle extends Ion {
|
|||||||
@Optional() toolbar: Toolbar,
|
@Optional() toolbar: Toolbar,
|
||||||
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
|
@Optional() @Inject(forwardRef(() => Navbar)) navbar: Navbar
|
||||||
) {
|
) {
|
||||||
super(elementRef, null);
|
super(elementRef);
|
||||||
toolbar && toolbar.setTitleCmp(this);
|
toolbar && toolbar.setTitleCmp(this);
|
||||||
navbar && navbar.setTitleCmp(this);
|
navbar && navbar.setTitleCmp(this);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user