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

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

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 25
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 2
dl 0
loc 25
rs 10
c 1
b 0
f 0
wmc 6
mnd 1
bc 4
fnc 4
bpm 1
cpm 1.5
noi 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