chore(components): ngmodule updates

This commit is contained in:
Adam Bradley
2016-09-13 17:07:33 -05:00
parent 16df3a4aab
commit 52ada1ca6d
50 changed files with 927 additions and 790 deletions

View File

@ -1,19 +1,17 @@
import { Component, ElementRef, EventEmitter, Input, HostListener, Output, QueryList, Renderer, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core';
import { NgClass, NgFor, NgIf } from '@angular/common';
import { DomSanitizationService } from '@angular/platform-browser';
import { DomSanitizer } from '@angular/platform-browser';
import { Animation } from '../../animations/animation';
import { Backdrop } from '../backdrop/backdrop';
import { cancelRaf, pointerCoord, raf } from '../../util/dom';
import { clamp, isNumber, isPresent, isString } from '../../util/util';
import { Config } from '../../config/config';
import { Key } from '../../util/key';
import { NavParams } from '../nav/nav-params';
import { NavParams } from '../../navigation/nav-params';
import { Picker } from './picker';
import { PickerOptions, PickerColumn, PickerColumnOption } from './picker-options';
import { Transition, TransitionOptions } from '../../transitions/transition';
import { Transition } from '../../transitions/transition';
import { UIEventManager } from '../../util/ui-event-manager';
import { ViewController } from '../nav/view-controller';
import { ViewController } from '../../navigation/view-controller';
/**
@ -21,16 +19,21 @@ import { ViewController } from '../nav/view-controller';
*/
@Component({
selector: '.picker-col',
template: `
<div *ngIf="col.prefix" class="picker-prefix" [style.width]="col.prefixWidth">{{col.prefix}}</div>
<div class="picker-opts" #colEle [style.width]="col.optionsWidth">
<button ion-button="picker-opt" *ngFor="let o of col.options; let i=index" [style.transform]="o._trans" [style.transitionDuration]="o._dur" [style.webkitTransform]="o._trans" [style.webkitTransitionDuration]="o._dur" [class.picker-opt-selected]="col.selectedIndex === i" [class.picker-opt-disabled]="o.disabled" (click)="optClick($event, i)" type="button">
{{o.text}}
</button>
</div>
<div *ngIf="col.suffix" class="picker-suffix" [style.width]="col.suffixWidth">{{col.suffix}}</div>
`,
directives: [NgFor, NgIf],
template:
'<div *ngIf="col.prefix" class="picker-prefix" [style.width]="col.prefixWidth">{{col.prefix}}</div>' +
'<div class="picker-opts" #colEle [style.width]="col.optionsWidth">' +
'<button *ngFor="let o of col.options; let i=index" [style.transform]="o._trans" ' +
'[style.transitionDuration]="o._dur" ' +
'[style.webkitTransform]="o._trans" ' +
'[style.webkitTransitionDuration]="o._dur" ' +
'[class.picker-opt-selected]="col.selectedIndex === i" [class.picker-opt-disabled]="o.disabled" ' +
'(click)="optClick($event, i)" ' +
'type="button" ' +
'ion-button="picker-opt">' +
'{{o.text}}' +
'</button>' +
'</div>' +
'<div *ngIf="col.suffix" class="picker-suffix" [style.width]="col.suffixWidth">{{col.suffix}}</div>',
host: {
'[style.min-width]': 'col.columnWidth',
'[class.picker-opts-left]': 'col.align=="left"',
@ -57,7 +60,7 @@ export class PickerColumnCmp {
@Output() ionChange: EventEmitter<any> = new EventEmitter();
constructor(config: Config, private elementRef: ElementRef, private _sanitizer: DomSanitizationService) {
constructor(config: Config, private elementRef: ElementRef, private _sanitizer: DomSanitizer) {
this.rotateFactor = config.getNumber('pickerRotateFactor', 0);
}
@ -344,7 +347,6 @@ export class PickerColumnCmp {
}
/**
* @private
*/
@ -367,18 +369,18 @@ export class PickerColumnCmp {
</div>
</div>
`,
directives: [Backdrop, NgClass, NgFor, PickerColumnCmp],
host: {
'role': 'dialog'
},
encapsulation: ViewEncapsulation.None,
})
export class PickerCmp {
@ViewChildren(PickerColumnCmp) private _cols: QueryList<PickerColumnCmp>;
private d: PickerOptions;
private enabled: boolean;
private lastClick: number;
private id: number;
@ViewChildren(PickerColumnCmp) _cols: QueryList<PickerColumnCmp>;
d: PickerOptions;
enabled: boolean;
lastClick: number;
id: number;
mode: string;
constructor(
private _viewCtrl: ViewController,
@ -388,6 +390,8 @@ export class PickerCmp {
renderer: Renderer
) {
this.d = params.data;
this.mode = _config.get('mode');
renderer.setElementClass(_elementRef.nativeElement, `picker-${this.mode}`, true);
if (this.d.cssClass) {
this.d.cssClass.split(' ').forEach(cssClass => {
@ -399,7 +403,7 @@ export class PickerCmp {
this.lastClick = 0;
}
ionViewLoaded() {
ionViewDidLoad() {
// normalize the data
let data = this.d;
@ -452,14 +456,14 @@ export class PickerCmp {
});
}
private _colChange(selectedOption: PickerColumnOption) {
_colChange(selectedOption: PickerColumnOption) {
// one of the columns has changed its selected index
var picker = <Picker>this._viewCtrl;
picker.ionChange.emit(this.getSelected());
}
@HostListener('body:keyup', ['$event'])
private _keyUp(ev: KeyboardEvent) {
_keyUp(ev: KeyboardEvent) {
if (this.enabled && this._viewCtrl.isLast()) {
if (ev.keyCode === Key.ENTER) {
if (this.lastClick + 1000 < Date.now()) {
@ -547,10 +551,8 @@ export class PickerCmp {
* Animations for pickers
*/
class PickerSlideIn extends Transition {
constructor(enteringView: ViewController, leavingView: ViewController, opts: TransitionOptions) {
super(enteringView, leavingView, opts);
let ele = enteringView.pageRef().nativeElement;
init() {
let ele = this.enteringView.pageRef().nativeElement;
let backdrop = new Animation(ele.querySelector('ion-backdrop'));
let wrapper = new Animation(ele.querySelector('.picker-wrapper'));
@ -564,10 +566,8 @@ Transition.register('picker-slide-in', PickerSlideIn);
class PickerSlideOut extends Transition {
constructor(enteringView: ViewController, leavingView: ViewController, opts: TransitionOptions) {
super(enteringView, leavingView, opts);
let ele = leavingView.pageRef().nativeElement;
init() {
let ele = this.leavingView.pageRef().nativeElement;
let backdrop = new Animation(ele.querySelector('ion-backdrop'));
let wrapper = new Animation(ele.querySelector('.picker-wrapper'));

View File

@ -2,10 +2,10 @@ import { EventEmitter, Injectable, Output } from '@angular/core';
import { App } from '../app/app';
import { isPresent } from '../../util/util';
import { NavOptions } from '../nav/nav-interfaces';
import { NavOptions } from '../../navigation/nav-util';
import { PickerCmp } from './picker-component';
import { PickerOptions, PickerColumn } from './picker-options';
import { ViewController } from '../nav/view-controller';
import { ViewController } from '../../navigation/view-controller';
/**
* @private
@ -20,16 +20,11 @@ export class Picker extends ViewController {
opts.buttons = opts.buttons || [];
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
super(PickerCmp, opts);
super(PickerCmp, opts, null);
this._app = app;
this.isOverlay = true;
this.ionChange = new EventEmitter<any>();
// by default, pickers should not fire lifecycle events of other views
// for example, when an picker enters, the current active view should
// not fire its lifecycle events because it's not conceptually leaving
this.fireOtherLifecycles = false;
}
/**
@ -59,7 +54,7 @@ export class Picker extends ViewController {
}
refresh() {
this.instance.refresh && this.instance.refresh();
this._cmp && this._cmp.instance.refresh && this._cmp.instance.refresh();
}
/**
@ -83,7 +78,7 @@ export class Picker extends ViewController {
* @private
* DEPRECATED: Please inject PickerController instead
*/
private static create(opt: any) {
static create(opt: any) {
// deprecated warning: added beta.11 2016-06-27
console.warn('Picker.create(..) has been deprecated. Please inject PickerController instead');
}