Passed
Push — master ( e0ac9d...715f03 )
by Paul
04:37
created

+/scripts/admin/pointers.js   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 34
rs 9.064
c 1
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A GLSR.Pointers.init_ 0 12 1
A GLSR.Pointers 0 5 1
A GLSR.Pointers.close_ 0 6 1
1
/** global: GLSR, jQuery */
2
;(function( $ ) {
3
4
	'use strict';
5
6
	GLSR.Pointers = function() {
7
		$.each( GLSR.pointers, function( i, pointer ) {
8
			this.init_( pointer );
9
		}.bind( this ));
10
	};
11
12
	GLSR.Pointers.prototype = {
13
		/** @return void */
14
		close_: function( pointerId ) { // string
15
			$.post( GLSR.ajaxurl, {
16
				action: 'dismiss-wp-pointer',
17
				pointer: pointerId,
18
			});
19
		},
20
21
		/** @return void */
22
		init_: function( pointer ) { // object
23
			$( 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
			$( document ).on( 'wp-window-resized', function() {
31
				$( pointer.target ).pointer( 'reposition' );
32
			});
33
		},
34
	};
35
})( jQuery );
36