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 {isTrueProperty} from '../../util/util';
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 {NativeInput, NextInput} from './native-input';
import {Platform} from '../../platform/platform';
export class InputBase {
protected _coord;
protected _deregScroll;
protected _coord: Coordinates;
protected _deregScroll: Function;
protected _disabled: boolean = false;
protected _keyboardHeight;
protected _keyboardHeight: number;
protected _scrollMove: EventListener;
protected _type: string = 'text';
protected _useAssist: boolean;
@ -31,7 +31,7 @@ export class InputBase {
inputControl: NgControl;
@Input() clearInput;
@Input() clearInput: any;
@Input() placeholder: string = '';
@ViewChild(NativeInput) protected _native: NativeInput;
@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-touched', control.touched);
element.setCssClass('ng-pristine', control.pristine);
@ -183,12 +183,12 @@ export class InputBase {
nativeInput.labelledBy(this._item.labelId);
}
nativeInput.valueChange.subscribe(inputValue => {
nativeInput.valueChange.subscribe((inputValue: any) => {
this.onChange(inputValue);
});
this.focusChange(this.hasFocus());
nativeInput.focusChange.subscribe(textInputHasFocus => {
nativeInput.focusChange.subscribe((textInputHasFocus: any) => {
this.focusChange(textInputHasFocus);
this.checkHasValue(nativeInput.getValue());
if (!textInputHasFocus) {
@ -257,7 +257,7 @@ export class InputBase {
* the checked value.
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34
*/
writeValue(val) {
writeValue(val: any) {
this._value = val;
this.checkHasValue(val);
}
@ -265,14 +265,14 @@ export class InputBase {
/**
* @private
*/
onChange(val) {
onChange(val: any) {
this.checkHasValue(val);
}
/**
* @private
*/
onTouched(val) {}
onTouched(val: any) {}
/**
* @private
@ -285,7 +285,7 @@ export class InputBase {
/**
* @private
*/
checkHasValue(inputValue) {
checkHasValue(inputValue: any) {
if (this._item) {
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
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
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
* @param {Function} fn the onChange event handler.
*/
registerOnChange(fn) { this.onChange = fn; }
registerOnChange(fn: any) { this.onChange = fn; }
/**
* @private
@ -443,7 +443,7 @@ export class InputBase {
* the onTouched event handler that marks model (Control) as touched.
* @param {Function} fn onTouched event handler.
*/
registerOnTouched(fn) { this.onTouched = fn; }
registerOnTouched(fn: any) { this.onTouched = fn; }
/**
* @private
@ -473,7 +473,7 @@ export class InputBase {
/**
* @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
let inputTop = (inputOffsetTop + scrollViewDimensions.contentTop - scrollViewDimensions.scrollTop);
let inputBottom = (inputTop + inputOffsetHeight);
@ -590,7 +590,7 @@ export class InputBase {
const SCROLL_ASSIST_SPEED = 0.3;
function getScrollAssistDuration(distanceToScroll) {
function getScrollAssistDuration(distanceToScroll: number) {
distanceToScroll = Math.abs(distanceToScroll);
let duration = distanceToScroll / SCROLL_ASSIST_SPEED;
return Math.min(400, Math.max(150, duration));

View File

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

View File

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

View File

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

View File

@ -212,7 +212,7 @@ class LoadingCmp {
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);
}

View File

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

View File

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

View File

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

View File

@ -1,5 +1,7 @@
import {MenuController} from './menu-controller';
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.
*/
class MenuRevealType extends MenuType {
constructor(menu) {
constructor(menu: Menu) {
super();
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.
*/
class MenuPushType extends MenuType {
constructor(menu) {
constructor(menu: Menu, platform: Platform) {
super();
this.ani
.easing('ease')
.duration(250);
let contentOpenedX, menuClosedX, menuOpenedX;
let contentOpenedX: string, menuClosedX: string, menuOpenedX: string;
if (menu.side === 'right') {
contentOpenedX = -menu.width() + 'px';
menuOpenedX = (menu._platform.width() - menu.width()) + 'px';
menuClosedX = menu._platform.width() + 'px';
menuOpenedX = (platform.width() - menu.width()) + 'px';
menuClosedX = platform.width() + 'px';
} else {
contentOpenedX = menu.width() + 'px';
@ -125,18 +127,18 @@ MenuController.registerType('push', MenuPushType);
* itself, which is under the menu, does not move.
*/
class MenuOverlayType extends MenuType {
constructor(menu) {
constructor(menu: Menu, platform: Platform) {
super();
this.ani
.easing('ease')
.duration(250);
let closedX, openedX;
let closedX: string, openedX: string;
if (menu.side === 'right') {
// right side
closedX = menu._platform.width() + 'px';
openedX = (menu._platform.width() - menu.width() - 8) + 'px';
closedX = platform.width() + 'px';
openedX = (platform.width() - menu.width() - 8) + 'px';
} else {
// left side

View File

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

View File

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

View File

@ -356,19 +356,6 @@ export class NavController extends Ion {
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
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
opts.direction = opts.direction || 'back';
let resolve;
let resolve: any;
let promise = new Promise(res => { resolve = res; });
// start the transition, fire resolve when done...
@ -611,7 +598,7 @@ export class NavController extends Ion {
opts.animation = enteringView.getTransitionName(opts.direction);
}
let resolve;
let resolve: any;
let promise = new Promise(res => { resolve = res; });
// 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);
}
let resolve;
let resolve: any;
let promise = new Promise(res => { resolve = res; });
if (!opts.animation) {
@ -1040,7 +1027,7 @@ export class NavController extends Ion {
/**
* @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
if (enteringView.state === STATE_INACTIVE) {
@ -1076,7 +1063,7 @@ export class NavController extends Ion {
/**
* @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
if (enteringView.state === STATE_INACTIVE) {
@ -1764,7 +1751,7 @@ export class NavController extends Ion {
/**
* @private
*/
private _setZIndex(enteringView: ViewController, leavingView: ViewController, direction) {
private _setZIndex(enteringView: ViewController, leavingView: ViewController, direction: string) {
if (enteringView) {
// get the leaving view, which could be in various states
if (!leavingView || !leavingView.isLoaded()) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -143,7 +143,7 @@ class PickerColumnCmp {
this.setSelected(this.col.selectedIndex, 0);
}
pointerStart(ev) {
pointerStart(ev: UIEvent) {
console.debug('picker, pointerStart', ev.type, this.startY);
if (this.isPrevented(ev)) {
@ -177,7 +177,7 @@ class PickerColumnCmp {
this.maxY = (maxY * this.optHeight * -1);
}
pointerMove(ev) {
pointerMove(ev: UIEvent) {
ev.preventDefault();
ev.stopPropagation();
@ -212,7 +212,7 @@ class PickerColumnCmp {
this.update(y, 0, false, false);
}
pointerEnd(ev) {
pointerEnd(ev: UIEvent) {
if (this.isPrevented(ev)) {
return;
}
@ -320,7 +320,7 @@ class PickerColumnCmp {
}
}
optClick(ev, index: number) {
optClick(ev: UIEvent, index: number) {
if (!this.velocity) {
ev.preventDefault();
ev.stopPropagation();
@ -410,7 +410,7 @@ class PickerColumnCmp {
}
}
isPrevented(ev): boolean {
isPrevented(ev: UIEvent): boolean {
let now = Date.now();
if (ev.type.indexOf('touch') > -1) {
// 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()) {
return;
}
@ -607,7 +607,7 @@ class PickerDisplayCmp {
}
}
dismiss(role): Promise<any> {
dismiss(role: any): Promise<any> {
return this._viewCtrl.dismiss(this.getSelected(), role);
}

View File

@ -105,7 +105,7 @@ const POPOVER_MD_BODY_PADDING = 12;
*/
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.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} opts Popover options
*/
static create(componentType, data = {}, opts: PopoverOptions = {}) {
static create(componentType: any, data = {}, opts: PopoverOptions = {}) {
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);
}
bdTouch(ev) {
bdTouch(ev: UIEvent) {
ev.preventDefault();
ev.stopPropagation();
}
@ -241,7 +241,7 @@ class PopoverTransition extends Transition {
super(opts);
}
mdPositionView(nativeEle: HTMLElement, ev) {
mdPositionView(nativeEle: HTMLElement, ev: any) {
let originY = 'top';
let originX = 'left';
@ -301,7 +301,7 @@ class PopoverTransition extends Transition {
popoverWrapperEle.style.opacity = '1';
}
iosPositionView(nativeEle: HTMLElement, ev) {
iosPositionView(nativeEle: HTMLElement, ev: any) {
let originY = 'top';
let originX = 'left';

View File

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

View File

@ -140,7 +140,7 @@ export class RadioGroup {
/**
* @private
*/
registerOnTouched(fn) { this.onTouched = fn; }
registerOnTouched(fn: any) { this.onTouched = fn; }
/**
* @private
@ -174,7 +174,7 @@ export class RadioGroup {
this._btns.push(button);
// listen for radiobutton select events
button.ionSelect.subscribe((val) => {
button.ionSelect.subscribe((val: any) => {
// this radiobutton has been selected
this.onChange(val);
});
@ -199,7 +199,7 @@ export class RadioGroup {
* @private
*/
@ContentChild(ListHeader)
private set _header(header) {
private set _header(header: any) {
if (header) {
if (!header.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 {isTrueProperty, isNumber, isString, isPresent, clamp} from '../../util/util';
import {Item} from '../item/item';
import {pointerCoord} from '../../util/dom';
import {pointerCoord, Coordinates} from '../../util/dom';
const RANGE_VALUE_ACCESSOR = new Provider(
@ -633,7 +633,7 @@ export class Range {
/**
* @private
*/
registerOnTouched(fn) { this.onTouched = fn; }
registerOnTouched(fn: any) { this.onTouched = fn; }
/**
* @input {boolean} Whether or not the range is disabled. Defaults to `false`.
@ -702,8 +702,3 @@ export interface ClientRect {
xOffset?: number;
yOffset?: number;
}
export interface Coordinates {
x?: number;
y?: number;
}

View File

@ -375,7 +375,7 @@ export class Refresher {
return 4;
}
private _onEnd(ev) {
private _onEnd(ev: UIEvent) {
// only run in a zone when absolutely necessary
if (this.state === STATE_READY) {
@ -438,9 +438,9 @@ export class Refresher {
}
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
if (ev) {
clearTimeout(timer);

View File

@ -78,7 +78,7 @@ export class Scroll extends Ion {
* @returns {?Function} a function to remove the specified handler, otherwise
* undefined if the scroll element doesn't exist.
*/
addScrollEventListener(handler) {
addScrollEventListener(handler: any) {
if (!this.scrollElement) { return; }
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 {NgControl} from '@angular/common';
import {Ion} from '../ion';
import {Button} from '../button/button';
import {Config} from '../../config/config';
import {Icon} from '../icon/icon';
import {Button} from '../button/button';
import {isPresent, debounce} from '../../util/util';
import {Ion} from '../ion';
import {isPresent} from '../../util/util';
/**
@ -15,7 +15,7 @@ import {isPresent, debounce} from '../../util/util';
selector: '.searchbar-input',
})
export class SearchbarInput {
constructor(private _elementRef: ElementRef) {}
constructor(public elementRef: ElementRef) {}
}
@ -63,7 +63,7 @@ export class Searchbar extends Ion {
/**
* @private
*/
@ViewChild(SearchbarInput) searchbarInput;
@ViewChild(SearchbarInput) searchbarInput: SearchbarInput;
/**
* @input {string} Sets the cancel button text to the value passed in
@ -144,12 +144,12 @@ export class Searchbar extends Ion {
/**
* @private
*/
@HostBinding('class.searchbar-focused') isFocused;
@HostBinding('class.searchbar-focused') isFocused: boolean;
/**
* @private
*/
@HostBinding('class.searchbar-left-aligned') shouldLeftAlign;
@HostBinding('class.searchbar-left-aligned') shouldLeftAlign: boolean;
constructor(
private _elementRef: ElementRef,
@ -248,7 +248,7 @@ export class Searchbar extends Ion {
* @private
* Update the Searchbar input value when the input changes
*/
inputChanged(ev) {
inputChanged(ev: any) {
let value = ev.target.value;
clearTimeout(this._tmr);
@ -280,7 +280,7 @@ export class Searchbar extends Ion {
// blurInput determines if it should blur
// if we are clearing the input we still want to stay focused in the input
if (this.blurInput === false) {
this.searchbarInput._elementRef.nativeElement.focus();
this.searchbarInput.elementRef.nativeElement.focus();
this.blurInput = true;
return;
}

View File

@ -94,8 +94,8 @@ export class SegmentButton {
* @private
* On click of a SegmentButton
*/
@HostListener('click', ['$event'])
private onClick(ev) {
@HostListener('click')
private onClick() {
console.debug('SegmentButton, select', this.value);
this.ionSelect.emit(this);
}
@ -112,7 +112,7 @@ export class SegmentButton {
/**
* @private
*/
set isActive(isActive) {
set isActive(isActive: any) {
this._renderer.setElementClass(this._elementRef.nativeElement, 'segment-activated', isActive);
this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-pressed', isActive);
}
@ -215,7 +215,7 @@ export class Segment {
* @private
* Write a new value to the element.
*/
writeValue(value) {
writeValue(value: any) {
this.value = isPresent(value) ? value : '';
if (this._buttons) {
let buttons = this._buttons.toArray();
@ -231,7 +231,7 @@ export class Segment {
ngAfterViewInit() {
let buttons = this._buttons.toArray();
for (let button of buttons) {
button.ionSelect.subscribe((selectedButton) => {
button.ionSelect.subscribe((selectedButton: any) => {
this.writeValue(selectedButton.value);
this.onChange(selectedButton.value);
this.ionChange.emit(selectedButton);
@ -251,22 +251,22 @@ export class Segment {
/**
* @private
*/
onChange = (_) => {};
onChange = (_: any) => {};
/**
* @private
*/
onTouched = (_) => {};
onTouched = (_: any) => {};
/**
* @private
* 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
* 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'])
private _click(ev) {
private _click(ev: UIEvent) {
if (ev.detail === 0) {
// do not continue if the click event came from a form submit
return;
@ -216,8 +216,8 @@ export class Select {
this._open();
}
@HostListener('keyup.space', ['$event'])
private _keyup(ev) {
@HostListener('keyup.space')
private _keyup() {
if (!this._isOpen) {
this._open();
}
@ -259,9 +259,8 @@ export class Select {
this.interface = 'alert';
}
let overlay;
let overlay: any;
if (this.interface === 'action-sheet') {
alertOptions.buttons = alertOptions.buttons.concat(options.map(input => {
return {
role: (input.checked ? 'selected' : ''),
@ -305,7 +304,7 @@ export class Select {
overlay.addButton({
text: this.okText,
handler: selectedValues => {
handler: (selectedValues: any) => {
this.onChange(selectedValues);
this.ionChange.emit(selectedValues);
}
@ -426,7 +425,7 @@ export class Select {
/**
* @private
*/
registerOnTouched(fn) { this.onTouched = fn; }
registerOnTouched(fn: any) { this.onTouched = fn; }
/**
* @private

View File

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

View File

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

View File

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

View File

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

View File

@ -161,7 +161,7 @@ export class Tabs extends Ion {
private _ids: number = -1;
private _preloadTabs: boolean = null;
private _tabs: Array<Tab> = [];
private _onReady = null;
private _onReady: any = null;
private _sbPadding: boolean;
private _useHighlight: boolean;
@ -213,7 +213,7 @@ export class Tabs extends Ion {
/**
* @private
*/
@ViewChildren(TabButton) private _btns;
@ViewChildren(TabButton) private _btns: any;
/**
* @private
@ -316,7 +316,7 @@ export class Tabs extends Ion {
/**
* @private
*/
private _setConfig(attrKey, fallback) {
private _setConfig(attrKey: string, fallback: any) {
var val = this[attrKey];
if (isBlank(val)) {
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
*/
select(tabOrIndex) {
select(tabOrIndex: any) {
let selectedTab = (typeof tabOrIndex === 'number' ? this.getByIndex(tabOrIndex) : tabOrIndex);
if (!selectedTab) {
return;
@ -354,7 +354,7 @@ export class Tabs extends Ion {
animate: false
};
let deselectedPage;
let deselectedPage: ViewController;
if (deselectedTab) {
deselectedPage = deselectedTab.getActive();
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';
export class Activator {
protected _css: string;
protected _queue: Array<HTMLElement> = [];
protected _active: Array<HTMLElement> = [];
protected _queue: HTMLElement[] = [];
protected _active: HTMLElement[] = [];
constructor(protected app, config) {
constructor(protected app: App, config: Config) {
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
let self = this;
if (self.disableActivated(ev)) {
@ -21,7 +23,7 @@ export class Activator {
self._queue.push(activatableEle);
rafFrames(2, function() {
let activatableEle;
let activatableEle: HTMLElement;
for (let i = 0; i < self._queue.length; i++) {
activatableEle = self._queue[i];
if (activatableEle && activatableEle.parentNode) {
@ -69,7 +71,7 @@ export class Activator {
});
}
disableActivated(ev) {
disableActivated(ev: any) {
if (ev.defaultPrevented) return true;
let targetEle = ev.target;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,19 +31,19 @@ export class Translate {
private _transMap: any = {};
private _language: any = {};
translations(lang, map) {
translations(lang: any, map: any) {
this._transMap[lang] = map;
}
setLanguage(lang) {
setLanguage(lang: any) {
this._language = lang;
}
getTranslations(lang) {
getTranslations(lang: any) {
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 (!lang && !this._language) {
return key;
@ -60,7 +60,7 @@ export class Translate {
return this._getTranslation(map, key);
}
_getTranslation(map, key) {
_getTranslation(map: any, key: any) {
return map && map[key] || '';
}
}

View File

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

View File

@ -6,7 +6,7 @@
var rafLastTime = 0;
const win: any = window;
if (!win.requestAnimationFrame) {
win.requestAnimationFrame = function(callback, element) {
win.requestAnimationFrame = function(callback: Function) {
var currTime = Date.now();
var timeToCall = Math.max(0, 16 - (currTime - rafLastTime));
@ -20,7 +20,7 @@
}
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 clearNativeTimeout = window[window['Zone']['__symbol__']('clearTimeout')]['bind'](window);
export function rafFrames(framesToWait, callback) {
export function rafFrames(framesToWait: number, callback: Function) {
framesToWait = Math.ceil(framesToWait);
if (framesToWait < 2) {
@ -62,7 +62,8 @@ export let CSS: {
(function() {
// 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'];
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) {
unregister();
callback(ev);
@ -125,7 +126,7 @@ export function transitionEnd(el: HTMLElement, callback: Function) {
}
export function ready(callback?: Function) {
let promise = null;
let promise: Promise<any> = null;
if (!callback) {
// 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) {
let promise = null;
let promise: Promise<any> = null;
if (!callback) {
// 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
// or a touch depending on the given event
let c = { x: 0, y: 0 };
@ -188,20 +189,20 @@ export function pointerCoord(ev: any): {x: number, y: number} {
return c;
}
export function hasPointerMoved(threshold, startCoord, endCoord) {
export function hasPointerMoved(threshold: number, startCoord: Coordinates, endCoord: Coordinates) {
return startCoord && endCoord &&
(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));
}
export function hasFocus(ele) {
export function hasFocus(ele: HTMLElement) {
return isActive(ele) && (ele.parentElement.querySelector(':focus') === ele);
}
export function isTextInput(ele) {
export function isTextInput(ele: any) {
return !!ele &&
(ele.tagName === 'TEXTAREA' ||
ele.contentEditable === 'true' ||
@ -209,7 +210,7 @@ export function isTextInput(ele) {
}
export function hasFocusedTextInput() {
let ele = document.activeElement;
let ele = <HTMLElement>document.activeElement;
if (isTextInput(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;
export function copyInputAttributes(srcElement, destElement) {
export function copyInputAttributes(srcElement: HTMLElement, destElement: HTMLElement) {
// copy attributes from one element to another
// however, skip over a few of them as they're already
// handled in the angular world
@ -231,7 +232,7 @@ export function copyInputAttributes(srcElement, destElement) {
}
let matchesFn: string;
let matchesMethods: Array<string> = ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector'];
let matchesMethods = ['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector'];
matchesMethods.some((fn: string) => {
if (typeof document.documentElement[fn] === 'function') {
matchesFn = fn;
@ -309,3 +310,9 @@ export function flushDimensionCache() {
}
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 {function} handler the event handler
*/
subscribe(topic, ...handlers) {
subscribe(topic: string, ...handlers: Function[]) {
if (!this._channels[topic]) {
this._channels[topic] = [];
}
@ -50,7 +50,7 @@ export class Events {
*
* @return true if a handler was removed
*/
unsubscribe(topic, handler) {
unsubscribe(topic: string, handler: Function) {
let t = this._channels[topic];
if (!t) {
// Wasn't found, wasn't removed
@ -87,14 +87,14 @@ export class Events {
* @param {string} topic the topic to publish to
* @param {any} eventData the data to send as the event
*/
publish(topic, ...args) {
publish(topic: string, ...args: any[]) {
var t = this._channels[topic];
if (!t) {
return null;
}
let responses = [];
t.forEach((handler) => {
let responses: any[] = [];
t.forEach((handler: any) => {
responses.push(handler(args));
});
return responses;

View File

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

View File

@ -7,19 +7,19 @@ import {Injectable} from '@angular/core';
@Injectable()
export class Form {
private _blur: HTMLElement;
private _focused = null;
private _focused: any = null;
private _ids: number = -1;
private _inputs: Array<any> = [];
private _inputs: any[] = [];
constructor() {
this.focusCtrl(document);
}
register(input) {
register(input: any) {
this._inputs.push(input);
}
deregister(input) {
deregister(input: any) {
let index = this._inputs.indexOf(input);
if (index > -1) {
this._inputs.splice(index, 1);
@ -29,7 +29,7 @@ export class Form {
}
}
focusCtrl(document) {
focusCtrl(document: any) {
// raw DOM fun
let focusCtrl = document.createElement('focus-ctrl');
focusCtrl.setAttribute('aria-hidden', true);
@ -50,14 +50,14 @@ export class Form {
this._blur.focus();
}
setAsFocused(input) {
setAsFocused(input: any) {
this._focused = input;
}
/**
* Focuses the next input element, if it exists.
*/
tabFocus(currentInput) {
tabFocus(currentInput: any) {
let index = this._inputs.indexOf(currentInput);
if (index > -1 && (index + 1) < this._inputs.length) {
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
* @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');
const self = this;
let checks = 0;
let promise = null;
let promise: Promise<any> = null;
if (!callback) {
// a callback wasn't provided, so let's return a promise instead
@ -120,7 +120,7 @@ export class Keyboard {
/**
* @private
*/
focusOutline(setting, document) {
focusOutline(setting: any, document: any) {
/* Focus Outline
* --------------------------------------------------
* 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
function keyDown(ev) {
function keyDown(ev: KeyboardEvent) {
if (!isKeyInputEnabled && ev.keyCode === 9) {
isKeyInputEnabled = true;
enableKeyInput();

View File

@ -151,7 +151,7 @@ export class ScrollView {
* @private
* Used for JS scrolling. May be removed in the future.
*/
private _start(ev) {
private _start(ev: UIEvent) {
this._velocity = 0;
this._pos.length = 0;
this._max = null;
@ -162,7 +162,7 @@ export class ScrollView {
* @private
* Used for JS scrolling. May be removed in the future.
*/
private _move(ev) {
private _move(ev: UIEvent) {
if (this._pos.length) {
let y = pointerCoord(ev).y;
@ -198,7 +198,7 @@ export class ScrollView {
* @private
* 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
let positions = this._pos;
this._velocity = 0;

View File

@ -6,7 +6,7 @@
* @param n the value
* @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));
}
@ -37,7 +37,7 @@ export function merge(dst: any, ...args: any[]) {
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) {
var obj = objs[i];
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 {
var timeout, args, context, timestamp: number, result;
var timeout: number, args: any, context: any, timestamp: number, result: any;
return function() {
context = this;
args = arguments;
@ -88,7 +88,7 @@ export function debounce(fn: Function, wait: number, immediate: boolean = false)
* the first object.
* @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--) {
let source = arguments[i] || {};
for (let key in source) {
@ -100,15 +100,15 @@ export function defaults(dest, ...args: any[]) {
return dest;
}
export const isBoolean = val => typeof val === 'boolean';
export const isString = val => typeof val === 'string';
export const isNumber = val => typeof val === 'number';
export const isFunction = val => typeof val === 'function';
export const isDefined = val => typeof val !== 'undefined';
export const isUndefined = val => typeof val === 'undefined';
export const isPresent = val => val !== undefined && val !== null;
export const isBlank = val => val === undefined || val === null;
export const isObject = val => typeof val === 'object';
export const isBoolean = (val: any) => typeof val === 'boolean';
export const isString = (val: any) => typeof val === 'string';
export const isNumber = (val: any) => typeof val === 'number';
export const isFunction = (val: any) => typeof val === 'function';
export const isDefined = (val: any) => typeof val !== 'undefined';
export const isUndefined = (val: any) => typeof val === 'undefined';
export const isPresent = (val: any) => val !== undefined && val !== null;
export const isBlank = (val: any) => val === undefined || val === null;
export const isObject = (val: any) => typeof val === 'object';
export const isArray = Array.isArray;
export const isTrueProperty = function(val: any): boolean {
@ -153,33 +153,12 @@ export function nextUid(): number {
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.
* @param url
*/
export function getQuerystring(url: string): any {
var queryParams = {};
var queryParams: any = {};
if (url) {
const startIndex = url.indexOf('?');
if (startIndex !== -1) {
@ -196,35 +175,3 @@ export function getQuerystring(url: string): any {
}
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;
};
}