Passed
Push — develop ( c6dd2a...1f8334 )
by Paul
03:38
created

assets/js/googlemaps.js   A

Complexity

Total Complexity 7
Complexity/F 1.4

Size

Lines of Code 58
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
nc 2
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 7
mnd 1
bc 6
fnc 5
bpm 1.2
cpm 1.4
noi 6

3 Functions

Rating   Name   Duplication   Size   Complexity  
A Plugin.init 0 13 1
A googlemaps.js ➔ Plugin 0 8 3
A Plugin.onResize 0 6 1
1
;(function( window, document, undefined ) {
0 ignored issues
show
Unused Code introduced by
The parameter undefined is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
2
	"use strict";
3
4
	var Plugin = function( selector, options, markerOptions )
5
	{
6
		this.el = castor._isString( selector ) ? document.querySelector( selector ) : selector;
0 ignored issues
show
Bug introduced by
The variable castor seems to be never declared. If this is a global, consider adding a /** global: castor */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
7
		if( this.el ) {
8
			this.options = castor._extend( this.defaults, options, this.el.getAttribute( 'data-map-options' ));
9
			this.init( markerOptions );
10
		}
11
	}
12
13
	Plugin.prototype =
14
	{
15
		defaults: {
16
			center: { lat:0, lng:0 },
17
			disableDoubleClickZoom: true,
18
			draggable: true,
19
			fullscreenControl: false,
20
			mapTypeControl: false,
21
			// mapTypeId: google.maps.MapTypeId.ROADMAP,
22
			overviewMapControl: false,
23
			rotateControl: false,
24
			scaleControl: false,
25
			scrollwheel: false,
26
			streetViewControl: false,
27
			styles: [],
28
			zoom: 16,
29
			zoomControl: true,
30
		},
31
32
		init: function( markerOptions )
33
		{
34
			this.map = new google.maps.Map( this.el, this.options );
0 ignored issues
show
Bug introduced by
The variable google seems to be never declared. If this is a global, consider adding a /** global: google */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
35
36
			this.markerOptions = castor._extend({
0 ignored issues
show
Bug introduced by
The variable castor seems to be never declared. If this is a global, consider adding a /** global: castor */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
37
				position: this.options.center,
38
				animation: google.maps.Animation.DROP,
39
			}, markerOptions, this.el.getAttribute( 'data-marker-options' ), { map: this.map });
40
41
			this.marker = new google.maps.Marker( this.markerOptions );
42
43
			google.maps.event.addDomListener( window, 'resize', this.onResize.bind( this ));
44
		},
45
46
		onResize: function()
47
		{
48
			(new AnimationFrame()).request( function() {
0 ignored issues
show
Bug introduced by
The variable AnimationFrame seems to be never declared. If this is a global, consider adding a /** global: AnimationFrame */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
49
				this.map.setCenter( this.marker.getPosition() );
50
			}.bind( this ));
51
		},
52
	};
53
54
	Plugin.defaults = Plugin.prototype.defaults;
55
56
	castor.GoogleMaps = Plugin;
0 ignored issues
show
Bug introduced by
The variable castor seems to be never declared. If this is a global, consider adding a /** global: castor */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
57
58
})( window, document );
59