Test Setup Failed
Push — master ( 51607c...6b8ca8 )
by Paul
03:43
created

T_IDENTIFIER   A

Complexity

Total Complexity 16
Complexity/F 1.6

Size

Lines of Code 1
Function Count 10

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 16
dl 0
loc 1
rs 10
c 0
b 0
f 0
cc 0
nc 2
mnd 1
bc 15
fnc 10
bpm 1.5
cpm 1.6
noi 3
1
/** global: GLSR, site_reviews_pointers, wp, x */
2
3
x( function()
4
{
5
	var GLSR_fix = GLSR.getURLParameter( 'fix' );
6
	var GLSR_textarea = x( '#contentdiv > textarea' );
7
8
	if( GLSR_fix ) {
9
		x( 'td [data-key="' + GLSR_fix + '"]').focus();
10
	}
11
12
	if( GLSR_textarea.length ) {
13
		GLSR.textareaResize( GLSR_textarea );
14
15
		x( document ).on( 'wp-window-resized.editor-expand', function() {
16
			GLSR.textareaResize( GLSR_textarea );
17
		});
18
	}
19
20
	x( 'form' ).on( 'change', ':input', GLSR.onFieldChange );
21
	x( 'form' ).on( 'click', '#clear-log', GLSR.onClearLog );
22
23
	GLSR.colorControls();
24
	GLSR.pinned.events();
25
26
	x.each( site_reviews_pointers.pointers, function( i, pointer ) {
27
		GLSR.pointers( pointer );
28
	});
29
30
	x( document ).on( 'click', function( ev )
31
	{
32
		if( !x( ev.target ).closest( '.glsr-mce' ).length ) {
33
			GLSR.shortcode.close();
34
		}
35
	});
36
37
	x( document ).on( 'click', '.glsr-mce-button', GLSR.shortcode.toggle );
38
	x( document ).on( 'click', '.glsr-mce-menu-item', GLSR.shortcode.trigger );
39
	x( document ).on( 'click', 'a.change-site-review-status', GLSR.onChangeStatus );
40
41
	// WP 4.0 - 4.2 support: toggle list table rows on small screens
42
	x( document ).on( 'click', '.branch-4 .toggle-row, .branch-4-1 .toggle-row, .branch-4-2 .toggle-row', function() {
43
		x( this ).closest( 'tr' ).toggleClass( 'is-expanded' );
44
	});
45
46
	new GLSR.search( '#glsr-search-translations', {
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new GLSR.search("#glsr-s...alse,false,None,None)}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
47
		action: 'search-translations',
48
		onInit: function() {
49
			this.makeSortable();
50
		},
51
		onResultClick: function( ev ) {
52
			var result = x( ev.target );
53
			var entry = result.data( 'entry' );
54
			var template = wp.template( 'glsr-string-' + ( entry.p1 ? 'plural' : 'single' ));
55
			entry.index = this.options.entriesEl.children().length;
56
			entry.prefix = this.options.resultsEl.data( 'prefix' );
57
			if( template ) {
58
				this.options.entriesEl.append( template( entry ));
59
				this.options.exclude.push({ id: entry.id });
60
				this.options.results = this.options.results.filter( function( i, el ) {
61
					return el !== result.get(0);
62
				});
63
			}
64
			this.setVisibility();
65
		},
66
	});
67
68
	new GLSR.search( '#glsr-search-posts', {
0 ignored issues
show
Unused Code Best Practice introduced by
The object created with new GLSR.search("#glsr-s...alse,false,None,None)}) is not used but discarded. Consider invoking another function instead of a constructor if you are doing this purely for side effects.
Loading history...
69
		action: 'search-posts',
70
		onInit: function() {
71
			this.el.on( 'click', '.glsr-remove-button', this.onUnassign.bind( this ));
72
		},
73
		onResultClick: function( ev ) {
74
			var result = x( ev.target );
75
			var template = wp.template( 'glsr-assigned-post' );
76
			var entry = {
77
				url: result.data( 'url' ),
78
				title: result.text(),
79
			};
80
			if( template ) {
81
				this.el.find( 'input#assigned_to' ).val( result.data( 'id' ));
82
				this.el.find( '.description' ).html( template( entry ));
83
				this.el.on( 'click', '.glsr-remove-button', this.onUnassign.bind( this ));
84
				this.reset();
85
			}
86
		},
87
	});
88
});
89