Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enables text area resize
  • Loading branch information
share-with-me committed Jun 19, 2017
commit eea5402540e1d65c390c5d3b470359891b20fe4a
10 changes: 9 additions & 1 deletion assets/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var TEXTAREA_AUTO_RESIZE_MINIMUM_WIDTH = 768,
BACK_TO_TOP_BUTTON_ACTIVATION_HEIGHT = 300,
THRESHOLD_REQUEST_URL_LENGTH = 2000; // maintain 48 characters buffer for generated parameters

var originalTextScrollHeight;

// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Polyfill
/* eslint-disable */
if (typeof Object.assign != 'function') {
Expand Down Expand Up @@ -162,6 +164,12 @@ $(document).ready(function () {
return false;
});

$('#originalText').mouseup( function() {
if($('#originalText').height() < originalTextScrollHeight) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to check something like :overflow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, :overflow to check if the element is having the overflow?

$('#originalText').css('overflow-y', 'scroll');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this situation be solved with simply a overflow: y-scroll? I'm guessing you've tried it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this situation be solved with simply a overflow: y-scroll?

Um, I had tried that! As soon as synchronizeTextareaHeights method is called, the CSS for this div changes. And thus, I started with this approach of checking if the textarea height falls in the range for scrolling!

}
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra line?

});

if(config.PIWIK_SITEID && config.PIWIK_URL) {
Expand Down Expand Up @@ -278,7 +286,7 @@ function synchronizeTextareaHeights() {
'overflow-y': 'hidden',
'height': 'auto'
});
var originalTextScrollHeight = $('#originalText')[0].scrollHeight;
originalTextScrollHeight = $('#originalText')[0].scrollHeight;
$('#originalText').css('height', originalTextScrollHeight + 'px');
$('#translatedText').css('height', originalTextScrollHeight + 'px');
}
Expand Down