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() {
return {
selector: 'ion-action-menu',
hostProperties: {
'zIndex': 'style.z-index'
host: {
'[style.z-index]': 'zIndex'
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {DirectiveMetadata} from 'angular2/src/render/api';
import * as util from 'ionic/util';
import {Platform} from 'ionic/platform/platform';
@ -20,10 +21,13 @@ export class IonicComponent extends Component {
function appendModeConfig(ComponentType) {
let config = ComponentType.config;
config.host = config.host || {};
// let host = DirectiveMetadata.parseHostConfig(config.host);
const defaultProperties = config.defaultProperties;
config.properties = config.properties || [];
config.hostProperties = config.hostProperties || {};
for (let prop in defaultProperties) {
// add the property to the component "properties"
@ -31,7 +35,7 @@ function appendModeConfig(ComponentType) {
// set the component "hostProperties", so the instance's
// 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
@ -88,10 +92,8 @@ function appendModeConfig(ComponentType) {
};
}
config.hostAttributes = config.hostAttributes || {};
let className = (config.hostAttributes['class'] || '');
let id = config.classId || config.selector.replace('ion-', '');
config.hostAttributes['class'] = (className + ' ' + id + ' ' + id + '-' + platformMode).trim();
config.host['class'] = (id + ' ' + id + '-' + platformMode);
return config;
}