use IonicComponent

This commit is contained in:
Adam Bradley
2015-04-22 16:56:57 -05:00
parent f34d314ae2
commit cdd62e98b9
10 changed files with 70 additions and 76 deletions

View File

@ -1,13 +1,11 @@
import {NgElement, Component, Template, Parent} from 'angular2/angular2' import {NgElement, Component, Template, Parent} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config' import {IonicComponent} from 'ionic2/config/component'
import {Icon} from 'ionic2/components/icon/icon' import {Icon} from 'ionic2/components/icon/icon'
import {Item} from 'ionic2/components/item/item' import {Item} from 'ionic2/components/item/item'
export let ActionMenuConfig = new ComponentConfig('action-menu')
@Component({ @Component({
selector: 'ion-action-menu', selector: 'ion-action-menu'
services: [ActionMenuConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -41,10 +39,11 @@ export let ActionMenuConfig = new ComponentConfig('action-menu')
}) })
export class ActionMenu { export class ActionMenu {
constructor( constructor(
configFactory: ActionMenuConfig,
@NgElement() ngElement:NgElement @NgElement() ngElement:NgElement
) { ) {
this.domElement = ngElement.domElement this.domElement = ngElement.domElement
this.config = configFactory.create(this) this.config = ActionMenu.config.invoke(this)
} }
} }
new IonicComponent(ActionMenu, {})

View File

@ -1,8 +1,6 @@
import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2' import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'
import {IonicComponent} from 'ionic2/config/component' import {IonicComponent} from 'ionic2/config/component'
export let CheckboxConfig = new ComponentConfig('checkbox')
@Component({ @Component({
selector: 'ion-checkbox', selector: 'ion-checkbox',
@ -11,8 +9,7 @@ export let CheckboxConfig = new ComponentConfig('checkbox')
}, },
events: { events: {
'^click': 'onClick()' '^click': 'onClick()'
}, }
services: [CheckboxConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -31,7 +28,6 @@ export let CheckboxConfig = new ComponentConfig('checkbox')
}) })
export class Checkbox { export class Checkbox {
constructor( constructor(
configFactory: CheckboxConfig,
@NgElement() ngElement: NgElement, @NgElement() ngElement: NgElement,
@PropertySetter('attr.role') setAriaRole: Function, @PropertySetter('attr.role') setAriaRole: Function,
@PropertySetter('attr.aria-checked') setAriaChecked: Function, @PropertySetter('attr.aria-checked') setAriaChecked: Function,

View File

@ -1,21 +1,20 @@
import {NgElement, Component, Template} from 'angular2/angular2' import {NgElement, Component, Template} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'; import {IonicComponent} from 'ionic2/config/component'
export let ListConfig = new ComponentConfig('list')
@Component({ @Component({
selector: 'ion-list', selector: 'ion-list'
services: [ListConfig]
}) })
@Template({ @Template({
inline: `<content></content>` inline: `<content></content>`
}) })
export class List { export class List {
constructor( constructor(
configFactory: ListConfig,
ngElement: NgElement ngElement: NgElement
) { ) {
this.domElement = ngElement.domElement; this.domElement = ngElement.domElement;
configFactory.create(this); this.config = List.config.invoke(this)
} }
} }
new IonicComponent(List, {})

View File

@ -1,5 +1,4 @@
import {Component, Template, For, NgElement, bind} from 'angular2/angular2' import {Component, Template, For, NgElement, bind} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'
import {NavPane} from 'ionic2/components/nav-pane/nav-pane' import {NavPane} from 'ionic2/components/nav-pane/nav-pane'
import * as util from 'ionic2/util' import * as util from 'ionic2/util'

View File

@ -1,11 +1,9 @@
import {NgElement, Component, Template} from 'angular2/angular2' import {NgElement, Component, Template} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'; import {IonicComponent} from 'ionic2/config/component'
export let RadioConfig = new ComponentConfig('radio');
@Component({ @Component({
selector: 'ion-radio', selector: 'ion-radio'
services: [RadioConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -25,13 +23,14 @@ export let RadioConfig = new ComponentConfig('radio');
}) })
export class RadioButton { export class RadioButton {
constructor( constructor(
configFactory: RadioConfig,
element: NgElement element: NgElement
) { ) {
this.domElement = element.domElement this.domElement = element.domElement
this.config = RadioButton.config.invoke(this)
this.domElement.classList.add('item') this.domElement.classList.add('item')
this.domElement.setAttribute('aria-checked', true) this.domElement.setAttribute('aria-checked', true)
}
}
configFactory.create(this) new IonicComponent(RadioButton, {})
}
}

View File

@ -1,23 +1,22 @@
import {NgElement, Component, Template} from 'angular2/angular2' import {NgElement, Component, Template} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'; import {IonicComponent} from 'ionic2/config/component'
export let RadioConfig = new ComponentConfig('radio');
@Component({ @Component({
selector: 'ion-radio-group', selector: 'ion-radio-group'
services: [RadioConfig]
}) })
@Template({ @Template({
inline: `<content></content>` inline: `<content></content>`
}) })
export class RadioGroup { export class RadioGroup {
constructor( constructor(
configFactory: RadioConfig,
element: NgElement element: NgElement
) { ) {
this.domElement = element.domElement this.domElement = element.domElement
this.config = RadioGroup.config.invoke(this)
this.domElement.classList.add('list') this.domElement.classList.add('list')
this.domElement.classList.add('radio-group')
configFactory.create(this)
} }
} }
new IonicComponent(RadioGroup, {})

View File

@ -1,33 +1,44 @@
import {NgElement, Component, Template} from 'angular2/angular2' import {NgElement, Component, Template} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config'; import {IonicComponent} from 'ionic2/config/component'
export let SearchBarConfig = new ComponentConfig('search-bar')
@Component({ @Component({
selector: 'ion-search-bar', selector: 'ion-search-bar',
bind: { bind: {
cancelText: 'cancel-text', cancelText: 'cancel-text',
placeholderText: 'placeholder-text' placeholderText: 'placeholder-text'
}, }
services: [SearchBarConfig]
}) })
@Template({ @Template({
inline: `<div class="search-bar-input-container"> inline: `<div class="search-bar-input-container">
<input class="search-bar-input" type="search" [placeholder]="placeholderText"> <input class="search-bar-input" type="search" [attr.placeholder]="placeholderText">
</div> </div>
<button class="button search-bar-cancel">{{ cancelText }}</button>` <button class="button search-bar-cancel">{{ cancelText }}</button>`
}) })
export class SearchBar { export class SearchBar {
constructor( constructor(
configFactory: SearchBarConfig,
ngElement: NgElement ngElement: NgElement
) { ) {
this.domElement = ngElement.domElement; this.domElement = ngElement.domElement
configFactory.create(this); this.config = SearchBar.config.invoke(this)
// Defaults
this.cancelText = this.cancelText || 'Cancel'
this.placeholderText = this.placeholderText || 'Search'
} }
} }
new IonicComponent(SearchBar, {
bind: {
cancelText: {
defaults: {
ios: 'Cancel',
android: 'Cancel',
core: 'Cancel'
}
},
placeholderText: {
defaults: {
ios: 'Search',
android: 'Search',
core: 'Search'
}
}
}
})

View File

@ -1,7 +1,6 @@
import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2' import {Component, Template, NgElement, PropertySetter} from 'angular2/angular2'
import {ComponentConfig} from 'ionic2/config/component-config' import {IonicComponent} from 'ionic2/config/component'
export let SwitchConfig = new ComponentConfig('switch')
@Component({ @Component({
selector: 'ion-switch', selector: 'ion-switch',
@ -10,8 +9,7 @@ export let SwitchConfig = new ComponentConfig('switch')
}, },
events: { events: {
'click': 'onClick()' 'click': 'onClick()'
}, }
services: [SwitchConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -29,30 +27,27 @@ export let SwitchConfig = new ComponentConfig('switch')
}) })
export class Switch { export class Switch {
constructor( constructor(
configFactory: SwitchConfig,
element: NgElement, element: NgElement,
@PropertySetter('attr.role') setAriaRole: Function, @PropertySetter('attr.role') setAriaRole: Function,
@PropertySetter('attr.aria-checked') setAriaChecked: Function, @PropertySetter('attr.aria-checked') setChecked: Function,
@PropertySetter('attr.aria-invalid') setAriaInvalid: Function, @PropertySetter('attr.aria-invalid') setInvalid: Function,
@PropertySetter('attr.aria-disabled') setAriaDisabled: Function @PropertySetter('attr.aria-disabled') setDisabled: Function
) { ) {
this.domElement = element.domElement this.domElement = element.domElement
this.config = Switch.config.invoke(this)
this.domElement.classList.add('item') this.domElement.classList.add('item')
this.config = configFactory.create(this)
setAriaRole('checkbox') setAriaRole('checkbox')
setAriaInvalid('false') setInvalid('false')
setAriaDisabled('false') setDisabled('false')
this.setAriaRole = setAriaRole this.setChecked = setChecked
this.setAriaChecked = setAriaChecked
this.setAriaInvalid = setAriaInvalid
this.setAriaDisabled = setAriaDisabled
} }
set checked(checked) { set checked(checked) {
this._checked = checked this._checked = checked
this.setAriaChecked(checked) this.setChecked(checked)
} }
get checked() { get checked() {
return this._checked return this._checked
@ -62,3 +57,4 @@ export class Switch {
} }
} }
new IonicComponent(Switch, {})

View File

@ -1,17 +1,14 @@
import {NgElement, Component, Template, Ancestor} from 'angular2/angular2' import {NgElement, Component, Template, Ancestor} from 'angular2/angular2'
import {Optional} from 'angular2/src/di/annotations' import {Optional} from 'angular2/src/di/annotations'
import {BackButton} from 'ionic2/components/toolbar/back-button' import {BackButton} from 'ionic2/components/toolbar/back-button'
import {ComponentConfig} from 'ionic2/config/component-config' import {IonicComponent} from 'ionic2/config/component'
import {raf} from 'ionic2/util/dom' import {raf} from 'ionic2/util/dom'
export let ToolbarConfig = new ComponentConfig('toolbar')
@Component({ @Component({
selector: 'ion-toolbar', selector: 'ion-toolbar',
bind: { bind: {
title: 'nav-title' title: 'nav-title'
}, }
services: [ToolbarConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -35,12 +32,10 @@ export let ToolbarConfig = new ComponentConfig('toolbar')
}) })
export class Toolbar { export class Toolbar {
constructor( constructor(
@NgElement() ngEle:NgElement, @NgElement() ngEle:NgElement
configFactory: ToolbarConfig
) { ) {
this.domElement = ngEle.domElement this.domElement = ngEle.domElement
this.config = Toolbar.config.invoke(this)
this.config = configFactory.create(this);
// TODO: make more better plz // TODO: make more better plz
setTimeout(() => { setTimeout(() => {
@ -88,3 +83,5 @@ export class Toolbar {
} }
} }
new IonicComponent(Toolbar, {})

View File

@ -1,15 +1,13 @@
import {NgElement, Component, Template, Parent, Ancestor} from 'angular2/angular2' import {NgElement, Component, Template, Parent, Ancestor} from 'angular2/angular2'
import {Toolbar} from 'ionic2/components/toolbar/toolbar' import {Toolbar} from 'ionic2/components/toolbar/toolbar'
import {ComponentConfig} from 'ionic2/config/component-config' import {IonicComponent} from 'ionic2/config/component'
export let ViewConfig = new ComponentConfig('view')
@Component({ @Component({
selector: 'ion-view', selector: 'ion-view',
bind: { bind: {
title: 'nav-title' title: 'nav-title'
}, }
services: [ViewConfig]
}) })
@Template({ @Template({
inline: ` inline: `
@ -23,13 +21,12 @@ export let ViewConfig = new ComponentConfig('view')
}) })
export class View { export class View {
constructor( constructor(
configFactory: ViewConfig,
@NgElement() ngElement:NgElement @NgElement() ngElement:NgElement
) { ) {
this.domElement = ngElement.domElement this.domElement = ngElement.domElement
this.domElement.classList.add('pane') this.config = View.config.invoke(this)
this.config = configFactory.create(this)
this.domElement.classList.add('pane')
/*** TODO: MAKE MORE GOOD!! HACK HACK HACK!!!!!!!!! *****/ /*** TODO: MAKE MORE GOOD!! HACK HACK HACK!!!!!!!!! *****/
@ -67,3 +64,5 @@ export class View {
} }
} }
new IonicComponent(View, {})