debian-mirror-gitlab/app/assets/javascripts/behaviors/autosize.js
2017-08-17 22:00:37 +05:30

23 lines
603 B
JavaScript

import autosize from 'vendor/autosize';
$(() => {
const $fields = $('.js-autosize');
$fields.on('autosize:resized', function resized() {
const $field = $(this);
$field.data('height', $field.outerHeight());
});
$fields.on('resize.autosize', function resize() {
const $field = $(this);
if ($field.data('height') !== $field.outerHeight()) {
$field.data('height', $field.outerHeight());
autosize.destroy($field);
$field.css('max-height', window.outerHeight);
}
});
autosize($fields);
autosize.update($fields);
$fields.css('resize', 'vertical');
});