Skip to content

Commit

Permalink
Release 1.9.1
Browse files Browse the repository at this point in the history
fixes fit-text directive
  • Loading branch information
billy clark authored Oct 1, 2021
2 parents 892ff5b + 0c8bc1d commit 581aa52
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/angular-app/languageforge/lexicon/editor/_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

.lexAppToolbar {
border: 1px solid $line-color;
margin: 10px 0 20px;
margin: 0 0 5px;
padding: 4px;
width: 100%;
float: left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@
.container-scroll {
overflow-y: scroll;
overflow-x: hidden;
height: calc(100vh - 296px);

@include media-breakpoint-up(sm) {
height: calc(100vh - 296px);
}
@include media-breakpoint-down(sm) {
height: calc(100vh - 270px);
}
}

.comments-right-panel {
color: $Eden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
}
}
.dc-rendered-overflow{
@include media-breakpoint-down(sm) {
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
46 changes: 14 additions & 32 deletions src/angular-app/languageforge/lexicon/shared/fit-text.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,34 @@ import * as angular from 'angular';
export class FitTextDirective implements angular.IDirective {

link(scope: angular.IScope, element: angular.IAugmentedJQuery, attr: angular.IAttributes) {
let kInput: boolean = false;
var defaultHeight = 24;
element.height(40);
element.css({ 'max-height': '40px' });
element.css({ height: '40px' });

function updateHeight(): any {
let height = element.prop('scrollHeight');
element.height = height;
element.css({ 'max-height': height + 'px' });
element.css({ height: height + 'px' });
updateContainersHeight();
}
function updateHeight(): void {

// element is a JQuery object, and element[0] is the textarea DOM object
// the DOM object is the only way we can access the calculated "scrollHeight",
// since the JQuery object doesn't have that property
let el = element[0] as HTMLTextAreaElement;

// start with a small minimum height
el.style.height = "10px";

function updateContainersHeight(): any {
var wHeight = angular.element(window).height();
var editorTitleTextElement = angular.element(document).find('#editor-title-text');
var tHeight = editorTitleTextElement.height();
var primaryNavigationElement = angular.element(document).find('#primary-navigation');
var primaryNavigationHeight = primaryNavigationElement.height();
var scrollingEditorContainerElement = angular.element(document).find('#scrolling-editor-container');

var adjHeight = wHeight - (tHeight - defaultHeight);
var sHeight = adjHeight - (177 + primaryNavigationHeight);
var lHeight = adjHeight - (447 + primaryNavigationHeight);
scrollingEditorContainerElement.css({ height: sHeight + 'px' });
// grow to the height necessary to fit all the text
el.style.height = el.scrollHeight+"px";
}

element.on('keyup', () => {
kInput = true;
scope.$apply(() => {
updateHeight();
});
});

angular.element(window).on('resize',() => {
angular.element(window).on('resize',() => {
updateHeight();
});

// this is required in order to resize the text area when switching between entries
scope.$watch(() => {
if (!kInput){
kInput = false;
updateHeight();
}
updateHeight();
});

}

static factory(): angular.IDirectiveFactory {
Expand Down

0 comments on commit 581aa52

Please sign in to comment.