replace @Parent w/ @Ancestor

This commit is contained in:
Adam Bradley
2015-07-30 21:15:22 -05:00
parent b89f383ecc
commit 8794182e6c
21 changed files with 35701 additions and 30919 deletions

View File

@ -4,7 +4,6 @@ import {
ElementRef, ElementRef,
Renderer, Renderer,
Optional, Optional,
Parent,
NgControl NgControl
} from 'angular2/angular2'; } from 'angular2/angular2';

View File

@ -1,4 +1,4 @@
import {Component, Directive, View, Parent, ElementRef, forwardRef} from 'angular2/angular2'; import {Component, Directive, View, Ancestor, ElementRef, forwardRef} from 'angular2/angular2';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
import * as dom from '../../util/dom'; import * as dom from '../../util/dom';
@ -75,7 +75,7 @@ export class FocusHolder {
} }
}) })
class FocusInput { class FocusInput {
constructor(elementRef: ElementRef, @Parent() holder: FocusHolder) { constructor(elementRef: ElementRef, @Ancestor() holder: FocusHolder) {
this.elementRef = elementRef; this.elementRef = elementRef;
holder.register(this); holder.register(this);
this.holder = holder; this.holder = holder;

View File

@ -1,4 +1,4 @@
import {Directive, Parent, Optional} from 'angular2/angular2'; import {Directive, Ancestor, Optional} from 'angular2/angular2';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
import * as dom from '../../util/dom'; import * as dom from '../../util/dom';
@ -21,10 +21,10 @@ import {Switch} from '../switch/switch';
}) })
export class Label { export class Label {
constructor( constructor(
@Optional() @Parent() textContainer: Input, @Optional() @Ancestor() textContainer: Input,
@Optional() @Parent() checkboxContainer: Checkbox, @Optional() @Ancestor() checkboxContainer: Checkbox,
@Optional() @Parent() radioContainer: RadioButton, @Optional() @Ancestor() radioContainer: RadioButton,
@Optional() @Parent() switchContainer: Switch, @Optional() @Ancestor() switchContainer: Switch,
config: IonicConfig config: IonicConfig
) { ) {
this.container = textContainer || checkboxContainer || radioContainer || switchContainer; this.container = textContainer || checkboxContainer || radioContainer || switchContainer;

View File

@ -1,4 +1,4 @@
import {Parent, Ancestor, Optional, ElementRef, Attribute, Directive} from 'angular2/angular2'; import {Ancestor, Optional, ElementRef, Attribute, Directive} from 'angular2/angular2';
import {IonInput} from './input'; import {IonInput} from './input';
import {IonicApp} from '../app/app'; import {IonicApp} from '../app/app';
@ -21,8 +21,8 @@ import {RadioButton} from '../radio/radio';
}) })
export class TapInput extends IonInput { export class TapInput extends IonInput {
constructor( constructor(
@Optional() @Parent() checkboxContainer: Checkbox, @Optional() @Ancestor() checkboxContainer: Checkbox,
@Optional() @Parent() radioContainer: RadioButton, @Optional() @Ancestor() radioContainer: RadioButton,
@Optional() @Ancestor() scrollView: Content, @Optional() @Ancestor() scrollView: Content,
@Attribute('type') type: string, @Attribute('type') type: string,
elementRef: ElementRef, elementRef: ElementRef,

View File

@ -1,4 +1,4 @@
import {Directive, View, Parent, Ancestor, Optional, ElementRef, Attribute, forwardRef} from 'angular2/angular2'; import {Directive, View, Ancestor, Optional, ElementRef, Attribute, forwardRef} from 'angular2/angular2';
import {IonicDirective} from '../../config/annotations'; import {IonicDirective} from '../../config/annotations';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
@ -51,7 +51,7 @@ export class Input extends IonInputItem {
}) })
export class TextInput extends IonInput { export class TextInput extends IonInput {
constructor( constructor(
@Optional() @Parent() container: Input, @Optional() @Ancestor() container: Input,
@Optional() @Ancestor() scrollView: Content, @Optional() @Ancestor() scrollView: Content,
@Attribute('type') type: string, @Attribute('type') type: string,
elementRef: ElementRef, elementRef: ElementRef,

View File

@ -1,4 +1,4 @@
import {Directive, View, CSSClass, ElementRef, Optional, Parent, Attribute} from 'angular2/angular2'; import {Directive, View, CSSClass, ElementRef, Optional, Ancestor, Attribute} from 'angular2/angular2';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
import {IonicComponent} from '../../config/annotations'; import {IonicComponent} from '../../config/annotations';
@ -66,7 +66,7 @@ Custom Font Icon
export class IconDirective { export class IconDirective {
constructor( constructor(
elementRef: ElementRef, elementRef: ElementRef,
@Optional() @Parent() parentButton: Button, @Optional() @Ancestor() AncestorButton: Button,
@Attribute('forward') forward: string, @Attribute('forward') forward: string,
config: IonicConfig config: IonicConfig
) { ) {
@ -79,7 +79,7 @@ export class IconDirective {
this.fwdIcon = config.setting('forwardIcon'); this.fwdIcon = config.setting('forwardIcon');
} }
if (parentButton) { if (AncestorButton) {
// this icon is within a button // this icon is within a button
this.withinButton = true; this.withinButton = true;
@ -97,7 +97,7 @@ export class IconDirective {
// tell the button there's a child icon // tell the button there's a child icon
// the button will set the correct css classes on itself // the button will set the correct css classes on itself
parentButton.registerIcon(this); AncestorButton.registerIcon(this);
} }
} }

View File

@ -1,7 +1,8 @@
import {ElementRef, Parent} from 'angular2/angular2' import {ElementRef, Ancestor, Directive} from 'angular2/angular2';
import {Directive} from 'angular2/angular2';
import {Item} from 'ionic/components/item/item' import {Item} from 'ionic/components/item/item';
import {SlideGesture} from 'ionic/gestures/slide-gesture' import {SlideGesture} from 'ionic/gestures/slide-gesture';
@Directive({ @Directive({
selector: 'ion-primary-swipe-buttons' selector: 'ion-primary-swipe-buttons'
@ -9,11 +10,11 @@ import {SlideGesture} from 'ionic/gestures/slide-gesture'
export class ItemPrimarySwipeButtons { export class ItemPrimarySwipeButtons {
constructor( constructor(
elementRef: ElementRef, elementRef: ElementRef,
@Parent() item: Item @Ancestor() item: Item
) { ) {
item.primarySwipeButtons = this item.primarySwipeButtons = this
this.ele = elementRef.nativeElement this.ele = elementRef.nativeElement
this.parentItem = item this.AncestorItem = item
this.gesture = new ItemSlideGesture(this) this.gesture = new ItemSlideGesture(this)
this.gesture.listen() this.gesture.listen()
} }
@ -36,7 +37,7 @@ export class ItemSecondarySwipeButtons {
class ItemSlideGesture extends SlideGesture { class ItemSlideGesture extends SlideGesture {
constructor(buttons) { constructor(buttons) {
super(buttons.parentItem.ele) super(buttons.AncestorItem.ele)
this.buttons = buttons this.buttons = buttons
} }

View File

@ -1,5 +1,5 @@
import {ProtoViewRef, ViewContainerRef} from 'angular2/angular2' import {ProtoViewRef, ViewContainerRef} from 'angular2/angular2'
import {Directive, Parent, forwardRef} from 'angular2/angular2'; import {Directive, Ancestor, forwardRef} from 'angular2/angular2';
import {App, List} from 'ionic/ionic'; import {App, List} from 'ionic/ionic';
@ -31,7 +31,7 @@ class IonicApp {
selector: 'template[cell]' selector: 'template[cell]'
}) })
export class ItemCellTemplate { export class ItemCellTemplate {
constructor(@Parent() list: List, viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef) { constructor(@Ancestor() list: List, viewContainer: ViewContainerRef, protoViewRef: ProtoViewRef) {
console.log('Item cell template', list, viewContainer, protoViewRef); console.log('Item cell template', list, viewContainer, protoViewRef);
this.protoViewRef = protoViewRef; this.protoViewRef = protoViewRef;

View File

@ -1,4 +1,4 @@
import {Directive, View, Parent, Optional, ElementRef, forwardRef} from 'angular2/angular2'; import {Directive, View, Ancestor, Optional, ElementRef, forwardRef} from 'angular2/angular2';
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref'; import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
import {ToolbarBase} from '../toolbar/toolbar'; import {ToolbarBase} from '../toolbar/toolbar';
@ -88,7 +88,7 @@ export class Navbar extends ToolbarBase {
} }
}) })
class BackButton { class BackButton {
constructor(@Parent() navbar: Navbar, @Optional() item: ViewItem, elementRef: ElementRef) { constructor(@Ancestor() navbar: Navbar, @Optional() item: ViewItem, elementRef: ElementRef) {
this.item = item; this.item = item;
navbar.backButtonElement(elementRef); navbar.backButtonElement(elementRef);
} }
@ -104,7 +104,7 @@ class BackButton {
selector: '.back-button-text' selector: '.back-button-text'
}) })
class BackButtonText { class BackButtonText {
constructor(@Parent() navbar: Navbar, elementRef: ElementRef) { constructor(@Ancestor() navbar: Navbar, elementRef: ElementRef) {
navbar.backButtonTextElement(elementRef); navbar.backButtonTextElement(elementRef);
} }
} }
@ -113,7 +113,7 @@ class BackButtonText {
selector: '.toolbar-title' selector: '.toolbar-title'
}) })
class Title { class Title {
constructor(@Parent() toolbar: Navbar, elementRef: ElementRef) { constructor(@Ancestor() toolbar: Navbar, elementRef: ElementRef) {
toolbar.titleElement(elementRef); toolbar.titleElement(elementRef);
} }
} }
@ -122,7 +122,7 @@ class Title {
selector: '.toolbar-item' selector: '.toolbar-item'
}) })
class NavbarItem { class NavbarItem {
constructor(@Parent() toolbar: Navbar, elementRef: ElementRef) { constructor(@Ancestor() toolbar: Navbar, elementRef: ElementRef) {
toolbar.itemElements(elementRef); toolbar.itemElements(elementRef);
} }
} }

View File

@ -1,4 +1,4 @@
import {Component, View, Directive, Parent, ElementRef, forwardRef, Inject} from 'angular2/angular2'; import {Component, View, Directive, Ancestor, ElementRef, forwardRef, Inject} from 'angular2/angular2';
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref'; import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
import {Pane} from './pane'; import {Pane} from './pane';
@ -8,7 +8,7 @@ import {ViewController} from '../view/view-controller';
@Directive({selector: 'template[pane-anchor]'}) @Directive({selector: 'template[pane-anchor]'})
export class PaneAnchor { export class PaneAnchor {
constructor( constructor(
@Parent() @Inject(forwardRef(() => Pane)) pane: Pane, @Ancestor() @Inject(forwardRef(() => Pane)) pane: Pane,
elementRef: ElementRef elementRef: ElementRef
) { ) {
pane.sectionAnchorElementRef = elementRef; pane.sectionAnchorElementRef = elementRef;
@ -19,7 +19,7 @@ export class PaneAnchor {
@Directive({selector: 'template[content-anchor]'}) @Directive({selector: 'template[content-anchor]'})
export class PaneContentAnchor { export class PaneContentAnchor {
constructor( constructor(
@Parent() @Inject(forwardRef(() => Pane)) pane: Pane, @Ancestor() @Inject(forwardRef(() => Pane)) pane: Pane,
viewContainerRef: ViewContainerRef viewContainerRef: ViewContainerRef
) { ) {
pane.contentContainerRef = viewContainerRef; pane.contentContainerRef = viewContainerRef;

View File

@ -1,4 +1,4 @@
import {Directive, View, ElementRef, Parent, Optional, forwardRef, Injector} from 'angular2/angular2'; import {Directive, View, ElementRef, Ancestor, Optional, forwardRef, Injector} from 'angular2/angular2';
import {IonicComponent} from '../../config/annotations'; import {IonicComponent} from '../../config/annotations';
import {ViewController} from '../view/view-controller'; import {ViewController} from '../view/view-controller';
@ -20,11 +20,11 @@ import {ViewController} from '../view/view-controller';
export class Nav extends ViewController { export class Nav extends ViewController {
constructor( constructor(
@Optional() parentViewCtrl: ViewController, @Optional() AncestorViewCtrl: ViewController,
injector: Injector, injector: Injector,
elementRef: ElementRef elementRef: ElementRef
) { ) {
super(parentViewCtrl, injector, elementRef); super(AncestorViewCtrl, injector, elementRef);
} }
onIonInit() { onIonInit() {
@ -42,7 +42,7 @@ export class Nav extends ViewController {
@Directive({selector: 'template[pane-anchor]'}) @Directive({selector: 'template[pane-anchor]'})
class NavPaneAnchor { class NavPaneAnchor {
constructor(@Parent() nav: Nav, elementRef: ElementRef) { constructor(@Ancestor() nav: Nav, elementRef: ElementRef) {
nav.anchorElementRef(elementRef); nav.anchorElementRef(elementRef);
} }
} }

View File

@ -1,4 +1,4 @@
import {ElementRef, Directive, Parent, Optional, Inject, forwardRef, NgZone} from 'angular2/angular2'; import {ElementRef, Directive, Ancestor, Optional, Inject, forwardRef, NgZone} from 'angular2/angular2';
import {ViewController} from '../view/view-controller'; import {ViewController} from '../view/view-controller';
import {Pane} from './pane'; import {Pane} from './pane';
@ -14,7 +14,7 @@ import {Gesture} from 'ionic/gestures/gesture';
export class SwipeHandle { export class SwipeHandle {
constructor( constructor(
@Optional() @Inject(forwardRef(() => ViewController)) viewCtrl: ViewController, @Optional() @Inject(forwardRef(() => ViewController)) viewCtrl: ViewController,
@Parent() @Inject(forwardRef(() => Pane)) pane: Pane, @Ancestor() @Inject(forwardRef(() => Pane)) pane: Pane,
elementRef: ElementRef, elementRef: ElementRef,
ngZone: NgZone ngZone: NgZone
) { ) {

View File

@ -1,4 +1,4 @@
import {Component, View, NgIf, CSSClass, ElementRef, EventEmitter, Parent, onInit} from 'angular2/angular2' import {Component, View, NgIf, CSSClass, ElementRef, EventEmitter, Ancestor, onInit} from 'angular2/angular2'
import {Content} from '../content/content'; import {Content} from '../content/content';
@ -39,7 +39,7 @@ import {raf, ready, CSS} from 'ionic/util/dom';
}) })
export class Refresher { export class Refresher {
constructor( constructor(
@Parent() content: Content, @Ancestor() content: Content,
element: ElementRef element: ElementRef
) { ) {
this.ele = element.nativeElement; this.ele = element.nativeElement;
@ -71,7 +71,7 @@ export class Refresher {
this.startY = null; this.startY = null;
this.deltaY = null; this.deltaY = null;
this.canOverscroll = true; this.canOverscroll = true;
this.scrollParent = sp; this.scrollAncestor = sp;
this.scrollChild = sc; this.scrollChild = sc;
util.defaults(this, { util.defaults(this, {
@ -248,7 +248,7 @@ export class Refresher {
// kitkat fix for touchcancel events http://updates.html5rocks.com/2014/05/A-More-Compatible-Smoother-Touch // kitkat fix for touchcancel events http://updates.html5rocks.com/2014/05/A-More-Compatible-Smoother-Touch
/* /*
if (ionic.Platform.isAndroid() && ionic.Platform.version() === 4.4 && scrollParent.scrollTop === 0) { if (ionic.Platform.isAndroid() && ionic.Platform.version() === 4.4 && scrollAncestor.scrollTop === 0) {
isDragging = true; isDragging = true;
e.preventDefault(); e.preventDefault();
} }
@ -260,7 +260,7 @@ export class Refresher {
// if we've dragged up and back down in to native scroll territory // if we've dragged up and back down in to native scroll territory
if (this.deltaY - this.dragOffset <= 0 || this.scrollParent.scrollTop !== 0) { if (this.deltaY - this.dragOffset <= 0 || this.scrollAncestor.scrollTop !== 0) {
if (this.isOverscrolling) { if (this.isOverscrolling) {
this.isOverscrolling = false; this.isOverscrolling = false;
@ -268,7 +268,7 @@ export class Refresher {
} }
if (this.isDragging) { if (this.isDragging) {
this.nativescroll(this.scrollParent, parseInt(this.deltaY - this.dragOffset, 10) * -1); this.nativescroll(this.scrollAncestor, parseInt(this.deltaY - this.dragOffset, 10) * -1);
} }
// if we're not at overscroll 0 yet, 0 out // if we're not at overscroll 0 yet, 0 out
@ -277,7 +277,7 @@ export class Refresher {
} }
return; return;
} else if (this.deltaY > 0 && this.scrollParent.scrollTop === 0 && !this.isOverscrolling) { } else if (this.deltaY > 0 && this.scrollAncestor.scrollTop === 0 && !this.isOverscrolling) {
// starting overscroll, but drag started below scrollTop 0, so we need to offset the position // starting overscroll, but drag started below scrollTop 0, so we need to offset the position
this.dragOffset = this.deltaY; this.dragOffset = this.deltaY;
} }

View File

@ -4,7 +4,6 @@ import {
ElementRef, ElementRef,
Renderer, Renderer,
Optional, Optional,
Parent,
NgControl NgControl
} from 'angular2/angular2'; } from 'angular2/angular2';

View File

@ -1,4 +1,4 @@
import {Directive, Component, View, onInit, Parent, ElementRef, forwardRef, Injector} from 'angular2/angular2'; import {Directive, Component, View, onInit, Ancestor, ElementRef, forwardRef, Injector} from 'angular2/angular2';
import {ViewController} from '../view/view-controller'; import {ViewController} from '../view/view-controller';
import {ViewItem} from '../view/view-item'; import {ViewItem} from '../view/view-item';
@ -27,19 +27,19 @@ import {Tabs} from './tabs';
export class Tab extends ViewController { export class Tab extends ViewController {
constructor( constructor(
@Parent() tabs: Tabs, @Ancestor() tabs: Tabs,
elementRef: ElementRef, elementRef: ElementRef,
injector: Injector injector: Injector
) { ) {
// A Tab is both a container of many views, and is a view itself. // A Tab is both a container of many views, and is a view itself.
// A Tab is one ViewItem within it's parent Tabs (which extends ViewController) // A Tab is one ViewItem within it's Ancestor Tabs (which extends ViewController)
// A Tab is a ViewController for its child ViewItems // A Tab is a ViewController for its child ViewItems
super(tabs, injector, elementRef); super(tabs, injector, elementRef);
this.tabs = tabs; this.tabs = tabs;
this.childNavbar(true); this.childNavbar(true);
let item = this.item = new ViewItem(tabs.parent); let item = this.item = new ViewItem(tabs.Ancestor);
item.setInstance(this); item.setInstance(this);
item.viewElement(elementRef.nativeElement); item.viewElement(elementRef.nativeElement);
tabs.addTab(this); tabs.addTab(this);
@ -105,7 +105,7 @@ export class Tab extends ViewController {
selector: 'template[pane-anchor]' selector: 'template[pane-anchor]'
}) })
class TabPaneAnchor { class TabPaneAnchor {
constructor(@Parent() tab: Tab, elementRef: ElementRef) { constructor(@Ancestor() tab: Tab, elementRef: ElementRef) {
tab.anchorElementRef(elementRef); tab.anchorElementRef(elementRef);
} }
} }

View File

@ -1,4 +1,4 @@
import {Component, Directive, View, Injector, NgFor, ElementRef, Optional, Parent, forwardRef} from 'angular2/angular2'; import {Component, Directive, View, Injector, NgFor, ElementRef, Optional, Ancestor, forwardRef} from 'angular2/angular2';
import {ViewController} from '../view/view-controller'; import {ViewController} from '../view/view-controller';
import {ViewItem} from '../view/view-item'; import {ViewItem} from '../view/view-item';
@ -30,12 +30,12 @@ import {IonicComponent, IonicView} from '../../config/annotations';
}) })
export class Tabs extends ViewController { export class Tabs extends ViewController {
constructor( constructor(
@Optional() parentViewCtrl: ViewController, @Optional() AncestorViewCtrl: ViewController,
@Optional() viewItem: ViewItem, @Optional() viewItem: ViewItem,
injector: Injector, injector: Injector,
elementRef: ElementRef elementRef: ElementRef
) { ) {
super(parentViewCtrl, injector, elementRef); super(AncestorViewCtrl, injector, elementRef);
// Tabs may also be an actual ViewItem which was navigated to // Tabs may also be an actual ViewItem which was navigated to
// if Tabs is static and not navigated to within a ViewController // if Tabs is static and not navigated to within a ViewController
@ -126,7 +126,7 @@ export class Tabs extends ViewController {
} }
}) })
class TabButton { class TabButton {
constructor(@Parent() tabs: Tabs) { constructor(@Ancestor() tabs: Tabs) {
this.tabs = tabs; this.tabs = tabs;
} }

View File

@ -1,4 +1,4 @@
import {Directive, View, Parent, onInit, ElementRef, forwardRef} from 'angular2/angular2'; import {Directive, View, Ancestor, onInit, ElementRef, forwardRef} from 'angular2/angular2';
import {Ion} from '../ion'; import {Ion} from '../ion';
import {IonicConfig} from '../../config/config'; import {IonicConfig} from '../../config/config';
@ -120,7 +120,7 @@ export class Toolbar extends ToolbarBase {
selector: '.toolbar-title' selector: '.toolbar-title'
}) })
class ToolbarTitle { class ToolbarTitle {
constructor(@Parent() toolbar: Toolbar, elementRef: ElementRef) { constructor(@Ancestor() toolbar: Toolbar, elementRef: ElementRef) {
toolbar.titleElement(elementRef); toolbar.titleElement(elementRef);
} }
} }
@ -130,7 +130,7 @@ class ToolbarTitle {
selector: '.toolbar-item' selector: '.toolbar-item'
}) })
class ToolbarItem { class ToolbarItem {
constructor(@Parent() toolbar: Toolbar, elementRef: ElementRef) { constructor(@Ancestor() toolbar: Toolbar, elementRef: ElementRef) {
toolbar.itemElements(elementRef); toolbar.itemElements(elementRef);
} }
} }

View File

@ -1,8 +1,4 @@
import {ElementRef, For, Parent, onInit} from 'angular2/angular2' import {onInit, Directive} from 'angular2/angular2';
import {Component, Directive} from 'angular2/angular2';
import {FormBuilder, Validators, FormDirectives, ControlGroup} from 'angular2/forms';
import {Log} from 'ionic/util'
import {IonicApp} from 'ionic/ionic' import {IonicApp} from 'ionic/ionic'

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

22
scripts/resources/angular2.min.js vendored Normal file

File diff suppressed because one or more lines are too long