+
+
+
+
+
-
-
-
-
-
- (, )
+
+
+ (, )
+
+
+
+
+
+
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index e05a086f60..202a4b0c23 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -43,6 +43,7 @@ import { VarDirective } from './utils/var.directive';
import { TruncatePipe } from './utils/truncate.pipe';
import { TruncatableComponent } from './truncatable/truncatable.component';
import { TruncatableService } from './truncatable/truncatable.service';
+import { TruncatablePartComponent } from './truncatable/truncatable-part/truncatable-part.component';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -82,7 +83,8 @@ const COMPONENTS = [
GridThumbnailComponent,
WrapperListElementComponent,
ViewModeSwitchComponent,
- TruncatableComponent
+ TruncatableComponent,
+ TruncatablePartComponent,
];
const ENTRY_COMPONENTS = [
diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html
new file mode 100644
index 0000000000..60c474395b
--- /dev/null
+++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.html
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss
new file mode 100644
index 0000000000..cd3d245f7f
--- /dev/null
+++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss
@@ -0,0 +1,42 @@
+@import '../../../../styles/variables';
+@import '../../../../styles/mixins';
+
+@mixin clamp($lines, $size-factor: 1, $line-height: $line-height-base) {
+ $height: $line-height * $font-size-base * $size-factor;
+ max-height: $lines * $height;
+ position: relative;
+ overflow: hidden;
+ line-height: $line-height;
+ overflow-wrap: break-word;
+ &:after {
+ content: "...";
+ color: $link-color;
+ text-align: right;
+ position: absolute;
+ padding-right: 15px;
+ top: ($lines - 1) * $height;
+ right: 0;
+ width: 30%;
+ min-width: 75px;
+ max-width: 150px;
+ height: $height;
+ background: linear-gradient(to right, rgba(255, 255, 255, 0), $body-bg 50%);
+ }
+
+}
+
+$h4-factor: strip-unit($h4-font-size);
+@for $i from 1 through 15 {
+ .clamp-#{$i} {
+ @include clamp($i);
+ &.title {
+ @include clamp($i, 1.25);
+ }
+ &.h4 {
+ @include clamp($i, $h4-factor, $headings-line-height);
+
+ }
+ }
+}
+
+
diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts
new file mode 100644
index 0000000000..83a5f04ba4
--- /dev/null
+++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.ts
@@ -0,0 +1,42 @@
+import {
+ Component, Input, OnDestroy, OnInit, ElementRef, ViewChild
+} from '@angular/core';
+import { TruncatableService } from '../truncatable.service';
+
+@Component({
+ selector: 'ds-truncatable-part',
+ templateUrl: './truncatable-part.component.html',
+ styleUrls: ['./truncatable-part.component.scss']
+})
+
+export class TruncatablePartComponent implements OnInit, OnDestroy {
+ @Input() minLines: number;
+ @Input() maxLines: number;
+ @Input() initialExpand = false;
+ @Input() id: string;
+ @Input() type: string;
+ private lines: number;
+ private sub;
+
+ public constructor(private service: TruncatableService) {
+ }
+
+ ngOnInit() {
+ this.setLines();
+ }
+
+ private setLines() {
+ this.sub = this.service.isCollapsed(this.id).subscribe((collapsed: boolean) => {
+ if (collapsed) {
+ this.lines = this.minLines;
+ } else {
+ this.lines = this.maxLines;
+ }
+ });
+ }
+
+ ngOnDestroy(): void {
+ this.sub.unsubscribe();
+ }
+
+}
diff --git a/src/app/shared/truncatable/truncatable.actions.ts b/src/app/shared/truncatable/truncatable.actions.ts
index bc9a7e2258..9d3a51219b 100644
--- a/src/app/shared/truncatable/truncatable.actions.ts
+++ b/src/app/shared/truncatable/truncatable.actions.ts
@@ -11,6 +11,8 @@ import { type } from '../ngrx/type';
*/
export const TruncatableActionTypes = {
TOGGLE: type('dspace/truncatable/TOGGLE'),
+ COLLAPSE: type('dspace/truncatable/COLLAPSE'),
+ EXPAND: type('dspace/truncatable/EXPAND'),
};
export class TruncatableAction implements Action {
@@ -26,4 +28,12 @@ export class TruncatableToggleAction extends TruncatableAction {
type = TruncatableActionTypes.TOGGLE;
}
+export class TruncatableCollapseAction extends TruncatableAction {
+ type = TruncatableActionTypes.COLLAPSE;
+}
+
+export class TruncatableExpandAction extends TruncatableAction {
+ type = TruncatableActionTypes.EXPAND;
+}
+
/* tslint:enable:max-classes-per-file */
diff --git a/src/app/shared/truncatable/truncatable.component.html b/src/app/shared/truncatable/truncatable.component.html
index bf03d73eca..d3ed37e596 100644
--- a/src/app/shared/truncatable/truncatable.component.html
+++ b/src/app/shared/truncatable/truncatable.component.html
@@ -1 +1,3 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/src/app/shared/truncatable/truncatable.component.scss b/src/app/shared/truncatable/truncatable.component.scss
index b68bfd1d6e..e69de29bb2 100644
--- a/src/app/shared/truncatable/truncatable.component.scss
+++ b/src/app/shared/truncatable/truncatable.component.scss
@@ -1,41 +0,0 @@
-@import '../../../styles/_variables.scss';
-@import '../../../styles/_mixins.scss';
-
-@mixin clamp($lines) {
- max-height: $lines * $line-height-base * $font-size-base;
- position: relative;
- overflow: hidden;
- line-height: $line-height-base;
- overflow-wrap: break-word;
-
- &:after {
- content: "...";
- color: $link-color;
- text-align: right;
- position: absolute;
- padding-right: 15px;
- top: ($lines - 1) * $line-height-base * $font-size-base;
- right: 0;
- width: 30%;
- min-width: 75px;
- max-width: 150px;
- height: $line-height-base * $font-size-base;
- background: linear-gradient(to right, rgba(255, 255, 255, 0), $body-bg 50%);
- }
-
-
-}
-.clamp-1 {
-@include clamp(1);
-}
-.clamp-2 {
- @include clamp(2);
- }
-.clamp-3 {
-@include clamp(3);
-}
-.clamp-15 {
-@include clamp(15);
-}
-
-
diff --git a/src/app/shared/truncatable/truncatable.component.ts b/src/app/shared/truncatable/truncatable.component.ts
index 88185140ed..b7667f6f51 100644
--- a/src/app/shared/truncatable/truncatable.component.ts
+++ b/src/app/shared/truncatable/truncatable.component.ts
@@ -9,34 +9,34 @@ import { TruncatableService } from './truncatable.service';
styleUrls: ['./truncatable.component.scss']
})
export class TruncatableComponent {
- @Input() minLines: number;
- @Input() maxLines: number;
@Input() initialExpand = false;
@Input() id: string;
- @Input() content;
- private lines: number;
+ @Input() onHover = false;
public constructor(private service: TruncatableService) {
-
}
ngOnInit() {
if (this.initialExpand) {
- this.service.toggle(this.id);
- }
- this.setLines();
- }
-
- public toggleCollapse() {
- this.service.toggle(this.id);
- this.setLines();
- }
-
- private setLines() {
- if (this.service.isCollapsed(this.id)) {
- this.lines = this.minLines;
+ this.service.expand(this.id);
} else {
- this.lines = this.maxLines;
+ this.service.collapse(this.id);
}
}
+
+ public hoverCollapse() {
+ if (this.onHover) {
+ this.service.collapse(this.id);
+ }
+ }
+
+ public hoverExpand() {
+ if (this.onHover) {
+ this.service.expand(this.id);
+ }
+ }
+
+ public toggle() {
+ this.service.toggle(this.id);
+ }
}
diff --git a/src/app/shared/truncatable/truncatable.reducer.ts b/src/app/shared/truncatable/truncatable.reducer.ts
index f48d92f49c..d9a2111682 100644
--- a/src/app/shared/truncatable/truncatable.reducer.ts
+++ b/src/app/shared/truncatable/truncatable.reducer.ts
@@ -14,7 +14,19 @@ export function truncatableReducer(state = initialState, action: TruncatableActi
switch (action.type) {
- case TruncatableActionTypes.TOGGLE: {
+ case TruncatableActionTypes.COLLAPSE: {
+ return Object.assign({}, state, {
+ [action.id]: {
+ collapsed: true,
+ }
+ });
+ } case TruncatableActionTypes.EXPAND: {
+ return Object.assign({}, state, {
+ [action.id]: {
+ collapsed: false,
+ }
+ });
+ } case TruncatableActionTypes.TOGGLE: {
if (!state[action.id]) {
state[action.id] = {collapsed: false};
}
diff --git a/src/app/shared/truncatable/truncatable.service.ts b/src/app/shared/truncatable/truncatable.service.ts
index e2851a8a3b..5f36c6a60d 100644
--- a/src/app/shared/truncatable/truncatable.service.ts
+++ b/src/app/shared/truncatable/truncatable.service.ts
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { createSelector, MemoizedSelector, Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { TruncatablesState, TruncatableState } from './truncatable.reducer';
-import { TruncatableToggleAction } from './truncatable.actions';
+import { TruncatableExpandAction, TruncatableToggleAction, TruncatableCollapseAction } from './truncatable.actions';
import { hasValue } from '../empty.util';
const truncatableStateSelector = (state: TruncatablesState) => state.truncatable;
@@ -16,7 +16,6 @@ export class TruncatableService {
isCollapsed(id: string): Observable
{
return this.store.select(truncatableByIdSelector(id))
.map((object: TruncatableState) => {
- console.log(object);
if (object) {
return object.collapsed;
} else {
@@ -28,6 +27,14 @@ export class TruncatableService {
public toggle(id: string): void {
this.store.dispatch(new TruncatableToggleAction(id));
}
+
+ public collapse(id: string): void {
+ this.store.dispatch(new TruncatableCollapseAction(id));
+ }
+
+ public expand(id: string): void {
+ this.store.dispatch(new TruncatableExpandAction(id));
+ }
}
function truncatableByIdSelector(id: string): MemoizedSelector {
@@ -36,8 +43,6 @@ function truncatableByIdSelector(id: string): MemoizedSelector(key: string): MemoizedSelector {
return createSelector(truncatableStateSelector, (state: TruncatableState) => {
- console.log(state, 'test');
-
if (hasValue(state)) {
return state[key];
} else {
diff --git a/src/styles/_functions.scss b/src/styles/_functions.scss
index 16c5040e03..81de954285 100644
--- a/src/styles/_functions.scss
+++ b/src/styles/_functions.scss
@@ -1,4 +1,12 @@
@function calculateRem($size) {
$remSize: $size / 16px;
@return $remSize;
+}
+
+@function strip-unit($number) {
+ @if type-of($number) == 'number' and not unitless($number) {
+ @return $number / ($number * 0 + 1);
+ }
+
+ @return $number;
}
\ No newline at end of file