Merge branch 'new-theme' of code-repo.d4science.org:MaDgIK/openaire-library into new-theme
This commit is contained in:
commit
8205f303a7
|
@ -89,9 +89,56 @@
|
|||
<div *ngIf="dataProviderInfo != null">
|
||||
|
||||
<!-- *ngIf="numberOfTabs > 0; else loadingBlock"-->
|
||||
<div class="main-tabs-div">
|
||||
<ng-template #summary_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
<div class="main-tabs-div" uk-sticky="offset: 100; ">
|
||||
<my-tabs (selectedActiveTab)="onSelectActiveTab($event)" >
|
||||
|
||||
<my-tab
|
||||
[tabTitle]="'Summary'" [tabId]="'summary'" [active]="true">
|
||||
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
|
||||
[tabId]="'projects'" >
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
|
||||
[tabId]="'datasources'" >
|
||||
</my-tab>
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
|
||||
>
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
|
||||
[tabId]="'publications'" >
|
||||
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
|
||||
[tabId]="'datasets'" >
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
|
||||
[tabId]="'software'">
|
||||
</my-tab>
|
||||
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
|
||||
[tabId]="'other'">
|
||||
|
||||
</my-tab>
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'" [active]="false"
|
||||
>
|
||||
</my-tab>
|
||||
</my-tabs>
|
||||
|
||||
|
||||
</div>
|
||||
<!--Summary-->
|
||||
<div #summary_tab>
|
||||
<div id="summary" class="uk-grid uk-margin-remove landing-section">
|
||||
<div *ngIf="hasPrimaryInfo || (!aggregationStatusIsInitialized || hasAggregationStatusInfo)"
|
||||
class="uk-width-expand uk-padding uk-inline">
|
||||
<!-- Description -->
|
||||
|
@ -240,9 +287,10 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #projects_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</div>
|
||||
<!--Projects-->
|
||||
<ng-container *ngIf="fetchProjects.searchUtils.totalResults > 0">
|
||||
<div id="projects" class="uk-grid uk-margin-remove landing-section">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchProjects" resultType="project"
|
||||
[params]="getParamsForSearchLink()"
|
||||
|
@ -252,9 +300,10 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #datasources_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Content Providers-->
|
||||
<ng-container *ngIf="fetchDataproviders.searchUtils.totalResults > 0">
|
||||
<div id="datasources" class="uk-grid uk-margin-remove landing-section">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchDataproviders" resultType="dataprovider"
|
||||
[params]="getParamsForSearchLink()"
|
||||
|
@ -264,9 +313,11 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #relatedDatasources_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Related Content Providers-->
|
||||
<ng-container *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)">
|
||||
<div id="relatedDatasources" class="uk-grid uk-margin-remove landing-section">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<relatedDatasourcesTab
|
||||
[dataproviderId]="datasourceId"
|
||||
|
@ -279,9 +330,10 @@
|
|||
</relatedDatasourcesTab>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #publications_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Publications-->
|
||||
<ng-container *ngIf="fetchPublications.searchUtils.totalResults > 0">
|
||||
<div id="publications" class="uk-grid uk-margin-remove landing-section">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchPublications" resultType="publication"
|
||||
[params]="getParamsForSearchLink('publications')"
|
||||
|
@ -291,9 +343,10 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #datasets_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Research Data-->
|
||||
<ng-container *ngIf="fetchDatasets.searchUtils.totalResults > 0">
|
||||
<div id="datasets" class="uk-grid uk-margin-remove">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchDatasets" resultType="dataset"
|
||||
[params]="getParamsForSearchLink('datasets')"
|
||||
|
@ -303,9 +356,10 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #software_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Software-->
|
||||
<ng-container *ngIf="fetchSoftware.searchUtils.totalResults > 0">
|
||||
<div id="software" class="uk-grid uk-margin-remove">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchSoftware" resultType="software"
|
||||
[params]="getParamsForSearchLink('software')"
|
||||
|
@ -315,9 +369,10 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #other_tab>
|
||||
<div class="uk-grid uk-margin-remove">
|
||||
</ng-container>
|
||||
<!--Other-->
|
||||
<ng-container *ngIf="fetchOrps.searchUtils.totalResults > 0">
|
||||
<div id="other" class="uk-grid uk-margin-remove">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
<search-tab [fetch]="fetchOrps" resultType="other"
|
||||
[params]="getParamsForSearchLink('other')"
|
||||
|
@ -327,10 +382,12 @@
|
|||
</div>
|
||||
<!-- <div class="uk-width-1-3@m uk-padding right-column"></div>-->
|
||||
</div>
|
||||
</ng-template>
|
||||
<ng-template #statistics_tab>
|
||||
<div class="">
|
||||
<div class="uk-width-expand uk-padding">
|
||||
</ng-container>
|
||||
<!--Statistics-->
|
||||
<ng-container *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)">
|
||||
|
||||
<div id="statistics" class="uk-width-expand uk-padding">
|
||||
<errorMessages [status]="[fetchPublications.searchUtils.status, fetchDatasets.searchUtils.status,
|
||||
fetchSoftware.searchUtils.status, fetchOrps.searchUtils.status]"
|
||||
[type]="'statistics'" tab_error_class=true></errorMessages>
|
||||
|
@ -345,131 +402,8 @@
|
|||
</statisticsTab>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<!-- [class]="numberOfTabs > 2 ? 'uk-visible@m' : ''"-->
|
||||
<my-tabs (selectedActiveTab)="onSelectActiveTab($event)">
|
||||
<!-- *ngIf="hasPrimaryInfo || hasSecondaryInfo"-->
|
||||
<!-- [class]="(firstTab === 'summary')?'uk-active':''"-->
|
||||
<my-tab
|
||||
[tabTitle]="'Summary'" [tabId]="'summary'" class="uk-active">
|
||||
<ng-container *ngTemplateOutlet="summary_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'projects')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
|
||||
[tabId]="'projects'" >
|
||||
<ng-container *ngTemplateOutlet="projects_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'datasources')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
|
||||
[tabId]="'datasources'" >
|
||||
<ng-container *ngTemplateOutlet="datasources_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'relatedDatasources')?'uk-active':''"-->
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
|
||||
>
|
||||
<ng-container *ngTemplateOutlet="relatedDatasources_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'publications')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
|
||||
[tabId]="'publications'" >
|
||||
<ng-container *ngTemplateOutlet="publications_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'datasets')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
|
||||
[tabId]="'datasets'" >
|
||||
<ng-container *ngTemplateOutlet="datasets_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'software')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
|
||||
[tabId]="'software'">
|
||||
<ng-container *ngTemplateOutlet="software_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'other')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
|
||||
[tabId]="'other'">
|
||||
<ng-container *ngTemplateOutlet="other_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'statistics')?'uk-active':''"-->
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'"
|
||||
>
|
||||
<ng-container *ngTemplateOutlet="statistics_tab;"></ng-container>
|
||||
</my-tab>
|
||||
</my-tabs>
|
||||
|
||||
<!-- <div *ngIf="numberOfTabs() > 2">TEST!!!</div>-->
|
||||
|
||||
<!-- *ngIf="numberOfTabs > 2"-->
|
||||
<my-small-tabs (selectedActiveTab)="onSelectActiveTab($event)">
|
||||
<!-- *ngIf="hasPrimaryInfo || hasSecondaryInfo"-->
|
||||
<!-- [class]="(firstTab === 'summary')?'uk-active':''"-->
|
||||
<my-tab
|
||||
[tabTitle]="'Summary'" [tabId]="'summary'" class="uk-active">
|
||||
<ng-container *ngTemplateOutlet="summary_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'projects')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchProjects.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Projects'" [tabNumber]="fetchProjects.searchUtils.totalResults"
|
||||
[tabId]="'projects'" >
|
||||
<ng-container *ngTemplateOutlet="projects_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'datasources')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchDataproviders.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Content Providers'" [tabNumber]="fetchDataproviders.searchUtils.totalResults"
|
||||
[tabId]="'datasources'" >
|
||||
<ng-container *ngTemplateOutlet="datasources_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'relatedDatasources')?'uk-active':''"-->
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Related Content Providers'" [tabId]="'relatedDatasources'"
|
||||
>
|
||||
<ng-container *ngTemplateOutlet="relatedDatasources_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'publications')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchPublications.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Publications'" [tabNumber]="fetchPublications.searchUtils.totalResults"
|
||||
[tabId]="'publications'" >
|
||||
<ng-container *ngTemplateOutlet="publications_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'datasets')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchDatasets.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Research Data'" [tabNumber]="fetchDatasets.searchUtils.totalResults"
|
||||
[tabId]="'datasets'" >
|
||||
<ng-container *ngTemplateOutlet="datasets_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'software')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchSoftware.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Software'" [tabNumber]="fetchSoftware.searchUtils.totalResults"
|
||||
[tabId]="'software'">
|
||||
<ng-container *ngTemplateOutlet="software_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'other')?'uk-active':''"-->
|
||||
<my-tab *ngIf="fetchOrps.searchUtils.totalResults > 0"
|
||||
[tabTitle]="'Other Research'" [tabNumber]="fetchOrps.searchUtils.totalResults"
|
||||
[tabId]="'other'">
|
||||
<ng-container *ngTemplateOutlet="other_tab;"></ng-container>
|
||||
</my-tab>
|
||||
<!-- [class]="(firstTab === 'statistics')?'uk-active':''"-->
|
||||
<my-tab *ngIf="(fetchPublications.searchUtils.totalResults > 0 || fetchDatasets.searchUtils.totalResults > 0
|
||||
|| fetchSoftware.searchUtils.totalResults > 0 || fetchOrps.searchUtils.totalResults > 0)"
|
||||
[tabTitle]="'Statistics'" customClass="statistics" [tabId]="'statistics'"
|
||||
>
|
||||
<ng-container *ngTemplateOutlet="statistics_tab;"></ng-container>
|
||||
</my-tab>
|
||||
</my-small-tabs>
|
||||
</div>
|
||||
</ng-container>
|
||||
<!-- <ng-template #loadingBlock>-->
|
||||
<!-- <div *ngIf="!tabsAreInitialized" class="uk-animation-fade uk-margin-top uk-width-1-1" role="alert">-->
|
||||
<!-- <span class="loading-gif uk-align-center" ></span>-->
|
||||
|
|
|
@ -26,6 +26,7 @@ import {ResultPreview} from "../../utils/result-preview/result-preview";
|
|||
import {IndexInfoService} from "../../utils/indexInfo.service";
|
||||
import {properties} from "../../../../environments/environment";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {TabComponent} from "../../utils/tabs/tab.component";
|
||||
|
||||
|
||||
@Component({
|
||||
|
@ -596,7 +597,7 @@ export class DataProviderComponent {
|
|||
}
|
||||
|
||||
public onSelectActiveTab(activeTabId) {
|
||||
if (this.activeTab != "activaTabId") { // tab really changed
|
||||
if (this.activeTab != activeTabId) { // tab really changed
|
||||
if (activeTabId == 'summary') {
|
||||
this.activeTab = 'summary';
|
||||
} else if (activeTabId == 'publications') {
|
||||
|
|
|
@ -27,4 +27,6 @@ export class TabComponent {
|
|||
@Input('customClass') customClass:string = "";
|
||||
@Input('tabId') tabId: string;
|
||||
@Input('tabIcon') tabIcon: TabIcon;
|
||||
@Input ('active') active: boolean = false;
|
||||
@Input ('disabled') disabled: boolean = false;
|
||||
}
|
||||
|
|
|
@ -2,15 +2,60 @@
|
|||
* The main component that renders single TabComponent
|
||||
* instances.
|
||||
*/
|
||||
import {AfterContentInit, Component, ContentChildren, EventEmitter, Input, Output, QueryList,} from '@angular/core';
|
||||
import {
|
||||
AfterContentInit,
|
||||
Component,
|
||||
ContentChildren,
|
||||
EventEmitter,
|
||||
HostListener,
|
||||
Output,
|
||||
QueryList,
|
||||
} from '@angular/core';
|
||||
import {TabComponent} from './tab.component';
|
||||
|
||||
@Component({
|
||||
selector: 'my-tabs',
|
||||
template: `
|
||||
<ul class="uk-tab" [ngClass]="customClass" uk-tab="connect: .tabs-content">
|
||||
<!-- [class.uk-active]="selected === tab.tabId"-->
|
||||
<li *ngFor="let tab of tabs.toArray(); let i=index" [ngClass]="tab.customClass" (click)="selectTab(tab)">
|
||||
<div class="uk-grid uk-margin-remove-left">
|
||||
|
||||
<div class="uk-margin-medium-right uk-padding-small uk-width-expand" >
|
||||
<div class=" uk-width-1-1" uk-slider="finite: true">
|
||||
<div class="uk-position-relative " >
|
||||
<div class="uk-slider-container ">
|
||||
<ul class=" uk-slider-items " style="flex-wrap: nowrap !important;" >
|
||||
<ng-container *ngFor="let tab of tabs.toArray(); let i=index">
|
||||
<ng-container *ngIf="!tab.customClass">
|
||||
<li [ngClass]="tab.customClass" (click)="selectTab(tab)" >
|
||||
<ul class="uk-tab">
|
||||
<li [class.uk-active]="tab.active" [class.uk-disabled]="tab.disabled">
|
||||
<a class="uk-width-1-1 uk-height-1-1 uk-flex uk-flex-center" [ngClass]="tab.tabIcon ? 'uk-flex-column' : ''">
|
||||
<icon *ngIf="tab.tabIcon" [svg]="tab.tabIcon.svg" [ratio]="tab.tabIcon.ratio?tab.tabIcon.ratio:1" class="uk-margin-small-bottom"
|
||||
[ngClass]="(selected === tab.tabId)?tab.tabIcon.active:null"></icon>
|
||||
<div>{{tab.title}}</div>
|
||||
<div *ngIf="tab.num && !tab.disabled" class="">({{tab.num | number}})</div>
|
||||
<div *ngIf="tab.disabled" class="">(-)</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="">
|
||||
<a class="uk-position-center-left-out" uk-slider-item="previous"><span uk-icon="chevron-left"></span></a>
|
||||
<a class="uk-position-center-right-out" uk-slider-item="next"><span uk-icon="chevron-right"></span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ng-container *ngFor="let tab of tabs.toArray(); let i=index">
|
||||
<ng-container *ngIf="tab.customClass">
|
||||
<div class="uk-width-small uk-padding-small">
|
||||
<ul class="uk-tab">
|
||||
<li [ngClass]="tab.customClass" (click)="selectTab(tab)" [class.uk-active]="tab.active" >
|
||||
<a class="uk-width-1-1 uk-height-1-1 uk-flex uk-flex-center" [ngClass]="tab.tabIcon ? 'uk-flex-column' : ''">
|
||||
<icon *ngIf="tab.tabIcon" [svg]="tab.tabIcon.svg" [ratio]="tab.tabIcon.ratio?tab.tabIcon.ratio:1" class="uk-margin-small-bottom"
|
||||
[ngClass]="(selected === tab.tabId)?tab.tabIcon.active:null"></icon>
|
||||
|
@ -19,26 +64,85 @@ import {TabComponent} from './tab.component';
|
|||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="uk-switcher tabs-content">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
`
|
||||
})
|
||||
export class TabsComponent implements AfterContentInit {
|
||||
@Input()
|
||||
|
||||
public customClass: string;
|
||||
@ContentChildren(TabComponent) tabs: QueryList<TabComponent>;
|
||||
@Output() public selectedActiveTab: EventEmitter<any> = new EventEmitter();
|
||||
public selected: string;
|
||||
|
||||
disableScroll = false;
|
||||
@HostListener("window:scroll", [])
|
||||
onWindowScroll() {
|
||||
this.scroll();
|
||||
}
|
||||
ngAfterContentInit() {
|
||||
if(this.tabs.length > 0) {
|
||||
this.selected = this.tabs.get(0).tabId;
|
||||
}
|
||||
}
|
||||
|
||||
selectTab(tab: TabComponent){
|
||||
selectTab(tab: TabComponent, scroll=true){
|
||||
console.log("Select tab ",tab.tabId);
|
||||
this.unSelectTab(this.selected, tab.tabId);
|
||||
tab.active = true;
|
||||
this.selected = tab.tabId;
|
||||
this.selectedActiveTab.emit(tab.tabId);
|
||||
if(scroll) {
|
||||
this.disableScroll = true;
|
||||
setTimeout(() => {
|
||||
window.scrollTo({
|
||||
top: document.getElementById(tab.tabId) ? document.getElementById(tab.tabId).offsetTop - 180 : 250,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.disableScroll = false;
|
||||
}, 600);
|
||||
console.log(window.scrollY, tab.tabId, document.getElementById(tab.tabId))
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
scroll(){
|
||||
if(this.disableScroll){
|
||||
return;
|
||||
}
|
||||
// console.log(window.scrollY)
|
||||
let currentTabView = null;
|
||||
let windowInnerHeight = window && window.innerHeight ? window.innerHeight : 300;
|
||||
// console.log("find CT", windowInnerHeight)
|
||||
for (let tab of this.tabs) {
|
||||
|
||||
let distanceFromCurrentViewTop = document.getElementById(tab.tabId) ? document.getElementById(tab.tabId).getBoundingClientRect().top : null;
|
||||
// console.log(pos, distanceFromCurrentViewTop, windowInnerHeight/2);
|
||||
if (distanceFromCurrentViewTop != null && distanceFromCurrentViewTop <= windowInnerHeight / 2) {
|
||||
currentTabView = tab;
|
||||
|
||||
} else if (distanceFromCurrentViewTop != null && distanceFromCurrentViewTop > windowInnerHeight) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log("current currentTabView", currentTabView.tabId)
|
||||
if (currentTabView && this.selected != currentTabView.tabId) {
|
||||
this.selectTab(currentTabView, false);
|
||||
this.disableScroll =true;
|
||||
setTimeout(() => {
|
||||
this.disableScroll = false;
|
||||
}, 600);
|
||||
}
|
||||
}
|
||||
unSelectTab(oldTabId, newTabId){
|
||||
for (let tab of this.tabs) {
|
||||
if(tab.tabId == oldTabId){
|
||||
tab.active = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.selected = newTabId;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue