Passed
Push — master ( 33081a...0dd98d )
by Paul
05:28
created

+/scripts/admin/textarea-resize.js   B

Complexity

Conditions 1
Paths 2

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 2
nop 1
dl 0
loc 25
rs 8.8571
c 1
b 0
f 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A textarea-resize.js ➔ TextareaResize 0 8 2
A TextareaResize.resize_ 0 6 2
1
/** global: GLSR, jQuery */
2
;(function( x ) {
3
4
	'use strict';
5
6
	var TextareaResize = function() {
7
		var textarea = document.querySelector( '#contentdiv > textarea' );
8
		if( !textarea )return;
9
		this.resize_( textarea );
10
		x( document ).on( 'wp-window-resized.editor-expand', function() {
11
			this.resize_( textarea );
12
		}.bind( this ));
13
	};
14
15
	TextareaResize.prototype = {
16
		/** @return void */
17
		resize_: function( textareaEl ) { // HTMLElement
18
			var minHeight = 320;
19
			var height = textareaEl.scrollHeight > minHeight ? textareaEl.scrollHeight : minHeight;
20
			textareaEl.style.height = 'auto';
21
			textareaEl.style.height = height + 'px';
22
		},
23
	};
24
25
	GLSR.TextareaResize = TextareaResize;
26
})( jQuery );
27