Merge in master to es6-shims

This commit is contained in:
jbavari
2015-10-16 11:47:58 -06:00
59 changed files with 405 additions and 319 deletions

View File

@@ -9,7 +9,7 @@
import {Component, Injectable, NgFor, NgIf} from 'angular2/angular2';
import {OverlayController} from '../overlay/overlay-controller';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Icon} from '../icon/icon';
import {Animation} from '../../animations/animation';
import * as util from 'ionic/util';
@@ -104,7 +104,7 @@ class ActionSheetCmp {
@Injectable()
export class ActionSheet {
constructor(ctrl: OverlayController, config: IonicConfig) {
constructor(ctrl: OverlayController, config: Config) {
this.ctrl = ctrl;
this._defaults = {
enterAnimation: config.get('actionSheetEnter'),

View File

@@ -1,6 +1,6 @@
import {Directive, ElementRef, Renderer, Attribute} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
/**
@@ -12,7 +12,7 @@ import {IonicConfig} from '../../config/config';
export class Button {
constructor(
config: IonicConfig,
config: Config,
elementRef: ElementRef,
renderer: Renderer,
@Attribute('type') type: string

View File

@@ -1,7 +1,7 @@
import {Component, Directive, Optional, NgControl, ElementRef, Renderer} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicForm} from '../../util/form';
import {Form} from '../../util/form';
/**
* The checkbox is no different than the HTML checkbox input, except it's styled differently
@@ -43,7 +43,7 @@ import {IonicForm} from '../../util/form';
export class Checkbox {
constructor(
form: IonicForm,
form: Form,
@Optional() ngControl: NgControl,
elementRef: ElementRef,
renderer: Renderer

View File

@@ -1,8 +1,8 @@
import {Component, ElementRef, Optional} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {IonicKeyboard} from '../../util/keyboard';
import {Config} from '../../config/config';
import {Keyboard} from '../../util/keyboard';
import {ViewController} from '../nav/view-controller';
import {Animation} from '../../animations/animation';
import {ScrollTo} from '../../animations/scroll-to';
@@ -33,9 +33,9 @@ import {ScrollTo} from '../../animations/scroll-to';
export class Content extends Ion {
/**
* @param {ElementRef} elementRef A reference to the component's DOM element.
* @param {IonicConfig} config The config object to change content's default settings.
* @param {Config} config The config object to change content's default settings.
*/
constructor(elementRef: ElementRef, config: IonicConfig, keyboard: IonicKeyboard, @Optional() viewCtrl: ViewController) {
constructor(elementRef: ElementRef, config: Config, keyboard: Keyboard, @Optional() viewCtrl: ViewController) {
super(elementRef, config);
this.scrollPadding = 0;
this.keyboard = keyboard;

View File

@@ -9,6 +9,7 @@ $outer-content-md-background-color: #efeff4 !default;
background: $outer-content-md-background-color;
}
ion-nav.has-views {
ion-nav.has-views,
ion-tab.has-views {
background: #000;
}

View File

@@ -1,6 +1,6 @@
import {Directive, ElementRef, Attribute, Renderer} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
@Directive({
@@ -19,7 +19,7 @@ export class Icon {
constructor(
private elementRef: ElementRef,
config: IonicConfig,
config: Config,
private renderer: Renderer
) {
this.eleRef = elementRef;

View File

@@ -1,4 +1,4 @@
import {IonicConfig} from '../config/config';
import {Config} from '../config/config';
import {isArray} from 'ionic/util';
import * as dom from 'ionic/util/dom';
@@ -9,7 +9,7 @@ import * as dom from 'ionic/util/dom';
* sending/receiving app-level events.
*/
export class Ion {
constructor(elementRef: ElementRef, config: IonicConfig) {
constructor(elementRef: ElementRef, config: Config) {
this.elementRef = elementRef;
this.config = config;
}

View File

@@ -1,8 +1,9 @@
import {Directive, ElementRef, Host, Optional} from 'angular2/angular2';
import {Content} from '../content/content';
import {throttle} from '../../util/util';
import {position, offset, CSS} from '../../util/dom';
import {IonicConfig} from '../../config/config';
import {position, offset, CSS, raf} from '../../util/dom';
import {FeatureDetect} from '../../util/feature-detect';
import {Config} from '../../config/config';
/**
* TODO
@@ -38,15 +39,16 @@ export class ItemGroupTitle {
* TODO
* @param {ElementRef} elementRef TODO
*/
constructor(elementRef: ElementRef, config: IonicConfig, content: Content) {
constructor(elementRef: ElementRef, config: Config, content: Content, featureDetect: FeatureDetect) {
this.isSticky = true;
this.content = content;
this.ele = elementRef.nativeElement;
this.parent = this.ele.parentNode;
this.isCssValid = featureDetect.has('positionsticky')
}
onInit() {
if(!this.content) { return; }
if (!this.content || this.isCssValid) { return; }
this.scrollContent = this.content.elementRef.nativeElement.children[0];
@@ -55,7 +57,6 @@ export class ItemGroupTitle {
this.scrollTransition = 0;
this.isSticking = false;
this.scrollContent.addEventListener('scroll', event => this.scrollEvent(event));
this.calculateScrollLimits = scrollTop => {
@@ -98,9 +99,7 @@ export class ItemGroupTitle {
this.applyTransform(element, translateDyPixelsUp);
}
else {
// see http://www.paulirish.com/2011/requestanimationframe-for-smart-animating/
// see http://ionicframework.com/docs/api/utility/ionic.DomUtil/
requestAnimationFrame( a => this.applyTransform(element, translateDyPixelsUp) );
raf( a => this.applyTransform(element, translateDyPixelsUp) );
}
}

View File

@@ -1,7 +1,7 @@
import {Directive, ElementRef, Renderer} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ListVirtualScroll} from './virtual';
import * as util from 'ionic/util';
@@ -28,9 +28,9 @@ export class List extends Ion {
/**
* TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
*/
constructor(elementRef: ElementRef, config: IonicConfig, renderer: Renderer) {
constructor(elementRef: ElementRef, config: Config, renderer: Renderer) {
super(elementRef, config);
renderer.setElementClass(elementRef, 'list', true);
this.ele = elementRef.nativeElement;

View File

@@ -2,10 +2,10 @@ import {forwardRef, Directive, Host, EventEmitter, ElementRef} from 'angular2/an
import {Ion} from '../ion';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ConfigComponent} from '../../config/decorators';
import {IonicPlatform} from '../../platform/platform';
import {IonicKeyboard} from '../../util/keyboard';
import {Platform} from '../../platform/platform';
import {Keyboard} from '../../util/keyboard';
import * as gestures from './menu-gestures';
@@ -67,9 +67,9 @@ export class Menu extends Ion {
constructor(
app: IonicApp,
elementRef: ElementRef,
config: IonicConfig,
platform: IonicPlatform,
keyboard: IonicKeyboard
config: Config,
platform: Platform,
keyboard: Keyboard
) {
super(elementRef, config);
this.app = app;

View File

@@ -1,7 +1,7 @@
import {Injectable} from 'angular2/angular2';
import {OverlayController} from '../overlay/overlay-controller';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Animation} from '../../animations/animation';
import {makeComponent} from '../../config/decorators';
import * as util from 'ionic/util';
@@ -14,7 +14,7 @@ import * as util from 'ionic/util';
* ```ts
* class MyApp {
*
* constructor(modal: Modal, app: IonicApp, ionicConfig: IonicConfig) {
* constructor(modal: Modal, app: IonicApp, Config: Config) {
* this.modal = modal;
* }
*
@@ -31,7 +31,7 @@ import * as util from 'ionic/util';
@Injectable()
export class Modal {
constructor(ctrl: OverlayController, config: IonicConfig) {
constructor(ctrl: OverlayController, config: Config) {
this.ctrl = ctrl;
this._defaults = {
enterAnimation: config.get('modalEnter') || 'modal-slide-in',

View File

@@ -1,4 +1,4 @@
import {App, Page, IonicApp, IonicConfig, IonicPlatform} from 'ionic/ionic';
import {App, Page, IonicApp, Config, Platform} from 'ionic/ionic';
import {Modal, ActionSheet, NavController, NavParams, Animation} from 'ionic/ionic';
@@ -7,7 +7,7 @@ import {Modal, ActionSheet, NavController, NavParams, Animation} from 'ionic/ion
})
class MyAppCmp {
constructor(modal: Modal, app: IonicApp, config: IonicConfig, platform: IonicPlatform) {
constructor(modal: Modal, app: IonicApp, config: Config, platform: Platform) {
this.modal = modal;
console.log('platforms', platform.platforms());

View File

@@ -3,7 +3,7 @@ import {Component, Directive, Optional, ElementRef, Renderer, TemplateRef, forwa
import {Ion} from '../ion';
import {Icon} from '../icon/icon';
import {ToolbarBase} from '../toolbar/toolbar';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Page} from '../../config/decorators';
import {IonicApp} from '../app/app';
import {ViewController} from '../nav/view-controller';
@@ -72,7 +72,7 @@ export class Navbar extends ToolbarBase {
app: IonicApp,
@Optional() viewCtrl: ViewController,
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer
) {
super(elementRef, config);

View File

@@ -1,9 +1,9 @@
import {Compiler, ElementRef, Injector, provide, NgZone, DynamicComponentLoader, AppViewManager} from 'angular2/angular2';
import {Compiler, ElementRef, Injector, provide, NgZone, DynamicComponentLoader, AppViewManager, Renderer} from 'angular2/angular2';
import {Ion} from '../ion';
import {makeComponent} from '../../config/decorators';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ViewController} from './view-controller';
import {Transition} from '../../transitions/transition';
import {SwipeBackGesture} from './swipe-back';
@@ -105,12 +105,13 @@ export class NavController extends Ion {
constructor(
parentnavCtrl: NavController,
app: IonicApp,
config: IonicConfig,
config: Config,
elementRef: ElementRef,
compiler: Compiler,
loader: DynamicComponentLoader,
viewManager: AppViewManager,
zone: NgZone
zone: NgZone,
renderer: Renderer
) {
super(elementRef, config);
@@ -122,6 +123,7 @@ export class NavController extends Ion {
this._loader = loader;
this._viewManager = viewManager;
this._zone = zone;
this.renderer = renderer;
this._views = [];
@@ -180,6 +182,10 @@ export class NavController extends Ion {
// add the view to the stack
this._add(enteringView);
raf(() => {
this._cleanup(enteringView);
});
if (this.router) {
// notify router of the state change
this.router.stateChange('push', enteringView, params);
@@ -755,11 +761,11 @@ export class NavController extends Ion {
});
}
_cleanup() {
_cleanup(activeView) {
// the active view, and the previous view, should be rendered in dom and ready to go
// all others, like a cached page 2 back, should be display: none and not rendered
let destroys = [];
let activeView = this.getActive();
activeView = activeView || this.getActive();
let previousView = this.getPrevious(activeView);
this._views.forEach(view => {
@@ -770,7 +776,7 @@ export class NavController extends Ion {
} else {
let isActiveView = (view === activeView);
let isPreviousView = (view === previousView);
view.domCache(isActiveView, isPreviousView);
view.domCache && view.domCache(isActiveView, isPreviousView);
}
}
});
@@ -783,6 +789,16 @@ export class NavController extends Ion {
});
}
addHasViews() {
if (this._views.length === 1) {
this._zone.runOutsideAngular(() => {
setTimeout(() => {
this.renderer.setElementClass(this.elementRef, 'has-views', true);
}, 200);
});
}
}
/**
* TODO
* @param {TODO} nbContainer TODO

View File

@@ -1,7 +1,7 @@
import {Component, Directive, ElementRef, Host, Optional, forwardRef, Inject, NgZone, Compiler, AppViewManager, DynamicComponentLoader, Renderer, ViewContainerRef} from 'angular2/angular2';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ConfigComponent} from '../../config/decorators';
import {NavController} from './nav-controller';
@@ -145,14 +145,15 @@ export class Nav extends NavController {
constructor(
@Optional() hostNavCtrl: NavController,
app: IonicApp,
config: IonicConfig,
config: Config,
elementRef: ElementRef,
compiler: Compiler,
loader: DynamicComponentLoader,
viewManager: AppViewManager,
zone: NgZone
zone: NgZone,
renderer: Renderer
) {
super(hostNavCtrl, app, config, elementRef, compiler, loader, viewManager, zone);
super(hostNavCtrl, app, config, elementRef, compiler, loader, viewManager, zone, renderer);
this.panes = [];
}
@@ -253,13 +254,7 @@ export class Nav extends NavController {
});
}
if (this._views.length === 1) {
this._zone.runOutsideAngular(() => {
// setTimeout(function() {
// componentRef && componentRef.location && componentRef.location.nativeElement.classList.add('has-views');
// }, 100);
});
}
this.addHasViews();
done();
});

View File

@@ -1,5 +1,5 @@
import {App, NavController} from 'ionic/ionic';
import {Page, IonicConfig, IonicApp} from 'ionic/ionic';
import {Page, Config, IonicApp} from 'ionic/ionic';
import {NavParams, NavController} from 'ionic/ionic';
@@ -31,7 +31,7 @@ class FirstPage {
constructor(
nav: NavController,
app: IonicApp,
config: IonicConfig
config: Config
) {
this.nav = nav;
this.title = 'First Page';

View File

@@ -17,7 +17,7 @@
import {
NavController,
IonicConfig,
Config,
Page,
ViewController
} from 'ionic/ionic';
@@ -58,7 +58,7 @@ export function run() {
// beforeEach(inject([Compiler], compiler => {
beforeEach(() => {
nav = new NavController(null, null, new IonicConfig(), null, null, null, null, null);
nav = new NavController(null, null, new Config(), null, null, null, null, null);
});
it('should exist', () => {

View File

@@ -2,7 +2,7 @@ import {FORM_DIRECTIVES, NgControl, NgControlGroup,
Component, ElementRef, Injectable, NgClass, NgIf, NgFor} from 'angular2/angular2';
import {OverlayController} from '../overlay/overlay-controller';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Animation} from '../../animations/animation';
import {Button} from '../button/button';
import * as util from 'ionic/util';
@@ -64,7 +64,7 @@ import * as util from 'ionic/util';
@Injectable()
export class Popup {
constructor(ctrl: OverlayController, config: IonicConfig) {
constructor(ctrl: OverlayController, config: Config) {
this.ctrl = ctrl;
this._defaults = {
enterAnimation: config.get('popupPopIn'),

View File

@@ -1,6 +1,6 @@
import {Component, Directive, ElementRef, Renderer, Host, Optional, NgControl, Query, QueryList} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Ion} from '../ion';
import {ListHeader} from '../list/list';
@@ -56,13 +56,13 @@ export class RadioGroup extends Ion {
/**
* TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
* @param {NgControl=} ngControl TODO
* @param {QueryList<ListHeader>} headerQuery TODO
*/
constructor(
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer,
@Optional() ngControl: NgControl,
@Query(ListHeader) private headerQuery: QueryList<ListHeader>
@@ -194,12 +194,12 @@ export class RadioButton extends Ion {
* Radio button constructor.
* @param {RadioGroup=} group The parent radio group, if any.
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
*/
constructor(
@Host() @Optional() group: RadioGroup,
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer
) {
super(elementRef, config);

View File

@@ -1,7 +1,7 @@
import {Component, ElementRef, onInit} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {Gesture} from '../../gestures/gesture';
import {CSS} from '../../util/dom';
import {Animation} from '../../animations/animation';
@@ -32,10 +32,10 @@ export class Scroll extends Ion {
/**
* TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
*/
constructor(elementRef: ElementRef, ionicConfig: IonicConfig) {
super(elementRef, ionicConfig);
constructor(elementRef: ElementRef, Config: Config) {
super(elementRef, Config);
this.maxScale = 3;
this.zoomDuration = 250;

View File

@@ -1,7 +1,7 @@
import {ElementRef, Pipe, NgControl, Renderer, FORM_DIRECTIVES, NgIf, NgClass} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ConfigComponent} from '../../config/decorators';
/**
@@ -41,11 +41,11 @@ export class SearchBar extends Ion {
/**
* TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
*/
constructor(
elementRef: ElementRef,
config: IonicConfig,
config: Config,
ngControl: NgControl,
renderer: Renderer
) {

View File

@@ -2,7 +2,7 @@ import {Component, Directive, Renderer, ElementRef, EventEmitter, Host, forwardR
import {Control, NgControl, NgFormControl, ControlGroup, ControlDirective} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {dom} from 'ionic/util';
/**
@@ -34,16 +34,16 @@ export class Segment extends Ion {
* TODO
* @param {NgControl} ngControl TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
* @param {Renderer} renderer TODO
*/
constructor(
@Optional() ngControl: NgControl,
elementRef: ElementRef,
ionicConfig: IonicConfig,
config: Config,
renderer: Renderer
) {
super(elementRef, ionicConfig);
super(elementRef, config);
this.ele = elementRef.nativeElement
this.elementRef = elementRef;
@@ -244,7 +244,7 @@ export class SegmentButton {
// selector: 'tab-highlight'
// })
// class TabHighlight {
// constructor(@Host() tabs: Tabs, config: IonicConfig, elementRef: ElementRef) {
// constructor(@Host() tabs: Tabs, config: Config, elementRef: ElementRef) {
// if (config.get('mode') === 'md') {
// tabs.highlight = this;
// this.elementRef = elementRef;

View File

@@ -1,6 +1,6 @@
import {Directive, Attribute, NgZone} from 'angular2/angular2'
import {IonicPlatform} from '../../platform/platform';
import {Platform} from '../../platform/platform';
class DisplayWhen {
@@ -68,7 +68,7 @@ export class ShowWhen extends DisplayWhen {
*/
constructor(
@Attribute('show-when') showWhen: string,
platform: IonicPlatform,
platform: Platform,
ngZone: NgZone
) {
super(showWhen, platform, ngZone);
@@ -97,7 +97,7 @@ export class HideWhen extends DisplayWhen {
*/
constructor(
@Attribute('hide-when') hideWhen: string,
platform: IonicPlatform,
platform: Platform,
ngZone: NgZone
) {
super(hideWhen, platform, ngZone);

View File

@@ -4,7 +4,7 @@ import {Ion} from '../ion';
import {Animation} from 'ionic/animations/animation';
import {Gesture} from 'ionic/gestures/gesture';
import {DragGesture} from 'ionic/gestures/drag-gesture';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {dom} from 'ionic/util';
import {CSS} from '../../util/dom';
import * as util from 'ionic/util';
@@ -55,7 +55,7 @@ export class Slides extends Ion {
* TODO
* @param {ElementRef} elementRef TODO
*/
constructor(elementRef: ElementRef, config: IonicConfig) {
constructor(elementRef: ElementRef, config: Config) {
super(elementRef, config);
this.rapidUpdate = util.debounce(() => {
this.update();

View File

@@ -1,7 +1,7 @@
import {Component, Directive, ElementRef, Renderer, Host, Optional, NgControl, Inject, forwardRef} from 'angular2/angular2';
import {IonicForm} from '../../util/form';
import {IonicConfig} from '../../config/config';
import {Form} from '../../util/form';
import {Config} from '../../config/config';
import {pointerCoord} from '../../util/dom';
/**
@@ -19,7 +19,7 @@ class MediaSwitch {
* TODO
* @param {Switch} swtch TODO
* @param {} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
*/
constructor(
@Host() @Inject(forwardRef(() => Switch)) swtch: Switch,
@@ -99,13 +99,13 @@ export class Switch {
/**
* TODO
* @param {ElementRef} elementRef TODO
* @param {IonicConfig} config TODO
* @param {Config} config TODO
* @param {NgControl=} ngControl TODO
*/
constructor(
form: IonicForm,
form: Form,
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer,
@Optional() private ngControl: NgControl
) {

View File

@@ -1,7 +1,7 @@
import {Component, Directive, Host, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, forwardRef, NgZone} from 'angular2/angular2';
import {Component, Directive, Host, ElementRef, Compiler, DynamicComponentLoader, AppViewManager, forwardRef, NgZone, Renderer} from 'angular2/angular2';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {NavController} from '../nav/nav-controller';
import {ViewController} from '../nav/view-controller';
import {Tabs} from './tabs';
@@ -72,25 +72,33 @@ export class Tab extends NavController {
constructor(
@Host() tabs: Tabs,
app: IonicApp,
config: IonicConfig,
config: Config,
elementRef: ElementRef,
compiler: Compiler,
loader: DynamicComponentLoader,
viewManager: AppViewManager,
zone: NgZone
zone: NgZone,
renderer: Renderer
) {
// A Tab is a NavController for its child pages
super(tabs, app, config, elementRef, compiler, loader, viewManager, zone);
super(tabs, app, config, elementRef, compiler, loader, viewManager, zone, renderer);
this.tabs = tabs;
this._isInitial = tabs.add(this);
}
onInit() {
console.debug('Tab onInit');
console.debug('Tab onInit', this.getIndex());
if (this._isInitial) {
this.tabs.select(this);
} else if (this.tabs.preloadTabs) {
setTimeout(() => {
this.load(() => {
console.debug('preloaded tab', this.getIndex());
});
}, 500 * this.getIndex());
}
}
@@ -144,12 +152,17 @@ export class Tab extends NavController {
});
}
done();
this.addHasViews();
done();
});
}
getIndex() {
return this.tabs.getIndex(this);
}
}

View File

@@ -2,7 +2,7 @@ import {Directive, ElementRef, Optional, Host, NgFor, forwardRef, ViewContainerR
import {Ion} from '../ion';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {ViewController} from '../nav/view-controller';
import {ConfigComponent} from '../../config/decorators';
import {Icon} from '../icon/icon';
@@ -62,7 +62,8 @@ import {Icon} from '../icon/icon';
selector: 'ion-tabs',
defaultInputs: {
'tabBarPlacement': 'bottom',
'tabBarIcons': 'top'
'tabBarIcons': 'top',
'preloadTabs': true
},
template:
'<ion-navbar-section>' +
@@ -100,12 +101,13 @@ export class Tabs extends Ion {
*/
constructor(
app: IonicApp,
config: IonicConfig,
config: Config,
elementRef: ElementRef,
@Optional() viewCtrl: ViewController
) {
super(elementRef, config);
this.app = app;
this.preload = config.get('preloadTabs');
// collection of children "Tab" instances, which extends NavController
this._tabs = [];
@@ -201,6 +203,10 @@ export class Tabs extends Ion {
return null;
}
getIndex(tab) {
return this._tabs.indexOf(tab);
}
/**
* @private
* "Touch" the active tab, either going back to the root view of the tab
@@ -241,7 +247,7 @@ let _tabIds = -1;
}
})
class TabButton extends Ion {
constructor(@Host() tabs: Tabs, config: IonicConfig, elementRef: ElementRef) {
constructor(@Host() tabs: Tabs, config: Config, elementRef: ElementRef) {
super(elementRef, config);
this.tabs = tabs;
@@ -273,7 +279,7 @@ class TabButton extends Ion {
selector: 'tab-highlight'
})
class TabHighlight {
constructor(@Host() tabs: Tabs, config: IonicConfig, elementRef: ElementRef) {
constructor(@Host() tabs: Tabs, config: Config, elementRef: ElementRef) {
if (config.get('mode') === 'md') {
tabs.highlight = this;
this.elementRef = elementRef;

View File

@@ -1,7 +1,7 @@
import {Injectable} from 'angular2/angular2';
import {IonicApp} from '../app/app';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {pointerCoord, hasPointerMoved, transitionEnd} from '../../util/dom';
import {Activator} from './activator';
import {RippleActivator} from './ripple';
@@ -10,7 +10,7 @@ import {RippleActivator} from './ripple';
@Injectable()
export class TapClick {
constructor(app: IonicApp, config: IonicConfig) {
constructor(app: IonicApp, config: Config) {
const self = this;
self.app = app;

View File

@@ -1,6 +1,6 @@
import {Directive, Optional} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {TextInput} from './text-input';
import {pointerCoord, hasPointerMoved} from '../../util/dom';
@@ -23,9 +23,9 @@ import {pointerCoord, hasPointerMoved} from '../../util/dom';
export class Label {
/**
* TODO
* @param {IonicConfig} config
* @param {Config} config
*/
constructor(config: IonicConfig, @Optional() container: TextInput) {
constructor(config: Config, @Optional() container: TextInput) {
this.scrollAssist = config.get('scrollAssist');
if (!this.id) {
this.id = 'lbl-' + (++labelIds);

View File

@@ -1,12 +1,12 @@
import {Component, Directive, NgIf, forwardRef, Host, Optional, ElementRef, Renderer, Attribute, Query, QueryList, NgZone} from 'angular2/angular2';
import {IonicConfig} from '../../config/config';
import {IonicForm} from '../../util/form';
import {Config} from '../../config/config';
import {Form} from '../../util/form';
import {Label} from './label';
import {IonicApp} from '../app/app';
import {Content} from '../content/content';
import * as dom from '../../util/dom';
import {IonicPlatform} from '../../platform/platform';
import {Platform} from '../../platform/platform';
/**
@@ -27,13 +27,13 @@ import {IonicPlatform} from '../../platform/platform';
export class TextInput {
constructor(
form: IonicForm,
form: Form,
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer,
app: IonicApp,
zone: NgZone,
platform: IonicPlatform,
platform: Platform,
@Optional() @Host() scrollView: Content
) {
renderer.setElementClass(elementRef, 'item', true);
@@ -403,7 +403,7 @@ export class TextInputElement {
})
class InputScrollAssist {
constructor(form: IonicForm, textInput: TextInput) {
constructor(form: Form, textInput: TextInput) {
this.form = form;
this.textInput = textInput;
}

View File

@@ -1,7 +1,7 @@
import {Component, Directive, Host, ElementRef, Renderer, Optional, forwardRef, Inject} from 'angular2/angular2';
import {Ion} from '../ion';
import {IonicConfig} from '../../config/config';
import {Config} from '../../config/config';
import {MenuToggle} from '../menu/menu-toggle';
import {Navbar} from '../nav-bar/nav-bar';
@@ -13,7 +13,7 @@ export class ToolbarBase extends Ion {
constructor(
elementRef: ElementRef,
config: IonicConfig
config: Config
) {
super(elementRef, config);
this.itemRefs = [];
@@ -69,7 +69,7 @@ export class ToolbarBase extends Ion {
export class Toolbar extends ToolbarBase {
constructor(
elementRef: ElementRef,
config: IonicConfig,
config: Config,
renderer: Renderer
) {
super(elementRef, config);

View File

@@ -2,11 +2,11 @@ import {bootstrap, provide} from 'angular2/angular2';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {IonicApp} from '../components/app/app';
import {IonicConfig} from './config';
import {IonicPlatform} from '../platform/platform';
import {Config} from './config';
import {Platform} from '../platform/platform';
import {OverlayController} from '../components/overlay/overlay-controller';
import {IonicForm} from '../util/form';
import {IonicKeyboard} from '../util/keyboard';
import {Form} from '../util/form';
import {Keyboard} from '../util/keyboard';
import {ActionSheet} from '../components/action-sheet/action-sheet';
import {Modal} from '../components/modal/modal';
import {Popup} from '../components/popup/popup';
@@ -14,16 +14,17 @@ import {Events} from '../util/events';
import {NavRegistry} from '../components/nav/nav-registry';
import {Translate} from '../translation/translate';
import {ClickBlock} from '../util/click-block';
import {FeatureDetect} from '../util/feature-detect';
import {TapClick} from '../components/tap-click/tap-click';
import * as dom from '../util/dom';
export function ionicProviders(config) {
let app = new IonicApp();
let platform = new IonicPlatform();
let platform = new Platform();
if (!(config instanceof IonicConfig)) {
config = new IonicConfig(config);
if (!(config instanceof Config)) {
config = new Config(config);
}
platform.url(window.location.href);
@@ -34,8 +35,9 @@ export function ionicProviders(config) {
let events = new Events();
let tapClick = new TapClick(app, config, window, document);
let featureDetect = new FeatureDetect();
setupDom(window, document, config, platform);
setupDom(window, document, config, platform, featureDetect);
bindEvents(window, document, platform, events);
// prepare the ready promise to fire....when ready
@@ -43,12 +45,13 @@ export function ionicProviders(config) {
return [
provide(IonicApp, {useValue: app}),
provide(IonicConfig, {useValue: config}),
provide(IonicPlatform, {useValue: platform}),
provide(Config, {useValue: config}),
provide(Platform, {useValue: platform}),
provide(TapClick, {useValue: tapClick}),
provide(FeatureDetect, {useValue: featureDetect}),
provide(Events, {useValue: events}),
IonicForm,
IonicKeyboard,
Form,
Keyboard,
OverlayController,
ActionSheet,
Modal,
@@ -61,7 +64,7 @@ export function ionicProviders(config) {
}
function setupDom(window, document, config, platform) {
function setupDom(window, document, config, platform, featureDetect) {
let bodyEle = document.body;
if (!bodyEle) {
return dom.ready(function() {
@@ -96,22 +99,8 @@ function setupDom(window, document, config, platform) {
bodyEle.classList.add('enable-hover');
}
/**
* Hairline Shim
* Add the "hairline" CSS class name to the body tag
* if the browser supports subpixels.
*/
if (window.devicePixelRatio >= 2) {
var hairlineEle = document.createElement('div');
hairlineEle.style.border = '.5px solid transparent';
bodyEle.appendChild(hairlineEle);
if (hairlineEle.offsetHeight === 1) {
bodyEle.classList.add('hairlines');
}
bodyEle.removeChild(hairlineEle);
}
// run feature detection tests
featureDetect.run(window, document);
}

View File

@@ -3,16 +3,16 @@
* @name Config
* @module ionic
* @description
* IonicConfig allows you to set the modes of your components
* Config allows you to set the modes of your components
*/
import {IonicPlatform} from '../platform/platform';
import {Platform} from '../platform/platform';
import {isObject, isDefined, isFunction, isArray, extend} from '../util/util';
/**
* TODO
*/
export class IonicConfig {
export class Config {
/**
* TODO
@@ -30,12 +30,12 @@ export class IonicConfig {
/**
* @name settings()
* @description
* IonicConfig lets you change multiple or a single value in an apps mode configuration. Things such as tab placement, icon changes, and view animations can be set here.
* Config lets you change multiple or a single value in an apps mode configuration. Things such as tab placement, icon changes, and view animations can be set here.
*
*
* @usage
* ```ts
* import {IonicConfig} from 'ionic/ionic';
* import {Config} from 'ionic/ionic';
* @App({
* template: `<ion-nav [root]="root"></ion-nav>`
* config: {
@@ -144,7 +144,7 @@ export class IonicConfig {
if (isDefined(configObj[key])) {
userPlatformValue = configObj[key];
}
configObj = IonicConfig.getModeConfig(configObj.mode);
configObj = Config.getModeConfig(configObj.mode);
if (configObj && isDefined(configObj[key])) {
userPlatformModeValue = configObj[key];
}
@@ -152,7 +152,7 @@ export class IonicConfig {
}
// get default platform's setting
configObj = IonicPlatform.get(activePlatformKeys[i]);
configObj = Platform.get(activePlatformKeys[i]);
if (configObj && configObj.settings) {
if (isDefined(configObj.settings[key])) {
@@ -160,7 +160,7 @@ export class IonicConfig {
platformValue = configObj.settings[key];
}
configObj = IonicConfig.getModeConfig(configObj.settings.mode);
configObj = Config.getModeConfig(configObj.settings.mode);
if (configObj && isDefined(configObj[key])) {
// found setting for this platform's mode
platformModeValue = configObj[key];
@@ -172,7 +172,7 @@ export class IonicConfig {
}
configObj = IonicConfig.getModeConfig(this._s.mode);
configObj = Config.getModeConfig(this._s.mode);
if (configObj && isDefined(configObj[key])) {
userDefaultModeValue = configObj[key];
}

View File

@@ -1,9 +1,9 @@
import {IonicConfig} from './config';
import {Config} from './config';
// iOS Mode Settings
IonicConfig.setModeConfig('ios', {
Config.setModeConfig('ios', {
actionSheetEnter: 'action-sheet-slide-in',
actionSheetLeave: 'action-sheet-slide-out',
@@ -27,7 +27,7 @@ IonicConfig.setModeConfig('ios', {
// Material Design Mode Settings
IonicConfig.setModeConfig('md', {
Config.setModeConfig('md', {
actionSheetEnter: 'action-sheet-md-slide-in',
actionSheetLeave: 'action-sheet-md-slide-out',

View File

@@ -1,41 +1,41 @@
import {IonicConfig, IonicPlatform, ionicProviders} from 'ionic/ionic';
import {Config, Platform, ionicProviders} from 'ionic/ionic';
export function run() {
it('should create a new IonicConfig instace when no confg passed in ionicProviders', () => {
it('should create a new Config instace when no confg passed in ionicProviders', () => {
let providers = ionicProviders();
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
let config = providers.find(provider => provider.useValue instanceof Config).useValue;
expect(config.get('mode')).toEqual('ios');
});
it('should used passed in IonicConfig instance in ionicProviders', () => {
let userConfig = new IonicConfig({
it('should used passed in Config instance in ionicProviders', () => {
let userConfig = new Config({
mode: 'configInstance'
})
let providers = ionicProviders(userConfig);
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
let config = providers.find(provider => provider.useValue instanceof Config).useValue;
expect(config.get('mode')).toEqual('configInstance');
});
it('should create new IonicConfig instance from config object in ionicProviders', () => {
it('should create new Config instance from config object in ionicProviders', () => {
let providers = ionicProviders({
mode: 'configObj'
});
let config = providers.find(provider => provider.useValue instanceof IonicConfig).useValue;
let config = providers.find(provider => provider.useValue instanceof Config).useValue;
expect(config.get('mode')).toEqual('configObj');
});
it('should override mode settings', () => {
let config = new IonicConfig({
let config = new Config({
mode: 'md'
});
let platform = new IonicPlatform(['ios']);
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('md');
@@ -43,14 +43,14 @@ export function run() {
});
it('should override mode settings from platforms setting', () => {
let config = new IonicConfig({
let config = new Config({
platforms: {
ios: {
mode: 'md'
}
}
});
let platform = new IonicPlatform(['ios']);
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('md');
@@ -58,7 +58,7 @@ export function run() {
});
it('should override mode platform', () => {
let config = new IonicConfig({
let config = new Config({
mode: 'modeA',
platforms: {
mobile: {
@@ -69,66 +69,66 @@ export function run() {
}
}
});
let platform = new IonicPlatform(['mobile']);
let platform = new Platform(['mobile']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('modeB');
});
it('should override mode', () => {
let config = new IonicConfig({
let config = new Config({
mode: 'modeA'
});
let platform = new IonicPlatform(['core']);
let platform = new Platform(['core']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('modeA');
});
it('should get user settings after user platform settings', () => {
let config = new IonicConfig({
let config = new Config({
hoverCSS: true
});
let platform = new IonicPlatform(['ios']);
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('hoverCSS')).toEqual(true);
});
it('should get ios mode for core platform', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['core']);
let config = new Config();
let platform = new Platform(['core']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('ios');
});
it('should get ios mode for ipad platform', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'ios', 'ipad', 'tablet']);
let config = new Config();
let platform = new Platform(['mobile', 'ios', 'ipad', 'tablet']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('ios');
});
it('should get md mode for windowsphone platform', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'windowsphone']);
let config = new Config();
let platform = new Platform(['mobile', 'windowsphone']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('md');
});
it('should get md mode for android platform', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'android']);
let config = new Config();
let platform = new Platform(['mobile', 'android']);
config.setPlatform(platform);
expect(config.get('mode')).toEqual('md');
});
it('should override ios mode config with user platform setting', () => {
let config = new IonicConfig({
let config = new Config({
tabBarPlacement: 'hide',
platforms: {
ios: {
@@ -136,41 +136,41 @@ export function run() {
}
}
});
let platform = new IonicPlatform(['ios']);
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('tabBarPlacement')).toEqual('top');
});
it('should override ios mode config with user setting', () => {
let config = new IonicConfig({
let config = new Config({
tabBarPlacement: 'top'
});
let platform = new IonicPlatform(['ios']);
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('tabBarPlacement')).toEqual('top');
});
it('should get setting from md mode', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['android']);
let config = new Config();
let platform = new Platform(['android']);
config.setPlatform(platform);
expect(config.get('tabBarPlacement')).toEqual('top');
});
it('should get setting from ios mode', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['ios']);
let config = new Config();
let platform = new Platform(['ios']);
config.setPlatform(platform);
expect(config.get('tabBarPlacement')).toEqual('bottom');
});
it('should set/get platform setting from set()', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['ios']);
let config = new Config();
let platform = new Platform(['ios']);
config.setPlatform(platform);
config.set('tabBarPlacement', 'bottom');
@@ -180,8 +180,8 @@ export function run() {
});
it('should set/get setting from set()', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['ios']);
let config = new Config();
let platform = new Platform(['ios']);
config.setPlatform(platform);
config.set('tabBarPlacement', 'top');
@@ -190,8 +190,8 @@ export function run() {
});
it('should set ios platform settings from settings()', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['ios']);
let config = new Config();
let platform = new Platform(['ios']);
config.setPlatform(platform);
config.settings('ios', {
@@ -202,8 +202,8 @@ export function run() {
});
it('should set/get mobile setting even w/ higher priority ios', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'ios']);
let config = new Config();
let platform = new Platform(['mobile', 'ios']);
config.setPlatform(platform);
config.settings({
@@ -219,8 +219,8 @@ export function run() {
});
it('should set/get mobile setting even w/ higher priority ios', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'ios']);
let config = new Config();
let platform = new Platform(['mobile', 'ios']);
config.setPlatform(platform);
config.settings({
@@ -236,8 +236,8 @@ export function run() {
});
it('should set/get android setting w/ higher priority than mobile', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['mobile', 'android']);
let config = new Config();
let platform = new Platform(['mobile', 'android']);
config.setPlatform(platform);
config.settings({
@@ -256,8 +256,8 @@ export function run() {
});
it('should set/get ios setting w/ platforms set', () => {
let config = new IonicConfig();
let platform = new IonicPlatform(['ios']);
let config = new Config();
let platform = new Platform(['ios']);
config.setPlatform(platform);
config.settings({
@@ -276,7 +276,7 @@ export function run() {
});
it('should set/get default setting w/ platforms set, but no platform match', () => {
let config = new IonicConfig();
let config = new Config();
config.settings({
key: 'defaultValue',
platforms: {
@@ -293,7 +293,7 @@ export function run() {
});
it('should set setting object', () => {
let config = new IonicConfig();
let config = new Config();
config.settings({
name: 'Doc Brown',
occupation: 'Weather Man'
@@ -306,7 +306,7 @@ export function run() {
});
it('should get null setting', () => {
let config = new IonicConfig();
let config = new Config();
expect(config.get('name')).toEqual(null);
expect(config.get('name')).toEqual(null);
@@ -315,7 +315,7 @@ export function run() {
});
it('should set/get single setting', () => {
let config = new IonicConfig();
let config = new Config();
config.set('name', 'Doc Brown');
config.set('occupation', 'Weather Man');
@@ -326,7 +326,7 @@ export function run() {
});
it('should init w/ given config settings', () => {
let config = new IonicConfig({
let config = new Config({
name: 'Doc Brown',
occupation: 'Weather Man'
});
@@ -335,7 +335,7 @@ export function run() {
});
it('should get settings object', () => {
let config = new IonicConfig({
let config = new Config({
name: 'Doc Brown',
occupation: 'Weather Man'
});
@@ -347,34 +347,34 @@ export function run() {
});
it('should create default config w/ bad settings value', () => {
let config = new IonicConfig(null);
let config = new Config(null);
expect(config.settings()).toEqual({});
config = new IonicConfig(undefined);
config = new Config(undefined);
expect(config.settings()).toEqual({});
config = new IonicConfig();
config = new Config();
expect(config.settings()).toEqual({});
config = new IonicConfig([1,2,3]);
config = new Config([1,2,3]);
expect(config.settings()).toEqual({});
config = new IonicConfig('im bad, you know it');
config = new Config('im bad, you know it');
expect(config.settings()).toEqual({});
config = new IonicConfig(8675309);
config = new Config(8675309);
expect(config.settings()).toEqual({});
config = new IonicConfig(true);
config = new Config(true);
expect(config.settings()).toEqual({});
config = new IonicConfig(false);
config = new Config(false);
expect(config.settings()).toEqual({});
config = new IonicConfig(1);
config = new Config(1);
expect(config.settings()).toEqual({});
config = new IonicConfig(function(){});
config = new Config(function(){});
expect(config.settings()).toEqual({});
});

View File

@@ -3,7 +3,7 @@
+* @name platform
+* @module ionic
+* @description
+* IonicPlatform returns the availble information about your current platform
+* Platform returns the availble information about your current platform
+*/
@@ -14,7 +14,7 @@ import * as dom from '../util/dom';
/**
* TODO
*/
export class IonicPlatform {
export class Platform {
constructor(platforms=[]) {
this._platforms = platforms;
@@ -33,9 +33,9 @@ export class IonicPlatform {
* @returns {bool}
*
* ```
* import {IonicPlatform} 'ionic/ionic';
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: IonicPlatform){
* constructor(platform: Platform){
* this.platform = platform;
* if(this.platform.is('ios'){
* // what ever you need to do for
@@ -57,9 +57,9 @@ export class IonicPlatform {
* it would return mobile, ios, and iphone.
*
* ```
* import {IonicPlatform} 'ionic/ionic';
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: IonicPlatform){
* constructor(platform: Platform){
* this.platform = platform;
* console.log(this.platform.platforms());
* // This will return an array of all the availble platforms
@@ -82,9 +82,9 @@ export class IonicPlatform {
* Returns an object containing the os version
*
* ```
* import {IonicPlatform} 'ionic/ionic';
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: IonicPlatform){
* constructor(platform: Platform){
* this.platform = platform;
* console.log(this.platform.versions('android'));
* // Returns an object with the os version as a string,
@@ -112,9 +112,9 @@ export class IonicPlatform {
* Returns a promise when the platform is ready and native functionality can be called
*
* ```
* import {IonicPlatform} 'ionic/ionic';
* import {Platform} 'ionic/ionic';
* export MyClass {
* constructor(platform: IonicPlatform){
* constructor(platform: Platform){
* this.platform = platform;
* this.platform.ready().then(() => {
* console.log('Platform ready');
@@ -450,7 +450,7 @@ function insertSuperset(platformNode) {
class PlatformNode {
constructor(platformName) {
this.c = IonicPlatform.get(platformName);
this.c = Platform.get(platformName);
this.isEngine = this.c.isEngine;
}
@@ -538,7 +538,7 @@ class PlatformNode {
}
getSubsetParents(subsetPlatformName) {
let platformRegistry = IonicPlatform.registry();
let platformRegistry = Platform.registry();
let parentPlatformNames = [];
let platform = null;

View File

@@ -1,23 +1,23 @@
import {IonicPlatform} from './platform';
import {Platform} from './platform';
import {windowLoad} from '../util/dom';
IonicPlatform.register({
Platform.register({
name: 'core',
settings: {
mode: 'ios',
keyboardHeight: 290,
}
});
IonicPlatform.setDefault('core');
Platform.setDefault('core');
IonicPlatform.register({
Platform.register({
name: 'mobile'
});
IonicPlatform.register({
Platform.register({
name: 'phablet',
isMatch(p) {
let smallest = Math.min(p.width(), p.height());
@@ -28,7 +28,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'tablet',
isMatch(p) {
let smallest = Math.min(p.width(), p.height());
@@ -39,7 +39,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'android',
superset: 'mobile',
subsets: [
@@ -62,7 +62,7 @@ IonicPlatform.register({
IonicPlatform.register({
Platform.register({
name: 'ios',
superset: 'mobile',
subsets: [
@@ -91,7 +91,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'ipad',
superset: 'tablet',
settings: {
@@ -103,7 +103,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'iphone',
subsets: [
'phablet'
@@ -114,7 +114,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'windowsphone',
superset: 'mobile',
subsets: [
@@ -133,7 +133,7 @@ IonicPlatform.register({
});
IonicPlatform.register({
Platform.register({
name: 'cordova',
isEngine: true,
methods: {

View File

@@ -1,9 +1,9 @@
import {IonicPlatform} from 'ionic/ionic';
import {Platform} from 'ionic/ionic';
export function run() {
it('should set core as the fallback', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.userAgent('idk');
platform.load();
@@ -13,7 +13,7 @@ export function run() {
});
it('should set android via platformOverride, despite ios user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.userAgent(IPAD_UA);
platform.load('android');
@@ -22,7 +22,7 @@ export function run() {
});
it('should set ios via platformOverride, despite android querystring', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.url('/?ionicplatform=android');
platform.load('ios');
@@ -31,7 +31,7 @@ export function run() {
});
it('should set ios via platformOverride', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.load('ios');
expect(platform.is('android')).toEqual(false);
@@ -39,7 +39,7 @@ export function run() {
});
it('should set android via platformOverride', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.load('android');
expect(platform.is('android')).toEqual(true);
@@ -47,7 +47,7 @@ export function run() {
});
it('should set ios via querystring', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.url('/?ionicplatform=ios');
platform.load();
@@ -58,7 +58,7 @@ export function run() {
});
it('should set ios via querystring, even with android user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.url('/?ionicplatform=ios');
platform.userAgent(ANDROID_UA);
platform.load();
@@ -68,7 +68,7 @@ export function run() {
});
it('should set android via querystring', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.url('/?ionicplatform=android');
platform.load();
@@ -77,7 +77,7 @@ export function run() {
});
it('should set android via querystring, even with ios user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.url('/?ionicplatform=android');
platform.userAgent(IPHONE_UA);
platform.load();
@@ -87,7 +87,7 @@ export function run() {
});
it('should set android via user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.userAgent(ANDROID_UA);
platform.load();
@@ -97,7 +97,7 @@ export function run() {
});
it('should set iphone via user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.userAgent(IPHONE_UA);
platform.load();
@@ -109,7 +109,7 @@ export function run() {
});
it('should set ipad via user agent', () => {
let platform = new IonicPlatform();
let platform = new Platform();
platform.userAgent(IPAD_UA);
platform.load();

View File

@@ -273,18 +273,8 @@ export function flushDimensionCache() {
let dimensionCache = {};
let dimensionIds = 0;
function getStyle(el, cssprop) {
if (el.currentStyle) { //IE
return el.currentStyle[cssprop];
} else if (window.getComputedStyle) {
return window.getComputedStyle(el)[cssprop];
}
// finally try and get inline style
return el.style[cssprop];
}
function isStaticPositioned(element) {
return (getStyle(element, 'position') || 'static') === 'static';
return (element.style.position || 'static') === 'static';
}
/**
@@ -317,8 +307,8 @@ export function position(element) {
var boundingClientRect = element.getBoundingClientRect();
return {
width: boundingClientRect.width || element.prop('offsetWidth'),
height: boundingClientRect.height || element.prop('offsetHeight'),
width: boundingClientRect.width || element.offsetWidth,
height: boundingClientRect.height || element.offsetHeight,
top: elBCR.top - offsetParentBCR.top,
left: elBCR.left - offsetParentBCR.left
};
@@ -333,8 +323,8 @@ export function position(element) {
export function offset(element) {
var boundingClientRect = element.getBoundingClientRect();
return {
width: boundingClientRect.width || element.prop('offsetWidth'),
height: boundingClientRect.height || element.prop('offsetHeight'),
width: boundingClientRect.width || element.offsetWidth,
height: boundingClientRect.height || element.offsetHeight,
top: boundingClientRect.top + (window.pageYOffset || document.documentElement.scrollTop),
left: boundingClientRect.left + (window.pageXOffset || document.documentElement.scrollLeft)
};

View File

@@ -0,0 +1,51 @@
export class FeatureDetect {
run(window, document) {
this._results = {};
for (let name in featureDetects) {
this._results[name] = featureDetects[name](window, document, document.body);
}
}
has(featureName) {
return !!this._results[featureName];
}
static add(name, fn) {
featureDetects[name] = fn;
}
}
let featureDetects = {};
FeatureDetect.add('positionsticky', 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) {
/**
* Hairline Shim
* Add the "hairline" CSS class name to the body tag
* if the browser supports subpixels.
*/
let canDo = false;
if (window.devicePixelRatio >= 2) {
var hairlineEle = document.createElement('div');
hairlineEle.style.border = '.5px solid transparent';
body.appendChild(hairlineEle);
if (hairlineEle.offsetHeight === 1) {
body.classList.add('hairlines');
canDo = true;
}
body.removeChild(hairlineEle);
}
return canDo;
});

View File

@@ -1,6 +1,6 @@
import {Injectable, NgZone} from 'angular2/angular2';
import {IonicConfig} from '../config/config';
import {Config} from '../config/config';
/**
@@ -15,9 +15,9 @@ import {IonicConfig} from '../config/config';
* ```
*/
@Injectable()
export class IonicForm {
export class Form {
constructor(config: IonicConfig, zone: NgZone) {
constructor(config: Config, zone: NgZone) {
this._config = config;
this._zone = zone;

View File

@@ -1,14 +1,14 @@
import {Injectable, NgZone} from 'angular2/angular2';
import {IonicConfig} from '../config/config';
import {IonicForm} from './form';
import {Config} from '../config/config';
import {Form} from './form';
import * as dom from './dom';
@Injectable()
export class IonicKeyboard {
export class Keyboard {
constructor(config: IonicConfig, form: IonicForm, zone: NgZone) {
constructor(config: Config, form: Form, zone: NgZone) {
this.form = form;
this.zone = zone;