Skip to content

Commit 8282173

Browse files
committed
Make tess-expandable expand to max height on first click
instead of expanding incrementally.
1 parent d59c95c commit 8282173

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

app/assets/javascripts/application.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,11 @@ document.addEventListener("turbolinks:load", function(e) {
283283
var maxHeight = parseInt(div.dataset.origHeight) + 80;
284284
var limit = parseInt(div.dataset.heightLimit || "300");
285285

286-
if (div.clientHeight < maxHeight && this.innerHTML !== 'Show less') {
287-
var newHeight = div.clientHeight + limit;
288-
if (newHeight > maxHeight) {
289-
div.classList.add('tess-expandable-open');
290-
div.classList.remove('tess-expandable-closed');
291-
newHeight = maxHeight;
292-
this.innerHTML = 'Show less';
293-
}
294-
div.style.maxHeight = '' + newHeight + 'px';
286+
if (div.classList.contains('tess-expandable-closed')) {
287+
div.classList.add('tess-expandable-open');
288+
div.classList.remove('tess-expandable-closed');
289+
div.style.maxHeight = '' + maxHeight + 'px';
290+
this.innerHTML = 'Show less';
295291
} else {
296292
div.classList.remove('tess-expandable-open');
297293
div.classList.add('tess-expandable-closed');

0 commit comments

Comments
 (0)