[Trunk | Library]:
1. tab.component.ts: Remove field 'active'. 2. tabs.component.ts: Add again "selectTab" to send output EventEmitter to parent component when tab changes. 3. small-tabs.component.ts: Tooltip in fake tab | in fake tab use uikit icon 'more' from (svg version) | hide active tab from list | Use field 'activeTab: TabComponent' | close drop when there is 'document'. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@58787 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
f7bf1fcbc0
commit
eeca3648eb
|
@ -17,12 +17,13 @@ declare var UIkit: any;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-small-tabs',
|
selector: 'my-small-tabs',
|
||||||
template: `
|
template: `
|
||||||
<ul uk-tab class="uk-tab main-tabs uk-margin-remove uk-child-width-expand">
|
<ul class="uk-tab main-tabs uk-margin-remove uk-child-width-expand">
|
||||||
<li *ngFor="let tab of activeTabs" [class]="'uk-active uk-padding-remove '+(tab.statistics ? ' statistics ' : '')">
|
<!-- *ngFor="let activeTab of activeTabs"-->
|
||||||
|
<li [class]="'uk-active uk-padding-remove '+(activeTab.statistics ? ' statistics ' : '')">
|
||||||
<a class="uk-width-1-1 uk-height-1-1">
|
<a class="uk-width-1-1 uk-height-1-1">
|
||||||
<div class="tab-header">{{tab.title}}</div>
|
<div class="tab-header">{{activeTab.title}}</div>
|
||||||
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
<div *ngIf="activeTab.num" class="number">{{activeTab.num | number}}</div>
|
||||||
<div *ngIf="tab.statistics" class="number">
|
<div *ngIf="activeTab.statistics" class="number">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
||||||
<path d="M0 0h24v24H0z" fill="none"></path>
|
<path d="M0 0h24v24H0z" fill="none"></path>
|
||||||
<path d="M10 20h4V4h-4v16zm-6 0h4v-8H4v8zM16 9v11h4V9h-4z"></path>
|
<path d="M10 20h4V4h-4v16zm-6 0h4v-8H4v8zM16 9v11h4V9h-4z"></path>
|
||||||
|
@ -30,14 +31,23 @@ declare var UIkit: any;
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="uk-padding-remove fake_tab">
|
<li class="uk-padding-remove fake_tab" uk-tooltip="title: More tabs">
|
||||||
<a class="uk-text-center uk-width-1-1 uk-height-1-1">...</a>
|
<a class="uk-text-center uk-width-1-1 uk-height-1-1 uk-icon">
|
||||||
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" data-svg="more">
|
||||||
|
<circle cx="3" cy="10" r="2"></circle>
|
||||||
|
<circle cx="10" cy="10" r="2"></circle>
|
||||||
|
<circle cx="17" cy="10" r="2"></circle>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
<div #drop_element uk-drop="mode: click" class="uk-drop">
|
<div #drop_element uk-drop="mode: click" class="uk-drop">
|
||||||
<div class="uk-card uk-card-body uk-card-default">
|
<div class="uk-card uk-card-body uk-card-default">
|
||||||
<ul class="uk-list uk-list-divider main-small-tabs" uk-switcher="connect: .small-tabs-content">
|
<ul class="uk-list uk-list-divider main-small-tabs" uk-switcher="connect: .small-tabs-content">
|
||||||
<li *ngFor="let tab of tabs" (click)="selectTab(tab)" [class]="' uk-height-1-1 uk-width-1-1'+(tab.active ? ' uk-text-bold' : '')">
|
<ng-container *ngFor="let tab of tabs.toArray()">
|
||||||
<a class="uk-display-block uk-height-1-1 uk-width-1-1">{{tab.title}}</a>
|
<li (click)="selectTab(tab)"
|
||||||
</li>
|
[class]="'uk-height-1-1 uk-width-1-1 ' + (tab == activeTab ? 'uk-hidden' : '')">
|
||||||
|
<a class="uk-display-block uk-height-1-1 uk-width-1-1">{{tab.title}}</a>
|
||||||
|
</li>
|
||||||
|
</ng-container>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -55,34 +65,23 @@ export class SmallTabsComponent implements AfterContentInit {
|
||||||
|
|
||||||
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
||||||
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
||||||
public activeTabs: TabComponent[] = [];
|
public activeTab: TabComponent = null;
|
||||||
|
|
||||||
// contentChildren are set
|
// contentChildren are set
|
||||||
ngAfterContentInit() {
|
ngAfterContentInit() {
|
||||||
// get all active tabs
|
|
||||||
this.activeTabs = this.tabs.filter((tab)=>tab.active);
|
|
||||||
|
|
||||||
// if there is no active tab set, activate the first
|
// if there is no active tab set, activate the first
|
||||||
if(this.tabs.length > 0 && this.activeTabs.length === 0) {
|
if(this.tabs && this.tabs.length > 0) {
|
||||||
this.selectTab(this.tabs.first);
|
this.selectTab(this.tabs.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectTab(tab: TabComponent){
|
selectTab(tab: TabComponent){
|
||||||
console.log("selectTab: "+tab.title);
|
this.activeTab = tab;
|
||||||
|
|
||||||
// deactivate all tabs
|
|
||||||
this.tabs.toArray().forEach(tab => tab.active = false);
|
|
||||||
|
|
||||||
this.activeTabs = [];
|
|
||||||
this.activeTabs.push(tab);
|
|
||||||
|
|
||||||
// activate the tab the user has clicked on.
|
// activate the tab the user has clicked on.
|
||||||
tab.active = true;
|
|
||||||
this.selectedActiveTab.emit(tab.tabId);
|
this.selectedActiveTab.emit(tab.tabId);
|
||||||
|
|
||||||
if(this.dropElement) {
|
if(typeof document !== 'undefined' && this.dropElement) {
|
||||||
console.log("dropElement: ",this.dropElement);
|
|
||||||
UIkit.drop(this.dropElement.nativeElement).hide(false);
|
UIkit.drop(this.dropElement.nativeElement).hide(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,5 +32,4 @@ export class TabComponent {
|
||||||
@Input('tabNumber') num: number;
|
@Input('tabNumber') num: number;
|
||||||
@Input('statistics') statistics: boolean = false;
|
@Input('statistics') statistics: boolean = false;
|
||||||
@Input('tabId') tabId: string;
|
@Input('tabId') tabId: string;
|
||||||
@Input() active = false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,11 @@ import { TabComponent } from './tab.component';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-tabs',
|
selector: 'my-tabs',
|
||||||
template: `
|
template: `
|
||||||
<ul uk-tab class="uk-tab main-tabs uk-margin-remove uk-child-width-expand" uk-switcher="connect: .tabs-content" uk-height-match="target: .tab-header">
|
<ul class="uk-tab main-tabs uk-margin-remove uk-child-width-expand"
|
||||||
<li *ngFor="let tab of tabs; let i=index" [class]="'uk-padding-remove'+(tab.statistics ? ' statistics ' : '') + (i == 0?' uk-active':'')">
|
uk-tab uk-switcher="connect: .tabs-content" uk-height-match="target: .tab-header">
|
||||||
|
<li *ngFor="let tab of tabs.toArray(); let i=index"
|
||||||
|
[class]="'uk-padding-remove'+(tab.statistics ? ' statistics ' : '') + (i == 0?' uk-active':'')"
|
||||||
|
(click)="selectTab(tab)">
|
||||||
<a class="uk-width-1-1 uk-height-1-1">
|
<a class="uk-width-1-1 uk-height-1-1">
|
||||||
<div class="tab-header">{{tab.title}}</div>
|
<div class="tab-header">{{tab.title}}</div>
|
||||||
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
||||||
|
@ -38,4 +41,9 @@ export class TabsComponent {
|
||||||
|
|
||||||
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
||||||
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
|
selectTab(tab: TabComponent){
|
||||||
|
// activate the tab the user has clicked on.
|
||||||
|
this.selectedActiveTab.emit(tab.tabId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue