mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
@ -5,7 +5,7 @@ import {Animation} from '../../animations/animation';
|
|||||||
import {Transition, TransitionOptions} from '../../transitions/transition';
|
import {Transition, TransitionOptions} from '../../transitions/transition';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
import {Icon} from '../icon/icon';
|
import {Icon} from '../icon/icon';
|
||||||
import {isDefined} from '../../util/util';
|
import {isPresent} from '../../util/util';
|
||||||
import {NavParams} from '../nav/nav-params';
|
import {NavParams} from '../nav/nav-params';
|
||||||
import {ViewController} from '../nav/view-controller';
|
import {ViewController} from '../nav/view-controller';
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ export class ActionSheet extends ViewController {
|
|||||||
|
|
||||||
constructor(opts: ActionSheetOptions = {}) {
|
constructor(opts: ActionSheetOptions = {}) {
|
||||||
opts.buttons = opts.buttons || [];
|
opts.buttons = opts.buttons || [];
|
||||||
opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
|
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
|
||||||
|
|
||||||
super(ActionSheetCmp, opts);
|
super(ActionSheetCmp, opts);
|
||||||
this.viewType = 'action-sheet';
|
this.viewType = 'action-sheet';
|
||||||
|
@ -4,7 +4,7 @@ import {NgClass, NgSwitch, NgIf, NgFor} from 'angular2/common';
|
|||||||
import {Animation} from '../../animations/animation';
|
import {Animation} from '../../animations/animation';
|
||||||
import {Transition, TransitionOptions} from '../../transitions/transition';
|
import {Transition, TransitionOptions} from '../../transitions/transition';
|
||||||
import {Config} from '../../config/config';
|
import {Config} from '../../config/config';
|
||||||
import {isDefined} from '../../util/util';
|
import {isPresent} from '../../util/util';
|
||||||
import {NavParams} from '../nav/nav-params';
|
import {NavParams} from '../nav/nav-params';
|
||||||
import {ViewController} from '../nav/view-controller';
|
import {ViewController} from '../nav/view-controller';
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export class Alert extends ViewController {
|
|||||||
constructor(opts: AlertOptions = {}) {
|
constructor(opts: AlertOptions = {}) {
|
||||||
opts.inputs = opts.inputs || [];
|
opts.inputs = opts.inputs || [];
|
||||||
opts.buttons = opts.buttons || [];
|
opts.buttons = opts.buttons || [];
|
||||||
opts.enableBackdropDismiss = isDefined(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
|
opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
|
||||||
|
|
||||||
super(AlertCmp, opts);
|
super(AlertCmp, opts);
|
||||||
this.viewType = 'alert';
|
this.viewType = 'alert';
|
||||||
@ -326,9 +326,9 @@ class AlertCmp {
|
|||||||
data.inputs = data.inputs.map((input, index) => {
|
data.inputs = data.inputs.map((input, index) => {
|
||||||
return {
|
return {
|
||||||
type: input.type || 'text',
|
type: input.type || 'text',
|
||||||
name: isDefined(input.name) ? input.name : index,
|
name: isPresent(input.name) ? input.name : index,
|
||||||
placeholder: isDefined(input.placeholder) ? input.placeholder : '',
|
placeholder: isPresent(input.placeholder) ? input.placeholder : '',
|
||||||
value: isDefined(input.value) ? input.value : '',
|
value: isPresent(input.value) ? input.value : '',
|
||||||
label: input.label,
|
label: input.label,
|
||||||
checked: !!input.checked,
|
checked: !!input.checked,
|
||||||
id: 'alert-input-' + this.id + '-' + index
|
id: 'alert-input-' + this.id + '-' + index
|
||||||
|
@ -2,7 +2,6 @@ import {Directive, ElementRef, Renderer, Attribute, NgZone} from 'angular2/core'
|
|||||||
|
|
||||||
import {Ion} from '../ion';
|
import {Ion} from '../ion';
|
||||||
import {ItemSlidingGesture} from '../item/item-sliding-gesture';
|
import {ItemSlidingGesture} from '../item/item-sliding-gesture';
|
||||||
import {isDefined} from '../../util';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The List is a widely used interface element in almost any mobile app,
|
* The List is a widely used interface element in almost any mobile app,
|
||||||
|
@ -7,7 +7,7 @@ import {IonicApp} from '../app/app';
|
|||||||
import {Keyboard} from '../../util/keyboard';
|
import {Keyboard} from '../../util/keyboard';
|
||||||
import {NavParams} from './nav-params';
|
import {NavParams} from './nav-params';
|
||||||
import {NavRouter} from './nav-router';
|
import {NavRouter} from './nav-router';
|
||||||
import {pascalCaseToDashCase, isTrueProperty, isUndefined} from '../../util/util';
|
import {pascalCaseToDashCase, isTrueProperty, isBlank} from '../../util/util';
|
||||||
import {raf} from '../../util/dom';
|
import {raf} from '../../util/dom';
|
||||||
import {SwipeBackGesture} from './swipe-back';
|
import {SwipeBackGesture} from './swipe-back';
|
||||||
import {Transition} from '../../transitions/transition';
|
import {Transition} from '../../transitions/transition';
|
||||||
@ -178,7 +178,7 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise when done
|
* @returns {Promise} Returns a promise when done
|
||||||
*/
|
*/
|
||||||
setRoot(page: Type, params: any = {}, opts: NavOptions = {}): Promise<any> {
|
setRoot(page: Type, params?: any, opts?: NavOptions): Promise<any> {
|
||||||
return this.setPages([{page, params}], opts);
|
return this.setPages([{page, params}], opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +255,15 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass
|
* @param {object} [opts={}] Any options you want to use pass
|
||||||
* @returns {Promise} Returns a promise when the pages are set
|
* @returns {Promise} Returns a promise when the pages are set
|
||||||
*/
|
*/
|
||||||
setPages(pages: Array<{page: Type, params?: any}>, opts: NavOptions = {}): Promise<any> {
|
setPages(pages: Array<{page: Type, params?: any}>, opts?: NavOptions): Promise<any> {
|
||||||
if (!pages || !pages.length) {
|
if (!pages || !pages.length) {
|
||||||
return Promise.resolve(false);
|
return Promise.resolve(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBlank(opts)) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
// deprecated warning
|
// deprecated warning
|
||||||
pages.forEach(pg => {
|
pages.forEach(pg => {
|
||||||
if (pg['componentType']) {
|
if (pg['componentType']) {
|
||||||
@ -303,7 +307,7 @@ export class NavController extends Ion {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private setViews(components, opts: NavOptions = {}) {
|
private setViews(components, opts?: NavOptions) {
|
||||||
console.warn('setViews() deprecated, use setPages() instead');
|
console.warn('setViews() deprecated, use setPages() instead');
|
||||||
return this.setPages(components, opts);
|
return this.setPages(components, opts);
|
||||||
}
|
}
|
||||||
@ -373,7 +377,7 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
||||||
*/
|
*/
|
||||||
push(page: Type, params: any = {}, opts: NavOptions = {}) {
|
push(page: Type, params?: any, opts?: NavOptions) {
|
||||||
return this.insertPages(-1, [{page: page, params: params}], opts);
|
return this.insertPages(-1, [{page: page, params: params}], opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +406,7 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
* @returns {Promise} Returns a promise, which resolves when the transition has completed
|
||||||
*/
|
*/
|
||||||
present(enteringView: ViewController, opts: NavOptions = {}): Promise<any> {
|
present(enteringView: ViewController, opts?: NavOptions): Promise<any> {
|
||||||
let rootNav = this.rootNav;
|
let rootNav = this.rootNav;
|
||||||
|
|
||||||
if (rootNav['_tabs']) {
|
if (rootNav['_tabs']) {
|
||||||
@ -412,6 +416,10 @@ export class NavController extends Ion {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBlank(opts)) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
enteringView.setNav(rootNav);
|
enteringView.setNav(rootNav);
|
||||||
|
|
||||||
opts.keyboardClose = false;
|
opts.keyboardClose = false;
|
||||||
@ -454,7 +462,7 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise when the page has been inserted into the navigation stack
|
* @returns {Promise} Returns a promise when the page has been inserted into the navigation stack
|
||||||
*/
|
*/
|
||||||
insert(insertIndex: number, page: Type, params: any = {}, opts: NavOptions = {}): Promise<any> {
|
insert(insertIndex: number, page: Type, params?: any, opts?: NavOptions): Promise<any> {
|
||||||
return this.insertPages(insertIndex, [{page: page, params: params}], opts);
|
return this.insertPages(insertIndex, [{page: page, params: params}], opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,16 +494,20 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise when the pages have been inserted into the navigation stack
|
* @returns {Promise} Returns a promise when the pages have been inserted into the navigation stack
|
||||||
*/
|
*/
|
||||||
insertPages(insertIndex: number, insertPages: Array<{page: Type, params?: any}>, opts: NavOptions = {}): Promise<any> {
|
insertPages(insertIndex: number, insertPages: Array<{page: Type, params?: any}>, opts?: NavOptions): Promise<any> {
|
||||||
let views = insertPages.map(p => new ViewController(p.page, p.params));
|
let views = insertPages.map(p => new ViewController(p.page, p.params));
|
||||||
return this._insertViews(insertIndex, views, opts);
|
return this._insertViews(insertIndex, views, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _insertViews(insertIndex: number, insertViews: Array<ViewController>, opts: NavOptions = {}): Promise<any> {
|
private _insertViews(insertIndex: number, insertViews: Array<ViewController>, opts?: NavOptions): Promise<any> {
|
||||||
if (!insertViews || !insertViews.length) {
|
if (!insertViews || !insertViews.length) {
|
||||||
return Promise.reject('invalid pages');
|
return Promise.reject('invalid pages');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBlank(opts)) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
// insert the new page into the stack
|
// insert the new page into the stack
|
||||||
// returns the newly created entering view
|
// returns the newly created entering view
|
||||||
let enteringView = this._insert(insertIndex, insertViews);
|
let enteringView = this._insert(insertIndex, insertViews);
|
||||||
@ -616,16 +628,20 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
* @returns {Promise} Returns a promise when the transition is completed
|
* @returns {Promise} Returns a promise when the transition is completed
|
||||||
*/
|
*/
|
||||||
pop(opts: NavOptions = {}): Promise<any> {
|
pop(opts?: NavOptions): Promise<any> {
|
||||||
// get the index of the active view
|
// get the index of the active view
|
||||||
// which will become the view to be leaving
|
// which will become the view to be leaving
|
||||||
let activeView = this.getByState(STATE_TRANS_ENTER) ||
|
let activeView = this.getByState(STATE_TRANS_ENTER) ||
|
||||||
this.getByState(STATE_INIT_ENTER) ||
|
this.getByState(STATE_INIT_ENTER) ||
|
||||||
this.getActive();
|
this.getActive();
|
||||||
|
|
||||||
|
if (isBlank(opts)) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
// if not set, by default climb up the nav controllers if
|
// if not set, by default climb up the nav controllers if
|
||||||
// there isn't a previous view in this nav controller
|
// there isn't a previous view in this nav controller
|
||||||
if (isUndefined(opts.climbNav)) {
|
if (isBlank(opts.climbNav)) {
|
||||||
opts.climbNav = true;
|
opts.climbNav = true;
|
||||||
}
|
}
|
||||||
return this.remove(this.indexOf(activeView), 1, opts);
|
return this.remove(this.indexOf(activeView), 1, opts);
|
||||||
@ -635,7 +651,7 @@ export class NavController extends Ion {
|
|||||||
* Similar to `pop()`, this method let's you navigate back to the root of the stack, no matter how many views that is
|
* Similar to `pop()`, this method let's you navigate back to the root of the stack, no matter how many views that is
|
||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
*/
|
*/
|
||||||
popToRoot(opts: NavOptions = {}): Promise<any> {
|
popToRoot(opts?: NavOptions): Promise<any> {
|
||||||
return this.popTo(this.first(), opts);
|
return this.popTo(this.first(), opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,7 +660,7 @@ export class NavController extends Ion {
|
|||||||
* @param {ViewController} view to pop to
|
* @param {ViewController} view to pop to
|
||||||
* @param {object} [opts={}] Any options you want to use pass to transtion
|
* @param {object} [opts={}] Any options you want to use pass to transtion
|
||||||
*/
|
*/
|
||||||
popTo(view: ViewController, opts: NavOptions = {}): Promise<any> {
|
popTo(view: ViewController, opts?: NavOptions): Promise<any> {
|
||||||
let startIndex = this.indexOf(view);
|
let startIndex = this.indexOf(view);
|
||||||
let activeView = this.getByState(STATE_TRANS_ENTER) ||
|
let activeView = this.getByState(STATE_TRANS_ENTER) ||
|
||||||
this.getByState(STATE_INIT_ENTER) ||
|
this.getByState(STATE_INIT_ENTER) ||
|
||||||
@ -673,7 +689,7 @@ export class NavController extends Ion {
|
|||||||
* @param {object} [opts={}] Any options you want to use pass to transtion.
|
* @param {object} [opts={}] Any options you want to use pass to transtion.
|
||||||
* @returns {Promise} Returns a promise when the page has been removed.
|
* @returns {Promise} Returns a promise when the page has been removed.
|
||||||
*/
|
*/
|
||||||
remove(startIndex: number = -1, removeCount: number = 1, opts: NavOptions = {}): Promise<any> {
|
remove(startIndex: number = -1, removeCount: number = 1, opts?: NavOptions): Promise<any> {
|
||||||
if (startIndex === -1) {
|
if (startIndex === -1) {
|
||||||
startIndex = this._views.length - 1;
|
startIndex = this._views.length - 1;
|
||||||
|
|
||||||
@ -681,6 +697,10 @@ export class NavController extends Ion {
|
|||||||
return Promise.reject("remove index out of range");
|
return Promise.reject("remove index out of range");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBlank(opts)) {
|
||||||
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
// default the direction to "back"
|
// default the direction to "back"
|
||||||
opts.direction = opts.direction || 'back';
|
opts.direction = opts.direction || 'back';
|
||||||
|
|
||||||
@ -878,8 +898,11 @@ export class NavController extends Ion {
|
|||||||
// lets time this sucker, ready go
|
// lets time this sucker, ready go
|
||||||
let wtfScope = wtfStartTimeRange('NavController#_transition', (enteringView && enteringView.name));
|
let wtfScope = wtfStartTimeRange('NavController#_transition', (enteringView && enteringView.name));
|
||||||
|
|
||||||
if (this.config.get('animate') === false ||
|
if (isBlank(opts)) {
|
||||||
(this._views.length === 1 && !this._init)) {
|
opts = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.config.get('animate') === false || (this._views.length === 1 && !this._init)) {
|
||||||
opts.animate = false;
|
opts.animate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,6 +45,7 @@ class MyCmpTest{}
|
|||||||
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setPages()">setPages() (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
<button ion-item (click)="setRoot()">setRoot(PrimaryHeaderPage) (Go to PrimaryHeaderPage)</button>
|
||||||
<button ion-item (click)="nav.pop()">Pop</button>
|
<button ion-item (click)="nav.pop()">Pop</button>
|
||||||
|
<button ion-item (click)="viewDismiss()">View Dismiss</button>
|
||||||
<button ion-item (click)="quickPush()">New push during transition</button>
|
<button ion-item (click)="quickPush()">New push during transition</button>
|
||||||
<button ion-item (click)="quickPop()">New pop during transition</button>
|
<button ion-item (click)="quickPop()">New pop during transition</button>
|
||||||
<button ion-item (click)="reload()">Reload</button>
|
<button ion-item (click)="reload()">Reload</button>
|
||||||
@ -62,8 +63,7 @@ class FirstPage {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private nav: NavController,
|
private nav: NavController,
|
||||||
app: IonicApp,
|
private view: ViewController
|
||||||
config: Config
|
|
||||||
) {
|
) {
|
||||||
this.pushPage = FullPage;
|
this.pushPage = FullPage;
|
||||||
|
|
||||||
@ -110,6 +110,10 @@ class FirstPage {
|
|||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
viewDismiss() {
|
||||||
|
this.view.dismiss();
|
||||||
|
}
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,20 @@ export function run() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('remove', () => {
|
||||||
|
|
||||||
|
it('should create opts if passed in arg is undefined or null', () => {
|
||||||
|
let view1 = new ViewController(Page1);
|
||||||
|
view1.state = STATE_INACTIVE;
|
||||||
|
let view2 = new ViewController(Page2);
|
||||||
|
view2.state = STATE_ACTIVE;
|
||||||
|
nav._views = [view1, view2];
|
||||||
|
|
||||||
|
nav.remove(1, 1, null);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('_remove', () => {
|
describe('_remove', () => {
|
||||||
|
|
||||||
it('should reassign activily transitioning leave that isnt getting removed, to become force active', () => {
|
it('should reassign activily transitioning leave that isnt getting removed, to become force active', () => {
|
||||||
|
@ -3,6 +3,7 @@ import {Output, EventEmitter, Type, TemplateRef, ViewContainerRef, ElementRef, R
|
|||||||
import {Navbar} from '../navbar/navbar';
|
import {Navbar} from '../navbar/navbar';
|
||||||
import {NavController, NavOptions} from './nav-controller';
|
import {NavController, NavOptions} from './nav-controller';
|
||||||
import {NavParams} from './nav-params';
|
import {NavParams} from './nav-params';
|
||||||
|
import {isPresent} from '../../util/util';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,9 +87,9 @@ export class ViewController {
|
|||||||
*/
|
*/
|
||||||
@Output() private _emitter: EventEmitter<any> = new EventEmitter();
|
@Output() private _emitter: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
constructor(public componentType?: Type, data: any = {}) {
|
constructor(public componentType?: Type, data?: any) {
|
||||||
// passed in data could be NavParams, but all we care about is its data object
|
// passed in data could be NavParams, but all we care about is its data object
|
||||||
this.data = (data instanceof NavParams ? data.data : data);
|
this.data = (data instanceof NavParams ? data.data : isPresent(data) ? data : {});
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(generatorOrNext?: any): any {
|
subscribe(generatorOrNext?: any): any {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {Directive, ElementRef, Input, Output, EventEmitter} from 'angular2/core';
|
import {Directive, ElementRef, Input, Output, EventEmitter} from 'angular2/core';
|
||||||
|
|
||||||
import {isDefined, isTrueProperty} from '../../util/util';
|
import {isPresent, isTrueProperty} from '../../util/util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Option
|
* @name Option
|
||||||
@ -40,7 +40,7 @@ export class Option {
|
|||||||
*/
|
*/
|
||||||
@Input()
|
@Input()
|
||||||
get value() {
|
get value() {
|
||||||
if (isDefined(this._value)) {
|
if (isPresent(this._value)) {
|
||||||
return this._value;
|
return this._value;
|
||||||
}
|
}
|
||||||
return this.text;
|
return this.text;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Component, Optional, Input, Output, HostListener, EventEmitter} from 'angular2/core';
|
import {Component, Optional, Input, Output, HostListener, EventEmitter} from 'angular2/core';
|
||||||
|
|
||||||
import {Form} from '../../util/form';
|
import {Form} from '../../util/form';
|
||||||
import {isTrueProperty, isDefined, isBlank} from '../../util/util';
|
import {isTrueProperty, isPresent, isBlank} from '../../util/util';
|
||||||
import {Item} from '../item/item';
|
import {Item} from '../item/item';
|
||||||
import {ListHeader} from '../list/list';
|
import {ListHeader} from '../list/list';
|
||||||
import {RadioGroup} from './radio-group';
|
import {RadioGroup} from './radio-group';
|
||||||
@ -142,7 +142,7 @@ export class RadioButton {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this._group && isDefined(this._group.value) && this._group.value == this.value) {
|
if (this._group && isPresent(this._group.value) && this._group.value == this.value) {
|
||||||
this.checked = true;
|
this.checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import {NG_VALUE_ACCESSOR} from 'angular2/common';
|
|||||||
|
|
||||||
import {RadioButton} from './radio-button';
|
import {RadioButton} from './radio-button';
|
||||||
import {ListHeader} from '../list/list';
|
import {ListHeader} from '../list/list';
|
||||||
import {isDefined} from '../../util/util';
|
import {isPresent} from '../../util/util';
|
||||||
|
|
||||||
const RADIO_VALUE_ACCESSOR = new Provider(
|
const RADIO_VALUE_ACCESSOR = new Provider(
|
||||||
NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => RadioGroup), multi: true});
|
NG_VALUE_ACCESSOR, {useExisting: forwardRef(() => RadioGroup), multi: true});
|
||||||
|
@ -5,7 +5,7 @@ import {Ion} from '../ion';
|
|||||||
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 {Button} from '../button/button';
|
||||||
import {isDefined, debounce} from '../../util/util';
|
import {isPresent, debounce} from '../../util/util';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +206,7 @@ export class Searchbar extends Ion {
|
|||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
// If the user passes an undefined variable to ngModel this will warn
|
// If the user passes an undefined variable to ngModel this will warn
|
||||||
// and set the value to an empty string
|
// and set the value to an empty string
|
||||||
if (!isDefined(this.value)) {
|
if (!isPresent(this.value)) {
|
||||||
console.warn('Searchbar was passed an undefined value in ngModel. Please make sure the variable is defined.');
|
console.warn('Searchbar was passed an undefined value in ngModel. Please make sure the variable is defined.');
|
||||||
this.value = '';
|
this.value = '';
|
||||||
this.onChange(this.value);
|
this.onChange(this.value);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {Directive, Component, ElementRef, Renderer, Optional, EventEmitter, Input, Output, HostListener, ContentChildren, QueryList} from 'angular2/core';
|
import {Directive, Component, ElementRef, Renderer, Optional, EventEmitter, Input, Output, HostListener, ContentChildren, QueryList} from 'angular2/core';
|
||||||
import {NgControl} from 'angular2/common';
|
import {NgControl} from 'angular2/common';
|
||||||
|
|
||||||
import {isDefined} from '../../util/util';
|
import {isPresent} from '../../util/util';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,7 @@ export class SegmentButton {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (!isDefined(this.value)) {
|
if (!isPresent(this.value)) {
|
||||||
console.warn('<ion-segment-button> requires a "value" attribute');
|
console.warn('<ion-segment-button> requires a "value" attribute');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ export class Segment {
|
|||||||
* Write a new value to the element.
|
* Write a new value to the element.
|
||||||
*/
|
*/
|
||||||
writeValue(value) {
|
writeValue(value) {
|
||||||
this.value = isDefined(value) ? value : '';
|
this.value = isPresent(value) ? value : '';
|
||||||
if (this._buttons) {
|
if (this._buttons) {
|
||||||
let buttons = this._buttons.toArray();
|
let buttons = this._buttons.toArray();
|
||||||
for (let button of buttons) {
|
for (let button of buttons) {
|
||||||
@ -195,7 +195,7 @@ export class Segment {
|
|||||||
this.change.emit(selectedButton);
|
this.change.emit(selectedButton);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isDefined(this.value)) {
|
if (isPresent(this.value)) {
|
||||||
button.isActive = (button.value === this.value);
|
button.isActive = (button.value === this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import {NavController} from '../nav/nav-controller';
|
|||||||
import {ViewController} from '../nav/view-controller';
|
import {ViewController} from '../nav/view-controller';
|
||||||
import {Icon} from '../icon/icon';
|
import {Icon} from '../icon/icon';
|
||||||
import {rafFrames} from '../../util/dom';
|
import {rafFrames} from '../../util/dom';
|
||||||
import {isUndefined, isTrueProperty} from '../../util/util';
|
import {isBlank, isTrueProperty} from '../../util/util';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,7 +193,7 @@ export class Tabs extends Ion {
|
|||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
let selectedIndex = this.selectedIndex ? parseInt(this.selectedIndex, 10) : 0;
|
let selectedIndex = this.selectedIndex ? parseInt(this.selectedIndex, 10) : 0;
|
||||||
|
|
||||||
let preloadTabs = (isUndefined(this.preloadTabs) ? this._config.getBoolean('preloadTabs') : isTrueProperty(this.preloadTabs));
|
let preloadTabs = (isBlank(this.preloadTabs) ? this._config.getBoolean('preloadTabs') : isTrueProperty(this.preloadTabs));
|
||||||
|
|
||||||
this._tabs.forEach((tab, index) => {
|
this._tabs.forEach((tab, index) => {
|
||||||
if (index === selectedIndex) {
|
if (index === selectedIndex) {
|
||||||
@ -210,7 +210,7 @@ export class Tabs extends Ion {
|
|||||||
*/
|
*/
|
||||||
private _setConfig(attrKey, fallback) {
|
private _setConfig(attrKey, fallback) {
|
||||||
var val = this[attrKey];
|
var val = this[attrKey];
|
||||||
if (isUndefined(val)) {
|
if (isBlank(val)) {
|
||||||
val = this._config.get(attrKey, fallback);
|
val = this._config.get(attrKey, fallback);
|
||||||
}
|
}
|
||||||
this._renderer.setElementAttribute(this._elementRef.nativeElement, attrKey, val);
|
this._renderer.setElementAttribute(this._elementRef.nativeElement, attrKey, val);
|
||||||
|
@ -106,6 +106,7 @@ export const isNumber = val => typeof val === 'number';
|
|||||||
export const isFunction = val => typeof val === 'function';
|
export const isFunction = val => typeof val === 'function';
|
||||||
export const isDefined = val => typeof val !== 'undefined';
|
export const isDefined = val => typeof val !== 'undefined';
|
||||||
export const isUndefined = 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 isBlank = val => val === undefined || val === null;
|
||||||
export const isObject = val => typeof val === 'object';
|
export const isObject = val => typeof val === 'object';
|
||||||
export const isArray = Array.isArray;
|
export const isArray = Array.isArray;
|
||||||
|
Reference in New Issue
Block a user