mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
popup and radio docs wip
This commit is contained in:
@ -120,7 +120,7 @@ export class Checkbox extends Ion {
|
||||
/**
|
||||
* @private
|
||||
* Angular2 Forms API method called by the the view (NgControl) to register
|
||||
* the onTouched event handler that marks model as touched.
|
||||
* the onTouched event handler that marks model (Control) as touched.
|
||||
* @param {Function} fn onTouched event handler.
|
||||
*/
|
||||
registerOnTouched(fn) { this.onTouched = fn; }
|
||||
|
@ -6,9 +6,18 @@ import {Animation} from '../../animations/animation';
|
||||
import * as util from 'ionic/util';
|
||||
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
@Injectable()
|
||||
export class Popup extends Overlay {
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} context TODO
|
||||
* @param {TODO} [opts={}] TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
popup(context, opts={}) {
|
||||
return new Promise((resolve, reject)=> {
|
||||
let defaults = {
|
||||
@ -23,6 +32,12 @@ export class Popup extends Overlay {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} context TODO
|
||||
* @param {TODO} [opts={}] TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
alert(context={}, opts={}) {
|
||||
if (typeof context === 'string') {
|
||||
context = {
|
||||
@ -48,6 +63,12 @@ export class Popup extends Overlay {
|
||||
return this.popup(context, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} context TODO
|
||||
* @param {TODO} [opts={}] TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
confirm(context={}, opts={}) {
|
||||
if (typeof context === 'string') {
|
||||
context = {
|
||||
@ -77,6 +98,12 @@ export class Popup extends Overlay {
|
||||
return this.popup(context, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} [context={}] TODO
|
||||
* @param {TODO} [opts={}] TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
prompt(context={}, opts={}) {
|
||||
if (typeof context === 'string') {
|
||||
context = {
|
||||
@ -112,6 +139,12 @@ export class Popup extends Overlay {
|
||||
return this.popup(context, opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {TODO} context TODO
|
||||
* @param {TODO} [opts={}] TODO
|
||||
* @returns {TODO} TODO
|
||||
*/
|
||||
get(handle) {
|
||||
if (handle) {
|
||||
return this.getByHandle(handle, OVERLAY_TYPE);
|
||||
|
@ -6,7 +6,9 @@ import {Ion} from '../ion';
|
||||
import {TapClick} from '../button/button';
|
||||
import {ListHeader} from '../list/list';
|
||||
|
||||
|
||||
/**
|
||||
* A radio group component.
|
||||
*/
|
||||
@IonicDirective({
|
||||
selector: 'ion-radio-group',
|
||||
host: {
|
||||
@ -19,10 +21,17 @@ import {ListHeader} from '../list/list';
|
||||
export class RadioGroup extends Ion {
|
||||
radios: Array<RadioButton> = [];
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @param {ElementRef} elementRef TODO
|
||||
* @param {IonicConfig} config TODO
|
||||
* @param {NgControl=} ngControl TODO
|
||||
* @param {QueryList<ListHeader>} headerQuery TODO
|
||||
*/
|
||||
constructor(
|
||||
elementRef: ElementRef,
|
||||
config: IonicConfig,
|
||||
@Optional() cd: NgControl,
|
||||
@Optional() ngControl: NgControl,
|
||||
@Query(ListHeader) private headerQuery: QueryList<ListHeader>
|
||||
) {
|
||||
super(elementRef, config);
|
||||
@ -31,7 +40,7 @@ export class RadioGroup extends Ion {
|
||||
this.onChange = (_) => {};
|
||||
this.onTouched = (_) => {};
|
||||
|
||||
if (cd) cd.valueAccessor = this;
|
||||
if (ngControl) ngControl.valueAccessor = this;
|
||||
}
|
||||
|
||||
onInit() {
|
||||
@ -44,6 +53,10 @@ export class RadioGroup extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the specified radio button with the radio group.
|
||||
* @param {RadioButton} radio The radio button to register.
|
||||
*/
|
||||
registerRadio(radio) {
|
||||
radio.id = radio.id || ('radio-' + this.id + '-' + (++this.radioIds));
|
||||
this.radios.push(radio);
|
||||
@ -54,6 +67,10 @@ export class RadioGroup extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update which radio button in the group is checked, unchecking all others.
|
||||
* @param {RadioButton} checkedRadio The radio button to check.
|
||||
*/
|
||||
update(checkedRadio) {
|
||||
this.value = checkedRadio.value;
|
||||
this.activeId = checkedRadio.id;
|
||||
@ -65,6 +82,12 @@ export class RadioGroup extends Ion {
|
||||
this.onChange(this.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Angular2 Forms API method called by the model (Control) on change to update
|
||||
* the checked value.
|
||||
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L34
|
||||
*/
|
||||
writeValue(value) {
|
||||
this.value = value;
|
||||
for (let radio of this.radios) {
|
||||
@ -72,14 +95,27 @@ export class RadioGroup extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
// Used by the view to update the model (Control)
|
||||
// Up to us to call it in update()
|
||||
/**
|
||||
* @private
|
||||
* Angular2 Forms API method called by the view (NgControl) to register the
|
||||
* onChange event handler that updates the model (Control).
|
||||
* https://github.com/angular/angular/blob/master/modules/angular2/src/forms/directives/shared.ts#L27
|
||||
* @param {Function} fn the onChange event handler.
|
||||
*/
|
||||
registerOnChange(fn) { this.onChange = fn; }
|
||||
|
||||
/**
|
||||
* @private
|
||||
* Angular2 Forms API method called by the the view (NgControl) to register
|
||||
* the onTouched event handler that marks the model (Control) as touched.
|
||||
* @param {Function} fn onTouched event handler.
|
||||
*/
|
||||
registerOnTouched(fn) { this.onTouched = fn; }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A radio button component.
|
||||
*/
|
||||
@IonicComponent({
|
||||
selector: 'ion-radio',
|
||||
properties: [
|
||||
@ -109,6 +145,13 @@ export class RadioGroup extends Ion {
|
||||
'</div>'
|
||||
})
|
||||
export class RadioButton extends Ion {
|
||||
/**
|
||||
* Radio button constructor.
|
||||
* @param {RadioGroup=} group The parent radio group, if any.
|
||||
* @param {ElementRef} elementRef TODO
|
||||
* @param {IonicConfig} config TODO
|
||||
* @param {TapClick} tapClick TODO
|
||||
*/
|
||||
constructor(
|
||||
@Host() @Optional() group: RadioGroup,
|
||||
elementRef: ElementRef,
|
||||
@ -135,6 +178,10 @@ export class RadioButton extends Ion {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the checked state of this radio button.
|
||||
* TODO: Call this toggle? Since unchecks as well
|
||||
*/
|
||||
check() {
|
||||
this.checked = !this.checked;
|
||||
this.group.update(this);
|
||||
|
Reference in New Issue
Block a user