mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
update to use host
This commit is contained in:
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ export class Navbar {
|
||||
|
||||
@Directive({
|
||||
selector: '.back-button',
|
||||
hostListeners: {
|
||||
'^click': 'goBack($event)'
|
||||
host: {
|
||||
'(^click)': 'goBack($event)'
|
||||
}
|
||||
})
|
||||
class BackButton {
|
||||
|
@ -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'
|
||||
}
|
||||
})
|
||||
|
@ -139,7 +139,7 @@ class PaneContentAnchor {
|
||||
|
||||
@Component({
|
||||
selector: 'section',
|
||||
hostAttributes: {
|
||||
host: {
|
||||
'class': 'navbar-container'
|
||||
}
|
||||
})
|
||||
|
@ -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 {
|
||||
|
@ -109,12 +109,12 @@ export class RadioButton {
|
||||
static get config() {
|
||||
return {
|
||||
selector: 'ion-radio',
|
||||
hostListeners: {
|
||||
'^click': 'buttonClicked($event)'
|
||||
},
|
||||
properties: [
|
||||
'value'
|
||||
]
|
||||
],
|
||||
host: {
|
||||
'(^click)': 'buttonClicked($event)'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -26,8 +26,8 @@ export class Switch {
|
||||
properties: [
|
||||
'checked'
|
||||
],
|
||||
hostListeners: {
|
||||
'click': 'switchClicked($event)'
|
||||
host: {
|
||||
'(click)': 'switchClicked($event)'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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]
|
||||
})
|
||||
|
@ -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'
|
||||
}
|
||||
})
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user