PageSourceSearch

https://www.tifviking.no/wp-content/plugins/wp-gpx-maps/ThirdParti…/Control.FullScreen.js?ver=1.4.5

js tifviking.no collected 2026-10-01 12:26:13 UTC 6,186 bytes, 202 lines download raw bytes

1(function () {
2
3L.Control.FullScreen = L.Control.extend({
4	options: {
5		position: 'topleft',
6		title: 'Full Screen',
7		titleCancel: 'Exit Full Screen',
8		forceSeparateButton: false,
9		forcePseudoFullscreen: false,
10		fullscreenElement: false
11	},
12	
13	onAdd: function (map) {
14		var className = 'leaflet-control-zoom-fullscreen', container, content = '';
15		
16		if (map.zoomControl && !this.options.forceSeparateButton) {
17			container = map.zoomControl._container;
18		} else {
19			container = L.DomUtil.create('div', 'leaflet-bar');
20		}
21		
22		if (this.options.content) {
23			content = this.options.content;
24		} else {
25			className += ' fullscreen-icon';
26		}
27
28		this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this);
29
30		this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this);
31
32		return container;
33	},
34	
35	_createButton: function (title, className, content, container, fn, context) {
36		this.link = L.DomUtil.create('a', className, container);
37		this.link.href = '#';
38		this.link.title = title;
39		this.link.innerHTML = content;
40
41		L.DomEvent
42			.addListener(this.link, 'click', L.DomEvent.stopPropagation)
43			.addListener(this.link, 'click', L.DomEvent.preventDefault)
44			.addListener(this.link, 'click', fn, context);
45		
46		L.DomEvent
47			.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
48			.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
49			.addListener(container, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context);
50		
51		L.DomEvent
52			.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
53			.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
54			.addListener(document, fullScreenApi.fullScreenEventName, this._handleFullscreenChange, context);
55
56		return this.link;
57	},
58	
59	toggleFullScreen: function () {
60		var map = this._map;
61		map._exitFired = false;
62		if (map._isFullscreen) {
63			if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
64				fullScreenApi.cancelFullScreen();
65			} else {
66				L.DomUtil.removeClass(this.options.fullscreenElement ? this.options.fullscreenElement : map._container, 'leaflet-pseudo-fullscreen');
67			}
68			map.fire('exitFullscreen');
69			map._exitFired = true;
70			map._isFullscreen = false;
71		}
72		else {
73			if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
74				fullScreenApi.requestFullScreen(this.options.fullscreenElement ? this.options.fullscreenElement : map._container);
75			} else {
76				L.DomUtil.addClass(this.options.fullscreenElement ? this.options.fullscreenElement : map._container, 'leaflet-pseudo-fullscreen');
77			}
78			map.fire('enterFullscreen');
79			map._isFullscreen = true;
80		}
81	},
82	
83	_toggleTitle: function () {
84		this.link.title = this._map._isFullscreen ? this.options.title : this.options.titleCancel;
85	},
86	
87	_handleFullscreenChange: function () {
88		var map = this._map;
89		map.invalidateSize();
90		if (!fullScreenApi.isFullScreen() && !map._exitFired) {
91			map.fire('exitFullscreen');
92			map._exitFired = true;
93			map._isFullscreen = false;
94		}
95	}
96});
97
98L.Map.addInitHook(function () {
99	if (this.options.fullscreenControl) {
100		this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions);
101		this.addControl(this.fullscreenControl);
102	}
103});
104
105L.control.fullscreen = function (options) {
106	return new L.Control.FullScreen(options);
107};
108
109/* 
110Native FullScreen JavaScript API
111-------------
112Assumes Mozilla naming conventions instead of W3C for now
113
114source : http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
115
116*/
117
118	var 
119		fullScreenApi = { 
120			supportsFullScreen: false,
121			isFullScreen: function () { return false; }, 
122			requestFullScreen: function () {}, 
123			cancelFullScreen: function () {},
124			fullScreenEventName: '',
125			prefix: ''
126		},
127		browserPrefixes = 'webkit moz o ms khtml'.split(' ');
128	
129	// check for native support
130	if (typeof document.exitFullscreen !== 'undefined') {
131		fullScreenApi.supportsFullScreen = true;
132	} else {
133		// check for fullscreen support by vendor prefix
134		for (var i = 0, il = browserPrefixes.length; i < il; i++) {
135			fullScreenApi.prefix = browserPrefixes[i];
136			if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] !== 'undefined') {
137				fullScreenApi.supportsFullScreen = true;
138				break;
139			}
140		}
141		if (typeof document['msExitFullscreen'] !== 'undefined') {
142			fullScreenApi.prefix = 'ms';
143			fullScreenApi.supportsFullScreen = true;
144		}
145	}
146	
147	// update methods to do something useful
148	if (fullScreenApi.supportsFullScreen) {
149		if (fullScreenApi.prefix === 'ms') {
150			fullScreenApi.fullScreenEventName = 'MSFullscreenChange';
151		} else {
152			fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
153		}
154		fullScreenApi.isFullScreen = function () {
155			switch (this.prefix) {
156				case '':
157					return document.fullscreen;
158				case 'webkit':
159					return document.webkitIsFullScreen;
160				case 'ms':
161					return document.msFullscreenElement;
162				default:
163					return document[this.prefix + 'FullScreen'];
164			}
165		};
166		fullScreenApi.requestFullScreen = function (el) {
167			switch (this.prefix) {
168				case '':
169					return el.requestFullscreen();
170				case 'ms':
171					return el.msRequestFullscreen();
172				default:
173					return el[this.prefix + 'RequestFullScreen']();
174			}
175		};
176		fullScreenApi.cancelFullScreen = function () {
177			switch (this.prefix) {
178				case '':
179					return document.exitFullscreen();
180				case 'ms':
181					return document.msExitFullscreen();
182				default:
183					return document[this.prefix + 'CancelFullScreen']();
184			}
185		};
186	}
187
188	// jQuery plugin
189	if (typeof jQuery !== 'undefined') {
190		jQuery.fn.requestFullScreen = function () {
191			return this.each(function () {
192				var el = jQuery(this);
193				if (fullScreenApi.supportsFullScreen) {
194					fullScreenApi.requestFullScreen(el);
195				}
196			});
197		};
198	}
199
200	// export api
201	window.fullScreenApi = fullScreenApi;
202})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.