-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
586 additions
and
457 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules/ | ||
npm-debug.log | ||
src/*.min.js | ||
src/*.min.css | ||
src/**/*.min.js | ||
src/**/*.min.css | ||
build/**/*.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,59 +13,57 @@ import 'leaflet-easyprint'; | |
import 'leaflet.control.resizer'; | ||
import 'leaflet.visualclick'; | ||
|
||
const currentScript = document.currentScript; | ||
const currentVersion = version.split("+")[0].trim(); | ||
|
||
(function() { | ||
|
||
var lazyLoader = { | ||
const currentScript = document.currentScript; | ||
const currentVersion = version.split("+")[0].trim(); | ||
|
||
baseURL: 'https://unpkg.com/', | ||
var lazyLoader = { | ||
|
||
// Sequentially download multiple scripts. | ||
loadSyncScripts: function(urls) { | ||
return urls.reduce((prev, curr) => prev.then(() => lazyLoader.loadAsyncScripts(curr)), Promise.resolve()); | ||
}, | ||
baseURL: 'https://unpkg.com/', | ||
|
||
// Parallel download multiple scripts. | ||
loadAsyncScripts: function(urls) { | ||
return Promise.all(urls.map((url) => lazyLoader.loadScript(url))); | ||
}, | ||
// Sequentially download multiple scripts. | ||
loadSyncScripts: function(urls) { | ||
return urls.reduce((prev, curr) => prev.then(() => lazyLoader.loadAsyncScripts(curr)), Promise.resolve()); | ||
}, | ||
|
||
// Dynamically load a single script. | ||
loadScript: function(url) { | ||
return new Promise((resolve, reject) => { | ||
// Parallel download multiple scripts. | ||
loadAsyncScripts: function(urls) { | ||
return Promise.all(urls.map((url) => lazyLoader.loadScript(url))); | ||
}, | ||
|
||
let type = url.split('.').pop().split('?')[0]; | ||
let tag = type == 'css' ? 'link' : 'script'; | ||
let script = document.createElement(tag); | ||
let head = document.head; | ||
let root_script = (head.contains(currentScript) ? currentScript : head.lastChild) || head; | ||
let prev_tag = lazyLoader["prev_" + tag] || (tag == 'script' && lazyLoader.prev_link ? lazyLoader.prev_link : root_script); | ||
let base_url = (url.indexOf(".") === 0 || url.indexOf("/") === 0 || url.indexOf('http://') === 0 || url.indexOf('https://') === 0) ? '' : lazyLoader.baseURL; | ||
// Dynamically load a single script. | ||
loadScript: function(url) { | ||
return new Promise((resolve, reject) => { | ||
|
||
if (type == 'css') { | ||
script.rel = 'stylesheet'; | ||
} | ||
let type = url.split('.').pop().split('?')[0]; | ||
let tag = type == 'css' ? 'link' : 'script'; | ||
let script = document.createElement(tag); | ||
let head = document.head; | ||
let root_script = (head.contains(currentScript) ? currentScript : head.lastChild) || head; | ||
let prev_tag = lazyLoader["prev_" + tag] || (tag == 'script' && lazyLoader.prev_link ? lazyLoader.prev_link : root_script); | ||
let base_url = (url.indexOf(".") === 0 || url.indexOf("/") === 0 || url.indexOf('http://') === 0 || url.indexOf('https://') === 0) ? '' : lazyLoader.baseURL; | ||
|
||
script.addEventListener('load', resolve, { | ||
once: true | ||
}); | ||
script.setAttribute(type == 'css' ? 'href' : 'src', base_url + url); | ||
|
||
if (prev_tag.parentNode && prev_tag.nextSibling) | ||
prev_tag.parentNode.insertBefore(script, prev_tag.nextSibling); | ||
else | ||
head.appendChild(script); | ||
if (type == 'css') { | ||
script.rel = 'stylesheet'; | ||
} | ||
|
||
lazyLoader["prev_" + tag] = script; | ||
script.addEventListener('load', resolve, { | ||
once: true | ||
}); | ||
script.setAttribute(type == 'css' ? 'href' : 'src', base_url + url); | ||
|
||
}); | ||
} | ||
if (prev_tag.parentNode && prev_tag.nextSibling) | ||
prev_tag.parentNode.insertBefore(script, prev_tag.nextSibling); | ||
else | ||
head.appendChild(script); | ||
|
||
}; | ||
lazyLoader["prev_" + tag] = script; | ||
|
||
}); | ||
} | ||
|
||
(function() { | ||
}; | ||
|
||
// You can ovveride them by passing one of the following to leaflet map constructor. | ||
var default_options = { | ||
|
@@ -132,7 +130,7 @@ var lazyLoader = { | |
position: 'bottomright' | ||
}, | ||
rotateControl: { | ||
position: 'bottomright' | ||
position: 'bottomright', | ||
}, | ||
scaleControl: { | ||
width: 200, | ||
|
@@ -247,6 +245,7 @@ var lazyLoader = { | |
resizerControl: false, | ||
disableDefaultUI: false, | ||
includeLeafletCSS: true, | ||
includeLeafletUICSS: true, | ||
apiKeys: undefined, // eg. { thunderforest: "", google: "", ... } | ||
_isMiniMap: false, // used to prevent infinite loops when loading the minimap control. | ||
}); | ||
|
@@ -483,7 +482,10 @@ var lazyLoader = { | |
// Load custom plugins. | ||
if (this.options.plugins) { | ||
if (!lazyLoader.loader) { | ||
var core_plugins = ["leaflet-ui@" + currentVersion + "/dist/leaflet-ui.css"]; | ||
var core_plugins = []; | ||
if (this.options.includeLeafletUICSS) { | ||
core_plugins.unshift("leaflet-ui@" + currentVersion + "/dist/leaflet-ui.css"); | ||
} | ||
if (!window.L) { | ||
core_plugins.unshift("[email protected]/dist/leaflet.css"); | ||
core_plugins.unshift("[email protected]/dist/leaflet.js"); | ||
|
@@ -515,10 +517,7 @@ var lazyLoader = { | |
}); | ||
} | ||
|
||
lazyLoader.loader | ||
.then(function() { | ||
this.fire('plugins_loaded'); | ||
}.bind(this)); | ||
lazyLoader.loader.then(() => this.fire('plugins_loaded')); | ||
} | ||
} | ||
|
||
|