[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({
|
||||
selector: 'my-small-tabs',
|
||||
template: `
|
||||
<ul uk-tab 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 ' : '')">
|
||||
<ul class="uk-tab main-tabs uk-margin-remove uk-child-width-expand">
|
||||
<!-- *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">
|
||||
<div class="tab-header">{{tab.title}}</div>
|
||||
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
||||
<div *ngIf="tab.statistics" class="number">
|
||||
<div class="tab-header">{{activeTab.title}}</div>
|
||||
<div *ngIf="activeTab.num" class="number">{{activeTab.num | number}}</div>
|
||||
<div *ngIf="activeTab.statistics" class="number">
|
||||
<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="M10 20h4V4h-4v16zm-6 0h4v-8H4v8zM16 9v11h4V9h-4z"></path>
|
||||
|
@ -30,14 +31,23 @@ declare var UIkit: any;
|
|||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class="uk-padding-remove fake_tab">
|
||||
<a class="uk-text-center uk-width-1-1 uk-height-1-1">...</a>
|
||||
<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 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 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">
|
||||
<li *ngFor="let tab of tabs" (click)="selectTab(tab)" [class]="' uk-height-1-1 uk-width-1-1'+(tab.active ? ' uk-text-bold' : '')">
|
||||
<a class="uk-display-block uk-height-1-1 uk-width-1-1">{{tab.title}}</a>
|
||||
</li>
|
||||
<ng-container *ngFor="let tab of tabs.toArray()">
|
||||
<li (click)="selectTab(tab)"
|
||||
[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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -55,34 +65,23 @@ export class SmallTabsComponent implements AfterContentInit {
|
|||
|
||||
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
||||
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
||||
public activeTabs: TabComponent[] = [];
|
||||
public activeTab: TabComponent = null;
|
||||
|
||||
// contentChildren are set
|
||||
ngAfterContentInit() {
|
||||
// get all active tabs
|
||||
this.activeTabs = this.tabs.filter((tab)=>tab.active);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
selectTab(tab: TabComponent){
|
||||
console.log("selectTab: "+tab.title);
|
||||
|
||||
// deactivate all tabs
|
||||
this.tabs.toArray().forEach(tab => tab.active = false);
|
||||
|
||||
this.activeTabs = [];
|
||||
this.activeTabs.push(tab);
|
||||
this.activeTab = tab;
|
||||
|
||||
// activate the tab the user has clicked on.
|
||||
tab.active = true;
|
||||
this.selectedActiveTab.emit(tab.tabId);
|
||||
|
||||
if(this.dropElement) {
|
||||
console.log("dropElement: ",this.dropElement);
|
||||
if(typeof document !== 'undefined' && this.dropElement) {
|
||||
UIkit.drop(this.dropElement.nativeElement).hide(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,5 +32,4 @@ export class TabComponent {
|
|||
@Input('tabNumber') num: number;
|
||||
@Input('statistics') statistics: boolean = false;
|
||||
@Input('tabId') tabId: string;
|
||||
@Input() active = false;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,11 @@ import { TabComponent } from './tab.component';
|
|||
@Component({
|
||||
selector: 'my-tabs',
|
||||
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">
|
||||
<li *ngFor="let tab of tabs; let i=index" [class]="'uk-padding-remove'+(tab.statistics ? ' statistics ' : '') + (i == 0?' uk-active':'')">
|
||||
<ul class="uk-tab main-tabs uk-margin-remove uk-child-width-expand"
|
||||
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">
|
||||
<div class="tab-header">{{tab.title}}</div>
|
||||
<div *ngIf="tab.num" class="number">{{tab.num | number}}</div>
|
||||
|
@ -38,4 +41,9 @@ export class TabsComponent {
|
|||
|
||||
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
||||
@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