mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 19:57:22 +08:00
IonicComponent_OLD cleanups
This commit is contained in:
@ -1,35 +1,40 @@
|
|||||||
import {Renderer, ElementRef} from 'angular2/angular2'
|
import {Renderer, ElementRef} from 'angular2/angular2'
|
||||||
|
|
||||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||||
|
|
||||||
import {ControlGroup, ControlDirective} from 'angular2/forms'
|
import {ControlGroup, ControlDirective} from 'angular2/forms'
|
||||||
import {dom} from 'ionic/util';
|
import {dom} from 'ionic/util';
|
||||||
import {IonicComponent_OLD} from 'ionic/config/component'
|
import {IonicComponent} from 'ionic/config/component'
|
||||||
import {Button} from 'ionic/components/button/button'
|
import {Button} from 'ionic/components/button/button'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@IonicComponent(Segment)
|
||||||
selector: 'ion-segment',
|
|
||||||
hostListeners: {
|
|
||||||
'click': 'buttonClicked($event)'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@View({
|
@View({
|
||||||
template: `<div class="ion-segment">
|
template: `<div class="ion-segment">
|
||||||
<content></content>
|
<content></content>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
directives: [Button, SegmentButton],
|
directives: [Button, SegmentButton]
|
||||||
|
})
|
||||||
|
export class Segment {
|
||||||
|
|
||||||
|
static get config() {
|
||||||
|
return {
|
||||||
|
selector: 'ion-segment',
|
||||||
|
hostListeners: {
|
||||||
|
'click': 'buttonClicked($event)'
|
||||||
|
},
|
||||||
properties: [
|
properties: [
|
||||||
'value'
|
'value'
|
||||||
],
|
],
|
||||||
hostProperties: {
|
hostProperties: {
|
||||||
value: 'value'
|
value: 'value'
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
export class Segment {
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
renderer: Renderer,
|
renderer: Renderer,
|
||||||
@ -47,6 +52,10 @@ export class Segment {
|
|||||||
this.buttons = [];
|
this.buttons = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onInit() {
|
||||||
|
Segment.applyConfig(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Much like ngModel, this is called from our valueAccessor for the attached
|
* Much like ngModel, this is called from our valueAccessor for the attached
|
||||||
* ControlDirective to update the value internally.
|
* ControlDirective to update the value internally.
|
||||||
@ -103,8 +112,6 @@ export class Segment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new IonicComponent_OLD(Segment, {
|
|
||||||
});
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ion-segment-button',
|
selector: 'ion-segment-button',
|
||||||
|
@ -2,14 +2,14 @@ import {For, ElementRef, Inject, Parent} from 'angular2/angular2'
|
|||||||
|
|
||||||
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
import {Ancestor} from 'angular2/src/core/annotations_impl/visibility';
|
||||||
|
|
||||||
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
|
import {Component, Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
|
||||||
import {View} from 'angular2/src/core/annotations_impl/view';
|
import {View} from 'angular2/src/core/annotations_impl/view';
|
||||||
|
|
||||||
import {DragGesture} from 'ionic/gestures/drag-gesture';
|
import {DragGesture} from 'ionic/gestures/drag-gesture';
|
||||||
import * as util from 'ionic/util';
|
import * as util from 'ionic/util';
|
||||||
|
|
||||||
import {dom} from 'ionic/util'
|
import {dom} from 'ionic/util'
|
||||||
import {IonicComponent_OLD} from 'ionic/config/component'
|
import {IonicComponent} from 'ionic/config/component'
|
||||||
|
|
||||||
import {Hammer} from 'ionic/gestures/hammer';
|
import {Hammer} from 'ionic/gestures/hammer';
|
||||||
|
|
||||||
@ -29,19 +29,24 @@ import {Hammer} from 'ionic/gestures/hammer';
|
|||||||
* * TODO: Test mouse support
|
* * TODO: Test mouse support
|
||||||
* * TODO: Port over mouse handling
|
* * TODO: Port over mouse handling
|
||||||
*/
|
*/
|
||||||
@Component({
|
@IonicComponent(Slides)
|
||||||
|
@View({
|
||||||
|
template: `<div class="slides-view"><content></content></div>`,
|
||||||
|
directives: [Slide, SlidePager]
|
||||||
|
})
|
||||||
|
export class Slides {
|
||||||
|
|
||||||
|
static get config() {
|
||||||
|
return {
|
||||||
selector: 'ion-slides',
|
selector: 'ion-slides',
|
||||||
properties: [
|
properties: [
|
||||||
'loop',
|
'loop',
|
||||||
'index',
|
'index',
|
||||||
'bounce'
|
'bounce'
|
||||||
]
|
]
|
||||||
})
|
}
|
||||||
@View({
|
}
|
||||||
template: `<div class="slides-view"><content></content></div>`,
|
|
||||||
directives: [Slide, SlidePager]
|
|
||||||
})
|
|
||||||
export class Slides {
|
|
||||||
constructor(elementRef: ElementRef) {
|
constructor(elementRef: ElementRef) {
|
||||||
// Grab the main container, and the slides-view wrapper
|
// Grab the main container, and the slides-view wrapper
|
||||||
this.domElement = elementRef.domElement;
|
this.domElement = elementRef.domElement;
|
||||||
@ -63,17 +68,9 @@ export class Slides {
|
|||||||
// Initialize our slides gesture handler
|
// Initialize our slides gesture handler
|
||||||
this.gesture = new SlidesGesture(this);
|
this.gesture = new SlidesGesture(this);
|
||||||
this.gesture.listen();
|
this.gesture.listen();
|
||||||
|
|
||||||
|
|
||||||
// Wait a cycle for the children to exist before computing sizes
|
|
||||||
setTimeout(() => {
|
|
||||||
// Continuous mode, but only if we have at least 2 slides
|
|
||||||
this.setup();
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
onInit() {
|
||||||
this.continuous = util.isDefined(this.loop) && (this.slides.length > 1 ? true : false);
|
this.continuous = util.isDefined(this.loop) && (this.slides.length > 1 ? true : false);
|
||||||
|
|
||||||
// Grab the wrapper element that contains the slides
|
// Grab the wrapper element that contains the slides
|
||||||
@ -464,15 +461,11 @@ export class Slides {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
new IonicComponent_OLD(Slides, {
|
|
||||||
});
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
|
@Directive({
|
||||||
selector: 'ion-slide',
|
selector: 'ion-slide',
|
||||||
})
|
})
|
||||||
@View({
|
|
||||||
template: `<content></content>`
|
|
||||||
})
|
|
||||||
export class Slide {
|
export class Slide {
|
||||||
constructor(
|
constructor(
|
||||||
@Ancestor() slides: Slides,
|
@Ancestor() slides: Slides,
|
||||||
@ -515,8 +508,6 @@ export class Slide {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new IonicComponent_OLD(Slide, {
|
|
||||||
});
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ion-pager',
|
selector: 'ion-pager',
|
||||||
@ -543,13 +534,10 @@ export class SlidePager {
|
|||||||
return this.slides.slides;
|
return this.slides.slides;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new IonicComponent_OLD(SlidePager, {
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
export class SlidesGesture extends DragGesture {
|
export class SlidesGesture extends DragGesture {
|
||||||
constructor(slides) {
|
constructor(slides) {
|
||||||
//util.defaults(opts, {});
|
|
||||||
super(slides.domElement);
|
super(slides.domElement);
|
||||||
this.slides = slides;
|
this.slides = slides;
|
||||||
}
|
}
|
||||||
@ -573,7 +561,6 @@ export class SlidesGesture extends DragGesture {
|
|||||||
this.slides._dragStart(event, this._drag);
|
this.slides._dragStart(event, this._drag);
|
||||||
}
|
}
|
||||||
onDragEnd(event) {
|
onDragEnd(event) {
|
||||||
|
|
||||||
this.slides._endDrag(event, this._drag);
|
this.slides._endDrag(event, this._drag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,45 +4,37 @@ import {View} from 'angular2/src/core/annotations_impl/view';
|
|||||||
|
|
||||||
import {ControlGroup, ControlDirective} from 'angular2/forms'
|
import {ControlGroup, ControlDirective} from 'angular2/forms'
|
||||||
import {dom} from 'ionic/util';
|
import {dom} from 'ionic/util';
|
||||||
import {IonicComponent_OLD} from 'ionic/config/component'
|
import {IonicComponent} from 'ionic/config/component'
|
||||||
|
|
||||||
@Component({
|
@IonicComponent(Switch)
|
||||||
selector: 'ion-switch',
|
|
||||||
properties: {
|
|
||||||
checked: 'checked'
|
|
||||||
},
|
|
||||||
hostListeners: {
|
|
||||||
'click': 'switchClicked($event)'
|
|
||||||
},
|
|
||||||
/*
|
|
||||||
TODO: For some reason this triggers a 'TypeError: array.map is not a function'
|
|
||||||
events: {
|
|
||||||
'click': 'onClick()'
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
})
|
|
||||||
@View({
|
@View({
|
||||||
template: `
|
template: `
|
||||||
<div class="item-content">
|
<div class="item-content">
|
||||||
|
|
||||||
<div class="item-title">
|
<div class="item-title">
|
||||||
<content></content>
|
<content></content>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item-media media-switch">
|
<div class="item-media media-switch">
|
||||||
<div class="switch-toggle"></div>
|
<div class="switch-toggle"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>`
|
</div>`
|
||||||
})
|
})
|
||||||
export class Switch {
|
export class Switch {
|
||||||
|
|
||||||
|
static get config() {
|
||||||
|
return {
|
||||||
|
selector: 'ion-switch',
|
||||||
|
properties: [
|
||||||
|
'checked'
|
||||||
|
],
|
||||||
|
hostListeners: {
|
||||||
|
'click': 'switchClicked($event)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
cd: ControlDirective
|
cd: ControlDirective
|
||||||
// @PropertySetter('attr.role') setAriaRole: Function,
|
|
||||||
// @PropertySetter('attr.aria-checked') setChecked: Function
|
|
||||||
// @PropertySetter('attr.aria-invalid') setInvalid: Function,
|
|
||||||
// @PropertySetter('attr.aria-disabled') setDisabled: Function
|
|
||||||
) {
|
) {
|
||||||
this.domElement = elementRef.domElement
|
this.domElement = elementRef.domElement
|
||||||
this.config = Switch.config.invoke(this)
|
this.config = Switch.config.invoke(this)
|
||||||
@ -89,5 +81,3 @@ export class Switch {
|
|||||||
this.checked = !this.checked;
|
this.checked = !this.checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new IonicComponent_OLD(Switch, {})
|
|
||||||
|
Reference in New Issue
Block a user