chore(tslint): fix noImplicitAny errors

This commit is contained in:
Adam Bradley
2016-05-31 21:07:17 -05:00
parent fc819dd9c4
commit 11448dcd0c
49 changed files with 284 additions and 353 deletions

View File

@ -8,17 +8,17 @@ import {Item} from '../item/item';
import {App} from '../app/app'; import {App} from '../app/app';
import {isTrueProperty} from '../../util/util'; import {isTrueProperty} from '../../util/util';
import {Label} from '../label/label'; import {Label} from '../label/label';
import {pointerCoord, hasPointerMoved, closest, copyInputAttributes} from '../../util/dom'; import {pointerCoord, hasPointerMoved, closest, copyInputAttributes, Coordinates} from '../../util/dom';
import {NavController} from '../nav/nav-controller'; import {NavController} from '../nav/nav-controller';
import {NativeInput, NextInput} from './native-input'; import {NativeInput, NextInput} from './native-input';
import {Platform} from '../../platform/platform'; import {Platform} from '../../platform/platform';
export class InputBase { export class InputBase {
protected _coord; protected _coord: Coordinates;
protected _deregScroll; protected _deregScroll: Function;
protected _disabled: boolean = false; protected _disabled: boolean = false;
protected _keyboardHeight; protected _keyboardHeight: number;
protected _scrollMove: EventListener; protected _scrollMove: EventListener;
protected _type: string = 'text'; protected _type: string = 'text';
protected _useAssist: boolean; protected _useAssist: boolean;
@ -31,7 +31,7 @@ export class InputBase {
inputControl: NgControl; inputControl: NgControl;
@Input() clearInput; @Input() clearInput: any;
@Input() placeholder: string = ''; @Input() placeholder: string = '';
@ViewChild(NativeInput) protected _native: NativeInput; @ViewChild(NativeInput) protected _native: NativeInput;
@Output() blur: EventEmitter<Event> = new EventEmitter; @Output() blur: EventEmitter<Event> = new EventEmitter;
@ -122,7 +122,7 @@ export class InputBase {
} }
} }
private setControlCss(element, control) { private setControlCss(element: any, control: any) {
element.setCssClass('ng-untouched', control.untouched); element.setCssClass('ng-untouched', control.untouched);
element.setCssClass('ng-touched', control.touched); element.setCssClass('ng-touched', control.touched);
element.setCssClass('ng-pristine', control.pristine); element.setCssClass('ng-pristine', control.pristine);
@ -183,12 +183,12 @@ export class InputBase {
nativeInput.labelledBy(this._item.labelId); nativeInput.labelledBy(this._item.labelId);
} }
nativeInput.valueChange.subscribe(inputValue => { nativeInput.valueChange.subscribe((inputValue: any) => {
this.onChange(inputValue); this.onChange(inputValue);
}); });
this.focusChange(this.hasFocus()); this.focusChange(this.hasFocus());
nativeInput.focusChange.subscribe(textInputHasFocus => { nativeInput.focusChange.subscribe((textInputHasFocus: any) => {
this.focusChange(textInputHasFocus); this.focusChange(textInputHasFocus);
this.checkHasValue(nativeInput.getValue()); this.checkHasValue(nativeInput.getValue());
if (!textInputHasFocus) { if (!textInputHasFocus) {
@ -257,7 +257,7 @@ export class InputBase {
* the checked value. * the checked value.
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34 * https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34
*/ */
writeValue(val) { writeValue(val: any) {
this._value = val; this._value = val;
this.checkHasValue(val); this.checkHasValue(val);
} }
@ -265,14 +265,14 @@ export class InputBase {
/** /**
* @private * @private
*/ */
onChange(val) { onChange(val: any) {
this.checkHasValue(val); this.checkHasValue(val);
} }
/** /**
* @private * @private
*/ */
onTouched(val) {} onTouched(val: any) {}
/** /**
* @private * @private
@ -285,7 +285,7 @@ export class InputBase {
/** /**
* @private * @private
*/ */
checkHasValue(inputValue) { checkHasValue(inputValue: any) {
if (this._item) { if (this._item) {
this._item.setCssClass('input-has-value', !!(inputValue && inputValue !== '')); this._item.setCssClass('input-has-value', !!(inputValue && inputValue !== ''));
} }
@ -303,7 +303,7 @@ export class InputBase {
} }
} }
private pointerStart(ev) { private pointerStart(ev: any) {
// input cover touchstart // input cover touchstart
console.debug('scroll assist pointerStart', ev.type); console.debug('scroll assist pointerStart', ev.type);
@ -317,7 +317,7 @@ export class InputBase {
} }
} }
private pointerEnd(ev) { private pointerEnd(ev: any) {
// input cover touchend/mouseup // input cover touchend/mouseup
console.debug('scroll assist pointerEnd', ev.type); console.debug('scroll assist pointerEnd', ev.type);
@ -435,7 +435,7 @@ export class InputBase {
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L27 * https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L27
* @param {Function} fn the onChange event handler. * @param {Function} fn the onChange event handler.
*/ */
registerOnChange(fn) { this.onChange = fn; } registerOnChange(fn: any) { this.onChange = fn; }
/** /**
* @private * @private
@ -443,7 +443,7 @@ export class InputBase {
* the onTouched event handler that marks model (Control) as touched. * the onTouched event handler that marks model (Control) as touched.
* @param {Function} fn onTouched event handler. * @param {Function} fn onTouched event handler.
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
/** /**
* @private * @private
@ -473,7 +473,7 @@ export class InputBase {
/** /**
* @private * @private
*/ */
static getScrollData(inputOffsetTop, inputOffsetHeight, scrollViewDimensions, keyboardHeight, plaformHeight) { static getScrollData(inputOffsetTop: number, inputOffsetHeight: number, scrollViewDimensions: any, keyboardHeight: number, plaformHeight: number) {
// compute input's Y values relative to the body // compute input's Y values relative to the body
let inputTop = (inputOffsetTop + scrollViewDimensions.contentTop - scrollViewDimensions.scrollTop); let inputTop = (inputOffsetTop + scrollViewDimensions.contentTop - scrollViewDimensions.scrollTop);
let inputBottom = (inputTop + inputOffsetHeight); let inputBottom = (inputTop + inputOffsetHeight);
@ -590,7 +590,7 @@ export class InputBase {
const SCROLL_ASSIST_SPEED = 0.3; const SCROLL_ASSIST_SPEED = 0.3;
function getScrollAssistDuration(distanceToScroll) { function getScrollAssistDuration(distanceToScroll: number) {
distanceToScroll = Math.abs(distanceToScroll); distanceToScroll = Math.abs(distanceToScroll);
let duration = distanceToScroll / SCROLL_ASSIST_SPEED; let duration = distanceToScroll / SCROLL_ASSIST_SPEED;
return Math.min(400, Math.max(150, duration)); return Math.min(400, Math.max(150, duration));

View File

@ -1,5 +1,5 @@
import {ElementRef} from '@angular/core'; import {ElementRef} from '@angular/core';
import * as dom from '../util/dom'; import {getDimensions, clearDimensions} from '../util/dom';
let ids: number = 0; let ids: number = 0;
@ -26,19 +26,19 @@ export class Ion {
getDimensions(): { getDimensions(): {
width: number, height: number, left: number, top: number width: number, height: number, left: number, top: number
} { } {
return dom.getDimensions(this.elementRef.nativeElement, this._id); return getDimensions(this.elementRef.nativeElement, this._id);
} }
width(): number { width(): number {
return dom.getDimensions(this.elementRef.nativeElement, this._id).width; return getDimensions(this.elementRef.nativeElement, this._id).width;
} }
height(): number { height(): number {
return dom.getDimensions(this.elementRef.nativeElement, this._id).height; return getDimensions(this.elementRef.nativeElement, this._id).height;
} }
ngOnDestroy() { ngOnDestroy() {
dom.clearDimensions(this._id); clearDimensions(this._id);
} }
} }

View File

@ -9,8 +9,8 @@ export class ItemSlidingGesture extends DragGesture {
canDrag: boolean = true; canDrag: boolean = true;
data = {}; data = {};
openItems: number = 0; openItems: number = 0;
onTap; onTap: any;
onMouseOut; onMouseOut: any;
preventDrag: boolean = false; preventDrag: boolean = false;
dragEnded: boolean = true; dragEnded: boolean = true;
@ -22,7 +22,7 @@ export class ItemSlidingGesture extends DragGesture {
this.listen(); this.listen();
this.onTap = (ev) => { this.onTap = (ev: UIEvent) => {
if (!isFromOptionButtons(ev.target)) { if (!isFromOptionButtons(ev.target)) {
let didClose = this.closeOpened(); let didClose = this.closeOpened();
if (didClose) { if (didClose) {
@ -32,7 +32,7 @@ export class ItemSlidingGesture extends DragGesture {
} }
}; };
this.onMouseOut = (ev) => { this.onMouseOut = (ev: any) => {
if (ev.target.tagName === 'ION-ITEM-SLIDING') { if (ev.target.tagName === 'ION-ITEM-SLIDING') {
console.debug('tap close sliding item'); console.debug('tap close sliding item');
this.onDragEnd(ev); this.onDragEnd(ev);
@ -40,7 +40,7 @@ export class ItemSlidingGesture extends DragGesture {
}; };
} }
onDragStart(ev): boolean { onDragStart(ev: any): boolean {
let itemContainerEle = getItemContainer(ev.target); let itemContainerEle = getItemContainer(ev.target);
if (!itemContainerEle) { if (!itemContainerEle) {
console.debug('onDragStart, no itemContainerEle'); console.debug('onDragStart, no itemContainerEle');
@ -70,7 +70,7 @@ export class ItemSlidingGesture extends DragGesture {
return true; return true;
} }
onDrag(ev): boolean { onDrag(ev: any): boolean {
if (this.dragEnded || this.preventDrag || Math.abs(ev.deltaY) > 30) { if (this.dragEnded || this.preventDrag || Math.abs(ev.deltaY) > 30) {
console.debug('onDrag preventDrag, dragEnded:', this.dragEnded, 'preventDrag:', this.preventDrag, 'ev.deltaY:', Math.abs(ev.deltaY)); console.debug('onDrag preventDrag, dragEnded:', this.dragEnded, 'preventDrag:', this.preventDrag, 'ev.deltaY:', Math.abs(ev.deltaY));
this.preventDrag = true; this.preventDrag = true;
@ -116,7 +116,7 @@ export class ItemSlidingGesture extends DragGesture {
}); });
} }
onDragEnd(ev) { onDragEnd(ev: any) {
this.preventDrag = false; this.preventDrag = false;
this.dragEnded = true; this.dragEnded = true;
@ -165,7 +165,7 @@ export class ItemSlidingGesture extends DragGesture {
return didClose; return didClose;
} }
open(itemContainerEle, openAmount, isFinal) { open(itemContainerEle: any, openAmount: number, isFinal: boolean) {
let slidingEle = itemContainerEle.querySelector('ion-item,[ion-item]'); let slidingEle = itemContainerEle.querySelector('ion-item,[ion-item]');
if (!slidingEle) { if (!slidingEle) {
console.debug('open, no slidingEle, openAmount:', openAmount); console.debug('open, no slidingEle, openAmount:', openAmount);
@ -203,15 +203,15 @@ export class ItemSlidingGesture extends DragGesture {
} }
} }
getOpenAmount(itemContainerEle) { getOpenAmount(itemContainerEle: any) {
return this.get(itemContainerEle).openAmount || 0; return this.get(itemContainerEle).openAmount || 0;
} }
get(itemContainerEle) { get(itemContainerEle: any) {
return this.data[itemContainerEle && itemContainerEle.$ionSlide] || {}; return this.data[itemContainerEle && itemContainerEle.$ionSlide] || {};
} }
set(itemContainerEle, key, value) { set(itemContainerEle: any, key: any, value: any) {
if (!this.data[itemContainerEle.$ionSlide]) { if (!this.data[itemContainerEle.$ionSlide]) {
this.data[itemContainerEle.$ionSlide] = {}; this.data[itemContainerEle.$ionSlide] = {};
} }
@ -224,32 +224,32 @@ export class ItemSlidingGesture extends DragGesture {
} }
} }
function isItemActive(ele, isActive) { function isItemActive(ele: any, isActive: boolean) {
ele.classList[isActive ? 'add' : 'remove']('active-slide'); ele.classList[isActive ? 'add' : 'remove']('active-slide');
ele.classList[isActive ? 'add' : 'remove']('active-options'); ele.classList[isActive ? 'add' : 'remove']('active-options');
} }
function preventDefault(ev) { function preventDefault(ev: any) {
console.debug('sliding item preventDefault', ev.type); console.debug('sliding item preventDefault', ev.type);
ev.preventDefault(); ev.preventDefault();
} }
function getItemContainer(ele) { function getItemContainer(ele: any) {
return closest(ele, 'ion-item-sliding', true); return closest(ele, 'ion-item-sliding', true);
} }
function isFromOptionButtons(ele) { function isFromOptionButtons(ele: any) {
return !!closest(ele, 'ion-item-options', true); return !!closest(ele, 'ion-item-options', true);
} }
function getOptionsWidth(itemContainerEle) { function getOptionsWidth(itemContainerEle: any) {
let optsEle = itemContainerEle.querySelector('ion-item-options'); let optsEle = itemContainerEle.querySelector('ion-item-options');
if (optsEle) { if (optsEle) {
return optsEle.offsetWidth; return optsEle.offsetWidth;
} }
} }
function isActive(itemContainerEle) { function isActive(itemContainerEle: any) {
return itemContainerEle.classList.contains('active-slide'); return itemContainerEle.classList.contains('active-slide');
} }

View File

@ -144,8 +144,8 @@ export class Item {
* @private * @private
*/ */
@ContentChildren(Button) @ContentChildren(Button)
private set _buttons(buttons) { private set _buttons(buttons: any) {
buttons.toArray().forEach(button => { buttons.toArray().forEach((button: any) => {
// Don't add the item-button class if the user specifies // Don't add the item-button class if the user specifies
// a different size button // a different size button
if (!button.isItem && !button._size) { if (!button.isItem && !button._size) {
@ -158,8 +158,8 @@ export class Item {
* @private * @private
*/ */
@ContentChildren(Icon) @ContentChildren(Icon)
private set _icons(icons) { private set _icons(icons: any) {
icons.toArray().forEach(icon => { icons.toArray().forEach((icon: any) => {
icon.addClass('item-icon'); icon.addClass('item-icon');
}); });
} }

View File

@ -212,7 +212,7 @@ class LoadingCmp {
this.d.duration ? setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null; this.d.duration ? setTimeout(() => this.dismiss('backdrop'), this.d.duration) : null;
} }
dismiss(role): Promise<any> { dismiss(role: any): Promise<any> {
return this._viewCtrl.dismiss(null, role); return this._viewCtrl.dismiss(null, role);
} }

View File

@ -35,7 +35,7 @@ export class MenuClose {
/** /**
* @private * @private
*/ */
@Input() menuClose; @Input() menuClose: string;
constructor(private _menu: MenuController) {} constructor(private _menu: MenuController) {}

View File

@ -1,5 +1,6 @@
import {Menu} from './menu'; import {Menu} from './menu';
import {MenuType} from './menu-types'; import {MenuType} from './menu-types';
import {Platform} from '../../platform/platform';
/** /**
@ -292,7 +293,7 @@ export class MenuController {
/** /**
* @private * @private
*/ */
static create(type, menuCmp) { static create(type: string, menuCmp: Menu, platform: Platform) {
return new menuTypes[type](menuCmp); return new menuTypes[type](menuCmp);
} }

View File

@ -44,7 +44,7 @@ export class MenuToggle {
/** /**
* @private * @private
*/ */
@Input() menuToggle; @Input() menuToggle: string;
/** /**
* @private * @private

View File

@ -1,5 +1,7 @@
import {MenuController} from './menu-controller';
import {Animation} from '../../animations/animation'; import {Animation} from '../../animations/animation';
import {Menu} from './menu';
import {MenuController} from './menu-controller';
import {Platform} from '../../platform/platform';
/** /**
@ -62,7 +64,7 @@ export class MenuType {
* The menu itself, which is under the content, does not move. * The menu itself, which is under the content, does not move.
*/ */
class MenuRevealType extends MenuType { class MenuRevealType extends MenuType {
constructor(menu) { constructor(menu: Menu) {
super(); super();
let openedX = (menu.width() * (menu.side === 'right' ? -1 : 1)) + 'px'; let openedX = (menu.width() * (menu.side === 'right' ? -1 : 1)) + 'px';
@ -86,19 +88,19 @@ MenuController.registerType('reveal', MenuRevealType);
* The menu itself also slides over to reveal its bad self. * The menu itself also slides over to reveal its bad self.
*/ */
class MenuPushType extends MenuType { class MenuPushType extends MenuType {
constructor(menu) { constructor(menu: Menu, platform: Platform) {
super(); super();
this.ani this.ani
.easing('ease') .easing('ease')
.duration(250); .duration(250);
let contentOpenedX, menuClosedX, menuOpenedX; let contentOpenedX: string, menuClosedX: string, menuOpenedX: string;
if (menu.side === 'right') { if (menu.side === 'right') {
contentOpenedX = -menu.width() + 'px'; contentOpenedX = -menu.width() + 'px';
menuOpenedX = (menu._platform.width() - menu.width()) + 'px'; menuOpenedX = (platform.width() - menu.width()) + 'px';
menuClosedX = menu._platform.width() + 'px'; menuClosedX = platform.width() + 'px';
} else { } else {
contentOpenedX = menu.width() + 'px'; contentOpenedX = menu.width() + 'px';
@ -125,18 +127,18 @@ MenuController.registerType('push', MenuPushType);
* itself, which is under the menu, does not move. * itself, which is under the menu, does not move.
*/ */
class MenuOverlayType extends MenuType { class MenuOverlayType extends MenuType {
constructor(menu) { constructor(menu: Menu, platform: Platform) {
super(); super();
this.ani this.ani
.easing('ease') .easing('ease')
.duration(250); .duration(250);
let closedX, openedX; let closedX: string, openedX: string;
if (menu.side === 'right') { if (menu.side === 'right') {
// right side // right side
closedX = menu._platform.width() + 'px'; closedX = platform.width() + 'px';
openedX = (menu._platform.width() - menu.width() - 8) + 'px'; openedX = (platform.width() - menu.width() - 8) + 'px';
} else { } else {
// left side // left side

View File

@ -394,7 +394,7 @@ export class Menu extends Ion {
*/ */
private _getType(): MenuType { private _getType(): MenuType {
if (!this._type) { if (!this._type) {
this._type = MenuController.create(this.type, this); this._type = MenuController.create(this.type, this, this._platform);
if (this._config.get('animate') === false) { if (this._config.get('animate') === false) {
this._type.ani.duration(0); this._type.ani.duration(0);
@ -453,7 +453,7 @@ export class Menu extends Ion {
// user has finished dragging the menu // user has finished dragging the menu
if (this._isEnabled && this._isSwipeEnabled) { if (this._isEnabled && this._isSwipeEnabled) {
this._prevent(); this._prevent();
this._getType().setProgressEnd(shouldComplete, currentStepValue, (isOpen) => { this._getType().setProgressEnd(shouldComplete, currentStepValue, (isOpen: boolean) => {
console.debug('menu, swipeEnd', this.side); console.debug('menu, swipeEnd', this.side);
this._after(isOpen); this._after(isOpen);
}); });
@ -630,7 +630,7 @@ export class MenuBackdrop {
/** /**
* @private * @private
*/ */
private clicked(ev) { private clicked(ev: UIEvent) {
console.debug('backdrop clicked'); console.debug('backdrop clicked');
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();

View File

@ -112,7 +112,7 @@ export class Modal extends ViewController {
public modalViewType: string; public modalViewType: string;
constructor(componentType, data: any = {}) { constructor(componentType: any, data: any = {}) {
data.componentType = componentType; data.componentType = componentType;
super(ModalCmp, data); super(ModalCmp, data);
this.modalViewType = componentType.name; this.modalViewType = componentType.name;
@ -123,7 +123,7 @@ export class Modal extends ViewController {
/** /**
* @private * @private
*/ */
getTransitionName(direction) { getTransitionName(direction: string) {
let key = (direction === 'back' ? 'modalLeave' : 'modalEnter'); let key = (direction === 'back' ? 'modalLeave' : 'modalEnter');
return this._nav && this._nav.config.get(key); return this._nav && this._nav.config.get(key);
} }
@ -132,12 +132,12 @@ export class Modal extends ViewController {
* @param {any} componentType Modal * @param {any} componentType Modal
* @param {object} data Modal options * @param {object} data Modal options
*/ */
static create(componentType, data = {}) { static create(componentType: any, data = {}) {
return new Modal(componentType, data); return new Modal(componentType, data);
} }
// Override the load method and load our child component // Override the load method and load our child component
loaded(done) { loaded(done: Function) {
// grab the instance, and proxy the ngAfterViewInit method // grab the instance, and proxy the ngAfterViewInit method
let originalNgAfterViewInit = this.instance.ngAfterViewInit; let originalNgAfterViewInit = this.instance.ngAfterViewInit;

View File

@ -356,19 +356,6 @@ export class NavController extends Ion {
opts = {}; opts = {};
} }
// deprecated warning
pages.forEach(pg => {
if (pg['componentType']) {
pg.page = pg['componentType'];
console.warn('setPages() now uses "page" instead of "componentType" in the array of pages. ' +
'What was: setPages([{componentType: About}, {componentType: Contact}]) is now: setPages([{page: About}, {page: Contact}])');
} else if (!pg['page']) {
console.error('setPages() now requires an object containing "page" and optionally "params" in the array of pages. ' +
'What was: setPages([About, Contact]) is now: setPages([{page: About}, {page: Contact}])');
}
});
// remove existing views // remove existing views
let leavingView = this._remove(0, this._views.length); let leavingView = this._remove(0, this._views.length);
@ -384,7 +371,7 @@ export class NavController extends Ion {
// set the nav direction to "back" if it wasn't set // set the nav direction to "back" if it wasn't set
opts.direction = opts.direction || 'back'; opts.direction = opts.direction || 'back';
let resolve; let resolve: any;
let promise = new Promise(res => { resolve = res; }); let promise = new Promise(res => { resolve = res; });
// start the transition, fire resolve when done... // start the transition, fire resolve when done...
@ -611,7 +598,7 @@ export class NavController extends Ion {
opts.animation = enteringView.getTransitionName(opts.direction); opts.animation = enteringView.getTransitionName(opts.direction);
} }
let resolve; let resolve: any;
let promise = new Promise(res => { resolve = res; }); let promise = new Promise(res => { resolve = res; });
// it's possible that the newly added view doesn't need to // it's possible that the newly added view doesn't need to
@ -856,7 +843,7 @@ export class NavController extends Ion {
return Promise.resolve(false); return Promise.resolve(false);
} }
let resolve; let resolve: any;
let promise = new Promise(res => { resolve = res; }); let promise = new Promise(res => { resolve = res; });
if (!opts.animation) { if (!opts.animation) {
@ -1040,7 +1027,7 @@ export class NavController extends Ion {
/** /**
* @private * @private
*/ */
private _render(transId, enteringView: ViewController, leavingView: ViewController, opts: NavOptions, done: Function) { private _render(transId: number, enteringView: ViewController, leavingView: ViewController, opts: NavOptions, done: Function) {
// compile/load the view into the DOM // compile/load the view into the DOM
if (enteringView.state === STATE_INACTIVE) { if (enteringView.state === STATE_INACTIVE) {
@ -1076,7 +1063,7 @@ export class NavController extends Ion {
/** /**
* @private * @private
*/ */
private _postRender(transId, enteringView: ViewController, leavingView: ViewController, isAlreadyTransitioning: boolean, opts: NavOptions, done: Function) { private _postRender(transId: number, enteringView: ViewController, leavingView: ViewController, isAlreadyTransitioning: boolean, opts: NavOptions, done: Function) {
// called after _render has completed and the view is compiled/loaded // called after _render has completed and the view is compiled/loaded
if (enteringView.state === STATE_INACTIVE) { if (enteringView.state === STATE_INACTIVE) {
@ -1764,7 +1751,7 @@ export class NavController extends Ion {
/** /**
* @private * @private
*/ */
private _setZIndex(enteringView: ViewController, leavingView: ViewController, direction) { private _setZIndex(enteringView: ViewController, leavingView: ViewController, direction: string) {
if (enteringView) { if (enteringView) {
// get the leaving view, which could be in various states // get the leaving view, which could be in various states
if (!leavingView || !leavingView.isLoaded()) { if (!leavingView || !leavingView.isLoaded()) {

View File

@ -54,12 +54,12 @@ export class NavPush {
/** /**
* @input {Page} the page you want to push * @input {Page} the page you want to push
*/ */
@Input() navPush; @Input() navPush: any;
/** /**
* @input {any} Any parameters you want to pass along * @input {any} Any parameters you want to pass along
*/ */
@Input() navParams; @Input() navParams: any;
constructor( constructor(
@Optional() private _nav: NavController, @Optional() private _nav: NavController,
@ -74,7 +74,7 @@ export class NavPush {
* @private * @private
*/ */
onClick() { onClick() {
let destination, params; let destination: any, params: any;
if (this.navPush instanceof Array) { if (this.navPush instanceof Array) {
if (this.navPush.length > 2) { if (this.navPush.length > 2) {

View File

@ -16,11 +16,11 @@ export class NavRegistry {
} }
} }
get(pageName) { get(pageName: any) {
return this._pages.get(pageName); return this._pages.get(pageName);
} }
set(page) { set(page: any) {
this._pages.set(page.name, page); this._pages.set(page.name, page);
} }
} }

View File

@ -350,7 +350,7 @@ export class ViewController {
/** /**
* @private * @private
*/ */
setContent(directive) { setContent(directive: any) {
this._cntDir = directive; this._cntDir = directive;
} }

View File

@ -26,7 +26,7 @@ class BackButton extends Ion {
navbar && navbar.setBackButtonRef(elementRef); navbar && navbar.setBackButtonRef(elementRef);
} }
goBack(ev) { goBack(ev: UIEvent) {
ev.stopPropagation(); ev.stopPropagation();
ev.preventDefault(); ev.preventDefault();
this._nav && this._nav.pop(); this._nav && this._nav.pop();

View File

@ -14,7 +14,7 @@ import {isPresent, isTrueProperty} from '../../util/util';
}) })
export class Option { export class Option {
private _checked: any = false; private _checked: any = false;
private _value; private _value: any;
/** /**
* @input {any} Event to evaluate when option is selected * @input {any} Event to evaluate when option is selected
@ -46,7 +46,7 @@ export class Option {
return this.text; return this.text;
} }
set value(val) { set value(val: any) {
this._value = val; this._value = val;
} }

View File

@ -143,7 +143,7 @@ class PickerColumnCmp {
this.setSelected(this.col.selectedIndex, 0); this.setSelected(this.col.selectedIndex, 0);
} }
pointerStart(ev) { pointerStart(ev: UIEvent) {
console.debug('picker, pointerStart', ev.type, this.startY); console.debug('picker, pointerStart', ev.type, this.startY);
if (this.isPrevented(ev)) { if (this.isPrevented(ev)) {
@ -177,7 +177,7 @@ class PickerColumnCmp {
this.maxY = (maxY * this.optHeight * -1); this.maxY = (maxY * this.optHeight * -1);
} }
pointerMove(ev) { pointerMove(ev: UIEvent) {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
@ -212,7 +212,7 @@ class PickerColumnCmp {
this.update(y, 0, false, false); this.update(y, 0, false, false);
} }
pointerEnd(ev) { pointerEnd(ev: UIEvent) {
if (this.isPrevented(ev)) { if (this.isPrevented(ev)) {
return; return;
} }
@ -320,7 +320,7 @@ class PickerColumnCmp {
} }
} }
optClick(ev, index: number) { optClick(ev: UIEvent, index: number) {
if (!this.velocity) { if (!this.velocity) {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
@ -410,7 +410,7 @@ class PickerColumnCmp {
} }
} }
isPrevented(ev): boolean { isPrevented(ev: UIEvent): boolean {
let now = Date.now(); let now = Date.now();
if (ev.type.indexOf('touch') > -1) { if (ev.type.indexOf('touch') > -1) {
// this is a touch event, so prevent mouse events for a while // this is a touch event, so prevent mouse events for a while
@ -575,7 +575,7 @@ class PickerDisplayCmp {
} }
} }
btnClick(button, dismissDelay?) { btnClick(button: any, dismissDelay?: number) {
if (!this.isEnabled()) { if (!this.isEnabled()) {
return; return;
} }
@ -607,7 +607,7 @@ class PickerDisplayCmp {
} }
} }
dismiss(role): Promise<any> { dismiss(role: any): Promise<any> {
return this._viewCtrl.dismiss(this.getSelected(), role); return this._viewCtrl.dismiss(this.getSelected(), role);
} }

View File

@ -105,7 +105,7 @@ const POPOVER_MD_BODY_PADDING = 12;
*/ */
export class Popover extends ViewController { export class Popover extends ViewController {
constructor(componentType, data: any = {}, opts: PopoverOptions = {}) { constructor(componentType: any, data: any = {}, opts: PopoverOptions = {}) {
opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true; opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true; opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
@ -143,7 +143,7 @@ export class Popover extends ViewController {
* @param {object} data Any data to pass to the Popover view * @param {object} data Any data to pass to the Popover view
* @param {object} opts Popover options * @param {object} opts Popover options
*/ */
static create(componentType, data = {}, opts: PopoverOptions = {}) { static create(componentType: any, data = {}, opts: PopoverOptions = {}) {
return new Popover(componentType, data, opts); return new Popover(componentType, data, opts);
} }
@ -206,11 +206,11 @@ class PopoverCmp {
} }
} }
dismiss(role): Promise<any> { dismiss(role: any): Promise<any> {
return this._viewCtrl.dismiss(null, role); return this._viewCtrl.dismiss(null, role);
} }
bdTouch(ev) { bdTouch(ev: UIEvent) {
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
} }
@ -241,7 +241,7 @@ class PopoverTransition extends Transition {
super(opts); super(opts);
} }
mdPositionView(nativeEle: HTMLElement, ev) { mdPositionView(nativeEle: HTMLElement, ev: any) {
let originY = 'top'; let originY = 'top';
let originX = 'left'; let originX = 'left';
@ -301,7 +301,7 @@ class PopoverTransition extends Transition {
popoverWrapperEle.style.opacity = '1'; popoverWrapperEle.style.opacity = '1';
} }
iosPositionView(nativeEle: HTMLElement, ev) { iosPositionView(nativeEle: HTMLElement, ev: any) {
let originY = 'top'; let originY = 'top';
let originX = 'left'; let originX = 'left';

View File

@ -145,7 +145,7 @@ export class RadioButton {
* @private * @private
*/ */
@HostListener('click', ['$event']) @HostListener('click', ['$event'])
private _click(ev) { private _click(ev: UIEvent) {
console.debug('radio, select', this.id); console.debug('radio, select', this.id);
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();

View File

@ -140,7 +140,7 @@ export class RadioGroup {
/** /**
* @private * @private
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
/** /**
* @private * @private
@ -174,7 +174,7 @@ export class RadioGroup {
this._btns.push(button); this._btns.push(button);
// listen for radiobutton select events // listen for radiobutton select events
button.ionSelect.subscribe((val) => { button.ionSelect.subscribe((val: any) => {
// this radiobutton has been selected // this radiobutton has been selected
this.onChange(val); this.onChange(val);
}); });
@ -199,7 +199,7 @@ export class RadioGroup {
* @private * @private
*/ */
@ContentChild(ListHeader) @ContentChild(ListHeader)
private set _header(header) { private set _header(header: any) {
if (header) { if (header) {
if (!header.id) { if (!header.id) {
header.id = 'rg-hdr-' + this.id; header.id = 'rg-hdr-' + this.id;

View File

@ -4,7 +4,7 @@ import {NG_VALUE_ACCESSOR} from '@angular/common';
import {Form} from '../../util/form'; import {Form} from '../../util/form';
import {isTrueProperty, isNumber, isString, isPresent, clamp} from '../../util/util'; import {isTrueProperty, isNumber, isString, isPresent, clamp} from '../../util/util';
import {Item} from '../item/item'; import {Item} from '../item/item';
import {pointerCoord} from '../../util/dom'; import {pointerCoord, Coordinates} from '../../util/dom';
const RANGE_VALUE_ACCESSOR = new Provider( const RANGE_VALUE_ACCESSOR = new Provider(
@ -633,7 +633,7 @@ export class Range {
/** /**
* @private * @private
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
/** /**
* @input {boolean} Whether or not the range is disabled. Defaults to `false`. * @input {boolean} Whether or not the range is disabled. Defaults to `false`.
@ -702,8 +702,3 @@ export interface ClientRect {
xOffset?: number; xOffset?: number;
yOffset?: number; yOffset?: number;
} }
export interface Coordinates {
x?: number;
y?: number;
}

View File

@ -375,7 +375,7 @@ export class Refresher {
return 4; return 4;
} }
private _onEnd(ev) { private _onEnd(ev: UIEvent) {
// only run in a zone when absolutely necessary // only run in a zone when absolutely necessary
if (this.state === STATE_READY) { if (this.state === STATE_READY) {
@ -438,9 +438,9 @@ export class Refresher {
} }
private _close(state: string, delay: string) { private _close(state: string, delay: string) {
var timer; var timer: number;
function close(ev) { function close(ev: any) {
// closing is done, return to inactive state // closing is done, return to inactive state
if (ev) { if (ev) {
clearTimeout(timer); clearTimeout(timer);

View File

@ -78,7 +78,7 @@ export class Scroll extends Ion {
* @returns {?Function} a function to remove the specified handler, otherwise * @returns {?Function} a function to remove the specified handler, otherwise
* undefined if the scroll element doesn't exist. * undefined if the scroll element doesn't exist.
*/ */
addScrollEventListener(handler) { addScrollEventListener(handler: any) {
if (!this.scrollElement) { return; } if (!this.scrollElement) { return; }
this.scrollElement.addEventListener('scroll', handler); this.scrollElement.addEventListener('scroll', handler);

View File

@ -1,11 +1,11 @@
import {ElementRef, Component, Directive, Host, HostBinding, HostListener, ViewChild, Input, Output, EventEmitter, Optional, ViewEncapsulation} from '@angular/core'; import {ElementRef, Component, Directive, Host, HostBinding, HostListener, ViewChild, Input, Output, EventEmitter, Optional, ViewEncapsulation} from '@angular/core';
import {NgControl} from '@angular/common'; import {NgControl} from '@angular/common';
import {Ion} from '../ion'; import {Button} from '../button/button';
import {Config} from '../../config/config'; import {Config} from '../../config/config';
import {Icon} from '../icon/icon'; import {Icon} from '../icon/icon';
import {Button} from '../button/button'; import {Ion} from '../ion';
import {isPresent, debounce} from '../../util/util'; import {isPresent} from '../../util/util';
/** /**
@ -15,7 +15,7 @@ import {isPresent, debounce} from '../../util/util';
selector: '.searchbar-input', selector: '.searchbar-input',
}) })
export class SearchbarInput { export class SearchbarInput {
constructor(private _elementRef: ElementRef) {} constructor(public elementRef: ElementRef) {}
} }
@ -63,7 +63,7 @@ export class Searchbar extends Ion {
/** /**
* @private * @private
*/ */
@ViewChild(SearchbarInput) searchbarInput; @ViewChild(SearchbarInput) searchbarInput: SearchbarInput;
/** /**
* @input {string} Sets the cancel button text to the value passed in * @input {string} Sets the cancel button text to the value passed in
@ -144,12 +144,12 @@ export class Searchbar extends Ion {
/** /**
* @private * @private
*/ */
@HostBinding('class.searchbar-focused') isFocused; @HostBinding('class.searchbar-focused') isFocused: boolean;
/** /**
* @private * @private
*/ */
@HostBinding('class.searchbar-left-aligned') shouldLeftAlign; @HostBinding('class.searchbar-left-aligned') shouldLeftAlign: boolean;
constructor( constructor(
private _elementRef: ElementRef, private _elementRef: ElementRef,
@ -248,7 +248,7 @@ export class Searchbar extends Ion {
* @private * @private
* Update the Searchbar input value when the input changes * Update the Searchbar input value when the input changes
*/ */
inputChanged(ev) { inputChanged(ev: any) {
let value = ev.target.value; let value = ev.target.value;
clearTimeout(this._tmr); clearTimeout(this._tmr);
@ -280,7 +280,7 @@ export class Searchbar extends Ion {
// blurInput determines if it should blur // blurInput determines if it should blur
// if we are clearing the input we still want to stay focused in the input // if we are clearing the input we still want to stay focused in the input
if (this.blurInput === false) { if (this.blurInput === false) {
this.searchbarInput._elementRef.nativeElement.focus(); this.searchbarInput.elementRef.nativeElement.focus();
this.blurInput = true; this.blurInput = true;
return; return;
} }

View File

@ -94,8 +94,8 @@ export class SegmentButton {
* @private * @private
* On click of a SegmentButton * On click of a SegmentButton
*/ */
@HostListener('click', ['$event']) @HostListener('click')
private onClick(ev) { private onClick() {
console.debug('SegmentButton, select', this.value); console.debug('SegmentButton, select', this.value);
this.ionSelect.emit(this); this.ionSelect.emit(this);
} }
@ -112,7 +112,7 @@ export class SegmentButton {
/** /**
* @private * @private
*/ */
set isActive(isActive) { set isActive(isActive: any) {
this._renderer.setElementClass(this._elementRef.nativeElement, 'segment-activated', isActive); this._renderer.setElementClass(this._elementRef.nativeElement, 'segment-activated', isActive);
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-pressed', isActive); this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-pressed', isActive);
} }
@ -215,7 +215,7 @@ export class Segment {
* @private * @private
* Write a new value to the element. * Write a new value to the element.
*/ */
writeValue(value) { writeValue(value: any) {
this.value = isPresent(value) ? value : ''; this.value = isPresent(value) ? value : '';
if (this._buttons) { if (this._buttons) {
let buttons = this._buttons.toArray(); let buttons = this._buttons.toArray();
@ -231,7 +231,7 @@ export class Segment {
ngAfterViewInit() { ngAfterViewInit() {
let buttons = this._buttons.toArray(); let buttons = this._buttons.toArray();
for (let button of buttons) { for (let button of buttons) {
button.ionSelect.subscribe((selectedButton) => { button.ionSelect.subscribe((selectedButton: any) => {
this.writeValue(selectedButton.value); this.writeValue(selectedButton.value);
this.onChange(selectedButton.value); this.onChange(selectedButton.value);
this.ionChange.emit(selectedButton); this.ionChange.emit(selectedButton);
@ -251,22 +251,22 @@ export class Segment {
/** /**
* @private * @private
*/ */
onChange = (_) => {}; onChange = (_: any) => {};
/** /**
* @private * @private
*/ */
onTouched = (_) => {}; onTouched = (_: any) => {};
/** /**
* @private * @private
* Set the function to be called when the control receives a change event. * Set the function to be called when the control receives a change event.
*/ */
registerOnChange(fn) { this.onChange = fn; } registerOnChange(fn: any) { this.onChange = fn; }
/** /**
* @private * @private
* Set the function to be called when the control receives a touch event. * Set the function to be called when the control receives a touch event.
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
} }

View File

@ -206,7 +206,7 @@ export class Select {
} }
@HostListener('click', ['$event']) @HostListener('click', ['$event'])
private _click(ev) { private _click(ev: UIEvent) {
if (ev.detail === 0) { if (ev.detail === 0) {
// do not continue if the click event came from a form submit // do not continue if the click event came from a form submit
return; return;
@ -216,8 +216,8 @@ export class Select {
this._open(); this._open();
} }
@HostListener('keyup.space', ['$event']) @HostListener('keyup.space')
private _keyup(ev) { private _keyup() {
if (!this._isOpen) { if (!this._isOpen) {
this._open(); this._open();
} }
@ -259,9 +259,8 @@ export class Select {
this.interface = 'alert'; this.interface = 'alert';
} }
let overlay; let overlay: any;
if (this.interface === 'action-sheet') { if (this.interface === 'action-sheet') {
alertOptions.buttons = alertOptions.buttons.concat(options.map(input => { alertOptions.buttons = alertOptions.buttons.concat(options.map(input => {
return { return {
role: (input.checked ? 'selected' : ''), role: (input.checked ? 'selected' : ''),
@ -305,7 +304,7 @@ export class Select {
overlay.addButton({ overlay.addButton({
text: this.okText, text: this.okText,
handler: selectedValues => { handler: (selectedValues: any) => {
this.onChange(selectedValues); this.onChange(selectedValues);
this.ionChange.emit(selectedValues); this.ionChange.emit(selectedValues);
} }
@ -426,7 +425,7 @@ export class Select {
/** /**
* @private * @private
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
/** /**
* @private * @private

View File

@ -372,41 +372,41 @@ export class Slides extends Ion {
pagination: paginationId pagination: paginationId
}, this.options); }, this.options);
options.onTap = (swiper, e) => { options.onTap = (swiper: any, e: any) => {
this.onTap(swiper, e); this.onTap(swiper, e);
return this.options.onTap && this.options.onTap(swiper, e); return this.options.onTap && this.options.onTap(swiper, e);
}; };
options.onClick = (swiper, e) => { options.onClick = (swiper: any, e: any) => {
this.onClick(swiper, e); this.onClick(swiper, e);
return this.options.onClick && this.options.onClick(swiper, e); return this.options.onClick && this.options.onClick(swiper, e);
}; };
options.onDoubleTap = (swiper, e) => { options.onDoubleTap = (swiper: any, e: any) => {
this.onDoubleTap(swiper, e); this.onDoubleTap(swiper, e);
return this.options.onDoubleTap && this.options.onDoubleTap(swiper, e); return this.options.onDoubleTap && this.options.onDoubleTap(swiper, e);
}; };
options.onTransitionStart = (swiper, e) => { options.onTransitionStart = (swiper: any, e: any) => {
this.onTransitionStart(swiper, e); this.onTransitionStart(swiper, e);
return this.options.onTransitionStart && this.options.onTransitionStart(swiper, e); return this.options.onTransitionStart && this.options.onTransitionStart(swiper, e);
}; };
options.onTransitionEnd = (swiper, e) => { options.onTransitionEnd = (swiper: any, e: any) => {
this.onTransitionEnd(swiper, e); this.onTransitionEnd(swiper, e);
return this.options.onTransitionEnd && this.options.onTransitionEnd(swiper, e); return this.options.onTransitionEnd && this.options.onTransitionEnd(swiper, e);
}; };
options.onSlideChangeStart = (swiper) => { options.onSlideChangeStart = (swiper: any) => {
this.ionWillChange.emit(swiper); this.ionWillChange.emit(swiper);
return this.options.onSlideChangeStart && this.options.onSlideChangeStart(swiper); return this.options.onSlideChangeStart && this.options.onSlideChangeStart(swiper);
}; };
options.onSlideChangeEnd = (swiper) => { options.onSlideChangeEnd = (swiper: any) => {
this.ionDidChange.emit(swiper); this.ionDidChange.emit(swiper);
return this.options.onSlideChangeEnd && this.options.onSlideChangeEnd(swiper); return this.options.onSlideChangeEnd && this.options.onSlideChangeEnd(swiper);
}; };
options.onLazyImageLoad = (swiper, slide, img) => { options.onLazyImageLoad = (swiper: any, slide: any, img: any) => {
return this.options.onLazyImageLoad && this.options.onLazyImageLoad(swiper, slide, img); return this.options.onLazyImageLoad && this.options.onLazyImageLoad(swiper, slide, img);
}; };
options.onLazyImageReady = (swiper, slide, img) => { options.onLazyImageReady = (swiper: any, slide: any, img: any) => {
return this.options.onLazyImageReady && this.options.onLazyImageReady(swiper, slide, img); return this.options.onLazyImageReady && this.options.onLazyImageReady(swiper, slide, img);
}; };
options.onSliderMove = (swiper, e) => { options.onSliderMove = (swiper: any, e: any) => {
this.ionDrag.emit(swiper); this.ionDrag.emit(swiper);
return this.options.onSliderMove && this.options.onSliderMove(swiper, e); return this.options.onSliderMove && this.options.onSliderMove(swiper, e);
}; };
@ -432,32 +432,32 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
onTap(swiper, e) { onTap(swiper: any, e: any) {
} }
/** /**
* @private * @private
*/ */
onClick(swiper, e) { onClick(swiper: any, e: any) {
} }
/** /**
* @private * @private
*/ */
onDoubleTap(swiper, e) { onDoubleTap(swiper: any, e: any) {
this.toggleZoom(swiper, e); this.toggleZoom(swiper, e);
} }
/** /**
* @private * @private
*/ */
onLazyImageLoad(swiper, slide, img) { onLazyImageLoad(swiper: any, slide: any, img: any) {
} }
/** /**
* @private * @private
*/ */
onLazyImageReady(swiper, slide, img) { onLazyImageReady(swiper: any, slide: any, img: any) {
} }
/* /*
nextButton(swiper, e) { nextButton(swiper: any, e: any) {
} }
prevButton() { prevButton() {
} }
@ -485,7 +485,7 @@ export class Slides extends Ion {
this.zoomLastPosY = 0; this.zoomLastPosY = 0;
let last_scale, startX, startY, posX = 0, posY = 0, zoomRect; let lastScale: number, startX: number, startY: number, posX = 0, posY = 0, zoomRect: any;
this.viewportWidth = this.getNativeElement().offsetWidth; this.viewportWidth = this.getNativeElement().offsetWidth;
this.viewportHeight = this.getNativeElement().offsetHeight; this.viewportHeight = this.getNativeElement().offsetHeight;
@ -502,13 +502,13 @@ export class Slides extends Ion {
this.onTouchEnd(e); this.onTouchEnd(e);
}); });
this.zoomGesture.on('pinchstart', (e) => { this.zoomGesture.on('pinchstart', (e: any) => {
last_scale = this.scale; lastScale = this.scale;
console.debug('Last scale', e.scale); console.debug('Last scale', e.scale);
}); });
this.zoomGesture.on('pinch', (e) => { this.zoomGesture.on('pinch', (e: any) => {
this.scale = Math.max(1, Math.min(last_scale * e.scale, 10)); this.scale = Math.max(1, Math.min(lastScale * e.scale, 10));
console.debug('Scaling', this.scale); console.debug('Scaling', this.scale);
this.zoomElement.style[CSS.transform] = 'scale(' + this.scale + ')'; this.zoomElement.style[CSS.transform] = 'scale(' + this.scale + ')';
@ -534,9 +534,7 @@ export class Slides extends Ion {
* @private * @private
*/ */
resetZoom() { resetZoom() {
if (this.zoomElement) { if (this.zoomElement) {
this.zoomElement.parentElement.style[CSS.transform] = ''; this.zoomElement.parentElement.style[CSS.transform] = '';
this.zoomElement.style[CSS.transform] = 'scale(1)'; this.zoomElement.style[CSS.transform] = 'scale(1)';
} }
@ -549,7 +547,7 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
toggleZoom(swiper, e) { toggleZoom(swiper: any, e: any) {
console.debug('Try toggle zoom'); console.debug('Try toggle zoom');
if (!this.enableZoom) { return; } if (!this.enableZoom) { return; }
@ -625,18 +623,18 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
onTransitionStart(swiper, e) { onTransitionStart(swiper: any, e: any) {
} }
/** /**
* @private * @private
*/ */
onTransitionEnd(swiper, e) { onTransitionEnd(swiper: any, e: any) {
} }
/** /**
* @private * @private
*/ */
onTouchStart(e) { onTouchStart(e: any) {
console.debug('Touch start', e); console.debug('Touch start', e);
// TODO: Support mice as well // TODO: Support mice as well
@ -665,7 +663,7 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
onTouchMove(e) { onTouchMove(e: any) {
this.touch.deltaX = e.touches[0].clientX - this.touch.startX; this.touch.deltaX = e.touches[0].clientX - this.touch.startX;
this.touch.deltaY = e.touches[0].clientY - this.touch.startY; this.touch.deltaY = e.touches[0].clientY - this.touch.startY;
@ -716,14 +714,14 @@ export class Slides extends Ion {
/** /**
* @private * @private
*/ */
onTouchEnd(e) { onTouchEnd(e: UIEvent) {
console.debug('PANEND', e); console.debug('PANEND', e);
if (this.scale > 1) { if (this.scale > 1) {
if (Math.abs(this.touch.x) > this.viewportWidth) { if (Math.abs(this.touch.x) > this.viewportWidth) {
// TODO what is posX? // TODO what is posX?
var posX = posX > 0 ? this.viewportWidth - 1 : -(this.viewportWidth - 1); var posX: number = posX > 0 ? this.viewportWidth - 1 : -(this.viewportWidth - 1);
console.debug('Setting on posx', this.touch.x); console.debug('Setting on posx', this.touch.x);
} }
@ -879,7 +877,7 @@ export class Slide {
/** /**
* @private * @private
*/ */
@Input() zoom; @Input() zoom: any;
constructor( constructor(
elementRef: ElementRef, elementRef: ElementRef,

View File

@ -206,7 +206,7 @@ const SPINNERS = {
ios: { ios: {
dur: 1000, dur: 1000,
lines: 12, lines: 12,
fn: function(dur, index, total) { fn: function(dur: number, index: number, total: number) {
return { return {
y1: 17, y1: 17,
y2: 29, y2: 29,
@ -221,7 +221,7 @@ const SPINNERS = {
'ios-small': { 'ios-small': {
dur: 1000, dur: 1000,
lines: 12, lines: 12,
fn: function(dur, index, total) { fn: function(dur: number, index: number, total: number) {
return { return {
y1: 12, y1: 12,
y2: 20, y2: 20,
@ -236,7 +236,7 @@ const SPINNERS = {
bubbles: { bubbles: {
dur: 1000, dur: 1000,
circles: 9, circles: 9,
fn: function(dur, index, total) { fn: function(dur: number, index: number, total: number) {
return { return {
r: 5, r: 5,
style: { style: {
@ -251,7 +251,7 @@ const SPINNERS = {
circles: { circles: {
dur: 1000, dur: 1000,
circles: 8, circles: 8,
fn: function(dur, index, total) { fn: function(dur: number, index: number, total: number) {
return { return {
r: 5, r: 5,
style: { style: {
@ -266,7 +266,7 @@ const SPINNERS = {
crescent: { crescent: {
dur: 750, dur: 750,
circles: 1, circles: 1,
fn: function(dur) { fn: function(dur: number) {
return { return {
r: 26, r: 26,
style: {} style: {}
@ -277,7 +277,7 @@ const SPINNERS = {
dots: { dots: {
dur: 750, dur: 750,
circles: 3, circles: 3,
fn: function(dur, index, total) { fn: function(dur: number, index: number, total: number) {
return { return {
r: 6, r: 6,
style: { style: {

View File

@ -1,6 +1,7 @@
import {Directive, ElementRef} from '@angular/core'; import {Directive, ElementRef} from '@angular/core';
import {rafFrames} from '../../util/dom'; import {rafFrames} from '../../util/dom';
import {Tab} from './tab';
/** /**
* @private * @private
@ -13,7 +14,7 @@ export class TabHighlight {
constructor(private _elementRef: ElementRef) {} constructor(private _elementRef: ElementRef) {}
select(tab) { select(tab: Tab) {
rafFrames(3, () => { rafFrames(3, () => {
let d = tab.btn.getDimensions(); let d = tab.btn.getDimensions();
let ele = this._elementRef.nativeElement; let ele = this._elementRef.nativeElement;

View File

@ -267,7 +267,7 @@ export class Tab extends NavController {
this.load({ this.load({
animate: false, animate: false,
preload: true, preload: true,
postLoad: (viewCtrl) => { postLoad: (viewCtrl: ViewController) => {
let navbar = viewCtrl.getNavbar(); let navbar = viewCtrl.getNavbar();
navbar && navbar.setHidden(true); navbar && navbar.setHidden(true);
} }

View File

@ -161,7 +161,7 @@ export class Tabs extends Ion {
private _ids: number = -1; private _ids: number = -1;
private _preloadTabs: boolean = null; private _preloadTabs: boolean = null;
private _tabs: Array<Tab> = []; private _tabs: Array<Tab> = [];
private _onReady = null; private _onReady: any = null;
private _sbPadding: boolean; private _sbPadding: boolean;
private _useHighlight: boolean; private _useHighlight: boolean;
@ -213,7 +213,7 @@ export class Tabs extends Ion {
/** /**
* @private * @private
*/ */
@ViewChildren(TabButton) private _btns; @ViewChildren(TabButton) private _btns: any;
/** /**
* @private * @private
@ -316,7 +316,7 @@ export class Tabs extends Ion {
/** /**
* @private * @private
*/ */
private _setConfig(attrKey, fallback) { private _setConfig(attrKey: string, fallback: any) {
var val = this[attrKey]; var val = this[attrKey];
if (isBlank(val)) { if (isBlank(val)) {
val = this._config.get(attrKey, fallback); val = this._config.get(attrKey, fallback);
@ -335,7 +335,7 @@ export class Tabs extends Ion {
/** /**
* @param {number} index Index of the tab you want to select * @param {number} index Index of the tab you want to select
*/ */
select(tabOrIndex) { select(tabOrIndex: any) {
let selectedTab = (typeof tabOrIndex === 'number' ? this.getByIndex(tabOrIndex) : tabOrIndex); let selectedTab = (typeof tabOrIndex === 'number' ? this.getByIndex(tabOrIndex) : tabOrIndex);
if (!selectedTab) { if (!selectedTab) {
return; return;
@ -354,7 +354,7 @@ export class Tabs extends Ion {
animate: false animate: false
}; };
let deselectedPage; let deselectedPage: ViewController;
if (deselectedTab) { if (deselectedTab) {
deselectedPage = deselectedTab.getActive(); deselectedPage = deselectedTab.getActive();
deselectedPage && deselectedPage.fireWillLeave(); deselectedPage && deselectedPage.fireWillLeave();

View File

@ -1,16 +1,18 @@
import {App} from '../app/app';
import {Config} from '../../config/config';
import {rafFrames, nativeTimeout} from '../../util/dom'; import {rafFrames, nativeTimeout} from '../../util/dom';
export class Activator { export class Activator {
protected _css: string; protected _css: string;
protected _queue: Array<HTMLElement> = []; protected _queue: HTMLElement[] = [];
protected _active: Array<HTMLElement> = []; protected _active: HTMLElement[] = [];
constructor(protected app, config) { constructor(protected app: App, config: Config) {
this._css = config.get('activatedClass') || 'activated'; this._css = config.get('activatedClass') || 'activated';
} }
downAction(ev, activatableEle, pointerX, pointerY) { downAction(ev: UIEvent, activatableEle: HTMLElement, pointerX: number, pointerY: number) {
// the user just pressed down // the user just pressed down
let self = this; let self = this;
if (self.disableActivated(ev)) { if (self.disableActivated(ev)) {
@ -21,7 +23,7 @@ export class Activator {
self._queue.push(activatableEle); self._queue.push(activatableEle);
rafFrames(2, function() { rafFrames(2, function() {
let activatableEle; let activatableEle: HTMLElement;
for (let i = 0; i < self._queue.length; i++) { for (let i = 0; i < self._queue.length; i++) {
activatableEle = self._queue[i]; activatableEle = self._queue[i];
if (activatableEle && activatableEle.parentNode) { if (activatableEle && activatableEle.parentNode) {
@ -69,7 +71,7 @@ export class Activator {
}); });
} }
disableActivated(ev) { disableActivated(ev: any) {
if (ev.defaultPrevented) return true; if (ev.defaultPrevented) return true;
let targetEle = ev.target; let targetEle = ev.target;

View File

@ -1,5 +1,7 @@
import {Activator} from './activator'; import {Activator} from './activator';
import {App} from '../app/app';
import {CSS, nativeRaf, rafFrames} from '../../util/dom'; import {CSS, nativeRaf, rafFrames} from '../../util/dom';
import {Config} from '../../config/config';
/** /**
@ -7,11 +9,11 @@ import {CSS, nativeRaf, rafFrames} from '../../util/dom';
*/ */
export class RippleActivator extends Activator { export class RippleActivator extends Activator {
constructor(app, config) { constructor(app: App, config: Config) {
super(app, config); super(app, config);
} }
downAction(ev, activatableEle, pointerX, pointerY) { downAction(ev: UIEvent, activatableEle: HTMLElement, pointerX: number, pointerY: number) {
let self = this; let self = this;
if (self.disableActivated(ev)) { if (self.disableActivated(ev)) {
return; return;
@ -21,9 +23,7 @@ export class RippleActivator extends Activator {
self._queue.push(activatableEle); self._queue.push(activatableEle);
nativeRaf(function() { nativeRaf(function() {
var i; for (var i = 0; i < self._queue.length; i++) {
for (i = 0; i < self._queue.length; i++) {
var queuedEle = self._queue[i]; var queuedEle = self._queue[i];
if (queuedEle && queuedEle.parentNode) { if (queuedEle && queuedEle.parentNode) {
self._active.push(queuedEle); self._active.push(queuedEle);

View File

@ -47,19 +47,19 @@ export class TapClick {
addListener('mouseup', self.mouseUp.bind(self), true); addListener('mouseup', self.mouseUp.bind(self), true);
}); });
self.pointerMove = function(ev) { self.pointerMove = function(ev: UIEvent) {
if ( hasPointerMoved(POINTER_MOVE_UNTIL_CANCEL, self.startCoord, pointerCoord(ev)) ) { if ( hasPointerMoved(POINTER_MOVE_UNTIL_CANCEL, self.startCoord, pointerCoord(ev)) ) {
self.pointerCancel(ev); self.pointerCancel(ev);
} }
}; };
} }
touchStart(ev) { touchStart(ev: UIEvent) {
this.lastTouch = Date.now(); this.lastTouch = Date.now();
this.pointerStart(ev); this.pointerStart(ev);
} }
touchEnd(ev) { touchEnd(ev: UIEvent) {
this.lastTouch = Date.now(); this.lastTouch = Date.now();
if (this.usePolyfill && this.startCoord && this.app.isEnabled()) { if (this.usePolyfill && this.startCoord && this.app.isEnabled()) {
@ -91,7 +91,7 @@ export class TapClick {
this.pointerEnd(ev); this.pointerEnd(ev);
} }
mouseDown(ev) { mouseDown(ev: any) {
if (this.isDisabledNativeClick()) { if (this.isDisabledNativeClick()) {
console.debug('mouseDown prevent ' + ev.target.tagName + ' ' + Date.now()); console.debug('mouseDown prevent ' + ev.target.tagName + ' ' + Date.now());
// does not prevent default on purpose // does not prevent default on purpose
@ -103,7 +103,7 @@ export class TapClick {
} }
} }
mouseUp(ev) { mouseUp(ev: any) {
if (this.isDisabledNativeClick()) { if (this.isDisabledNativeClick()) {
console.debug('mouseUp prevent ' + ev.target.tagName + ' ' + Date.now()); console.debug('mouseUp prevent ' + ev.target.tagName + ' ' + Date.now());
ev.preventDefault(); ev.preventDefault();
@ -115,7 +115,7 @@ export class TapClick {
} }
} }
pointerStart(ev) { pointerStart(ev: any) {
let activatableEle = getActivatableTarget(ev.target); let activatableEle = getActivatableTarget(ev.target);
if (activatableEle) { if (activatableEle) {
@ -134,7 +134,7 @@ export class TapClick {
} }
} }
pointerEnd(ev) { pointerEnd(ev: any) {
let activatableEle = getActivatableTarget(ev.target); let activatableEle = getActivatableTarget(ev.target);
if (activatableEle && this.startCoord) { if (activatableEle && this.startCoord) {
this.activator && this.activator.upAction(ev, activatableEle, this.startCoord.x, this.startCoord.y); this.activator && this.activator.upAction(ev, activatableEle, this.startCoord.x, this.startCoord.y);
@ -142,13 +142,13 @@ export class TapClick {
this.moveListeners(false); this.moveListeners(false);
} }
pointerCancel(ev) { pointerCancel(ev: UIEvent) {
console.debug('pointerCancel from ' + ev.type + ' ' + Date.now()); console.debug('pointerCancel from ' + ev.type + ' ' + Date.now());
this.activator && this.activator.clearState(); this.activator && this.activator.clearState();
this.moveListeners(false); this.moveListeners(false);
} }
moveListeners(shouldAdd) { moveListeners(shouldAdd: boolean) {
removeListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove); removeListener(this.usePolyfill ? 'touchmove' : 'mousemove', this.pointerMove);
if (shouldAdd) { if (shouldAdd) {
@ -157,7 +157,7 @@ export class TapClick {
} }
click(ev: any) { click(ev: any) {
let preventReason = null; let preventReason: string = null;
if (!this.app.isEnabled()) { if (!this.app.isEnabled()) {
preventReason = 'appDisabled'; preventReason = 'appDisabled';
@ -180,7 +180,7 @@ export class TapClick {
} }
function getActivatableTarget(ele) { function getActivatableTarget(ele: HTMLElement) {
let targetEle = ele; let targetEle = ele;
for (let x = 0; x < 4; x++) { for (let x = 0; x < 4; x++) {
if (!targetEle) break; if (!targetEle) break;
@ -193,7 +193,7 @@ function getActivatableTarget(ele) {
/** /**
* @private * @private
*/ */
export function isActivatable(ele) { export function isActivatable(ele: HTMLElement) {
if (ACTIVATABLE_ELEMENTS.test(ele.tagName)) { if (ACTIVATABLE_ELEMENTS.test(ele.tagName)) {
return true; return true;
} }
@ -208,11 +208,11 @@ export function isActivatable(ele) {
return false; return false;
} }
function addListener(type, listener, useCapture?) { function addListener(type: string, listener: any, useCapture?: boolean) {
document.addEventListener(type, listener, useCapture); document.addEventListener(type, listener, useCapture);
} }
function removeListener(type, listener) { function removeListener(type: string, listener: any) {
document.removeEventListener(type, listener); document.removeEventListener(type, listener);
} }

View File

@ -192,7 +192,7 @@ class ToastCmp {
} }
} }
dismiss(role): Promise<any> { dismiss(role: any): Promise<any> {
clearTimeout(this.dismissTimeout); clearTimeout(this.dismissTimeout);
this.dismissTimeout = undefined; this.dismissTimeout = undefined;
return this._viewCtrl.dismiss(null, role); return this._viewCtrl.dismiss(null, role);
@ -215,7 +215,7 @@ export interface ToastOptions {
} }
class ToastSlideIn extends Transition { class ToastSlideIn extends Transition {
constructor(enteringView, leavingView, opts: TransitionOptions) { constructor(enteringView: ViewController, leavingView: ViewController, opts: TransitionOptions) {
super(opts); super(opts);
let ele = enteringView.pageRef().nativeElement; let ele = enteringView.pageRef().nativeElement;

View File

@ -116,7 +116,7 @@ export class Toggle implements ControlValueAccessor {
/** /**
* @private * @private
*/ */
private pointerDown(ev) { private pointerDown(ev: UIEvent) {
if (this._isPrevented(ev)) { if (this._isPrevented(ev)) {
return; return;
} }
@ -128,7 +128,7 @@ export class Toggle implements ControlValueAccessor {
/** /**
* @private * @private
*/ */
private pointerMove(ev) { private pointerMove(ev: UIEvent) {
if (this._startX) { if (this._startX) {
if (this._isPrevented(ev)) { if (this._isPrevented(ev)) {
return; return;
@ -155,7 +155,7 @@ export class Toggle implements ControlValueAccessor {
/** /**
* @private * @private
*/ */
private pointerUp(ev) { private pointerUp(ev: UIEvent) {
if (this._startX) { if (this._startX) {
if (this._isPrevented(ev)) { if (this._isPrevented(ev)) {
@ -224,7 +224,7 @@ export class Toggle implements ControlValueAccessor {
/** /**
* @private * @private
*/ */
registerOnTouched(fn) { this.onTouched = fn; } registerOnTouched(fn: any) { this.onTouched = fn; }
@Input() @Input()
get disabled(): boolean { get disabled(): boolean {
@ -268,7 +268,7 @@ export class Toggle implements ControlValueAccessor {
/** /**
* @private * @private
*/ */
private _isPrevented(ev) { private _isPrevented(ev: UIEvent) {
if (ev.type.indexOf('touch') > -1) { if (ev.type.indexOf('touch') > -1) {
this._msPrv = Date.now() + 2000; this._msPrv = Date.now() + 2000;

View File

@ -12,8 +12,8 @@ import {ViewController} from '../nav/view-controller';
* @private * @private
*/ */
export class ToolbarBase extends Ion { export class ToolbarBase extends Ion {
itemRefs = []; itemRefs: ElementRef[] = [];
titleRef = null; titleRef: any = null;
titleCmp: any; titleCmp: any;
constructor(elementRef: ElementRef) { constructor(elementRef: ElementRef) {
@ -23,7 +23,7 @@ export class ToolbarBase extends Ion {
/** /**
* @private * @private
*/ */
setTitleCmp(titleCmp) { setTitleCmp(titleCmp: any) {
this.titleCmp = titleCmp; this.titleCmp = titleCmp;
} }
@ -55,7 +55,7 @@ export class ToolbarBase extends Ion {
/** /**
* @private * @private
*/ */
addItemRef(itemElementRef) { addItemRef(itemElementRef: ElementRef) {
this.itemRefs.push(itemElementRef); this.itemRefs.push(itemElementRef);
} }
@ -215,7 +215,7 @@ export class ToolbarItem {
} }
@ContentChildren(Button) @ContentChildren(Button)
set _buttons(buttons) { set _buttons(buttons: any) {
if (this.inToolbar) { if (this.inToolbar) {
Button.setRoles(buttons, 'bar-button'); Button.setRoles(buttons, 'bar-button');
} }

View File

@ -23,7 +23,7 @@ Platform.register({
Platform.register({ Platform.register({
name: 'phablet', name: 'phablet',
isMatch(p) { isMatch(p: Platform) {
let smallest = Math.min(p.width(), p.height()); let smallest = Math.min(p.width(), p.height());
let largest = Math.max(p.width(), p.height()); let largest = Math.max(p.width(), p.height());
return (smallest > 390 && smallest < 520) && return (smallest > 390 && smallest < 520) &&
@ -34,7 +34,7 @@ Platform.register({
Platform.register({ Platform.register({
name: 'tablet', name: 'tablet',
isMatch(p) { isMatch(p: Platform) {
let smallest = Math.min(p.width(), p.height()); let smallest = Math.min(p.width(), p.height());
let largest = Math.max(p.width(), p.height()); let largest = Math.max(p.width(), p.height());
return (smallest > 460 && smallest < 820) && return (smallest > 460 && smallest < 820) &&

View File

@ -23,7 +23,7 @@ export class Transition extends Animation {
return new TransitionClass(enteringView, leavingView, opts); return new TransitionClass(enteringView, leavingView, opts);
} }
static register(name: string, TransitionClass) { static register(name: string, TransitionClass: any) {
TransitionRegistry[name] = TransitionClass; TransitionRegistry[name] = TransitionClass;
} }

View File

@ -31,19 +31,19 @@ export class Translate {
private _transMap: any = {}; private _transMap: any = {};
private _language: any = {}; private _language: any = {};
translations(lang, map) { translations(lang: any, map: any) {
this._transMap[lang] = map; this._transMap[lang] = map;
} }
setLanguage(lang) { setLanguage(lang: any) {
this._language = lang; this._language = lang;
} }
getTranslations(lang) { getTranslations(lang: any) {
return this._transMap[lang]; return this._transMap[lang];
} }
translate(key, lang) { translate(key: any, lang: any) {
// If the language isn't specified and we have no overridden one, return the string passed. // If the language isn't specified and we have no overridden one, return the string passed.
if (!lang && !this._language) { if (!lang && !this._language) {
return key; return key;
@ -60,7 +60,7 @@ export class Translate {
return this._getTranslation(map, key); return this._getTranslation(map, key);
} }
_getTranslation(map, key) { _getTranslation(map: any, key: any) {
return map && map[key] || ''; return map && map[key] || '';
} }
} }

View File

@ -21,13 +21,13 @@ export class TranslatePipe implements PipeTransform {
constructor(translate: Translate) { constructor(translate: Translate) {
this.translate = translate; this.translate = translate;
} }
transform(value, args) { transform(value: any, args: any) {
let lang; let lang: any;
if (args.length > 0) { if (args.length > 0) {
lang = args[0]; lang = args[0];
} }
return this.translate.translate(value, lang); return this.translate.translate(value, lang);
} }
supports(obj) { return true; } supports(obj: any) { return true; }
} }

View File

@ -6,7 +6,7 @@
var rafLastTime = 0; var rafLastTime = 0;
const win: any = window; const win: any = window;
if (!win.requestAnimationFrame) { if (!win.requestAnimationFrame) {
win.requestAnimationFrame = function(callback, element) { win.requestAnimationFrame = function(callback: Function) {
var currTime = Date.now(); var currTime = Date.now();
var timeToCall = Math.max(0, 16 - (currTime - rafLastTime)); var timeToCall = Math.max(0, 16 - (currTime - rafLastTime));
@ -20,7 +20,7 @@
} }
if (!win.cancelAnimationFrame) { if (!win.cancelAnimationFrame) {
win.cancelAnimationFrame = function(id) { clearTimeout(id); }; win.cancelAnimationFrame = function(id: number) { clearTimeout(id); };
} }
})(); })();
@ -36,7 +36,7 @@ export const cancelRaf = window.cancelAnimationFrame.bind(window);
export const nativeTimeout = window[window['Zone']['__symbol__']('setTimeout')]['bind'](window); export const nativeTimeout = window[window['Zone']['__symbol__']('setTimeout')]['bind'](window);
export const clearNativeTimeout = window[window['Zone']['__symbol__']('clearTimeout')]['bind'](window); export const clearNativeTimeout = window[window['Zone']['__symbol__']('clearTimeout')]['bind'](window);
export function rafFrames(framesToWait, callback) { export function rafFrames(framesToWait: number, callback: Function) {
framesToWait = Math.ceil(framesToWait); framesToWait = Math.ceil(framesToWait);
if (framesToWait < 2) { if (framesToWait < 2) {
@ -62,7 +62,8 @@ export let CSS: {
(function() { (function() {
// transform // transform
var i, keys = ['webkitTransform', 'transform', '-webkit-transform', 'webkit-transform', var i: number;
var keys = ['webkitTransform', 'transform', '-webkit-transform', 'webkit-transform',
'-moz-transform', 'moz-transform', 'MozTransform', 'mozTransform', 'msTransform']; '-moz-transform', 'moz-transform', 'MozTransform', 'mozTransform', 'msTransform'];
for (i = 0; i < keys.length; i++) { for (i = 0; i < keys.length; i++) {
@ -116,7 +117,7 @@ export function transitionEnd(el: HTMLElement, callback: Function) {
}); });
} }
function onEvent(ev) { function onEvent(ev: UIEvent) {
if (el === ev.target) { if (el === ev.target) {
unregister(); unregister();
callback(ev); callback(ev);
@ -125,7 +126,7 @@ export function transitionEnd(el: HTMLElement, callback: Function) {
} }
export function ready(callback?: Function) { export function ready(callback?: Function) {
let promise = null; let promise: Promise<any> = null;
if (!callback) { if (!callback) {
// a callback wasn't provided, so let's return a promise instead // a callback wasn't provided, so let's return a promise instead
@ -150,7 +151,7 @@ export function ready(callback?: Function) {
} }
export function windowLoad(callback?: Function) { export function windowLoad(callback?: Function) {
let promise = null; let promise: Promise<any> = null;
if (!callback) { if (!callback) {
// a callback wasn't provided, so let's return a promise instead // a callback wasn't provided, so let's return a promise instead
@ -173,7 +174,7 @@ export function windowLoad(callback?: Function) {
} }
} }
export function pointerCoord(ev: any): {x: number, y: number} { export function pointerCoord(ev: any): Coordinates {
// get coordinates for either a mouse click // get coordinates for either a mouse click
// or a touch depending on the given event // or a touch depending on the given event
let c = { x: 0, y: 0 }; let c = { x: 0, y: 0 };
@ -188,20 +189,20 @@ export function pointerCoord(ev: any): {x: number, y: number} {
return c; return c;
} }
export function hasPointerMoved(threshold, startCoord, endCoord) { export function hasPointerMoved(threshold: number, startCoord: Coordinates, endCoord: Coordinates) {
return startCoord && endCoord && return startCoord && endCoord &&
(Math.abs(startCoord.x - endCoord.x) > threshold || Math.abs(startCoord.y - endCoord.y) > threshold); (Math.abs(startCoord.x - endCoord.x) > threshold || Math.abs(startCoord.y - endCoord.y) > threshold);
} }
export function isActive(ele) { export function isActive(ele: HTMLElement) {
return !!(ele && (document.activeElement === ele)); return !!(ele && (document.activeElement === ele));
} }
export function hasFocus(ele) { export function hasFocus(ele: HTMLElement) {
return isActive(ele) && (ele.parentElement.querySelector(':focus') === ele); return isActive(ele) && (ele.parentElement.querySelector(':focus') === ele);
} }
export function isTextInput(ele) { export function isTextInput(ele: any) {
return !!ele && return !!ele &&
(ele.tagName === 'TEXTAREA' || (ele.tagName === 'TEXTAREA' ||
ele.contentEditable === 'true' || ele.contentEditable === 'true' ||
@ -209,7 +210,7 @@ export function isTextInput(ele) {
} }
export function hasFocusedTextInput() { export function hasFocusedTextInput() {
let ele = document.activeElement; let ele = <HTMLElement>document.activeElement;
if (isTextInput(ele)) { if (isTextInput(ele)) {
return (ele.parentElement.querySelector(':focus') === ele); return (ele.parentElement.querySelector(':focus') === ele);
} }
@ -217,7 +218,7 @@ export function hasFocusedTextInput() {
} }
const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i; const skipInputAttrsReg = /^(value|checked|disabled|type|class|style|id|autofocus|autocomplete|autocorrect)$/i;
export function copyInputAttributes(srcElement, destElement) { export function copyInputAttributes(srcElement: HTMLElement, destElement: HTMLElement) {
// copy attributes from one element to another // copy attributes from one element to another
// however, skip over a few of them as they're already // however, skip over a few of them as they're already
// handled in the angular world // handled in the angular world
@ -231,7 +232,7 @@ export function copyInputAttributes(srcElement, destElement) {
} }
let matchesFn: string; let matchesFn: string;
let matchesMethods: Array<string> = ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector']; let matchesMethods = ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector'];
matchesMethods.some((fn: string) => { matchesMethods.some((fn: string) => {
if (typeof document.documentElement[fn] === 'function') { if (typeof document.documentElement[fn] === 'function') {
matchesFn = fn; matchesFn = fn;
@ -309,3 +310,9 @@ export function flushDimensionCache() {
} }
let dimensionCache: any = {}; let dimensionCache: any = {};
export interface Coordinates {
x?: number;
y?: number;
}

View File

@ -33,7 +33,7 @@ export class Events {
* @param {string} topic the topic to subscribe to * @param {string} topic the topic to subscribe to
* @param {function} handler the event handler * @param {function} handler the event handler
*/ */
subscribe(topic, ...handlers) { subscribe(topic: string, ...handlers: Function[]) {
if (!this._channels[topic]) { if (!this._channels[topic]) {
this._channels[topic] = []; this._channels[topic] = [];
} }
@ -50,7 +50,7 @@ export class Events {
* *
* @return true if a handler was removed * @return true if a handler was removed
*/ */
unsubscribe(topic, handler) { unsubscribe(topic: string, handler: Function) {
let t = this._channels[topic]; let t = this._channels[topic];
if (!t) { if (!t) {
// Wasn't found, wasn't removed // Wasn't found, wasn't removed
@ -87,14 +87,14 @@ export class Events {
* @param {string} topic the topic to publish to * @param {string} topic the topic to publish to
* @param {any} eventData the data to send as the event * @param {any} eventData the data to send as the event
*/ */
publish(topic, ...args) { publish(topic: string, ...args: any[]) {
var t = this._channels[topic]; var t = this._channels[topic];
if (!t) { if (!t) {
return null; return null;
} }
let responses = []; let responses: any[] = [];
t.forEach((handler) => { t.forEach((handler: any) => {
responses.push(handler(args)); responses.push(handler(args));
}); });
return responses; return responses;

View File

@ -2,17 +2,17 @@
export class FeatureDetect { export class FeatureDetect {
private _results: any = {}; private _results: any = {};
run(window, document) { run(window: Window, document: Document) {
for (let name in featureDetects) { for (let name in featureDetects) {
this._results[name] = featureDetects[name](window, document, document.body); this._results[name] = featureDetects[name](window, document, document.body);
} }
} }
has(featureName) { has(featureName: string) {
return !!this._results[featureName]; return !!this._results[featureName];
} }
static add(name, fn) { static add(name: string, fn: any) {
featureDetects[name] = fn; featureDetects[name] = fn;
} }
@ -21,15 +21,7 @@ export class FeatureDetect {
let featureDetects = {}; let featureDetects = {};
// FeatureDetect.add('sticky', function(window, document) { FeatureDetect.add('hairlines', function(window: Window, document: Document, body: HTMLBodyElement) {
// // css position sticky
// let ele = document.createElement('div');
// ele.style.cssText = 'position:-webkit-sticky;position:sticky';
// return ele.style.position.indexOf('sticky') > -1;
// });
FeatureDetect.add('hairlines', function(window, document, body) {
/** /**
* Hairline Shim * Hairline Shim
* Add the "hairline" CSS class name to the body tag * Add the "hairline" CSS class name to the body tag

View File

@ -7,19 +7,19 @@ import {Injectable} from '@angular/core';
@Injectable() @Injectable()
export class Form { export class Form {
private _blur: HTMLElement; private _blur: HTMLElement;
private _focused = null; private _focused: any = null;
private _ids: number = -1; private _ids: number = -1;
private _inputs: Array<any> = []; private _inputs: any[] = [];
constructor() { constructor() {
this.focusCtrl(document); this.focusCtrl(document);
} }
register(input) { register(input: any) {
this._inputs.push(input); this._inputs.push(input);
} }
deregister(input) { deregister(input: any) {
let index = this._inputs.indexOf(input); let index = this._inputs.indexOf(input);
if (index > -1) { if (index > -1) {
this._inputs.splice(index, 1); this._inputs.splice(index, 1);
@ -29,7 +29,7 @@ export class Form {
} }
} }
focusCtrl(document) { focusCtrl(document: any) {
// raw DOM fun // raw DOM fun
let focusCtrl = document.createElement('focus-ctrl'); let focusCtrl = document.createElement('focus-ctrl');
focusCtrl.setAttribute('aria-hidden', true); focusCtrl.setAttribute('aria-hidden', true);
@ -50,14 +50,14 @@ export class Form {
this._blur.focus(); this._blur.focus();
} }
setAsFocused(input) { setAsFocused(input: any) {
this._focused = input; this._focused = input;
} }
/** /**
* Focuses the next input element, if it exists. * Focuses the next input element, if it exists.
*/ */
tabFocus(currentInput) { tabFocus(currentInput: any) {
let index = this._inputs.indexOf(currentInput); let index = this._inputs.indexOf(currentInput);
if (index > -1 && (index + 1) < this._inputs.length) { if (index > -1 && (index + 1) < this._inputs.length) {
let nextInput = this._inputs[index + 1]; let nextInput = this._inputs[index + 1];

View File

@ -70,12 +70,12 @@ export class Keyboard {
* @param {function} callback method you want to call when the keyboard has been closed * @param {function} callback method you want to call when the keyboard has been closed
* @return {function} returns a callback that gets fired when the keyboard is closed * @return {function} returns a callback that gets fired when the keyboard is closed
*/ */
onClose(callback, pollingInternval = KEYBOARD_CLOSE_POLLING, pollingChecksMax = KEYBOARD_POLLING_CHECKS_MAX) { onClose(callback: Function, pollingInternval = KEYBOARD_CLOSE_POLLING, pollingChecksMax = KEYBOARD_POLLING_CHECKS_MAX) {
console.debug('keyboard onClose'); console.debug('keyboard onClose');
const self = this; const self = this;
let checks = 0; let checks = 0;
let promise = null; let promise: Promise<any> = null;
if (!callback) { if (!callback) {
// a callback wasn't provided, so let's return a promise instead // a callback wasn't provided, so let's return a promise instead
@ -120,7 +120,7 @@ export class Keyboard {
/** /**
* @private * @private
*/ */
focusOutline(setting, document) { focusOutline(setting: any, document: any) {
/* Focus Outline /* Focus Outline
* -------------------------------------------------- * --------------------------------------------------
* By default, when a keydown event happens from a tab key, then * By default, when a keydown event happens from a tab key, then
@ -151,7 +151,7 @@ export class Keyboard {
} }
// default is to add the focus-outline when the tab key is used // default is to add the focus-outline when the tab key is used
function keyDown(ev) { function keyDown(ev: KeyboardEvent) {
if (!isKeyInputEnabled && ev.keyCode === 9) { if (!isKeyInputEnabled && ev.keyCode === 9) {
isKeyInputEnabled = true; isKeyInputEnabled = true;
enableKeyInput(); enableKeyInput();

View File

@ -151,7 +151,7 @@ export class ScrollView {
* @private * @private
* Used for JS scrolling. May be removed in the future. * Used for JS scrolling. May be removed in the future.
*/ */
private _start(ev) { private _start(ev: UIEvent) {
this._velocity = 0; this._velocity = 0;
this._pos.length = 0; this._pos.length = 0;
this._max = null; this._max = null;
@ -162,7 +162,7 @@ export class ScrollView {
* @private * @private
* Used for JS scrolling. May be removed in the future. * Used for JS scrolling. May be removed in the future.
*/ */
private _move(ev) { private _move(ev: UIEvent) {
if (this._pos.length) { if (this._pos.length) {
let y = pointerCoord(ev).y; let y = pointerCoord(ev).y;
@ -198,7 +198,7 @@ export class ScrollView {
* @private * @private
* Used for JS scrolling. May be removed in the future. * Used for JS scrolling. May be removed in the future.
*/ */
private _end(ev) { private _end(ev: UIEvent) {
// figure out what the scroll position was about 100ms ago // figure out what the scroll position was about 100ms ago
let positions = this._pos; let positions = this._pos;
this._velocity = 0; this._velocity = 0;

View File

@ -6,7 +6,7 @@
* @param n the value * @param n the value
* @param max the maximum * @param max the maximum
*/ */
export function clamp(min, n, max) { export function clamp(min: number, n: number, max: number) {
return Math.max(min, Math.min(n, max)); return Math.max(min, Math.min(n, max));
} }
@ -37,7 +37,7 @@ export function merge(dst: any, ...args: any[]) {
return _baseExtend(dst, [].slice.call(arguments, 1), true); return _baseExtend(dst, [].slice.call(arguments, 1), true);
} }
function _baseExtend(dst, objs, deep) { function _baseExtend(dst: any, objs: any, deep: boolean) {
for (var i = 0, ii = objs.length; i < ii; ++i) { for (var i = 0, ii = objs.length; i < ii; ++i) {
var obj = objs[i]; var obj = objs[i];
if (!obj || !isObject(obj) && !isFunction(obj)) continue; if (!obj || !isObject(obj) && !isFunction(obj)) continue;
@ -59,7 +59,7 @@ function _baseExtend(dst, objs, deep) {
} }
export function debounce(fn: Function, wait: number, immediate: boolean = false): any { export function debounce(fn: Function, wait: number, immediate: boolean = false): any {
var timeout, args, context, timestamp: number, result; var timeout: number, args: any, context: any, timestamp: number, result: any;
return function() { return function() {
context = this; context = this;
args = arguments; args = arguments;
@ -88,7 +88,7 @@ export function debounce(fn: Function, wait: number, immediate: boolean = false)
* the first object. * the first object.
* @param the destination to apply defaults to. * @param the destination to apply defaults to.
*/ */
export function defaults(dest, ...args: any[]) { export function defaults(dest: any, ...args: any[]) {
for (let i = arguments.length - 1; i >= 1; i--) { for (let i = arguments.length - 1; i >= 1; i--) {
let source = arguments[i] || {}; let source = arguments[i] || {};
for (let key in source) { for (let key in source) {
@ -100,15 +100,15 @@ export function defaults(dest, ...args: any[]) {
return dest; return dest;
} }
export const isBoolean = val => typeof val === 'boolean'; export const isBoolean = (val: any) => typeof val === 'boolean';
export const isString = val => typeof val === 'string'; export const isString = (val: any) => typeof val === 'string';
export const isNumber = val => typeof val === 'number'; export const isNumber = (val: any) => typeof val === 'number';
export const isFunction = val => typeof val === 'function'; export const isFunction = (val: any) => typeof val === 'function';
export const isDefined = val => typeof val !== 'undefined'; export const isDefined = (val: any) => typeof val !== 'undefined';
export const isUndefined = val => typeof val === 'undefined'; export const isUndefined = (val: any) => typeof val === 'undefined';
export const isPresent = val => val !== undefined && val !== null; export const isPresent = (val: any) => val !== undefined && val !== null;
export const isBlank = val => val === undefined || val === null; export const isBlank = (val: any) => val === undefined || val === null;
export const isObject = val => typeof val === 'object'; export const isObject = (val: any) => typeof val === 'object';
export const isArray = Array.isArray; export const isArray = Array.isArray;
export const isTrueProperty = function(val: any): boolean { export const isTrueProperty = function(val: any): boolean {
@ -153,33 +153,12 @@ export function nextUid(): number {
return ++uid; return ++uid;
} }
export const array = {
find(arr, cb) {
for (let i = 0, ii = arr.length; i < ii; i++) {
if (cb(arr[i], i)) return arr[i];
}
},
remove(arr, itemOrIndex) {
let index = -1;
if (isNumber(itemOrIndex)) {
index = itemOrIndex;
} else {
index = arr.indexOf(itemOrIndex);
}
if (index < 0) {
return false;
}
arr.splice(index, 1);
return true;
}
};
/** /**
* Grab all query strings keys and values. * Grab all query strings keys and values.
* @param url * @param url
*/ */
export function getQuerystring(url: string): any { export function getQuerystring(url: string): any {
var queryParams = {}; var queryParams: any = {};
if (url) { if (url) {
const startIndex = url.indexOf('?'); const startIndex = url.indexOf('?');
if (startIndex !== -1) { if (startIndex !== -1) {
@ -196,35 +175,3 @@ export function getQuerystring(url: string): any {
} }
return queryParams; return queryParams;
} }
/**
* Throttle the given fun, only allowing it to be
* called at most every `wait` ms.
*/
export function throttle(fn: Function, wait: number, options: any): any {
var context, args, result;
var timeout = null;
var previous = 0;
options || (options = {});
var later = function() {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
result = fn.apply(context, args);
};
return function() {
var now = Date.now();
if (!previous && options.leading === false) previous = now;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0) {
clearTimeout(timeout);
timeout = null;
previous = now;
result = fn.apply(context, args);
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
}