mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-18 07:01:58 +08:00
a3bbf94643
This fixes the mentioned issues @mlorb mentioned. Closes SCI-637.
30 lines
786 B
JavaScript
30 lines
786 B
JavaScript
$(document).on(
|
|
'focus',
|
|
'textarea.smart-text-area:not([readonly]):not([disabled])',
|
|
function() {
|
|
var $this = $(this);
|
|
var height = $this.css('height');
|
|
|
|
if ($this.hasClass('textarea-sm-present')) {
|
|
$this
|
|
.removeClass('textarea-sm-present')
|
|
.addClass('textarea-sm');
|
|
$this.attr('rows', '1');
|
|
} else if ($this.hasClass('textarea-sm')) {
|
|
// Set the nr. of rows to 1 if small textarea
|
|
$this.attr('rows', '1');
|
|
} else {
|
|
$this.removeAttr('rows');
|
|
}
|
|
|
|
// Initialize autosize plugin if it's not initialized yet
|
|
if (_.isUndefined($this.data('autosize'))) {
|
|
$this.autosize({append: ''});
|
|
|
|
// Restore previous height!
|
|
$this.css('height', height);
|
|
}
|
|
|
|
$this.trigger('autosize.resize');
|
|
}
|
|
);
|