Skip to content

Commit 02e6e64

Browse files
author
Vitaly Kravtsov
committed
get rid of exports-loader dependency and use webpack for building
1 parent 50ce3a0 commit 02e6e64

File tree

8 files changed

+357
-82
lines changed

8 files changed

+357
-82
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015", "react", "stage-1"]
3+
}

dist/index.js

Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
(function webpackUniversalModuleDefinition(root, factory) {
2+
if(typeof exports === 'object' && typeof module === 'object')
3+
module.exports = factory(require("react"), require("react-leaflet"));
4+
else if(typeof define === 'function' && define.amd)
5+
define(["react", "react-leaflet"], factory);
6+
else if(typeof exports === 'object')
7+
exports["FullscreenControl"] = factory(require("react"), require("react-leaflet"));
8+
else
9+
root["FullscreenControl"] = factory(root["react"], root["react-leaflet"]);
10+
})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {
11+
return /******/ (function(modules) { // webpackBootstrap
12+
/******/ // The module cache
13+
/******/ var installedModules = {};
14+
15+
/******/ // The require function
16+
/******/ function __webpack_require__(moduleId) {
17+
18+
/******/ // Check if module is in cache
19+
/******/ if(installedModules[moduleId])
20+
/******/ return installedModules[moduleId].exports;
21+
22+
/******/ // Create a new module (and put it into the cache)
23+
/******/ var module = installedModules[moduleId] = {
24+
/******/ exports: {},
25+
/******/ id: moduleId,
26+
/******/ loaded: false
27+
/******/ };
28+
29+
/******/ // Execute the module function
30+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31+
32+
/******/ // Flag the module as loaded
33+
/******/ module.loaded = true;
34+
35+
/******/ // Return the exports of the module
36+
/******/ return module.exports;
37+
/******/ }
38+
39+
40+
/******/ // expose the modules object (__webpack_modules__)
41+
/******/ __webpack_require__.m = modules;
42+
43+
/******/ // expose the module cache
44+
/******/ __webpack_require__.c = installedModules;
45+
46+
/******/ // __webpack_public_path__
47+
/******/ __webpack_require__.p = "";
48+
49+
/******/ // Load entry module and return exports
50+
/******/ return __webpack_require__(0);
51+
/******/ })
52+
/************************************************************************/
53+
/******/ ([
54+
/* 0 */
55+
/***/ function(module, exports, __webpack_require__) {
56+
57+
'use strict';
58+
59+
Object.defineProperty(exports, "__esModule", {
60+
value: true
61+
});
62+
63+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
64+
65+
var _react = __webpack_require__(1);
66+
67+
var _reactLeaflet = __webpack_require__(2);
68+
69+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
70+
71+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
72+
73+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
74+
75+
__webpack_require__(3);
76+
var fullscreen = __webpack_require__(9);
77+
78+
var FullscreenControl = function (_MapControl) {
79+
_inherits(FullscreenControl, _MapControl);
80+
81+
function FullscreenControl() {
82+
_classCallCheck(this, FullscreenControl);
83+
84+
return _possibleConstructorReturn(this, Object.getPrototypeOf(FullscreenControl).apply(this, arguments));
85+
}
86+
87+
_createClass(FullscreenControl, [{
88+
key: 'componentWillMount',
89+
value: function componentWillMount() {
90+
this.leafletElement = fullscreen(this.props);
91+
}
92+
}]);
93+
94+
return FullscreenControl;
95+
}(_reactLeaflet.MapControl);
96+
97+
FullscreenControl.propTypes = {
98+
position: _react.PropTypes.string,
99+
title: _react.PropTypes.string,
100+
titleCancel: _react.PropTypes.string,
101+
content: _react.PropTypes.node,
102+
forceSeparateButton: _react.PropTypes.bool,
103+
forcePseudoFullscreen: _react.PropTypes.bool,
104+
fullscreenElement: _react.PropTypes.bool
105+
};
106+
107+
exports.default = FullscreenControl;
108+
109+
/***/ },
110+
/* 1 */
111+
/***/ function(module, exports) {
112+
113+
module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
114+
115+
/***/ },
116+
/* 2 */
117+
/***/ function(module, exports) {
118+
119+
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
120+
121+
/***/ },
122+
/* 3 */
123+
/***/ function(module, exports) {
124+
125+
// removed by extract-text-webpack-plugin
126+
127+
/***/ },
128+
/* 4 */,
129+
/* 5 */,
130+
/* 6 */,
131+
/* 7 */,
132+
/* 8 */,
133+
/* 9 */
134+
/***/ function(module, exports) {
135+
136+
(function () {
137+
138+
L.Control.FullScreen = L.Control.extend({
139+
options: {
140+
position: 'topleft',
141+
title: 'Full Screen',
142+
titleCancel: 'Exit Full Screen',
143+
forceSeparateButton: false,
144+
forcePseudoFullscreen: false,
145+
fullscreenElement: false
146+
},
147+
148+
onAdd: function (map) {
149+
var className = 'leaflet-control-zoom-fullscreen', container, content = '';
150+
151+
if (map.zoomControl && !this.options.forceSeparateButton) {
152+
container = map.zoomControl._container;
153+
} else {
154+
container = L.DomUtil.create('div', 'leaflet-bar');
155+
}
156+
157+
if (this.options.content) {
158+
content = this.options.content;
159+
} else {
160+
className += ' fullscreen-icon';
161+
}
162+
163+
this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this);
164+
165+
this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this);
166+
167+
return container;
168+
},
169+
170+
_createButton: function (title, className, content, container, fn, context) {
171+
this.link = L.DomUtil.create('a', className, container);
172+
this.link.href = '#';
173+
this.link.title = title;
174+
this.link.innerHTML = content;
175+
176+
L.DomEvent
177+
.addListener(this.link, 'click', L.DomEvent.stopPropagation)
178+
.addListener(this.link, 'click', L.DomEvent.preventDefault)
179+
.addListener(this.link, 'click', fn, context);
180+
181+
L.DomEvent
182+
.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
183+
.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
184+
.addListener(container, fullScreenApi.fullScreenEventName, this._handleEscKey, context);
185+
186+
L.DomEvent
187+
.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
188+
.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
189+
.addListener(document, fullScreenApi.fullScreenEventName, this._handleEscKey, context);
190+
191+
return this.link;
192+
},
193+
194+
toggleFullScreen: function () {
195+
var map = this._map;
196+
map._exitFired = false;
197+
if (map._isFullscreen) {
198+
if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
199+
fullScreenApi.cancelFullScreen(this.options.fullscreenElement ? this.options.fullscreenElement : map._container);
200+
} else {
201+
L.DomUtil.removeClass(map._container, 'leaflet-pseudo-fullscreen');
202+
}
203+
map.invalidateSize();
204+
map.fire('exitFullscreen');
205+
map._exitFired = true;
206+
map._isFullscreen = false;
207+
}
208+
else {
209+
if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
210+
fullScreenApi.requestFullScreen(this.options.fullscreenElement ? this.options.fullscreenElement : map._container);
211+
} else {
212+
L.DomUtil.addClass(map._container, 'leaflet-pseudo-fullscreen');
213+
}
214+
map.invalidateSize();
215+
map.fire('enterFullscreen');
216+
map._isFullscreen = true;
217+
}
218+
},
219+
220+
_toggleTitle: function () {
221+
this.link.title = this._map._isFullscreen ? this.options.title : this.options.titleCancel;
222+
},
223+
224+
_handleEscKey: function () {
225+
var map = this._map;
226+
if (!fullScreenApi.isFullScreen(map) && !map._exitFired) {
227+
map.fire('exitFullscreen');
228+
map._exitFired = true;
229+
map._isFullscreen = false;
230+
}
231+
}
232+
});
233+
234+
L.Map.addInitHook(function () {
235+
if (this.options.fullscreenControl) {
236+
this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions);
237+
this.addControl(this.fullscreenControl);
238+
}
239+
});
240+
241+
L.control.fullscreen = function (options) {
242+
return new L.Control.FullScreen(options);
243+
};
244+
245+
/*
246+
Native FullScreen JavaScript API
247+
-------------
248+
Assumes Mozilla naming conventions instead of W3C for now
249+
250+
source : http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
251+
252+
*/
253+
254+
var
255+
fullScreenApi = {
256+
supportsFullScreen: false,
257+
isFullScreen: function () { return false; },
258+
requestFullScreen: function () {},
259+
cancelFullScreen: function () {},
260+
fullScreenEventName: '',
261+
prefix: ''
262+
},
263+
browserPrefixes = 'webkit moz o ms khtml'.split(' ');
264+
265+
// check for native support
266+
if (typeof document.exitFullscreen !== 'undefined') {
267+
fullScreenApi.supportsFullScreen = true;
268+
} else {
269+
// check for fullscreen support by vendor prefix
270+
for (var i = 0, il = browserPrefixes.length; i < il; i++) {
271+
fullScreenApi.prefix = browserPrefixes[i];
272+
if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] !== 'undefined') {
273+
fullScreenApi.supportsFullScreen = true;
274+
break;
275+
}
276+
}
277+
if (typeof document['msExitFullscreen'] !== 'undefined') {
278+
fullScreenApi.prefix = 'ms';
279+
fullScreenApi.supportsFullScreen = true;
280+
}
281+
}
282+
283+
// update methods to do something useful
284+
if (fullScreenApi.supportsFullScreen) {
285+
if (fullScreenApi.prefix === 'ms') {
286+
fullScreenApi.fullScreenEventName = 'MSFullscreenChange';
287+
} else {
288+
fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
289+
}
290+
fullScreenApi.isFullScreen = function () {
291+
switch (this.prefix) {
292+
case '':
293+
return document.fullScreen;
294+
case 'webkit':
295+
return document.webkitIsFullScreen;
296+
case 'ms':
297+
return document.msFullscreenElement;
298+
default:
299+
return document[this.prefix + 'FullScreen'];
300+
}
301+
};
302+
fullScreenApi.requestFullScreen = function (el) {
303+
switch (this.prefix) {
304+
case '':
305+
return el.requestFullscreen();
306+
case 'ms':
307+
return el.msRequestFullscreen();
308+
default:
309+
return el[this.prefix + 'RequestFullScreen']();
310+
}
311+
};
312+
fullScreenApi.cancelFullScreen = function () {
313+
switch (this.prefix) {
314+
case '':
315+
return document.exitFullscreen();
316+
case 'ms':
317+
return document.msExitFullscreen();
318+
default:
319+
return document[this.prefix + 'CancelFullScreen']();
320+
}
321+
};
322+
}
323+
324+
// jQuery plugin
325+
if (typeof jQuery !== 'undefined') {
326+
jQuery.fn.requestFullScreen = function () {
327+
return this.each(function () {
328+
var el = jQuery(this);
329+
if (fullScreenApi.supportsFullScreen) {
330+
fullScreenApi.requestFullScreen(el);
331+
}
332+
});
333+
};
334+
}
335+
336+
// export api
337+
window.fullScreenApi = fullScreenApi;
338+
})();
339+
340+
341+
/*** EXPORTS FROM exports-loader ***/
342+
module.exports = L.control.fullscreen;
343+
344+
/***/ }
345+
/******/ ])
346+
});
347+
;
File renamed without changes.

gulpfile.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
require('./node_modules/leaflet.fullscreen/Control.FullScreen.css');
2+
const fullscreen = require('exports?L.control.fullscreen!leaflet.fullscreen');
13
import { PropTypes } from 'react';
24
import { MapControl } from 'react-leaflet';
3-
const fullscreen = require('exports?L.control.fullscreen!leaflet.fullscreen');
45

56
class FullscreenControl extends MapControl {
67
componentWillMount() {

0 commit comments

Comments
 (0)