mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Merge pull request #295 from alphagov/resize-textbox
Make textboxes expand to fit contents
This commit is contained in:
@@ -20,8 +20,9 @@
|
|||||||
<div class="textbox-highlight-mask" aria-hidden="true" />
|
<div class="textbox-highlight-mask" aria-hidden="true" />
|
||||||
<div class="textbox-highlight-foreground" aria-hidden="true" />
|
<div class="textbox-highlight-foreground" aria-hidden="true" />
|
||||||
`))
|
`))
|
||||||
.on("input", this.update)
|
.on("input", this.update);
|
||||||
.on("scroll", this.maintainScrollParity);
|
|
||||||
|
this.initialHeight = this.$textbox.height();
|
||||||
|
|
||||||
this.$backgroundMaskForeground.width(
|
this.$backgroundMaskForeground.width(
|
||||||
this.$textbox.width()
|
this.$textbox.width()
|
||||||
@@ -32,14 +33,21 @@
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.update = () => this.$backgroundMaskForeground.html(
|
this.resize = () => this.$textbox.height(
|
||||||
|
Math.max(
|
||||||
|
this.initialHeight,
|
||||||
|
this.$backgroundMaskForeground.outerHeight()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
this.replacePlaceholders = () => this.$backgroundMaskForeground.html(
|
||||||
$('<div/>').text(this.$textbox.val()).html().replace(
|
$('<div/>').text(this.$textbox.val()).html().replace(
|
||||||
tagPattern, match => `<span class='tag'>${match}</span>`
|
tagPattern, match => `<span class='tag'>${match}</span>`
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.maintainScrollParity = () => this.$backgroundMaskForeground.scrollTop(
|
this.update = () => (
|
||||||
this.$textbox.scrollTop()
|
this.replacePlaceholders() && this.resize()
|
||||||
);
|
);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
resize: none;
|
resize: none;
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
background: none;
|
background: none;
|
||||||
|
height: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-textbox,
|
&-textbox,
|
||||||
@@ -23,7 +24,6 @@
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 200px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-background,
|
&-background,
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
color: transparent;
|
color: transparent;
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
border: 2px solid transparent;
|
border: 2px solid transparent;
|
||||||
|
padding-bottom: $gutter;
|
||||||
}
|
}
|
||||||
|
|
||||||
&-background {
|
&-background {
|
||||||
|
|||||||
Reference in New Issue
Block a user