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

+/scripts/admin/pointers.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 36
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
nc 1
dl 0
loc 36
rs 10
c 1
b 0
f 0
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A Pointers.init_ 0 12 1
A pointers.js ➔ Pointers 0 5 1
A Pointers.close_ 0 6 1
1
/** global: GLSR, jQuery */
2
;(function( x ) {
3
4
	'use strict';
5
6
	var Pointers = function() {
7
		x.each( GLSR.pointers, function( i, pointer ) {
8
			this.init_( pointer );
9
		}.bind( this ));
10
	};
11
12
	Pointers.prototype = {
13
		/** @return void */
14
		close_: function( pointerId ) { // string
15
			x.post( GLSR.ajaxurl, {
16
				pointer: pointerId,
17
				action: 'dismiss-wp-pointer',
18
			});
19
		},
20
21
		/** @return void */
22
		init_: function( pointer ) { // object
23
			x( pointer.target ).pointer({
24
				content: pointer.options.content,
25
				position: pointer.options.position,
26
				close: this.close_.bind( pointer.id ),
27
			})
28
			.pointer( 'open' )
29
			.pointer( 'sendToTop' );
30
			x( document ).on( 'wp-window-resized', function() {
31
				x( pointer.target ).pointer( 'reposition' );
32
			});
33
		},
34
	};
35
36
	GLSR.Pointers = Pointers;
37
})( jQuery );
38