292 lines
7.7 KiB
HTML
292 lines
7.7 KiB
HTML
<html lang="en"><head></head><body><form id="mainForm" method="post" action="http://plnkr.co/edit/?p=preview" target="_self"><input type="hidden" name="files[app/app.module.ts]" value="import { NgModule } from '@angular/core';
|
|
import { BrowserModule } from '@angular/platform-browser';
|
|
|
|
import { DiDemoComponent } from './di_demo';
|
|
import { UiTabsComponent, UiPaneDirective } from './ui_tabs';
|
|
|
|
@NgModule({
|
|
imports: [ BrowserModule ],
|
|
declarations: [
|
|
DiDemoComponent,
|
|
UiTabsComponent,
|
|
UiPaneDirective
|
|
],
|
|
bootstrap: [ DiDemoComponent ]
|
|
})
|
|
export class AppModule { }
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/di_demo.ts]" value="import { Component } from '@angular/core';
|
|
|
|
class Detail {
|
|
title: string;
|
|
text: string;
|
|
}
|
|
|
|
@Component({
|
|
selector: 'di-demo',
|
|
template: `
|
|
<h4>Tabs Demo</h4>
|
|
<ui-tabs>
|
|
<template uiPane title='Overview' active="true">
|
|
You have {{details.length}} details.
|
|
</template>
|
|
<template *ngFor="let detail of details" uiPane [title]="detail.title">
|
|
{{detail.text}} <br><br>
|
|
<button class="btn" (click)="removeDetail(detail)">Remove</button>
|
|
</template>
|
|
<template uiPane title='Summary'>
|
|
Next last ID is {{id}}.
|
|
</template>
|
|
</ui-tabs>
|
|
<hr>
|
|
<button class="btn" (click)="addDetail()">Add Detail</button>
|
|
`
|
|
})
|
|
export class DiDemoComponent {
|
|
details: Detail[] = [];
|
|
id: number = 0;
|
|
|
|
addDetail() {
|
|
this.id++;
|
|
this.details.push({
|
|
title: `Detail ${this.id}`,
|
|
text: `Some detail text for ${this.id}...`
|
|
});
|
|
}
|
|
|
|
removeDetail(detail: Detail) {
|
|
this.details = this.details.filter((d) => d !== detail);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[app/ui_tabs.ts]" value="import { Component, Directive, Input, QueryList,
|
|
ViewContainerRef, TemplateRef, ContentChildren } from '@angular/core';
|
|
|
|
@Directive({
|
|
selector: '[uiPane]'
|
|
})
|
|
export class UiPaneDirective {
|
|
@Input() title: string;
|
|
private _active: boolean = false;
|
|
|
|
constructor(public viewContainer: ViewContainerRef,
|
|
public templateRef: TemplateRef<any>) { }
|
|
|
|
@Input() set active(active: boolean) {
|
|
if (active === this._active) { return; }
|
|
this._active = active;
|
|
if (active) {
|
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
} else {
|
|
this.viewContainer.remove(0);
|
|
}
|
|
}
|
|
|
|
get active(): boolean {
|
|
return this._active;
|
|
}
|
|
}
|
|
|
|
@Component({
|
|
selector: 'ui-tabs',
|
|
template: `
|
|
<ul class="nav nav-tabs">
|
|
<li *ngFor="let pane of panes"
|
|
(click)="select(pane)"
|
|
role="presentation" [class.active]="pane.active">
|
|
<a>{{pane.title}}</a>
|
|
</li>
|
|
</ul>
|
|
<ng-content></ng-content>
|
|
`,
|
|
styles: ['a { cursor: pointer; cursor: hand; }']
|
|
})
|
|
export class UiTabsComponent {
|
|
@ContentChildren(UiPaneDirective) panes: QueryList<UiPaneDirective>;
|
|
|
|
select(pane: UiPaneDirective) {
|
|
this.panes.toArray().forEach((p: UiPaneDirective) => p.active = p === pane);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[main.ts]" value="import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
|
|
import { AppModule } from './app/app.module';
|
|
|
|
platformBrowserDynamic().bootstrapModule(AppModule);
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[styles.css]" value="/* Master Styles */
|
|
h1 {
|
|
color: #369;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 250%;
|
|
}
|
|
h2, h3 {
|
|
color: #444;
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-weight: lighter;
|
|
}
|
|
body {
|
|
margin: 2em;
|
|
}
|
|
body, input[text], button {
|
|
color: #888;
|
|
font-family: Cambria, Georgia;
|
|
}
|
|
a {
|
|
cursor: pointer;
|
|
cursor: hand;
|
|
}
|
|
button {
|
|
font-family: Arial;
|
|
background-color: #eee;
|
|
border: none;
|
|
padding: 5px 10px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
cursor: hand;
|
|
}
|
|
button:hover {
|
|
background-color: #cfd8dc;
|
|
}
|
|
button:disabled {
|
|
background-color: #eee;
|
|
color: #aaa;
|
|
cursor: auto;
|
|
}
|
|
|
|
/* Navigation link styles */
|
|
nav a {
|
|
padding: 5px 10px;
|
|
text-decoration: none;
|
|
margin-right: 10px;
|
|
margin-top: 10px;
|
|
display: inline-block;
|
|
background-color: #eee;
|
|
border-radius: 4px;
|
|
}
|
|
nav a:visited, a:link {
|
|
color: #607D8B;
|
|
}
|
|
nav a:hover {
|
|
color: #039be5;
|
|
background-color: #CFD8DC;
|
|
}
|
|
nav a.active {
|
|
color: #039be5;
|
|
}
|
|
|
|
/* items class */
|
|
.items {
|
|
margin: 0 0 2em 0;
|
|
list-style-type: none;
|
|
padding: 0;
|
|
width: 24em;
|
|
}
|
|
.items li {
|
|
cursor: pointer;
|
|
position: relative;
|
|
left: 0;
|
|
background-color: #EEE;
|
|
margin: .5em;
|
|
padding: .3em 0;
|
|
height: 1.6em;
|
|
border-radius: 4px;
|
|
}
|
|
.items li:hover {
|
|
color: #607D8B;
|
|
background-color: #DDD;
|
|
left: .1em;
|
|
}
|
|
.items li.selected {
|
|
background-color: #CFD8DC;
|
|
color: white;
|
|
}
|
|
.items li.selected:hover {
|
|
background-color: #BBD8DC;
|
|
}
|
|
.items .text {
|
|
position: relative;
|
|
top: -3px;
|
|
}
|
|
.items .badge {
|
|
display: inline-block;
|
|
font-size: small;
|
|
color: white;
|
|
padding: 0.8em 0.7em 0 0.7em;
|
|
background-color: #607D8B;
|
|
line-height: 1em;
|
|
position: relative;
|
|
left: -1px;
|
|
top: -4px;
|
|
height: 1.8em;
|
|
margin-right: .8em;
|
|
border-radius: 4px 0 0 4px;
|
|
}
|
|
/* everywhere else */
|
|
* {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
}
|
|
|
|
|
|
/*
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
*/"><input type="hidden" name="files[index.html]" value="<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Angular Tabs</title>
|
|
<script>document.write('<base href="' + document.location + '" />');</script>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="https://unpkg.com/bootstrap@3.3.7/dist/css/bootstrap.min.css">
|
|
<link rel="stylesheet" href="styles.css">
|
|
|
|
<!-- Polyfills -->
|
|
<script src="https://unpkg.com/core-js/client/shim.min.js"></script>
|
|
|
|
<script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
|
|
<script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
|
|
|
|
<script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
|
|
<script>
|
|
System.import('main.js').catch(function(err){ console.error(err); });
|
|
</script>
|
|
</head>
|
|
|
|
<!-- Display the application -->
|
|
<body>
|
|
<di-demo class="container" style="display: block">Loading...</di-demo>
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
<!--
|
|
Copyright 2016 Google Inc. All Rights Reserved.
|
|
Use of this source code is governed by an MIT-style license that
|
|
can be found in the LICENSE file at http://angular.io/license
|
|
-->"><input type="hidden" name="tags[0]" value="angular"><input type="hidden" name="tags[1]" value="example"><input type="hidden" name="private" value="true"><input type="hidden" name="description" value="Angular Example - Tabs"></form><script>document.getElementById("mainForm").submit();</script></body></html> |