update to use host

This commit is contained in:
Adam Bradley
2015-06-22 13:05:47 -05:00
parent 43042ed999
commit e81a78e9d6
13 changed files with 46 additions and 59 deletions

View File

@ -42,8 +42,8 @@ export class ActionMenu extends Overlay {
static get config() { static get config() {
return { return {
selector: 'ion-action-menu', selector: 'ion-action-menu',
hostProperties: { host: {
'zIndex': 'style.z-index' '[style.z-index]': 'zIndex'
} }
} }
} }

View File

@ -7,10 +7,8 @@ import {ElementRef} from 'angular2/src/core/compiler/element_ref';
properties: [ properties: [
'name' 'name'
], ],
hostProperties: { host: {
'label': 'attr.aria-label' '[attr.aria-label]': 'label'
},
hostAttributes: {
'role': 'img' 'role': 'img'
}, },
lifecycle: [onInit] lifecycle: [onInit]

View File

@ -7,8 +7,8 @@ export class Modal extends Overlay {
static get config() { static get config() {
return { return {
selector: 'ion-modal', selector: 'ion-modal',
hostProperties: { host: {
'zIndex': 'style.z-index' '[style.z-index]': 'zIndex'
} }
} }
} }

View File

@ -133,8 +133,8 @@ export class Navbar {
@Directive({ @Directive({
selector: '.back-button', selector: '.back-button',
hostListeners: { host: {
'^click': 'goBack($event)' '(^click)': 'goBack($event)'
} }
}) })
class BackButton { class BackButton {

View File

@ -10,14 +10,12 @@ import {NavController} from './nav-controller';
@Directive({ @Directive({
selector: '[nav-push]', selector: '[nav-push]',
hostListeners: {
'^click': 'onClick($event)'
},
properties: [ properties: [
'navPush', 'navPush',
'pushData' 'pushData'
], ],
hostAttributes: { host: {
'(^click)': 'onClick($event)',
'role': 'link' 'role': 'link'
} }
}) })
@ -33,10 +31,8 @@ export class NavPush {
@Directive({ @Directive({
selector: '[nav-pop]', selector: '[nav-pop]',
hostListeners: { host: {
'^click': 'onClick($event)' '(^click)': 'onClick($event)',
},
hostAttributes: {
'role': 'link' 'role': 'link'
} }
}) })

View File

@ -139,7 +139,7 @@ class PaneContentAnchor {
@Component({ @Component({
selector: 'section', selector: 'section',
hostAttributes: { host: {
'class': 'navbar-container' 'class': 'navbar-container'
} }
}) })

View File

@ -10,8 +10,8 @@ import {Gesture} from 'ionic/gestures/gesture';
@Directive({ @Directive({
selector: '.swipe-handle', selector: '.swipe-handle',
hostProperties: { host: {
'showHandle()': 'class.show-handle' '[class.show-handle]': 'showHandle()'
} }
}) })
export class SwipeHandle { export class SwipeHandle {

View File

@ -109,12 +109,12 @@ export class RadioButton {
static get config() { static get config() {
return { return {
selector: 'ion-radio', selector: 'ion-radio',
hostListeners: {
'^click': 'buttonClicked($event)'
},
properties: [ properties: [
'value' 'value'
] ],
host: {
'(^click)': 'buttonClicked($event)'
}
} }
} }

View File

@ -23,14 +23,12 @@ export class Segment {
return { return {
selector: 'ion-segment', selector: 'ion-segment',
appInjector: [ControlDirective], appInjector: [ControlDirective],
hostListeners: {
'click': 'buttonClicked($event)'
},
properties: [ properties: [
'value' 'value'
], ],
hostProperties: { host: {
value: 'value' '(click)': 'buttonClicked($event)',
'[value]': 'value'
} }
} }
} }
@ -113,17 +111,14 @@ export class Segment {
} }
@Component({ @Directive({
selector: 'ion-segment-button', selector: 'ion-segment-button',
hostListeners: {
'click': 'buttonClicked($event)'
},
properties: [ properties: [
'value' 'value'
] ],
}) host: {
@View({ '(click)': 'buttonClicked($event)'
template: '<content></content>' }
}) })
export class SegmentButton { export class SegmentButton {
constructor( constructor(

View File

@ -26,8 +26,8 @@ export class Switch {
properties: [ properties: [
'checked' 'checked'
], ],
hostListeners: { host: {
'click': 'switchClicked($event)' '(click)': 'switchClicked($event)'
} }
} }
} }

View File

@ -7,13 +7,11 @@ import {Tabs} from './tabs';
@Directive({ @Directive({
selector: 'button.tab-button', selector: 'button.tab-button',
properties: ['tab'], properties: ['tab'],
hostProperties: { host: {
'btnId': 'attr.id', '[attr.id]': 'btnId',
'panelId': 'attr.aria-controls', '[attr.aria-controls]': 'panelId',
'tab.isSelected': 'attr.aria-selected' '[attr.aria-selected]': 'tab.isSelected',
}, '(^click)': 'onClick($event)'
hostListeners: {
'^click': 'onClick($event)'
}, },
lifecycle: [onInit] lifecycle: [onInit]
}) })

View File

@ -20,13 +20,11 @@ import {Content} from '../content/content';
'tabTitle', 'tabTitle',
'tabIcon' 'tabIcon'
], ],
hostProperties: { host: {
'panelId': 'attr.id', '[attr.id]': 'panelId',
'labeledBy': 'attr.aria-labelledby', '[attr.aria-labelledby]': 'labeledBy',
'!isSelected': 'attr.aria-hidden', '[attr.aria-hidden]': '!isSelected',
'isSelected': 'class.tab-selected' '[class.tab-selected]': 'isSelected',
},
hostAttributes: {
'role': 'tabpanel' 'role': 'tabpanel'
} }
}) })

View File

@ -1,4 +1,5 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations'; import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {DirectiveMetadata} from 'angular2/src/render/api';
import * as util from 'ionic/util'; import * as util from 'ionic/util';
import {Platform} from 'ionic/platform/platform'; import {Platform} from 'ionic/platform/platform';
@ -20,10 +21,13 @@ export class IonicComponent extends Component {
function appendModeConfig(ComponentType) { function appendModeConfig(ComponentType) {
let config = ComponentType.config; let config = ComponentType.config;
config.host = config.host || {};
// let host = DirectiveMetadata.parseHostConfig(config.host);
const defaultProperties = config.defaultProperties; const defaultProperties = config.defaultProperties;
config.properties = config.properties || []; config.properties = config.properties || [];
config.hostProperties = config.hostProperties || {};
for (let prop in defaultProperties) { for (let prop in defaultProperties) {
// add the property to the component "properties" // add the property to the component "properties"
@ -31,7 +35,7 @@ function appendModeConfig(ComponentType) {
// set the component "hostProperties", so the instance's // set the component "hostProperties", so the instance's
// property value will be used to set the element's attribute // property value will be used to set the element's attribute
config.hostProperties[prop] = 'attr.' + util.pascalCaseToDashCase(prop); config.host['[attr.' + util.pascalCaseToDashCase(prop)] = prop;
} }
// called by the component's onInit when an instance has been created and properties bound // called by the component's onInit when an instance has been created and properties bound
@ -88,10 +92,8 @@ function appendModeConfig(ComponentType) {
}; };
} }
config.hostAttributes = config.hostAttributes || {};
let className = (config.hostAttributes['class'] || '');
let id = config.classId || config.selector.replace('ion-', ''); let id = config.classId || config.selector.replace('ion-', '');
config.hostAttributes['class'] = (className + ' ' + id + ' ' + id + '-' + platformMode).trim(); config.host['class'] = (id + ' ' + id + '-' + platformMode);
return config; return config;
} }