Total Complexity | 6 |
Complexity/F | 1.5 |
Lines of Code | 25 |
Function Count | 4 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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 |