mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +08:00
168
demos/popover/index.ts
Normal file
168
demos/popover/index.ts
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
import {ViewChild, ElementRef} from '@angular/core';
|
||||||
|
import {App, Page, Popover, NavController, Content, NavParams} from 'ionic-angular';
|
||||||
|
|
||||||
|
|
||||||
|
@Page({
|
||||||
|
template: `
|
||||||
|
<ion-list radio-group [(ngModel)]="fontFamily" (change)="changeFontFamily()">
|
||||||
|
<ion-row>
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeFontSize('smaller')" ion-item detail-none class="text-button text-smaller">A</button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeFontSize('larger')" ion-item detail-none class="text-button text-larger">A</button>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-row class="row-dots">
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeBackground('white')" category="dot" class="dot-white" [class.selected]="background == 'white'"></button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeBackground('tan')" category="dot" class="dot-tan" [class.selected]="background == 'tan'"></button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeBackground('grey')" category="dot" class="dot-grey" [class.selected]="background == 'grey'"></button>
|
||||||
|
</ion-col>
|
||||||
|
<ion-col>
|
||||||
|
<button (click)="changeBackground('black')" category="dot" class="dot-black" [class.selected]="background == 'black'"></button>
|
||||||
|
</ion-col>
|
||||||
|
</ion-row>
|
||||||
|
<ion-item class="text-athelas">
|
||||||
|
<ion-label>Athelas</ion-label>
|
||||||
|
<ion-radio value="Athelas"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-charter">
|
||||||
|
<ion-label>Charter</ion-label>
|
||||||
|
<ion-radio value="Charter"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-iowan">
|
||||||
|
<ion-label>Iowan</ion-label>
|
||||||
|
<ion-radio value="Iowan"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-palatino">
|
||||||
|
<ion-label>Palatino</ion-label>
|
||||||
|
<ion-radio value="Palatino"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-san-francisco">
|
||||||
|
<ion-label>San Francisco</ion-label>
|
||||||
|
<ion-radio value="San Francisco"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-seravek">
|
||||||
|
<ion-label>Seravek</ion-label>
|
||||||
|
<ion-radio value="Seravek"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
<ion-item class="text-times-new-roman">
|
||||||
|
<ion-label>Times New Roman</ion-label>
|
||||||
|
<ion-radio value="Times New Roman"></ion-radio>
|
||||||
|
</ion-item>
|
||||||
|
</ion-list>
|
||||||
|
`,
|
||||||
|
})
|
||||||
|
class PopoverRadioPage {
|
||||||
|
background: string;
|
||||||
|
contentEle: any;
|
||||||
|
textEle: any;
|
||||||
|
fontFamily;
|
||||||
|
|
||||||
|
colors = {
|
||||||
|
'white': {
|
||||||
|
'bg': 'rgb(255, 255, 255)',
|
||||||
|
'fg': 'rgb(0, 0, 0)'
|
||||||
|
},
|
||||||
|
'tan': {
|
||||||
|
'bg': 'rgb(249, 241, 228)',
|
||||||
|
'fg': 'rgb(0, 0, 0)'
|
||||||
|
},
|
||||||
|
'grey': {
|
||||||
|
'bg': 'rgb(76, 75, 80)',
|
||||||
|
'fg': 'rgb(255, 255, 255)'
|
||||||
|
},
|
||||||
|
'black': {
|
||||||
|
'bg': 'rgb(0, 0, 0)',
|
||||||
|
'fg': 'rgb(255, 255, 255)'
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(private navParams: NavParams) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
if (this.navParams.data) {
|
||||||
|
this.contentEle = this.navParams.data.contentEle;
|
||||||
|
this.textEle = this.navParams.data.textEle;
|
||||||
|
|
||||||
|
this.background = this.getColorName(this.contentEle.style.backgroundColor);
|
||||||
|
this.setFontFamily();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getColorName(background) {
|
||||||
|
let colorName = 'white';
|
||||||
|
|
||||||
|
if (!background) return 'white';
|
||||||
|
|
||||||
|
for(var key in this.colors) {
|
||||||
|
if (this.colors[key].bg == background) {
|
||||||
|
colorName = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFontFamily() {
|
||||||
|
if (this.textEle.style.fontFamily) {
|
||||||
|
this.fontFamily = this.textEle.style.fontFamily.replace(/'/g, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
changeBackground(color) {
|
||||||
|
this.background = color;
|
||||||
|
this.contentEle.style.backgroundColor = this.colors[color].bg;
|
||||||
|
this.textEle.style.color = this.colors[color].fg;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeFontSize(direction) {
|
||||||
|
this.textEle.style.fontSize = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
changeFontFamily() {
|
||||||
|
if (this.fontFamily) this.textEle.style.fontFamily = this.fontFamily;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Page({
|
||||||
|
templateUrl: 'main.html'
|
||||||
|
})
|
||||||
|
class PopoverPage {
|
||||||
|
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef;
|
||||||
|
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
|
||||||
|
|
||||||
|
constructor(private nav: NavController) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
presentRadioPopover(ev) {
|
||||||
|
let popover = Popover.create(PopoverRadioPage, {
|
||||||
|
contentEle: this.content.nativeElement,
|
||||||
|
textEle: this.text.nativeElement
|
||||||
|
});
|
||||||
|
|
||||||
|
this.nav.present(popover, {
|
||||||
|
ev: ev
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@App({
|
||||||
|
template: '<ion-nav [root]="root"></ion-nav>'
|
||||||
|
})
|
||||||
|
class ApiDemoApp {
|
||||||
|
root = PopoverPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.innerHTML += '<link href="style.css" rel="stylesheet">'
|
22
demos/popover/main.html
Normal file
22
demos/popover/main.html
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<ion-navbar *navbar primary>
|
||||||
|
<ion-title>Popover</ion-title>
|
||||||
|
<ion-buttons end>
|
||||||
|
<button (click)="presentRadioPopover($event)">
|
||||||
|
<ion-icon name="more"></ion-icon>
|
||||||
|
</button>
|
||||||
|
</ion-buttons>
|
||||||
|
</ion-navbar>
|
||||||
|
|
||||||
|
<ion-content #popoverContent padding>
|
||||||
|
<div #popoverText class="text-to-change">
|
||||||
|
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vel ipsum in purus mollis dictum eget vitae purus. Nulla ultrices est odio, a maximus velit pretium ac. Donec vel elementum mi. Proin elementum pulvinar neque, in lacinia nibh tempus auctor. Nam sapien velit, commodo ac nibh a, maximus ullamcorper nunc. Integer luctus tortor dignissim, dictum neque at, scelerisque purus. Vivamus nec erat vel magna posuere euismod. Sed ac augue eu tellus tincidunt fermentum eget sit amet nunc. Donec sit amet mi libero. Cras nunc arcu, ultrices nec sapien eu, convallis posuere libero. Pellentesque vulputate lacus eros, at lobortis lorem egestas et. Vestibulum tempus quam in efficitur lobortis. Maecenas consectetur consequat sem pharetra aliquet. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</div>
|
||||||
|
|
||||||
|
<div>Mauris ac ligula elit. Nulla pulvinar eget leo ut aliquet. Praesent sit amet luctus quam. Nam fringilla iaculis mi, ut maximus mauris molestie feugiat. Curabitur nec scelerisque elit. Nunc eu odio facilisis, tempor enim eget, venenatis sem. Sed vitae lorem vehicula, auctor orci ultrices, finibus mauris. Donec vitae pulvinar diam. Nulla luctus congue quam, sed lacinia arcu dictum a.</div>
|
||||||
|
|
||||||
|
<div>Morbi laoreet magna elit, id dapibus massa varius consequat. Praesent rhoncus nunc quam, eu mollis velit commodo ut. Etiam euismod elit mi, non auctor velit blandit ut. Aenean vitae pulvinar mi, ac pretium tellus. Morbi eu auctor sem, sollicitudin cursus felis. Praesent vestibulum velit sed eros iaculis ornare. Praesent diam diam, pellentesque eget scelerisque sed, bibendum ut risus. Sed sed fermentum sem. Integer vel justo felis. Proin eget quam est. In sit amet ipsum sagittis, convallis ipsum fringilla, interdum ante. Etiam vel tincidunt mauris. Nunc feugiat eros nunc, et vestibulum metus mollis et. Nullam eu viverra velit, id ultrices nisl. Donec non enim elementum, laoreet sapien id, feugiat tellus.</div>
|
||||||
|
|
||||||
|
<div>Sed pellentesque ipsum eget ante hendrerit maximus. Aliquam id venenatis nulla. Nullam in nibh at enim vestibulum ullamcorper. Nam felis dolor, lobortis vel est non, condimentum malesuada nisl. In metus sapien, malesuada at nulla in, pretium aliquam turpis. Quisque elementum purus mi, sed tristique turpis ultricies in. Donec feugiat dolor non ultricies ultricies. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin ut purus et diam porta cursus vitae semper mi. Donec fringilla tellus orci. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nunc vitae commodo sem. Duis vehicula quam sit amet imperdiet facilisis. Pellentesque eget dignissim neque, et scelerisque libero. Maecenas molestie metus sed orci cursus, in venenatis justo dapibus.</div>
|
||||||
|
|
||||||
|
<p>Aenean rhoncus urna at interdum blandit. Donec ac massa nec libero vehicula tincidunt. Sed sit amet hendrerit risus. Aliquam vitae vestibulum ipsum, non feugiat orci. Vivamus eu rutrum elit. Nulla dapibus tortor non dignissim pretium. Nulla in luctus turpis. Etiam non mattis tortor, at aliquet ex. Nunc ut ante varius, auctor dui vel, volutpat elit. Nunc laoreet augue sit amet ultrices porta. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum pellentesque lobortis est, ut tincidunt ligula mollis sit amet. In porta risus arcu, quis pellentesque dolor mattis non. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;</p>
|
||||||
|
</div>
|
||||||
|
</ion-content>
|
117
demos/popover/style.css
Normal file
117
demos/popover/style.css
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
.text-to-change div {
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
ion-row,
|
||||||
|
ion-col {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-button {
|
||||||
|
padding-left: 0;
|
||||||
|
text-align: center;
|
||||||
|
min-height: 20px;
|
||||||
|
line-height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-button .item-inner {
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-smaller {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ios .text-smaller {
|
||||||
|
border-right: 1px solid #c8c7cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.md .text-smaller {
|
||||||
|
border-right: 1px solid #dedede;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-larger {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-dots {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ios .row-dots {
|
||||||
|
border-bottom: 1px solid #c8c7cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.md .row-dots {
|
||||||
|
border-bottom: 1px solid #dedede;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ios .dot {
|
||||||
|
border: 1px solid #c8c7cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.md .dot {
|
||||||
|
border: 1px solid #dedede;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hairlines .text-smaller,
|
||||||
|
.hairlines .row-dots,
|
||||||
|
.hairlines .dot {
|
||||||
|
border-width: 0.55px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-dots .dot {
|
||||||
|
height: 30px;
|
||||||
|
width: 30px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin: 10px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-white {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-tan {
|
||||||
|
background-color: #f9f1e4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-grey {
|
||||||
|
background-color: #4c4b50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot-black {
|
||||||
|
background-color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dot.selected {
|
||||||
|
border-width: 2px;
|
||||||
|
border-color: #327eff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-athelas {
|
||||||
|
font-family: "Athelas";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-charter {
|
||||||
|
font-family: "Charter";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-iowan {
|
||||||
|
font-family: "Iowan";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-palatino {
|
||||||
|
font-family: "Palatino";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-san-francisco {
|
||||||
|
font-family: "San Francisco";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-seravek {
|
||||||
|
font-family: "Seravek";
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-times-new-roman {
|
||||||
|
font-family: "Times New Roman";
|
||||||
|
}
|
@ -15,6 +15,9 @@ const POPOVER_BODY_PADDING = 2;
|
|||||||
* @name Popover
|
* @name Popover
|
||||||
* @description
|
* @description
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @demo /docs/v2/demos/popover/
|
||||||
*/
|
*/
|
||||||
export class Popover extends ViewController {
|
export class Popover extends ViewController {
|
||||||
|
|
||||||
|
@ -59,27 +59,27 @@ import {App, Page, Popover, NavController, Content, NavParams} from '../../../..
|
|||||||
`,
|
`,
|
||||||
})
|
})
|
||||||
class PopoverRadioPage {
|
class PopoverRadioPage {
|
||||||
background: string = 'white';
|
background: string;
|
||||||
contentEle: any;
|
contentEle: any;
|
||||||
textEle: any;
|
textEle: any;
|
||||||
fontFamily;
|
fontFamily;
|
||||||
|
|
||||||
colors = {
|
colors = {
|
||||||
"white": {
|
'white': {
|
||||||
"bg": "#fff",
|
'bg': 'rgb(255, 255, 255)',
|
||||||
"fg": "#000"
|
'fg': 'rgb(0, 0, 0)'
|
||||||
},
|
},
|
||||||
"tan": {
|
'tan': {
|
||||||
"bg": "#f9f1e4",
|
'bg': 'rgb(249, 241, 228)',
|
||||||
"fg": "#000"
|
'fg': 'rgb(0, 0, 0)'
|
||||||
},
|
},
|
||||||
"grey": {
|
'grey': {
|
||||||
"bg": "#4c4b50",
|
'bg': 'rgb(76, 75, 80)',
|
||||||
"fg": "#fff"
|
'fg': 'rgb(255, 255, 255)'
|
||||||
},
|
},
|
||||||
"black": {
|
'black': {
|
||||||
"bg": "#000",
|
'bg': 'rgb(0, 0, 0)',
|
||||||
"fg": "#fff"
|
'fg': 'rgb(255, 255, 255)'
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -91,12 +91,35 @@ class PopoverRadioPage {
|
|||||||
if (this.navParams.data) {
|
if (this.navParams.data) {
|
||||||
this.contentEle = this.navParams.data.contentEle;
|
this.contentEle = this.navParams.data.contentEle;
|
||||||
this.textEle = this.navParams.data.textEle;
|
this.textEle = this.navParams.data.textEle;
|
||||||
|
|
||||||
|
this.background = this.getColorName(this.contentEle.style.backgroundColor);
|
||||||
|
this.setFontFamily();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getColorName(background) {
|
||||||
|
let colorName = 'white';
|
||||||
|
|
||||||
|
if (!background) return 'white';
|
||||||
|
|
||||||
|
for(var key in this.colors) {
|
||||||
|
if (this.colors[key].bg == background) {
|
||||||
|
colorName = key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorName;
|
||||||
|
}
|
||||||
|
|
||||||
|
setFontFamily() {
|
||||||
|
if (this.textEle.style.fontFamily) {
|
||||||
|
this.fontFamily = this.textEle.style.fontFamily.replace(/'/g, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeBackground(color) {
|
changeBackground(color) {
|
||||||
this.background = color;
|
this.background = color;
|
||||||
this.contentEle.style.background = this.colors[color].bg;
|
this.contentEle.style.backgroundColor = this.colors[color].bg;
|
||||||
this.textEle.style.color = this.colors[color].fg;
|
this.textEle.style.color = this.colors[color].fg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,8 +156,6 @@ class E2EPage {
|
|||||||
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef;
|
@ViewChild('popoverContent', {read: ElementRef}) content: ElementRef;
|
||||||
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
|
@ViewChild('popoverText', {read: ElementRef}) text: ElementRef;
|
||||||
|
|
||||||
popover: any;
|
|
||||||
|
|
||||||
constructor(private nav: NavController) {
|
constructor(private nav: NavController) {
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -164,10 +185,7 @@ class E2EPage {
|
|||||||
template: '<ion-nav [root]="root"></ion-nav>'
|
template: '<ion-nav [root]="root"></ion-nav>'
|
||||||
})
|
})
|
||||||
class E2EApp {
|
class E2EApp {
|
||||||
root;
|
root = E2EPage;
|
||||||
constructor() {
|
|
||||||
this.root = E2EPage;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.body.innerHTML += '<link href="style.css" rel="stylesheet">'
|
document.body.innerHTML += '<link href="style.css" rel="stylesheet">'
|
||||||
|
@ -14,6 +14,10 @@ ion-col {
|
|||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.text-button .item-inner {
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.text-smaller {
|
.text-smaller {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
@ -64,19 +68,19 @@ ion-col {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dot-white {
|
.dot-white {
|
||||||
background-color: #fff;
|
background-color: rgb(255,255,255);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot-tan {
|
.dot-tan {
|
||||||
background-color: #f9f1e4;
|
background-color: rgb(249,241,228);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot-grey {
|
.dot-grey {
|
||||||
background-color: #4c4b50;
|
background-color: rgb(76,75,80);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot-black {
|
.dot-black {
|
||||||
background-color: #000;
|
background-color: rgb(0,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dot.selected {
|
.dot.selected {
|
||||||
|
Reference in New Issue
Block a user