Skip to content

Commit 581aa52

Browse files
author
billy clark
authored
Release 1.9.1
fixes fit-text directive
2 parents 892ff5b + 0c8bc1d commit 581aa52

File tree

4 files changed

+26
-40
lines changed

4 files changed

+26
-40
lines changed

src/angular-app/languageforge/lexicon/editor/_editor.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
.lexAppToolbar {
88
border: 1px solid $line-color;
9-
margin: 10px 0 20px;
9+
margin: 0 0 5px;
1010
padding: 4px;
1111
width: 100%;
1212
float: left;

src/angular-app/languageforge/lexicon/editor/comment/lex-comments-view.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818
.container-scroll {
1919
overflow-y: scroll;
2020
overflow-x: hidden;
21-
height: calc(100vh - 296px);
21+
22+
@include media-breakpoint-up(sm) {
23+
height: calc(100vh - 296px);
24+
}
25+
@include media-breakpoint-down(sm) {
26+
height: calc(100vh - 270px);
2227
}
28+
}
2329

2430
.comments-right-panel {
2531
color: $Eden;

src/angular-app/languageforge/lexicon/editor/field/_dc-rendered.scss

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
}
2727
}
2828
.dc-rendered-overflow{
29-
@include media-breakpoint-down(sm) {
30-
display: -webkit-box;
31-
-webkit-line-clamp: 3;
32-
-webkit-box-orient: vertical;
33-
overflow: hidden;
34-
}
29+
display: -webkit-box;
30+
-webkit-line-clamp: 2;
31+
-webkit-box-orient: vertical;
32+
overflow: hidden;
3533
}

src/angular-app/languageforge/lexicon/shared/fit-text.directive.ts

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,34 @@ import * as angular from 'angular';
33
export class FitTextDirective implements angular.IDirective {
44

55
link(scope: angular.IScope, element: angular.IAugmentedJQuery, attr: angular.IAttributes) {
6-
let kInput: boolean = false;
7-
var defaultHeight = 24;
8-
element.height(40);
9-
element.css({ 'max-height': '40px' });
10-
element.css({ height: '40px' });
11-
12-
function updateHeight(): any {
13-
let height = element.prop('scrollHeight');
14-
element.height = height;
15-
element.css({ 'max-height': height + 'px' });
16-
element.css({ height: height + 'px' });
17-
updateContainersHeight();
18-
}
6+
function updateHeight(): void {
7+
8+
// element is a JQuery object, and element[0] is the textarea DOM object
9+
// the DOM object is the only way we can access the calculated "scrollHeight",
10+
// since the JQuery object doesn't have that property
11+
let el = element[0] as HTMLTextAreaElement;
12+
13+
// start with a small minimum height
14+
el.style.height = "10px";
1915

20-
function updateContainersHeight(): any {
21-
var wHeight = angular.element(window).height();
22-
var editorTitleTextElement = angular.element(document).find('#editor-title-text');
23-
var tHeight = editorTitleTextElement.height();
24-
var primaryNavigationElement = angular.element(document).find('#primary-navigation');
25-
var primaryNavigationHeight = primaryNavigationElement.height();
26-
var scrollingEditorContainerElement = angular.element(document).find('#scrolling-editor-container');
27-
28-
var adjHeight = wHeight - (tHeight - defaultHeight);
29-
var sHeight = adjHeight - (177 + primaryNavigationHeight);
30-
var lHeight = adjHeight - (447 + primaryNavigationHeight);
31-
scrollingEditorContainerElement.css({ height: sHeight + 'px' });
16+
// grow to the height necessary to fit all the text
17+
el.style.height = el.scrollHeight+"px";
3218
}
3319

3420
element.on('keyup', () => {
35-
kInput = true;
3621
scope.$apply(() => {
3722
updateHeight();
3823
});
3924
});
4025

41-
angular.element(window).on('resize',() => {
26+
angular.element(window).on('resize',() => {
4227
updateHeight();
4328
});
4429

30+
// this is required in order to resize the text area when switching between entries
4531
scope.$watch(() => {
46-
if (!kInput){
47-
kInput = false;
48-
updateHeight();
49-
}
32+
updateHeight();
5033
});
51-
5234
}
5335

5436
static factory(): angular.IDirectiveFactory {

0 commit comments

Comments
 (0)