ES6 setup (#10)

* Updates

* New setup

* Make dist
This commit is contained in:
Jelte Lagendijk
2017-11-20 09:11:22 +01:00
committed by GitHub
parent d10164476f
commit eb82978b8f
35 changed files with 9898 additions and 2726 deletions

11
.babelrc Normal file
View File

@@ -0,0 +1,11 @@
{
"presets": [
"stage-1",
["env", {
"modules": false
}]
],
"plugins": [
]
}

3
.eslintignore Normal file
View File

@@ -0,0 +1,3 @@
webpack.config.js
Gulpfile.js
build/**/*

139
.eslintrc Normal file
View File

@@ -0,0 +1,139 @@
{
"extends": ["eslint:recommended"],
"env": {
"amd": true,
"browser": true
},
"plugins": [],
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module",
"ecmaFeatures": {
"globalReturn": true
}
},
"globals": {
"mendix": true,
"mx": true,
"logger": true,
"mxui": true,
"config": true
},
"rules": {
"comma-dangle": [1,"always-multiline"],
"no-cond-assign": [2,"except-parens"],
"no-console": 0,
"no-constant-condition": 1,
"no-control-regex": 1,
"no-debugger": 2,
"no-dupe-args": 2,
"no-dupe-keys": 2,
"no-duplicate-case": 2,
"no-empty-character-class": 2,
"no-empty": 1,
"no-ex-assign": 2,
"no-extra-boolean-cast": 1,
"no-extra-parens": [1,"all"],
"no-extra-semi": 1,
"no-func-assign": 2,
"no-inner-declarations": [2,"both"],
"no-invalid-regexp": 2,
"no-irregular-whitespace": 2,
"no-obj-calls": 2,
"no-regex-spaces": 1,
"no-sparse-arrays": 2,
"no-unreachable": 2,
"use-isnan": 2,
"valid-typeof": 2,
"no-unexpected-multiline": 2,
"accessor-pairs": [1,{"getWithoutSet":true,"setWithoutGet":true}],
"block-scoped-var": 2,
"consistent-return": 1,
"curly": ["error", "all"],
"default-case": 1,
"dot-notation": 2,
"dot-location": [1,"property"],
"eqeqeq": [2,"smart"],
"guard-for-in": 1,
"no-alert": 2,
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 1,
"no-eq-null": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 1,
"no-fallthrough": 1,
"no-floating-decimal": 2,
"no-implied-eval": 2,
"no-invalid-this": 1,
"no-iterator": 1,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 1,
"no-multi-str": 1,
"no-native-reassign": 2,
"no-new-func": 2,
"no-new-wrappers": 2,
"no-new": 1,
"no-octal-escape": 2,
"no-octal": 2,
"no-param-reassign": [2,{"props":true}],
"no-process-env": 0,
"no-proto": 2,
"no-redeclare": [2,{"builtinGlobals":true}],
"no-return-assign": [2,"always"],
"no-script-url": 2,
"no-self-compare": 1,
"no-sequences": 2,
"no-throw-literal": 2,
"no-useless-call": 2,
"no-with": 2,
"radix": 1,
"wrap-iife": [2,"inside"],
"yoda": [1,"always",{}],
"strict": [1,"global"],
"no-catch-shadow": 2,
"no-delete-var": 2,
"no-label-var": 2,
"no-shadow-restricted-names": 2,
"no-shadow": [2,{"builtinGlobals":true,"hoist":"all"}],
"no-undef-init": 2,
"no-undef": 2,
"no-undefined": 2,
"no-unused-vars": 2,
"no-use-before-define": [2,"nofunc"],
"brace-style": [1,"1tbs",{"allowSingleLine":true}],
"camelcase": [1,{"properties":"always"}],
"comma-spacing": [1,{"after":true}],
"comma-style": 1,
"computed-property-spacing": [2,"always"],
"eol-last": 1,
"indent": [1,4],
"key-spacing": [1,{"mode":"minimum"}],
"new-parens": 2,
"no-lonely-if": 1,
"no-mixed-spaces-and-tabs": [2,"smart-tabs"],
"no-multiple-empty-lines": [1,{"max":4}],
"no-new-object": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-unneeded-ternary": 1,
"semi": [2,"always"],
"space-infix-ops": 1,
"arrow-parens": [2,"as-needed"],
"arrow-spacing": [2,{"before":true,"after":true}],
"constructor-super": 1,
"no-class-assign": 2,
"no-const-assign": 2,
"no-this-before-super": 2,
"no-var": 1,
"prefer-const": 1,
"prefer-spread": 2,
"prefer-reflect": 0,
"require-yield": 1,
"max-len": [1,140,4,{}],
"max-statements": [1,40]
}
}

10
.gitignore vendored
View File

@@ -1,3 +1,8 @@
build
node_modules
package-lock.json
*.*DS_Store*
test/javasource/
test/deployment/
test/.classpath
@@ -11,10 +16,7 @@ test/.project
*.lock
.idea/
dist/
node_modules/
.editorconfig
*DS_Store*
.vscode/
*.bak
*.bak

View File

@@ -1,23 +0,0 @@
{
// Enforcing
"curly" : false,
"forin" : false,
"latedef" : "nofunc",
"newcap" : true,
"quotmark" : "double",
"eqeqeq" : true,
"undef" : true,
"globals" : {
"mendix" : false,
"mx" : false,
"logger" : false
},
// Relaxing
"laxbreak" : true,
// Environments
"browser" : true,
"devel" : true,
"dojo" : true
}

View File

@@ -1,86 +1,117 @@
// Generated on 2016-12-08 using generator-mendix 2.0.3 :: git+https://github.com/mendix/generator-mendix.git
/*jshint -W069,-W097*/
"use strict";
const path = require('path');
const fs = require('fs-extra');
const gulp = require('gulp-help')(require('gulp'));
const gutil = require('gulp-util');
const webpack = require('webpack');
const watch = require('gulp-watch');
const gulpCopy = require('gulp-copy');
const sequence = require('gulp-sequence');
const del = require('del');
// In case you seem to have trouble starting Mendix through `gulp modeler`, you might have to set the path to the Mendix application, otherwise leave both values as they are
var MODELER_PATH = null;
var MODELER_ARGS = "/file:{path}";
const banner = (color, banner) => gutil.colors[color || 'cyan'](banner ? `[${banner}]` : '[GULP]');
/********************************************************************************
* Do not edit anything below, unless you know what you are doing
********************************************************************************/
var gulp = require("gulp"),
zip = require("gulp-zip"),
del = require("del"),
newer = require("gulp-newer"),
gutil = require("gulp-util"),
gulpif = require("gulp-if"),
jsonTransform = require("gulp-json-transform"),
intercept = require("gulp-intercept"),
argv = require("yargs").argv,
widgetBuilderHelper = require("widgetbuilder-gulp-helper");
const pkg = require('./package.json');
var pkg = require("./package.json"),
paths = widgetBuilderHelper.generatePaths(pkg),
xmlversion = widgetBuilderHelper.xmlversion;
// Set paths for our project folder
gulp.task("default", function() {
gulp.watch("./src/**/*", ["compress"]);
gulp.watch("./src/**/*.js", ["copy:js"]);
const projectPath = pkg.widget.path ? path.resolve(pkg.widget.path) + '/' : false;
const widgetsFolder = projectPath ? path.join(projectPath, `/widgets/`) : false;
const deploymentFolder = projectPath ? path.join(projectPath, `/deployment/web/widgets/`) : false;
// Check if project folder exists and is accessible
let stat = null;
if (!projectPath) {
gutil.log(`${banner()} No testproject defined, only copying files to dist/build folder. Set project path in ${gutil.colors.cyan('widget.path')} in ${gutil.colors.magenta('package.json')}`);
} else {
gutil.log(`${banner()} Testproject defined: ${gutil.colors.magenta(projectPath)}`);
try {
stat = projectPath ? fs.statSync(projectPath) : null;
} catch (e) {
gutil.log(`${banner('red')} Error getting project directory:`, e.toString());
gutil.log(`${banner('red')} Copying to the project directory has been disabled`);
stat = null;
}
}
// Helper functions
const runWebpack = callback => {
webpack(require('./webpack.config.js'), function (err, stats) {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log(banner('cyan', 'WEBPACK'), stats.toString({
colors: true,
modules: false
}));
callback && callback();
});
};
const copyFile = paths => {
try {
fs.copySync(paths.src, paths.dest);
} catch (err) {
gutil.log(`${banner('red')} Copy fail`, err);
}
};
const getPaths = (file, srcFolder, destFolder) => {
return {
src: path.join(__dirname, srcFolder, file.relative),
dest: path.join(destFolder, file.relative),
}
}
// Base tasks
gulp.task('watch:src', () => {
return watch('src/**/*', {
verbose: true
}, () => {
runWebpack();
})
});
gulp.task("clean", function () {
gulp.task('watch:build', () => {
return watch('build/**/*', {
verbose: stat !== null,
read: false
}, file => {
if (stat !== null) {
const paths = getPaths(file, 'build', deploymentFolder);
if (paths.src.indexOf('package.xml') !== -1) {
return;
}
copyFile(paths);
}
})
});
gulp.task('watch:dist', () => {
return watch(`dist/${pkg.widget.package}.mpk`, {
verbose: stat !== null,
read: false
}, file => {
if (stat !== null) {
const paths = getPaths(file, 'dist', widgetsFolder);
copyFile(paths);
}
})
});
gulp.task('clean', `Cleanup the dist/build`, () => {
return del([
paths.WIDGET_TEST_DEST,
paths.WIDGET_DIST_DEST
'dist',
'build'
], { force: true });
});
gulp.task("compress", ["clean"], function () {
return gulp.src("src/**/*")
.pipe(zip(pkg.name + ".mpk"))
.pipe(gulp.dest(paths.TEST_WIDGETS_FOLDER))
.pipe(gulp.dest("dist"));
// Final tasks
gulp.task('build', 'Build the widget', done => {
sequence('clean', 'build-dist', done);
});
gulp.task("copy:js", function () {
return gulp.src(["./src/**/*.js"])
.pipe(newer(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER))
.pipe(gulp.dest(paths.TEST_WIDGETS_DEPLOYMENT_FOLDER));
});
gulp.task('build-dist', callback => { runWebpack(callback); });
gulp.task("version:xml", function () {
return gulp.src(paths.PACKAGE_XML)
.pipe(xmlversion(argv.n))
.pipe(gulp.dest("./src/"));
});
gulp.task("version:json", function () {
return gulp.src("./package.json")
.pipe(gulpif(typeof argv.n !== "undefined", jsonTransform(function(data) {
data.version = argv.n;
return data;
}, 2)))
.pipe(gulp.dest("./"));
});
gulp.task("icon", function (cb) {
var icon = (typeof argv.file !== "undefined") ? argv.file : "./icon.png";
console.log("\nUsing this file to create a base64 string: " + gutil.colors.cyan(icon));
gulp.src(icon)
.pipe(intercept(function (file) {
console.log("\nCopy the following to your " + pkg.name + ".xml (after description):\n\n" + gutil.colors.cyan("<icon>") + file.contents.toString("base64") + gutil.colors.cyan("<\/icon>") + "\n");
cb();
}));
});
gulp.task("folders", function () {
paths.showPaths(); return;
});
gulp.task("modeler", function (cb) {
widgetBuilderHelper.runmodeler(MODELER_PATH, MODELER_ARGS, paths.TEST_PATH, cb);
});
gulp.task("build", ["compress"]);
gulp.task("version", ["version:xml", "version:json"]);
gulp.task('default', ['watch:src', 'watch:build', 'watch:dist']);

BIN
dist/Leaflet.mpk vendored Normal file

Binary file not shown.

View File

@@ -1,36 +1,79 @@
{
"name": "Leaflet",
"version": "1.3.0",
"description": "",
"license": "",
"author": "",
"private": true,
"dependencies": {},
"devDependencies": {
"del": "^2.2.2",
"gulp": "^3.9.1",
"gulp-if": "^2.0.1",
"gulp-intercept": "^0.1.0",
"gulp-json-transform": "^0.4.2",
"gulp-newer": "^1.3.0",
"gulp-util": "^3.0.7",
"gulp-zip": "^3.2.0",
"widgetbuilder-gulp-helper": "https://github.com/JelteMX/widgetbuilder-gulp-helper/archive/1.0.1.tar.gz",
"yargs": "^6.0.0"
},
"engines": {
"node": ">=5"
},
"generatorVersion": "2.0.3",
"paths": {
"testProjectFolder": "./test/",
"testProjectFileName": "Test.mpr"
},
"version": "2.0.1",
"description": "Add different type of maps to your application, using Leaflet.js!",
"scripts": {
"build": "node ./node_modules/gulp/bin/gulp build",
"version": "node ./node_modules/gulp/bin/gulp version",
"icon": "node ./node_modules/gulp/bin/gulp icon",
"folders": "node ./node_modules/gulp/bin/gulp folders",
"modeler": "node ./node_modules/gulp/bin/gulp modeler"
"webpack": "./node_modules/.bin/webpack",
"dev": "cross-env WEBPACK_ENV=dev gulp",
"dev-prod": "cross-env WEBPACK_ENV=production gulp",
"build": "npm run build-prod",
"build-prod": "cross-env WEBPACK_ENV=production gulp build",
"build-dev": "cross-env WEBPACK_ENV=dev gulp build",
"clean": "gulp clean"
},
"widget": {
"package": "Leaflet",
"filesFolder": "widget",
"libraries": false,
"core": false,
"path": "./test/"
},
"keywords": [
"widget",
"webpack",
"mendix",
"es2015",
"es6"
],
"author": "J.W. Lagendijk <jelte.lagendijk@mendix.com>",
"license": "MIT",
"devDependencies": {
"autoprefixer": "^7.1.4",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-1": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"copy-webpack-plugin": "^4.0.1",
"cross-env": "^5.0.5",
"css-loader": "^0.28.7",
"del": "^3.0.0",
"eslint": "^4.7.1",
"eslint-config-recommended": "^1.5.0",
"eslint-config-standard": "^10.2.1",
"eslint-loader": "^1.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"extract-text-webpack-plugin": "^3.0.0",
"fs-extra": "^4.0.2",
"gulp": "^3.9.1",
"gulp-copy": "^1.0.1",
"gulp-help": "^1.6.1",
"gulp-sequence": "^0.4.6",
"gulp-util": "^3.0.8",
"gulp-watch": "^4.3.11",
"img-loader": "^2.0.0",
"loadcss": "^0.0.2",
"node-sass": "^4.5.3",
"postcss-loader": "^2.0.6",
"raw-loader": "^0.5.1",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"url-loader": "^0.6.2",
"webpack": "^3.6.0",
"webpack-archive-plugin": "^3.0.0",
"webpack-strip-block": "^0.2.0",
"xml-webpack-plugin": "^0.0.2"
},
"dependencies": {
"es6-promise": "^4.1.1",
"leaflet": "^1.2.0",
"leaflet-fullscreen": "^1.0.2",
"leaflet-providers": "^1.1.17",
"leaflet.locatecontrol": "^0.62.0",
"whatwg-fetch": "^2.0.3"
}
}
}

1
postcss.config.js Normal file
View File

@@ -0,0 +1 @@
module.exports = {};

File diff suppressed because one or more lines are too long

View File

@@ -1,189 +0,0 @@
/* jshint -W108 */
// Source: https://github.com/brunob/leaflet.fullscreen/blob/master/Control.FullScreen.js
/*
Edited by J.W. Lagendijk <jelte.lagendijk@mendix.com> to make sure it works within the Mendix environment
*/
(function (root, factory) {
define(['Leaflet/lib/leaflet'], factory);
}(this, function (L) {
'use strict';
L.Control.FullScreen = L.Control.extend({
options: {
position: 'topleft',
title: 'Full Screen',
titleCancel: 'Exit Full Screen',
forceSeparateButton: false,
forcePseudoFullscreen: false
},
onAdd: function(map) {
var className = 'leaflet-control-zoom-fullscreen',
container, content = '';
if (map.zoomControl && !this.options.forceSeparateButton) {
container = map.zoomControl._container;
} else {
container = L.DomUtil.create('div', 'leaflet-bar');
}
if (this.options.content) {
content = this.options.content;
} else {
className += ' fullscreen-icon';
}
this._createButton(this.options.title, className, content, container, this.toggleFullScreen, this);
this._map.on('enterFullscreen exitFullscreen', this._toggleTitle, this);
return container;
},
_createButton: function(title, className, content, container, fn, context) {
this.link = L.DomUtil.create('a', className, container);
this.link.href = '#';
this.link.title = title;
this.link.innerHTML = content;
L.DomEvent.addListener(this.link, 'click', L.DomEvent.stopPropagation)
.addListener(this.link, 'click', L.DomEvent.preventDefault)
.addListener(this.link, 'click', fn, context);
L.DomEvent.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
.addListener(container, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
.addListener(container, fullScreenApi.fullScreenEventName, this._handleEscKey, context);
L.DomEvent.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.stopPropagation)
.addListener(document, fullScreenApi.fullScreenEventName, L.DomEvent.preventDefault)
.addListener(document, fullScreenApi.fullScreenEventName, this._handleEscKey, context);
return this.link;
},
toggleFullScreen: function() {
var map = this._map;
map._exitFired = false;
if (map._isFullscreen) {
if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
fullScreenApi.cancelFullScreen(map._container);
} else {
L.DomUtil.removeClass(map._container, 'leaflet-pseudo-fullscreen');
}
map.invalidateSize();
map.fire('exitFullscreen');
map._exitFired = true;
map._isFullscreen = false;
} else {
if (fullScreenApi.supportsFullScreen && !this.options.forcePseudoFullscreen) {
fullScreenApi.requestFullScreen(map._container);
} else {
L.DomUtil.addClass(map._container, 'leaflet-pseudo-fullscreen');
}
map.invalidateSize();
map.fire('enterFullscreen');
map._isFullscreen = true;
}
},
_toggleTitle: function() {
this.link.title = this._map._isFullscreen ? this.options.title : this.options.titleCancel;
},
_handleEscKey: function() {
var map = this._map;
if (!fullScreenApi.isFullScreen(map) && !map._exitFired) {
map.fire('exitFullscreen');
map._exitFired = true;
map._isFullscreen = false;
}
}
});
L.Map.addInitHook(function() {
if (this.options.fullscreenControl) {
this.fullscreenControl = L.control.fullscreen(this.options.fullscreenControlOptions);
this.addControl(this.fullscreenControl);
}
});
L.control.fullscreen = function(options) {
return new L.Control.FullScreen(options);
};
/*
Native FullScreen JavaScript API
-------------
Assumes Mozilla naming conventions instead of W3C for now
source : http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
*/
var
fullScreenApi = {
supportsFullScreen: false,
isFullScreen: function() {
return false;
},
requestFullScreen: function() {},
cancelFullScreen: function() {},
fullScreenEventName: '',
prefix: ''
},
browserPrefixes = 'webkit moz o ms khtml'.split(' ');
// check for native support
if (typeof document.exitFullscreen !== 'undefined') {
fullScreenApi.supportsFullScreen = true;
} else {
// check for fullscreen support by vendor prefix
for (var i = 0, il = browserPrefixes.length; i < il; i++) {
fullScreenApi.prefix = browserPrefixes[i];
if (typeof document[fullScreenApi.prefix + 'CancelFullScreen'] !== 'undefined') {
fullScreenApi.supportsFullScreen = true;
break;
}
}
}
// update methods to do something useful
if (fullScreenApi.supportsFullScreen) {
fullScreenApi.fullScreenEventName = fullScreenApi.prefix + 'fullscreenchange';
fullScreenApi.isFullScreen = function() {
switch (this.prefix) {
case '':
return document.fullScreen;
case 'webkit':
return document.webkitIsFullScreen;
default:
return document[this.prefix + 'FullScreen'];
}
};
fullScreenApi.requestFullScreen = function(el) {
return (this.prefix === '') ? el.requestFullscreen() : el[this.prefix + 'RequestFullScreen']();
};
fullScreenApi.cancelFullScreen = function() {
return (this.prefix === '') ? document.exitFullscreen() : document[this.prefix + 'CancelFullScreen']();
};
}
// jQuery plugin
if (typeof jQuery !== 'undefined') {
jQuery.fn.requestFullScreen = function() {
return this.each(function() {
var el = jQuery(this);
if (fullScreenApi.supportsFullScreen) {
fullScreenApi.requestFullScreen(el);
}
});
};
}
// export api
window.fullScreenApi = fullScreenApi;
return L;
}));

View File

@@ -1,491 +0,0 @@
/* jshint -W108 */
/*!
Copyright (c) 2016 Dominik Moritz
This file is part of the leaflet locate control. It is licensed under the MIT license.
You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
*/
(function (factory, window) {
define(['Leaflet/lib/leaflet'], factory);
// attach your plugin to the global 'L' variable
if(typeof window !== 'undefined' && window.L){
window.L.Locate = factory(L);
}
} (function (L) {
L.Control.Locate = L.Control.extend({
options: {
position: 'topleft',
layer: undefined, // use your own layer for the location marker
drawCircle: true,
follow: false, // follow with zoom and pan the user's location
stopFollowingOnDrag: false, // if follow is true, stop following when map is dragged (deprecated)
// if true locate control remains active on click even if the user's location is in view.
// clicking control will just pan to location
remainActive: false,
markerClass: L.circleMarker, // L.circleMarker or L.marker
// range circle
circleStyle: {
color: '#136AEC',
fillColor: '#136AEC',
fillOpacity: 0.15,
weight: 2,
opacity: 0.5
},
// inner marker
markerStyle: {
color: '#136AEC',
fillColor: '#2A93EE',
fillOpacity: 0.7,
weight: 2,
opacity: 0.9,
radius: 5
},
// changes to range circle and inner marker while following
// it is only necessary to provide the things that should change
followCircleStyle: {},
followMarkerStyle: {
//color: '#FFA500',
//fillColor: '#FFB000'
},
icon: 'fa fa-map-marker', // fa-location-arrow or fa-map-marker
iconLoading: 'fa fa-spinner fa-spin',
iconElementTag: 'span', // span or i
circlePadding: [0, 0],
metric: true,
onLocationError: function(err) {
// this event is called in case of any location error
// that is not a time out error.
alert(err.message);
},
onLocationOutsideMapBounds: function(control) {
// this event is repeatedly called when the location changes
control.stop();
alert(control.options.strings.outsideMapBoundsMsg);
},
setView: true, // automatically sets the map view to the user's location
// keep the current map zoom level when displaying the user's location. (if 'false', use maxZoom)
keepCurrentZoomLevel: false,
showPopup: true, // display a popup when the user click on the inner marker
strings: {
title: "Show me where I am",
metersUnit: "meters",
feetUnit: "feet",
popup: "You are within {distance} {unit} from this point",
outsideMapBoundsMsg: "You seem located outside the boundaries of the map"
},
locateOptions: {
maxZoom: Infinity,
watch: true // if you overwrite this, visualization cannot be updated
}
},
initialize: function (options) {
L.Map.addInitHook(function () {
if (this.options.locateControl) {
this.addControl(this);
}
});
for (var i in options) {
if (typeof this.options[i] === 'object') {
L.extend(this.options[i], options[i]);
} else {
this.options[i] = options[i];
}
}
L.extend(this.options.locateOptions, {
setView: false // have to set this to false because we have to
// do setView manually
});
},
/**
* This method launches the location engine.
* It is called before the marker is updated,
* event if it does not mean that the event will be ready.
*
* Override it if you want to add more functionalities.
* It should set the this._active to true and do nothing if
* this._active is not true.
*/
_activate: function() {
if (this.options.setView) {
this._locateOnNextLocationFound = true;
}
if(!this._active) {
this._map.locate(this.options.locateOptions);
}
this._active = true;
if (this.options.follow) {
this._startFollowing(this._map);
}
},
/**
* Called to stop the location engine.
*
* Override it to shutdown any functionalities you added on start.
*/
_deactivate: function() {
this._map.stopLocate();
this._map.off('dragstart', this._stopFollowing, this);
if (this.options.follow && this._following) {
this._stopFollowing(this._map);
}
},
/**
* Draw the resulting marker on the map.
*
* Uses the event retrieved from onLocationFound from the map.
*/
drawMarker: function(map) {
if (this._event.accuracy === undefined) {
this._event.accuracy = 0;
}
var radius = this._event.accuracy;
if (this._locateOnNextLocationFound) {
if (this._isOutsideMapBounds()) {
this.options.onLocationOutsideMapBounds(this);
} else {
// If accuracy info isn't desired, keep the current zoom level
if(this.options.keepCurrentZoomLevel) {
map.panTo([this._event.latitude, this._event.longitude]);
} else {
map.fitBounds(this._event.bounds, {
padding: this.options.circlePadding,
maxZoom: this.options.keepCurrentZoomLevel ?
map.getZoom() : this.options.locateOptions.maxZoom
});
}
}
this._locateOnNextLocationFound = false;
}
// circle with the radius of the location's accuracy
var style, o;
if (this.options.drawCircle) {
if (this._following) {
style = this.options.followCircleStyle;
} else {
style = this.options.circleStyle;
}
if (!this._circle) {
this._circle = L.circle(this._event.latlng, radius, style)
.addTo(this._layer);
} else {
this._circle.setLatLng(this._event.latlng).setRadius(radius);
for (o in style) {
this._circle.options[o] = style[o];
}
}
}
var distance, unit;
if (this.options.metric) {
distance = radius.toFixed(0);
unit = this.options.strings.metersUnit;
} else {
distance = (radius * 3.2808399).toFixed(0);
unit = this.options.strings.feetUnit;
}
// small inner marker
var mStyle;
if (this._following) {
mStyle = this.options.followMarkerStyle;
} else {
mStyle = this.options.markerStyle;
}
if (!this._marker) {
this._marker = this.createMarker(this._event.latlng, mStyle)
.addTo(this._layer);
} else {
this.updateMarker(this._event.latlng, mStyle);
}
var t = this.options.strings.popup;
if (this.options.showPopup && t) {
this._marker.bindPopup(L.Util.template(t, {distance: distance, unit: unit}))
._popup.setLatLng(this._event.latlng);
}
this._toggleContainerStyle();
},
/**
* Creates the marker.
*
* Should return the base marker so it is possible to bind a pop-up if the
* option is activated.
*
* Used by drawMarker, you can ignore it if you have overridden it.
*/
createMarker: function(latlng, mStyle) {
return this.options.markerClass(latlng, mStyle);
},
/**
* Updates the marker with current coordinates.
*
* Used by drawMarker, you can ignore it if you have overridden it.
*/
updateMarker: function(latlng, mStyle) {
this._marker.setLatLng(latlng);
for (var o in mStyle) {
this._marker.options[o] = mStyle[o];
}
},
/**
* Remove the marker from map.
*/
removeMarker: function() {
this._layer.clearLayers();
this._marker = undefined;
this._circle = undefined;
},
onAdd: function (map) {
var container = L.DomUtil.create('div',
'leaflet-control-locate leaflet-bar leaflet-control');
this._layer = this.options.layer || new L.LayerGroup();
this._layer.addTo(map);
this._event = undefined;
// extend the follow marker style and circle from the normal style
var tmp = {};
L.extend(tmp, this.options.markerStyle, this.options.followMarkerStyle);
this.options.followMarkerStyle = tmp;
tmp = {};
L.extend(tmp, this.options.circleStyle, this.options.followCircleStyle);
this.options.followCircleStyle = tmp;
this._link = L.DomUtil.create('a', 'leaflet-bar-part leaflet-bar-part-single', container);
this._link.href = '#';
this._link.title = this.options.strings.title;
this._icon = L.DomUtil.create(this.options.iconElementTag, this.options.icon, this._link);
L.DomEvent
.on(this._link, 'click', L.DomEvent.stopPropagation)
.on(this._link, 'click', L.DomEvent.preventDefault)
.on(this._link, 'click', function() {
var shouldStop = (this._event === undefined ||
this._map.getBounds().contains(this._event.latlng) ||
!this.options.setView || this._isOutsideMapBounds());
if (!this.options.remainActive && (this._active && shouldStop)) {
this.stop();
} else {
this.start();
}
}, this)
.on(this._link, 'dblclick', L.DomEvent.stopPropagation);
this._resetVariables();
this.bindEvents(map);
return container;
},
/**
* Binds the actions to the map events.
*/
bindEvents: function(map) {
map.on('locationfound', this._onLocationFound, this);
map.on('locationerror', this._onLocationError, this);
map.on('unload', this.stop, this);
},
/**
* Starts the plugin:
* - activates the engine
* - draws the marker (if coordinates available)
*/
start: function() {
this._activate();
if (!this._event) {
this._setClasses('requesting');
} else {
this.drawMarker(this._map);
}
},
/**
* Stops the plugin:
* - deactivates the engine
* - reinitializes the button
* - removes the marker
*/
stop: function() {
this._deactivate();
this._cleanClasses();
this._resetVariables();
this.removeMarker();
},
/**
* Calls deactivate and dispatches an error.
*/
_onLocationError: function(err) {
// ignore time out error if the location is watched
if (err.code == 3 && this.options.locateOptions.watch) {
return;
}
this.stop();
this.options.onLocationError(err);
},
/**
* Stores the received event and updates the marker.
*/
_onLocationFound: function(e) {
// no need to do anything if the location has not changed
if (this._event &&
(this._event.latlng.lat === e.latlng.lat &&
this._event.latlng.lng === e.latlng.lng &&
this._event.accuracy === e.accuracy)) {
return;
}
if (!this._active) {
return;
}
this._event = e;
if (this.options.follow && this._following) {
this._locateOnNextLocationFound = true;
}
this.drawMarker(this._map);
},
/**
* Dispatches the 'startfollowing' event on map.
*/
_startFollowing: function() {
this._map.fire('startfollowing', this);
this._following = true;
if (this.options.stopFollowingOnDrag) {
this._map.on('dragstart', this._stopFollowing, this);
}
},
/**
* Dispatches the 'stopfollowing' event on map.
*/
_stopFollowing: function() {
this._map.fire('stopfollowing', this);
this._following = false;
if (this.options.stopFollowingOnDrag) {
this._map.off('dragstart', this._stopFollowing, this);
}
this._toggleContainerStyle();
},
/**
* Check if location is in map bounds
*/
_isOutsideMapBounds: function() {
if (this._event === undefined)
return false;
return this._map.options.maxBounds &&
!this._map.options.maxBounds.contains(this._event.latlng);
},
/**
* Toggles button class between following and active.
*/
_toggleContainerStyle: function() {
if (!this._container) {
return;
}
if (this._following) {
this._setClasses('following');
} else {
this._setClasses('active');
}
},
/**
* Sets the CSS classes for the state.
*/
_setClasses: function(state) {
if (state == 'requesting') {
L.DomUtil.removeClasses(this._container, "active following");
L.DomUtil.addClasses(this._container, "requesting");
L.DomUtil.removeClasses(this._icon, this.options.icon);
L.DomUtil.addClasses(this._icon, this.options.iconLoading);
} else if (state == 'active') {
L.DomUtil.removeClasses(this._container, "requesting following");
L.DomUtil.addClasses(this._container, "active");
L.DomUtil.removeClasses(this._icon, this.options.iconLoading);
L.DomUtil.addClasses(this._icon, this.options.icon);
} else if (state == 'following') {
L.DomUtil.removeClasses(this._container, "requesting");
L.DomUtil.addClasses(this._container, "active following");
L.DomUtil.removeClasses(this._icon, this.options.iconLoading);
L.DomUtil.addClasses(this._icon, this.options.icon);
}
},
/**
* Removes all classes from button.
*/
_cleanClasses: function() {
L.DomUtil.removeClass(this._container, "requesting");
L.DomUtil.removeClass(this._container, "active");
L.DomUtil.removeClass(this._container, "following");
L.DomUtil.removeClasses(this._icon, this.options.iconLoading);
L.DomUtil.addClasses(this._icon, this.options.icon);
},
/**
* Reinitializes attributes.
*/
_resetVariables: function() {
this._active = false;
this._locateOnNextLocationFound = this.options.setView;
this._following = false;
}
});
L.control.locate = function (options) {
return new L.Control.Locate(options);
};
(function(){
// leaflet.js raises bug when trying to addClass / removeClass multiple classes at once
// Let's create a wrapper on it which fixes it.
var LDomUtilApplyClassesMethod = function(method, element, classNames) {
classNames = classNames.split(' ');
classNames.forEach(function(className) {
L.DomUtil[method].call(this, element, className);
});
};
L.DomUtil.addClasses = function(el, names) { LDomUtilApplyClassesMethod('addClass', el, names); };
L.DomUtil.removeClasses = function(el, names) { LDomUtilApplyClassesMethod('removeClass', el, names); };
})();
return L.Control.Locate;
}, window));

View File

@@ -1,691 +0,0 @@
/* jshint -W108 */
(function (root, factory) {
define(['Leaflet/lib/leaflet'], factory);
}(this, function (L) {
'use strict';
L.TileLayer.Provider = L.TileLayer.extend({
initialize: function(arg, options) {
var providers = L.TileLayer.Provider.providers;
var parts = arg.split('.');
var providerName = parts[0];
var variantName = parts[1];
if (!providers[providerName]) {
throw 'No such provider (' + providerName + ')';
}
var provider = {
url: providers[providerName].url,
options: providers[providerName].options
};
// overwrite values in provider from variant.
if (variantName && 'variants' in providers[providerName]) {
if (!(variantName in providers[providerName].variants)) {
throw 'No such variant of ' + providerName + ' (' + variantName + ')';
}
var variant = providers[providerName].variants[variantName];
var variantOptions;
if (typeof variant === 'string') {
variantOptions = {
variant: variant
};
} else {
variantOptions = variant.options;
}
provider = {
url: variant.url || provider.url,
options: L.Util.extend({}, provider.options, variantOptions)
};
}
var forceHTTP = window.location.protocol === 'file:' || provider.options.forceHTTP;
if (provider.url.indexOf('//') === 0 && forceHTTP) {
provider.url = 'http:' + provider.url;
}
// If retina option is set
if (provider.options.retina) {
// Check retina screen
if (options.detectRetina && L.Browser.retina) {
// The retina option will be active now
// But we need to prevent Leaflet retina mode
options.detectRetina = false;
} else {
// No retina, remove option
provider.options.retina = '';
}
}
// replace attribution placeholders with their values from toplevel provider attribution,
// recursively
var attributionReplacer = function(attr) {
if (attr.indexOf('{attribution.') === -1) {
return attr;
}
return attr.replace(/\{attribution.(\w*)\}/,
function(match, attributionName) {
return attributionReplacer(providers[attributionName].options.attribution);
});
};
provider.options.attribution = attributionReplacer(provider.options.attribution);
// Compute final options combining provider options with any user overrides
var layerOpts = L.Util.extend({}, provider.options, options);
L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts);
}
});
/**
* Definition of providers.
* see http://leafletjs.com/reference.html#tilelayer for options in the options map.
*/
L.TileLayer.Provider.providers = {
OpenStreetMap: {
url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
},
variants: {
Mapnik: {},
BlackAndWhite: {
url: 'http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png',
options: {
maxZoom: 18
}
},
DE: {
url: '//{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png',
options: {
maxZoom: 18
}
},
France: {
url: '//{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png',
options: {
maxZoom: 20,
attribution: '© Openstreetmap France | {attribution.OpenStreetMap}'
}
},
HOT: {
url: '//{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
}
},
BZH: {
url: 'http://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenStreetMap}, Tiles courtesy of <a href="http://www.openstreetmap.bzh/" target="_blank">Breton OpenStreetMap Team</a>',
bounds: [
[46.2, - 5.5],
[50, 0.7]
]
}
}
}
},
OpenSeaMap: {
url: 'http://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
options: {
attribution: 'Map data: © <a href="http://www.openseamap.org">OpenSeaMap</a> contributors'
}
},
OpenTopoMap: {
url: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
options: {
maxZoom: 17,
attribution: 'Map data: {attribution.OpenStreetMap}, <a href="http://viewfinderpanoramas.org">SRTM</a> | Map style: © <a href="https://opentopomap.org">OpenTopoMap</a> (<a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA</a>)'
}
},
Thunderforest: {
url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}',
options: {
attribution: '© <a href="http://www.thunderforest.com/">Thunderforest</a>, {attribution.OpenStreetMap}',
variant: 'cycle',
apikey: '<insert your api key here>',
maxZoom: 22
},
variants: {
OpenCycleMap: 'cycle',
Transport: {
options: {
variant: 'transport'
}
},
TransportDark: {
options: {
variant: 'transport-dark'
}
},
SpinalMap: {
options: {
variant: 'spinal-map'
}
},
Landscape: 'landscape',
Outdoors: 'outdoors',
Pioneer: 'pioneer'
}
},
OpenMapSurfer: {
url: 'http://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}',
options: {
maxZoom: 20,
variant: 'roads',
attribution: 'Imagery from <a href="http://giscience.uni-hd.de/">GIScience Research Group @ University of Heidelberg</a> — Map data {attribution.OpenStreetMap}'
},
variants: {
Roads: 'roads',
AdminBounds: {
options: {
variant: 'adminb',
maxZoom: 19
}
},
Grayscale: {
options: {
variant: 'roadsg',
maxZoom: 19
}
}
}
},
Hydda: {
url: '//{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png',
options: {
maxZoom: 18,
variant: 'full',
attribution: 'Tiles courtesy of <a href="http://openstreetmap.se/" target="_blank">OpenStreetMap Sweden</a> — Map data {attribution.OpenStreetMap}'
},
variants: {
Full: 'full',
Base: 'base',
RoadsAndLabels: 'roads_and_labels'
}
},
MapBox: {
url: '//api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}',
options: {
attribution: 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> — ' + 'Map data {attribution.OpenStreetMap}',
subdomains: 'abcd',
id: 'streets',
accessToken: '<insert your access token here>',
}
},
Stamen: {
url: '//stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}',
options: {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, ' + '<a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — ' + 'Map data {attribution.OpenStreetMap}',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
variant: 'toner',
ext: 'png'
},
variants: {
Toner: 'toner',
TonerBackground: 'toner-background',
TonerHybrid: 'toner-hybrid',
TonerLines: 'toner-lines',
TonerLabels: 'toner-labels',
TonerLite: 'toner-lite',
Watercolor: {
options: {
variant: 'watercolor',
minZoom: 1,
maxZoom: 16
}
},
Terrain: {
options: {
variant: 'terrain',
minZoom: 0,
maxZoom: 18
}
},
TerrainBackground: {
options: {
variant: 'terrain-background',
minZoom: 0,
maxZoom: 18
}
},
TopOSMRelief: {
options: {
variant: 'toposm-color-relief',
ext: 'jpg',
bounds: [
[22, - 132],
[51, - 56]
]
}
},
TopOSMFeatures: {
options: {
variant: 'toposm-features',
bounds: [
[22, - 132],
[51, - 56]
],
opacity: 0.9
}
}
}
},
Esri: {
url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}',
options: {
variant: 'World_Street_Map',
attribution: 'Tiles © Esri'
},
variants: {
WorldStreetMap: {
options: {
attribution: '{attribution.Esri} — ' + 'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012'
}
},
DeLorme: {
options: {
variant: 'Specialty/DeLorme_World_Base_Map',
minZoom: 1,
maxZoom: 11,
attribution: '{attribution.Esri} — Copyright: ©2012 DeLorme'
}
},
WorldTopoMap: {
options: {
variant: 'World_Topo_Map',
attribution: '{attribution.Esri} — ' + 'Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community'
}
},
WorldImagery: {
options: {
variant: 'World_Imagery',
attribution: '{attribution.Esri} — ' + 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
}
},
WorldTerrain: {
options: {
variant: 'World_Terrain_Base',
maxZoom: 13,
attribution: '{attribution.Esri} — ' + 'Source: USGS, Esri, TANA, DeLorme, and NPS'
}
},
WorldShadedRelief: {
options: {
variant: 'World_Shaded_Relief',
maxZoom: 13,
attribution: '{attribution.Esri} — Source: Esri'
}
},
WorldPhysical: {
options: {
variant: 'World_Physical_Map',
maxZoom: 8,
attribution: '{attribution.Esri} — Source: US National Park Service'
}
},
OceanBasemap: {
options: {
variant: 'Ocean_Basemap',
maxZoom: 13,
attribution: '{attribution.Esri} — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri'
}
},
NatGeoWorldMap: {
options: {
variant: 'NatGeo_World_Map',
maxZoom: 16,
attribution: '{attribution.Esri} — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC'
}
},
WorldGrayCanvas: {
options: {
variant: 'Canvas/World_Light_Gray_Base',
maxZoom: 16,
attribution: '{attribution.Esri} — Esri, DeLorme, NAVTEQ'
}
}
}
},
OpenWeatherMap: {
url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution: 'Map data © <a href="http://openweathermap.org">OpenWeatherMap</a>',
opacity: 0.5
},
variants: {
Clouds: 'clouds',
CloudsClassic: 'clouds_cls',
Precipitation: 'precipitation',
PrecipitationClassic: 'precipitation_cls',
Rain: 'rain',
RainClassic: 'rain_cls',
Pressure: 'pressure',
PressureContour: 'pressure_cntr',
Wind: 'wind',
Temperature: 'temp',
Snow: 'snow'
}
},
HERE: {
/*
* HERE maps, formerly Nokia maps.
* These basemaps are free, but you need an API key. Please sign up at
* http://developer.here.com/getting-started
*
* Note that the base urls contain '.cit' whichs is HERE's
* 'Customer Integration Testing' environment. Please remove for production
* envirionments.
*/
url: '//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + 'app_id={app_id}&app_code={app_code}&lg={language}',
options: {
attribution: 'Map © 1987-2014 <a href="http://developer.here.com">HERE</a>',
subdomains: '1234',
mapID: 'newest',
'app_id': '<insert your app_id here>',
'app_code': '<insert your app_code here>',
base: 'base',
variant: 'normal.day',
maxZoom: 20,
type: 'maptile',
language: 'eng',
format: 'png8',
size: '256'
},
variants: {
normalDay: 'normal.day',
normalDayCustom: 'normal.day.custom',
normalDayGrey: 'normal.day.grey',
normalDayMobile: 'normal.day.mobile',
normalDayGreyMobile: 'normal.day.grey.mobile',
normalDayTransit: 'normal.day.transit',
normalDayTransitMobile: 'normal.day.transit.mobile',
normalNight: 'normal.night',
normalNightMobile: 'normal.night.mobile',
normalNightGrey: 'normal.night.grey',
normalNightGreyMobile: 'normal.night.grey.mobile',
basicMap: {
options: {
type: 'basetile'
}
},
mapLabels: {
options: {
type: 'labeltile',
format: 'png'
}
},
trafficFlow: {
options: {
base: 'traffic',
type: 'flowtile'
}
},
carnavDayGrey: 'carnav.day.grey',
hybridDay: {
options: {
base: 'aerial',
variant: 'hybrid.day'
}
},
hybridDayMobile: {
options: {
base: 'aerial',
variant: 'hybrid.day.mobile'
}
},
pedestrianDay: 'pedestrian.day',
pedestrianNight: 'pedestrian.night',
satelliteDay: {
options: {
base: 'aerial',
variant: 'satellite.day'
}
},
terrainDay: {
options: {
base: 'aerial',
variant: 'terrain.day'
}
},
terrainDayMobile: {
options: {
base: 'aerial',
variant: 'terrain.day.mobile'
}
}
}
},
FreeMapSK: {
url: 'http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg',
options: {
minZoom: 8,
maxZoom: 16,
subdomains: '1234',
bounds: [
[47.204642, 15.996093],
[49.830896, 22.576904]
],
attribution: '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 <a href="http://freemap.sk">Freemap.sk</a>'
}
},
MtbMap: {
url: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenStreetMap} & USGS'
}
},
CartoDB: {
url: 'http://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}.png',
options: {
attribution: '{attribution.OpenStreetMap} © <a href="http://cartodb.com/attributions">CartoDB</a>',
subdomains: 'abcd',
maxZoom: 19,
variant: 'light_all'
},
variants: {
Positron: 'light_all',
PositronNoLabels: 'light_nolabels',
PositronOnlyLabels: 'light_only_labels',
DarkMatter: 'dark_all',
DarkMatterNoLabels: 'dark_nolabels',
DarkMatterOnlyLabels: 'dark_only_labels'
}
},
HikeBike: {
url: 'http://{s}.tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png',
options: {
maxZoom: 19,
attribution: '{attribution.OpenStreetMap}',
variant: 'hikebike'
},
variants: {
HikeBike: {},
HillShading: {
options: {
maxZoom: 15,
variant: 'hillshading'
}
}
}
},
BasemapAT: {
url: 'https://maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}',
options: {
maxZoom: 19,
attribution: 'Datenquelle: <a href="www.basemap.at">basemap.at</a>',
subdomains: ['', '1', '2', '3', '4'],
format: 'png',
bounds: [
[46.358770, 8.782379],
[49.037872, 17.189532]
],
variant: 'geolandbasemap'
},
variants: {
basemap: {
options: {
maxZoom: 20, // currently only in Vienna
variant: 'geolandbasemap'
}
},
grau: 'bmapgrau',
overlay: 'bmapoverlay',
highdpi: {
options: {
variant: 'bmaphidpi',
format: 'jpeg'
}
},
orthofoto: {
options: {
maxZoom: 20, // currently only in Vienna
variant: 'bmaporthofoto30cm',
format: 'jpeg'
}
}
}
},
nlmaps: {
url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png',
options: {
minZoom: 6,
maxZoom: 19,
bounds: [
[50.5, 3.25],
[54, 7.6]
],
attribution: 'Kaartgegevens © <a href="kadaster.nl">Kadaster</a>'
},
variants: {
'standaard': 'brtachtergrondkaart',
'pastel': 'brtachtergrondkaartpastel',
'grijs': 'brtachtergrondkaartgrijs',
'luchtfoto': {
'url': 'https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/1.0.0/2016_ortho25/EPSG:3857/{z}/{x}/{y}.png',
}
}
},
NASAGIBS: {
url: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}',
options: {
attribution: 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' + '(<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
bounds: [
[-85.0511287776, - 179.999999975],
[85.0511287776, 179.999999975]
],
minZoom: 1,
maxZoom: 9,
format: 'jpg',
time: '',
tilematrixset: 'GoogleMapsCompatible_Level'
},
variants: {
ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_TrueColor',
ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367',
ViirsEarthAtNight2012: {
options: {
variant: 'VIIRS_CityLights_2012',
maxZoom: 8
}
},
ModisTerraLSTDay: {
options: {
variant: 'MODIS_Terra_Land_Surface_Temp_Day',
format: 'png',
maxZoom: 7,
opacity: 0.75
}
},
ModisTerraSnowCover: {
options: {
variant: 'MODIS_Terra_Snow_Cover',
format: 'png',
maxZoom: 8,
opacity: 0.75
}
},
ModisTerraAOD: {
options: {
variant: 'MODIS_Terra_Aerosol',
format: 'png',
maxZoom: 6,
opacity: 0.75
}
},
ModisTerraChlorophyll: {
options: {
variant: 'MODIS_Terra_Chlorophyll_A',
format: 'png',
maxZoom: 7,
opacity: 0.75
}
}
}
},
NLS: {
// NLS maps are copyright National library of Scotland.
// http://maps.nls.uk/projects/api/index.html
// Please contact NLS for anything other than non-commercial low volume usage
//
// Map sources: Ordnance Survey 1:1m to 1:63K, 1920s-1940s
// z0-9 - 1:1m
// z10-11 - quarter inch (1:253440)
// z12-18 - one inch (1:63360)
url: '//nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg',
options: {
attribution: '<a href="http://geo.nls.uk/maps/">National Library of Scotland Historic Maps</a>',
bounds: [
[49.6, - 12],
[61.7, 3]
],
minZoom: 1,
maxZoom: 18,
subdomains: '0123',
}
},
JusticeMap: {
// Justice Map (http://www.justicemap.org/)
// Visualize race and income data for your community, county and country.
// Includes tools for data journalists, bloggers and community activists.
url: 'http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png',
options: {
attribution: '<a href="http://www.justicemap.org/terms.php">Justice Map</a>',
// one of 'county', 'tract', 'block'
size: 'county',
// Bounds for USA, including Alaska and Hawaii
bounds: [
[14, - 180],
[72, - 56]
]
},
variants: {
income: 'income',
americanIndian: 'indian',
asian: 'asian',
black: 'black',
hispanic: 'hispanic',
multi: 'multi',
nonWhite: 'nonwhite',
white: 'white',
plurality: 'plural'
}
}
};
L.tileLayer.provider = function(provider, options) {
return new L.TileLayer.Provider(provider, options);
};
return L;
}));

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
.widget {
background: #CCC;
}

View File

@@ -1,3 +1,3 @@
<div class="openLayers">
<div data-dojo-attach-point="mapContainer"></div>
</div>
</div>

View File

@@ -1,673 +0,0 @@
/* required styles */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
position: absolute;
left: 0;
top: 0;
}
.leaflet-container {
overflow: hidden;
}
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
-webkit-user-drag: none;
}
/* Safari renders non-retina tile on retina better with this, but Chrome is worse */
.leaflet-safari .leaflet-tile {
image-rendering: -webkit-optimize-contrast;
}
/* hack that prevents hw layers "stretching" when loading new tiles */
.leaflet-safari .leaflet-tile-container {
width: 1600px;
height: 1600px;
-webkit-transform-origin: 0 0;
}
.leaflet-marker-icon,
.leaflet-marker-shadow {
display: block;
}
/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */
/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */
.leaflet-container .leaflet-overlay-pane svg,
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer {
max-width: none !important;
}
.leaflet-container.leaflet-touch-zoom {
-ms-touch-action: pan-x pan-y;
touch-action: pan-x pan-y;
}
.leaflet-container.leaflet-touch-drag {
-ms-touch-action: pinch-zoom;
}
.leaflet-container.leaflet-touch-drag.leaflet-touch-drag {
-ms-touch-action: none;
touch-action: none;
}
.leaflet-tile {
filter: inherit;
visibility: hidden;
}
.leaflet-tile-loaded {
visibility: inherit;
}
.leaflet-zoom-box {
width: 0;
height: 0;
-moz-box-sizing: border-box;
box-sizing: border-box;
z-index: 800;
}
/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
.leaflet-overlay-pane svg {
-moz-user-select: none;
}
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-vml-shape {
width: 1px;
height: 1px;
}
.lvml {
behavior: url(#default#VML);
display: inline-block;
position: absolute;
}
/* control positioning */
.leaflet-control {
position: relative;
z-index: 800;
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
.leaflet-top,
.leaflet-bottom {
position: absolute;
z-index: 1000;
pointer-events: none;
}
.leaflet-top {
top: 0;
}
.leaflet-right {
right: 0;
}
.leaflet-bottom {
bottom: 0;
}
.leaflet-left {
left: 0;
}
.leaflet-control {
float: left;
clear: both;
}
.leaflet-right .leaflet-control {
float: right;
}
.leaflet-top .leaflet-control {
margin-top: 10px;
}
.leaflet-bottom .leaflet-control {
margin-bottom: 10px;
}
.leaflet-left .leaflet-control {
margin-left: 10px;
}
.leaflet-right .leaflet-control {
margin-right: 10px;
}
/* zoom and fade animations */
.leaflet-fade-anim .leaflet-tile {
will-change: opacity;
}
.leaflet-fade-anim .leaflet-popup {
opacity: 0;
-webkit-transition: opacity 0.2s linear;
-moz-transition: opacity 0.2s linear;
-o-transition: opacity 0.2s linear;
transition: opacity 0.2s linear;
}
.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
opacity: 1;
}
.leaflet-zoom-animated {
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
will-change: transform;
}
.leaflet-zoom-anim .leaflet-zoom-animated {
-webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
-moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
-o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
transition: transform 0.25s cubic-bezier(0,0,0.25,1);
}
.leaflet-zoom-anim .leaflet-tile,
.leaflet-pan-anim .leaflet-tile {
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
}
.leaflet-zoom-anim .leaflet-zoom-hide {
visibility: hidden;
}
/* cursors */
.leaflet-interactive {
cursor: pointer;
}
.leaflet-grab {
cursor: -webkit-grab;
cursor: -moz-grab;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
cursor: crosshair;
}
.leaflet-popup-pane,
.leaflet-control {
cursor: auto;
}
.leaflet-dragging .leaflet-grab,
.leaflet-dragging .leaflet-grab .leaflet-interactive,
.leaflet-dragging .leaflet-marker-draggable {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
}
/* marker & overlays interactivity */
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-image-layer,
.leaflet-pane > svg path,
.leaflet-tile-container {
pointer-events: none;
}
.leaflet-marker-icon.leaflet-interactive,
.leaflet-image-layer.leaflet-interactive,
.leaflet-pane > svg path.leaflet-interactive {
pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */
pointer-events: auto;
}
/* visual tweaks */
.leaflet-container {
background: #ddd;
outline: 0;
}
.leaflet-container a {
color: #0078A8;
}
.leaflet-container a.leaflet-active {
outline: 2px solid orange;
}
.leaflet-zoom-box {
border: 2px dotted #38f;
background: rgba(255,255,255,0.5);
}
/* general typography */
.leaflet-container {
font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
}
/* general toolbar styles */
.leaflet-bar {
box-shadow: 0 1px 5px rgba(0,0,0,0.65);
border-radius: 4px;
}
.leaflet-bar a,
.leaflet-bar a:hover {
background-color: #fff;
border-bottom: 1px solid #ccc;
width: 26px;
height: 26px;
line-height: 26px;
display: block;
text-align: center;
text-decoration: none;
color: black;
}
.leaflet-bar a,
.leaflet-control-layers-toggle {
background-position: 50% 50%;
background-repeat: no-repeat;
display: block;
}
.leaflet-bar a:hover {
background-color: #f4f4f4;
}
.leaflet-bar a:first-child {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.leaflet-bar a:last-child {
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
border-bottom: none;
}
.leaflet-bar a.leaflet-disabled {
cursor: default;
background-color: #f4f4f4;
color: #bbb;
}
.leaflet-touch .leaflet-bar a {
width: 30px;
height: 30px;
line-height: 30px;
}
/* zoom control */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
font: bold 18px 'Lucida Console', Monaco, monospace;
text-indent: 1px;
}
.leaflet-control-zoom-out {
font-size: 20px;
}
.leaflet-touch .leaflet-control-zoom-in {
font-size: 22px;
}
.leaflet-touch .leaflet-control-zoom-out {
font-size: 24px;
}
/* layers control */
.leaflet-control-layers {
box-shadow: 0 1px 5px rgba(0,0,0,0.4);
background: #fff;
border-radius: 5px;
}
.leaflet-control-layers-toggle {
background-image: url("/widgets/Leaflet/widget/ui/layers.png");
width: 36px;
height: 36px;
}
.leaflet-retina .leaflet-control-layers-toggle {
background-image: url(images/layers-2x.png);
background-size: 26px 26px;
}
.leaflet-touch .leaflet-control-layers-toggle {
width: 44px;
height: 44px;
}
.leaflet-control-layers .leaflet-control-layers-list,
.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
display: none;
}
.leaflet-control-layers-expanded .leaflet-control-layers-list {
display: block;
position: relative;
}
.leaflet-control-layers-expanded {
padding: 6px 10px 6px 6px;
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;
top: 1px;
}
.leaflet-control-layers label {
display: block;
}
.leaflet-control-layers-separator {
height: 0;
border-top: 1px solid #ddd;
margin: 5px -10px 5px -6px;
}
/* Default icon URLs */
.leaflet-default-icon-path {
background-image: url(images/marker-icon.png);
}
/* attribution and scale controls */
.leaflet-container .leaflet-control-attribution {
background: #fff;
background: rgba(255, 255, 255, 0.7);
margin: 0;
}
.leaflet-control-attribution,
.leaflet-control-scale-line {
padding: 0 5px;
color: #333;
}
.leaflet-control-attribution a {
text-decoration: none;
}
.leaflet-control-attribution a:hover {
text-decoration: underline;
}
.leaflet-container .leaflet-control-attribution,
.leaflet-container .leaflet-control-scale {
font-size: 11px;
}
.leaflet-left .leaflet-control-scale {
margin-left: 5px;
}
.leaflet-bottom .leaflet-control-scale {
margin-bottom: 5px;
}
.leaflet-control-scale-line {
border: 2px solid #777;
border-top: none;
line-height: 1.1;
padding: 2px 5px 1px;
font-size: 11px;
white-space: nowrap;
overflow: hidden;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: #fff;
background: rgba(255, 255, 255, 0.5);
}
.leaflet-control-scale-line:not(:first-child) {
border-top: 2px solid #777;
border-bottom: none;
margin-top: -2px;
}
.leaflet-control-scale-line:not(:first-child):not(:last-child) {
border-bottom: 2px solid #777;
}
.leaflet-touch .leaflet-control-attribution,
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
box-shadow: none;
}
.leaflet-touch .leaflet-control-layers,
.leaflet-touch .leaflet-bar {
border: 2px solid rgba(0,0,0,0.2);
background-clip: padding-box;
}
/* popup */
.leaflet-popup {
position: absolute;
text-align: center;
margin-bottom: 20px;
}
.leaflet-popup-content-wrapper {
padding: 1px;
text-align: left;
border-radius: 12px;
}
.leaflet-popup-content {
margin: 13px 19px;
line-height: 1.4;
}
.leaflet-popup-content p {
margin: 18px 0;
}
.leaflet-popup-tip-container {
width: 40px;
height: 20px;
position: absolute;
left: 50%;
margin-left: -20px;
overflow: hidden;
pointer-events: none;
}
.leaflet-popup-tip {
width: 17px;
height: 17px;
padding: 1px;
margin: -10px auto 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
background: white;
color: #333;
box-shadow: 0 3px 14px rgba(0,0,0,0.4);
}
.leaflet-container a.leaflet-popup-close-button {
position: absolute;
top: 0;
right: 0;
padding: 4px 4px 0 0;
border: none;
text-align: center;
width: 18px;
height: 14px;
font: 16px/14px Tahoma, Verdana, sans-serif;
color: #c3c3c3;
text-decoration: none;
font-weight: bold;
background: transparent;
}
.leaflet-container a.leaflet-popup-close-button:hover {
color: #999;
}
.leaflet-popup-scrolled {
overflow: auto;
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
}
.leaflet-oldie .leaflet-popup-content-wrapper {
zoom: 1;
}
.leaflet-oldie .leaflet-popup-tip {
width: 24px;
margin: 0 auto;
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
}
.leaflet-oldie .leaflet-popup-tip-container {
margin-top: -1px;
}
.leaflet-oldie .leaflet-control-zoom,
.leaflet-oldie .leaflet-control-layers,
.leaflet-oldie .leaflet-popup-content-wrapper,
.leaflet-oldie .leaflet-popup-tip {
border: 1px solid #999;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Tooltip */
/* Base styles for the element that has a tooltip */
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: nowrap;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-tooltip.leaflet-clickable {
cursor: pointer;
pointer-events: auto;
}
.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
position: absolute;
pointer-events: none;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Directions */
.leaflet-tooltip-bottom {
margin-top: 6px;
}
.leaflet-tooltip-top {
margin-top: -6px;
}
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-top:before {
left: 50%;
margin-left: -6px;
}
.leaflet-tooltip-top:before {
bottom: 0;
margin-bottom: -12px;
border-top-color: #fff;
}
.leaflet-tooltip-bottom:before {
top: 0;
margin-top: -12px;
margin-left: -6px;
border-bottom-color: #fff;
}
.leaflet-tooltip-left {
margin-left: -6px;
}
.leaflet-tooltip-right {
margin-left: 6px;
}
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
top: 50%;
margin-top: -6px;
}
.leaflet-tooltip-left:before {
right: 0;
margin-right: -12px;
border-left-color: #fff;
}
.leaflet-tooltip-right:before {
left: 0;
margin-left: -12px;
border-right-color: #fff;
}
/* div icon */
.leaflet-div-icon {
background: #fff;
border: 1px solid #666;
}
/* Leaflet Locate Control */
.leaflet-control-locate .glyphicon {
top: 4px;
}
.leaflet-control-locate a {
font-size: 1.4em;
color: #444;
}
.leaflet-control-locate.active a {
color: #2074B6;
}
.leaflet-control-locate.active.following a {
color: #FC8428;
}
/* Leaflet Fullscreen */
.fullscreen-icon {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAYElEQVR42u2UwQkAIAwDHckROpobdgRHURQRQcgngn3kIL9o+kibhAhFO+TA56eXDTLgs5dBFfgqG+Rj2vVRBr68PDbfkJQ98a3ytBhICvoQRJQhQr35hQ19gvijKkQYOnXBYeFRr/ZKAAAAAElFTkSuQmCC');
}
.leaflet-retina .fullscreen-icon {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAAq0lEQVR42u2Y0QmAMAwFHcHR3DAjOUJH6AhV/CgE0UJK6wPv4H0aOFtjmwUAAAAAfkV5yR6otzdqjqUhswbqrVVKSCg7mZhUVlshW+KYzgr1S5nKN5QHCuV5Qr4B2IAtZ65RDOfezaxH5qlOlfqY7Uyqb7uddD0jhZcpkahKpQ6hpChUeoIQQggh5ELb5scqcvThcMr1YdIFjys4Q5IJYywGjYyCAQAAAECZA/11ewjNJ8u0AAAAAElFTkSuQmCC');
background-size: 26px 26px;
}
.leaflet-container:-webkit-full-screen {
width: 100% !important;
height: 100% !important;
z-index: 99999;
}
.leaflet-pseudo-fullscreen {
position: fixed !important;
width: 100% !important;
height: 100% !important;
top: 0px !important;
left: 0px !important;
z-index: 99999;
}

17
src/helpers/data.js Normal file
View File

@@ -0,0 +1,17 @@
import Promise from 'dojo/promise/Promise';
export const getData = params => new Promise((resolve, reject) => {
mx.data.get({
params,
callback: resolve,
error: reject,
});
});
export const fetchAttr = (obj, attr) => new Promise((resolve, reject) => {
try {
obj.fetch(attr, val => resolve(val));
} catch (e) {
reject(e);
}
});

26
src/helpers/index.js Normal file
View File

@@ -0,0 +1,26 @@
/*eslint no-invalid-this: 0*/
/**
* Logs using the Mendix logger
*
* @export
* @param {string} methodName
* @param {...any} args
*/
export function log(methodName, ...args) {
logger.debug(`${this.id}.${methodName}`, args.length ? args[ 0 ] : '');
}
/**
* Runs a callback and logs the method where it comes from
*
* @export
* @param {() => {}} cb
* @param {string} from
*/
export function runCallback(cb, from) {
log.call(this, '_callback', from ? `from ${from}` : '');
if (cb && 'function' === typeof cb) {
cb();
}
}

44
src/helpers/microflow.js Normal file
View File

@@ -0,0 +1,44 @@
/*eslint no-invalid-this: 0*/
import lang from 'dojo/_base/lang';
import { log } from '@/helpers';
export function execute(microflow, guid, cb, errCb) {
if (microflow) {
log.call(this, 'execute microflow', `microflow: ${microflow}:${guid}`);
const action = {
params: {
applyto: 'selection',
guids: [],
actionname: microflow,
},
callback: lang.hitch(this, objs => {
if (cb && 'function' == typeof cb) {
cb(objs);
}
}),
error: lang.hitch(this, error => {
if (errCb && 'function' == typeof errCb) {
errCb(error);
} else {
mx.ui.error(`Error executing microflow ${microflow} : ${error.message}`);
console.error(this.id + "._execMf", error);
}
}),
};
if (guid) {
action.params.guids = [guid];
}
if (!mx.version || mx.version && 7 > parseInt(mx.version.split(".")[ 0 ], 10)) {
action.store = {
caller: this.mxform,
};
} else {
action.origin = this.mxform;
}
mx.data.action(action, this);
}
}

39
src/helpers/widget.js Normal file
View File

@@ -0,0 +1,39 @@
import declare from 'dojoBaseDeclare';
import widgetBase from 'widgetBase';
import templateMixin from 'dijit/_TemplatedMixin';
const { packageName, version, widgetFolder } = config;
/**
* Defines a widget. Use this when you have multiple sub widgets. For a single widget this might be overkill
*
* @export
* @param {string} id
* @param {string} template
* @param {{}}} obj
* @param {any} base
* @returns
*/
export function defineWidget(id, template, obj, base) {
const widgetObj = obj;
widgetObj._WIDGET_VERSION = version;
const mixins = [];
if ('undefined' !== typeof base) {
if (null !== base) {
mixins.push(base);
}
} else {
mixins.push(widgetBase);
}
if (template) {
mixins.push(templateMixin);
}
if ('boolean' !== typeof template){
widgetObj.templateString = template;
}
return declare(`${packageName}.${widgetFolder}.${id}`, mixins, widgetObj);
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="OpenLayers" version="1.3.0" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<widgetFile path="Leaflet/Leaflet.xml"/>
</widgetFiles>
<files>
<file path="Leaflet/widget/"/>
</files>
</clientModule>
</package>

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Policy file that matches the functionality of the Bootstrap rich text widget
-->
<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="antisamy.xsd">
<directives>
<directive name="omitXmlDeclaration" value="true" />
<directive name="omitDoctypeDeclaration" value="true" />
<directive name="maxInputSize" value="100000" />
<directive name="embedStyleSheets" value="false" />
<directive name="useXHTML" value="true" />
<directive name="formatOutput" value="false" />
</directives>
<common-regexps>
<!--
From W3C:
This attribute assigns a class name or set of class names to an
element. Any number of elements may be assigned the same class
name or names. Multiple class names must be separated by white
space characters.
-->
<regexp name="htmlTitle" value="[a-zA-Z0-9\s\-_',:\[\]!\./\\\(\)&amp;]*" />
<!-- force non-empty with a '+' at the end instead of '*'
-->
<regexp name="onsiteURL" value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~])+" />
<!-- ([\w\\/\.\?=&amp;;\#-~]+|\#(\w)+)
-->
<!-- ([\p{L}/ 0-9&amp;\#-.?=])*
-->
<regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[A-Za-z0-9]+[~a-zA-Z0-9-_\.@\#\$%&amp;;:,\?=/\+!\(\)]*(\s)*" />
<regexp name="imgsrc" value="data:image/[jpg|gif|png].*"/>
<regexp name="positiveLength" value="((\+)?0|(\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/>
</common-regexps>
<!--
Tag.name = a, b, div, body, etc.
Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents
Attribute.name = id, class, href, align, width, etc.
Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag)
Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML
-->
<!--
Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no
collisions between any of these attribute names with attribute names of other tags that are for different purposes.
-->
<common-attributes>
<attribute name="name">
<regexp-list>
<regexp value="[a-zA-Z0-9\-_]+"/>
</regexp-list>
</attribute>
<attribute name="lang"
description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}" />
</regexp-list>
</attribute>
<attribute name="title"
description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
<regexp-list>
<regexp name="htmlTitle" />
</regexp-list>
</attribute>
<attribute name="href" onInvalid="filterTag">
<regexp-list>
<regexp name="onsiteURL" />
<regexp name="offsiteURL" />
<!--
-->
</regexp-list>
</attribute>
<attribute name="align"
description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'">
<literal-list>
<literal value="center" />
<literal value="left" />
<literal value="right" />
<literal value="justify" />
<literal value="char" />
</literal-list>
</attribute>
<attribute name="style"
description="The 'style' attribute provides the ability for users to change many attributes of the tag's contents using a strict syntax" />
</common-attributes>
<!--
This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue
this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after
a while?
-->
<global-tag-attributes>
<attribute name="title" />
<attribute name="lang" />
<attribute name="style" />
</global-tag-attributes>
<tags-to-encode>
<tag>g</tag>
<tag>grin</tag>
</tags-to-encode>
<tag-rules>
<!-- Remove -->
<tag name="script" action="remove" />
<tag name="noscript" action="remove" />
<tag name="iframe" action="remove" />
<tag name="frameset" action="remove" />
<tag name="frame" action="remove" />
<tag name="noframes" action="remove" />
<tag name="head" action="remove" />
<tag name="title" action="remove" />
<tag name="base" action="remove" />
<tag name="style" action="remove" />
<tag name="link" action="remove" />
<tag name="input" action="remove" />
<tag name="textarea" action="remove" />
<!-- Truncate -->
<tag name="br" action="truncate" />
<!-- Validate -->
<tag name="h1" action="validate"/>
<tag name="h2" action="validate"/>
<tag name="h3" action="validate"/>
<tag name="h4" action="validate"/>
<tag name="h5" action="validate"/>
<tag name="h6" action="validate"/>
<tag name="p" action="validate">
<attribute name="align" />
</tag>
<tag name="div" action="validate" />
<tag name="span" action="validate" />
<tag name="i" action="validate" />
<tag name="b" action="validate" />
<tag name="strong" action="validate" />
<tag name="s" action="validate" />
<tag name="strike" action="validate" />
<tag name="u" action="validate" />
<tag name="em" action="validate" />
<tag name="blockquote" action="validate" />
<tag name="tt" action="truncate" />
<tag name="font" action="validate">
<attribute name="face">
<regexp-list>
<regexp value="[\w;, \-]+"/>
</regexp-list>
</attribute>
<attribute name="size">
<regexp-list>
<regexp value="(\+|-){0,1}(\d)+"/>
</regexp-list>
</attribute>
</tag>
<tag name="a" action="validate">
<attribute name="href" onInvalid="filterTag" />
<attribute name="nohref">
<literal-list>
<literal value="nohref" />
<literal value="" />
</literal-list>
</attribute>
<attribute name="rel">
<literal-list>
<literal value="nofollow" />
</literal-list>
</attribute>
</tag>
<!-- Image & image related tags -->
<tag name="img" action="validate">
<attribute name="src" onInvalid="removeTag">
<regexp-list>
<regexp name="imgsrc"/>
</regexp-list>
</attribute>
</tag>
<!-- List tags
-->
<tag name="ul" action="validate" />
<tag name="ol" action="validate" />
<tag name="li" action="validate" />
<tag name="dl" action="validate" />
<tag name="dt" action="validate" />
<tag name="dd" action="validate" />
</tag-rules>
<css-rules>
<property name="margin" description="">
<category-list>
<category value="visual"/>
</category-list>
<regexp-list>
<regexp name="positiveLength"/>
</regexp-list>
</property>
<property name="padding" description="">
<category-list>
<category value="visual"/>
</category-list>
<regexp-list>
<regexp name="positiveLength"/>
</regexp-list>
</property>
<property name="border" description="">
<category-list>
<category value="visual"/>
</category-list>
<literal-list>
<literal value="none"/>
</literal-list>
</property>
<property name="text-align" description="This property describes how inline content of a block is aligned.">
<category-list>
<category value="visual"/>
</category-list>
<!-- For safety, ignoring string alignment which can be used to line table cells on characters -->
<literal-list>
<literal value="left"/>
<literal value="right"/>
<literal value="center"/>
<literal value="justify"/>
</literal-list>
</property>
</css-rules>
</anti-samy-rules>

View File

@@ -0,0 +1,252 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Policy file that matches the functionality of the Bootstrap rich text widget, without hyperlinks
-->
<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="antisamy.xsd">
<directives>
<directive name="omitXmlDeclaration" value="true" />
<directive name="omitDoctypeDeclaration" value="true" />
<directive name="maxInputSize" value="100000" />
<directive name="embedStyleSheets" value="false" />
<directive name="useXHTML" value="true" />
<directive name="formatOutput" value="false" />
</directives>
<common-regexps>
<!--
From W3C:
This attribute assigns a class name or set of class names to an
element. Any number of elements may be assigned the same class
name or names. Multiple class names must be separated by white
space characters.
-->
<regexp name="htmlTitle" value="[a-zA-Z0-9\s\-_',:\[\]!\./\\\(\)&amp;]*" />
<!-- force non-empty with a '+' at the end instead of '*'
-->
<regexp name="onsiteURL" value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~])+" />
<!-- ([\w\\/\.\?=&amp;;\#-~]+|\#(\w)+)
-->
<!-- ([\p{L}/ 0-9&amp;\#-.?=])*
-->
<regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[A-Za-z0-9]+[~a-zA-Z0-9-_\.@\#\$%&amp;;:,\?=/\+!\(\)]*(\s)*" />
<regexp name="imgsrc" value="data:image/[jpg|gif|png].*"/>
<regexp name="positiveLength" value="((\+)?0|(\+)?([0-9]+(\.[0-9]+)?)(em|ex|px|in|cm|mm|pt|pc))"/>
</common-regexps>
<!--
Tag.name = a, b, div, body, etc.
Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents
Attribute.name = id, class, href, align, width, etc.
Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag)
Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML
-->
<!--
Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no
collisions between any of these attribute names with attribute names of other tags that are for different purposes.
-->
<common-attributes>
<attribute name="name">
<regexp-list>
<regexp value="[a-zA-Z0-9\-_]+"/>
</regexp-list>
</attribute>
<attribute name="lang"
description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}" />
</regexp-list>
</attribute>
<attribute name="title"
description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
<regexp-list>
<regexp name="htmlTitle" />
</regexp-list>
</attribute>
<attribute name="href" onInvalid="filterTag">
<regexp-list>
<regexp name="onsiteURL" />
<regexp name="offsiteURL" />
<!--
-->
</regexp-list>
</attribute>
<attribute name="align"
description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'">
<literal-list>
<literal value="center" />
<literal value="left" />
<literal value="right" />
<literal value="justify" />
<literal value="char" />
</literal-list>
</attribute>
<attribute name="style"
description="The 'style' attribute provides the ability for users to change many attributes of the tag's contents using a strict syntax" />
</common-attributes>
<!--
This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue
this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after
a while?
-->
<global-tag-attributes>
<attribute name="title" />
<attribute name="lang" />
<attribute name="style" />
</global-tag-attributes>
<tags-to-encode>
<tag>g</tag>
<tag>grin</tag>
</tags-to-encode>
<tag-rules>
<!-- Remove -->
<tag name="script" action="remove" />
<tag name="noscript" action="remove" />
<tag name="iframe" action="remove" />
<tag name="frameset" action="remove" />
<tag name="frame" action="remove" />
<tag name="noframes" action="remove" />
<tag name="head" action="remove" />
<tag name="title" action="remove" />
<tag name="base" action="remove" />
<tag name="style" action="remove" />
<tag name="link" action="remove" />
<tag name="input" action="remove" />
<tag name="textarea" action="remove" />
<!-- Truncate -->
<tag name="br" action="truncate" />
<!-- Validate -->
<tag name="h1" action="validate"/>
<tag name="h2" action="validate"/>
<tag name="h3" action="validate"/>
<tag name="h4" action="validate"/>
<tag name="h5" action="validate"/>
<tag name="h6" action="validate"/>
<tag name="p" action="validate">
<attribute name="align" />
</tag>
<tag name="div" action="validate" />
<tag name="span" action="validate" />
<tag name="i" action="validate" />
<tag name="b" action="validate" />
<tag name="strong" action="validate" />
<tag name="s" action="validate" />
<tag name="strike" action="validate" />
<tag name="u" action="validate" />
<tag name="em" action="validate" />
<tag name="blockquote" action="validate" />
<tag name="tt" action="truncate" />
<tag name="font" action="validate">
<attribute name="face">
<regexp-list>
<regexp value="[\w;, \-]+"/>
</regexp-list>
</attribute>
<attribute name="size">
<regexp-list>
<regexp value="(\+|-){0,1}(\d)+"/>
</regexp-list>
</attribute>
</tag>
<!-- Image & image related tags -->
<tag name="img" action="validate">
<attribute name="src" onInvalid="removeTag">
<regexp-list>
<regexp name="imgsrc"/>
</regexp-list>
</attribute>
</tag>
<!-- List tags
-->
<tag name="ul" action="validate" />
<tag name="ol" action="validate" />
<tag name="li" action="validate" />
<tag name="dl" action="validate" />
<tag name="dt" action="validate" />
<tag name="dd" action="validate" />
</tag-rules>
<css-rules>
<property name="margin" description="">
<category-list>
<category value="visual"/>
</category-list>
<regexp-list>
<regexp name="positiveLength"/>
</regexp-list>
</property>
<property name="padding" description="">
<category-list>
<category value="visual"/>
</category-list>
<regexp-list>
<regexp name="positiveLength"/>
</regexp-list>
</property>
<property name="border" description="">
<category-list>
<category value="visual"/>
</category-list>
<literal-list>
<literal value="none"/>
</literal-list>
</property>
<property name="text-align" description="This property describes how inline content of a block is aligned.">
<category-list>
<category value="visual"/>
</category-list>
<!-- For safety, ignoring string alignment which can be used to line table cells on characters -->
<literal-list>
<literal value="left"/>
<literal value="right"/>
<literal value="center"/>
<literal value="justify"/>
</literal-list>
</property>
</css-rules>
</anti-samy-rules>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
W3C rules retrieved from:
http://www.w3.org/TR/html401/struct/global.html
-->
<!--
Slashdot allowed tags taken from "Reply" page:
<b> <i> <p> <br> <a> <ol> <ul> <li> <dl> <dt> <dd> <em> <strong> <tt> <blockquote> <div> <ecode> <quote>
-->
<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="antisamy.xsd">
<directives>
<directive name="omitXmlDeclaration" value="true"/>
<directive name="omitDoctypeDeclaration" value="true"/>
<directive name="maxInputSize" value="5000"/>
<directive name="useXHTML" value="true"/>
<directive name="formatOutput" value="true"/>
<directive name="embedStyleSheets" value="false"/>
</directives>
<common-regexps>
<!--
From W3C:
This attribute assigns a class name or set of class names to an
element. Any number of elements may be assigned the same class
name or names. Multiple class names must be separated by white
space characters.
-->
<regexp name="htmlTitle" value="[\p{L}\p{N}\s\-_',:\[\]!\./\\\(\)&amp;]*"/> <!-- force non-empty with a '+' at the end instead of '*' -->
<regexp name="onsiteURL" value="([\p{L}\p{N}\\/\.\?=\#&amp;;\-_~]+|\#(\w)+)"/>
<regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[\p{L}\p{N}]+[~\p{L}\p{N}\p{Zs}\-_\.@\#\$%&amp;;:,\?=/\+!\(\)]*(\s)*"/>
</common-regexps>
<!--
Tag.name = a, b, div, body, etc.
Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents
Attribute.name = id, class, href, align, width, etc.
Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag)
Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML
-->
<!--
Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no
collisions between any of these attribute names with attribute names of other tags that are for different purposes.
-->
<common-attributes>
<attribute name="lang" description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}"/>
</regexp-list>
</attribute>
<attribute name="title" description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
<regexp-list>
<regexp name="htmlTitle"/>
</regexp-list>
</attribute>
<attribute name="href" onInvalid="filterTag">
<regexp-list>
<regexp name="onsiteURL"/>
<regexp name="offsiteURL"/>
</regexp-list>
</attribute>
<attribute name="align" description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'">
<literal-list>
<literal value="center"/>
<literal value="left"/>
<literal value="right"/>
<literal value="justify"/>
<literal value="char"/>
</literal-list>
</attribute>
</common-attributes>
<!--
This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue
this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after
a while?
-->
<global-tag-attributes>
<attribute name="title"/>
<attribute name="lang"/>
</global-tag-attributes>
<tags-to-encode>
<tag>g</tag>
<tag>grin</tag>
</tags-to-encode>
<tag-rules>
<!-- Tags related to JavaScript -->
<tag name="script" action="remove"/>
<tag name="noscript" action="remove"/>
<!-- Frame & related tags -->
<tag name="iframe" action="remove"/>
<tag name="frameset" action="remove"/>
<tag name="frame" action="remove"/>
<tag name="noframes" action="remove"/>
<!-- CSS related tags -->
<tag name="style" action="remove"/>
<!-- All reasonable formatting tags -->
<tag name="p" action="validate">
<attribute name="align"/>
</tag>
<tag name="div" action="validate"/>
<tag name="i" action="validate"/>
<tag name="b" action="validate"/>
<tag name="em" action="validate"/>
<tag name="blockquote" action="validate"/>
<tag name="tt" action="validate"/>
<tag name="strong" action="validate"/>
<tag name="br" action="truncate"/>
<!-- Custom Slashdot tags, though we're trimming the idea of having a possible mismatching end tag with the endtag="" attribute -->
<tag name="quote" action="validate"/>
<tag name="ecode" action="validate"/>
<!-- Anchor and anchor related tags -->
<tag name="a" action="validate">
<attribute name="href" onInvalid="filterTag"/>
<attribute name="nohref">
<literal-list>
<literal value="nohref"/>
<literal value=""/>
</literal-list>
</attribute>
<attribute name="rel">
<literal-list>
<literal value="nofollow"/>
</literal-list>
</attribute>
</tag>
<!-- List tags -->
<tag name="ul" action="validate"/>
<tag name="ol" action="validate"/>
<tag name="li" action="validate"/>
</tag-rules>
<!-- No CSS on Slashdot posts -->
<css-rules>
</css-rules>
</anti-samy-rules>

View File

@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
TinyMCE
-->
<anti-samy-rules xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="antisamy.xsd">
<directives>
<directive name="omitXmlDeclaration" value="true" />
<directive name="omitDoctypeDeclaration" value="false" />
<directive name="maxInputSize" value="100000" />
<directive name="embedStyleSheets" value="false" />
<directive name="useXHTML" value="true" />
<directive name="formatOutput" value="true" />
</directives>
<common-regexps>
<!--
From W3C:
This attribute assigns a class name or set of class names to an
element. Any number of elements may be assigned the same class
name or names. Multiple class names must be separated by white
space characters.
-->
<regexp name="htmlTitle" value="[a-zA-Z0-9\s\-_',:\[\]!\./\\\(\)&amp;]*" />
<!-- force non-empty with a '+' at the end instead of '*'
-->
<regexp name="onsiteURL" value="([\p{L}\p{N}\p{Zs}/\.\?=&amp;\-~])+" />
<!-- ([\w\\/\.\?=&amp;;\#-~]+|\#(\w)+)
-->
<!-- ([\p{L}/ 0-9&amp;\#-.?=])*
-->
<regexp name="offsiteURL" value="(\s)*((ht|f)tp(s?)://|mailto:)[A-Za-z0-9]+[~a-zA-Z0-9-_\.@\#\$%&amp;;:,\?=/\+!\(\)]*(\s)*" />
</common-regexps>
<!--
Tag.name = a, b, div, body, etc.
Tag.action = filter: remove tags, but keep content, validate: keep content as long as it passes rules, remove: remove tag and contents
Attribute.name = id, class, href, align, width, etc.
Attribute.onInvalid = what to do when the attribute is invalid, e.g., remove the tag (removeTag), remove the attribute (removeAttribute), filter the tag (filterTag)
Attribute.description = What rules in English you want to tell the users they can have for this attribute. Include helpful things so they'll be able to tune their HTML
-->
<!--
Some attributes are common to all (or most) HTML tags. There aren't many that qualify for this. You have to make sure there's no
collisions between any of these attribute names with attribute names of other tags that are for different purposes.
-->
<common-attributes>
<attribute name="lang"
description="The 'lang' attribute tells the browser what language the element's attribute values and content are written in">
<regexp-list>
<regexp value="[a-zA-Z]{2,20}" />
</regexp-list>
</attribute>
<attribute name="title"
description="The 'title' attribute provides text that shows up in a 'tooltip' when a user hovers their mouse over the element">
<regexp-list>
<regexp name="htmlTitle" />
</regexp-list>
</attribute>
<attribute name="href" onInvalid="filterTag">
<regexp-list>
<regexp name="onsiteURL" />
<regexp name="offsiteURL" />
<!--
-->
</regexp-list>
</attribute>
<attribute name="align"
description="The 'align' attribute of an HTML element is a direction word, like 'left', 'right' or 'center'">
<literal-list>
<literal value="center" />
<literal value="left" />
<literal value="right" />
<literal value="justify" />
<literal value="char" />
</literal-list>
</attribute>
<attribute name="style"
description="The 'style' attribute provides the ability for users to change many attributes of the tag's contents using a strict syntax" />
</common-attributes>
<!--
This requires normal updates as browsers continue to diverge from the W3C and each other. As long as the browser wars continue
this is going to continue. I'm not sure war is the right word for what's going on. Doesn't somebody have to win a war after
a while?
-->
<global-tag-attributes>
<attribute name="title" />
<attribute name="lang" />
<attribute name="style" />
</global-tag-attributes>
<tags-to-encode>
<tag>g</tag>
<tag>grin</tag>
</tags-to-encode>
<tag-rules>
<!-- Remove -->
<tag name="script" action="remove" />
<tag name="noscript" action="remove" />
<tag name="iframe" action="remove" />
<tag name="frameset" action="remove" />
<tag name="frame" action="remove" />
<tag name="noframes" action="remove" />
<tag name="head" action="remove" />
<tag name="title" action="remove" />
<tag name="base" action="remove" />
<tag name="style" action="remove" />
<tag name="link" action="remove" />
<tag name="input" action="remove" />
<tag name="textarea" action="remove" />
<!-- Truncate -->
<tag name="br" action="truncate" />
<!-- Validate -->
<tag name="p" action="validate">
<attribute name="align" />
</tag>
<tag name="div" action="validate" />
<tag name="span" action="validate" />
<tag name="i" action="validate" />
<tag name="b" action="validate" />
<tag name="strong" action="validate" />
<tag name="s" action="validate" />
<tag name="strike" action="validate" />
<tag name="u" action="validate" />
<tag name="em" action="validate" />
<tag name="blockquote" action="validate" />
<tag name="tt" action="truncate" />
<tag name="a" action="validate">
<attribute name="href" onInvalid="filterTag" />
<attribute name="nohref">
<literal-list>
<literal value="nohref" />
<literal value="" />
</literal-list>
</attribute>
<attribute name="rel">
<literal-list>
<literal value="nofollow" />
</literal-list>
</attribute>
</tag>
<!-- List tags
-->
<tag name="ul" action="validate" />
<tag name="ol" action="validate" />
<tag name="li" action="validate" />
<tag name="dl" action="validate" />
<tag name="dt" action="validate" />
<tag name="dd" action="validate" />
</tag-rules>
<css-rules>
<property name="text-decoration" default="none"
description="">
<category-list>
<category value="visual" />
</category-list>
<literal-list>
<literal value="underline" />
<literal value="overline" />
<literal value="line-through" />
</literal-list>
</property>
</css-rules>
</anti-samy-rules>

Binary file not shown.

226
webpack.config.js Normal file
View File

@@ -0,0 +1,226 @@
const webpack = require('webpack');
const path = require('path');
const fs = require('fs-extra');
const BabiliPlugin = require('babili-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const XMLWebpackPlugin = require('xml-webpack-plugin');
const ZipPlugin = require('webpack-archive-plugin');
const autoprefixer = require('autoprefixer');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const env = process.env.WEBPACK_ENV;
const pkg = require('./package.json');
const version = pkg.version;
const widgetConfig = pkg.widget;
const packageName = widgetConfig.package;
const widgetFolder = widgetConfig.filesFolder;
const name = pkg.name;
const srcDir = 'src';
const rootDir = `src/${packageName}`;
const uiDir = `src/${packageName}/widget/ui`;
const widgetDir = `${rootDir}/widget`;
const buildDir = 'build';
const uiBuildDir = `build/${packageName}/widget/ui`;
const mpkDir = 'dist';
fs.ensureDirSync(buildDir);
fs.ensureDirSync(uiBuildDir);
fs.ensureDirSync(mpkDir);
const entry = {};
fs.readdirSync(widgetDir)
.filter(file => file.indexOf('.js') !== -1)
.filter(file => {
return widgetConfig.libraries || (!widgetConfig.libraries && file.indexOf('Libraries') === -1);
})
.filter(file => {
return widgetConfig.core || (!widgetConfig.core && file.indexOf('Core') === -1);
})
.forEach(e => {
entry[e.replace('.js', '')] = path.join(__dirname, widgetDir, e);
});
const packageXml = {
template: path.join(__dirname, 'widgetpackage.template.xml.ejs'),
filename: 'package.xml',
data: {
packageName,
version,
widgetFolder,
files: []
}
};
const copyFiles = [];
fs.readdirSync(rootDir)
.filter(e => e.indexOf('.xml') !== -1)
.forEach(file => {
packageXml.data.files.push(file);
copyFiles.push({
from: path.join(rootDir, file),
to: path.join(__dirname, buildDir, packageName)
});
});
fs.readdirSync(uiDir)
.forEach(file => {
copyFiles.push({
from: path.join(uiDir, file),
to: path.join(__dirname, uiBuildDir)
});
});
const webpackDefinitions = {
version,
packageName,
widgetFolder
};
const externals = [
/^mxui\/|^mendix\/|^dojo\/|^dijit\//,
{
dojoBaseDeclare: 'dojo/_base/declare'
},
{
widgetBase: 'mxui/widget/_WidgetBase'
},
];
if (widgetConfig.libraries) {
externals.push({
Libraries: `${packageName}/${widgetFolder}/Libraries`
});
}
if (widgetConfig.core) {
externals.push({
Core: `${packageName}/${widgetFolder}/Core`
});
}
const webpackConfig = {
target: 'web',
entry,
output: {
libraryTarget: 'amd',
path: path.resolve(__dirname, buildDir),
publicPath: '',
filename: `${packageName}/${widgetFolder}/[name].js`
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: [
'babel-loader',
'eslint-loader'
]
},
{
test: /\.(css|scss)$/,
loaders: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader!sass-loader!postcss-loader'
})
},
{
test: /\.template\.html$/,
use: 'raw-loader'
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: [
'url-loader?limit=10000',
{
loader: 'img-loader',
options: {
// enabled: process.env.NODE_ENV === 'production',
gifsicle: {
interlaced: false
},
mozjpeg: {
progressive: true,
arithmetic: false
},
optipng: true, // disabled
pngquant: {
floyd: 0.5,
speed: 2
},
svgo: {
plugins: [
{
removeTitle: true
},
{
convertPathData: false
}
]
}
}
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'config': JSON.stringify(webpackDefinitions),
'version': JSON.stringify(version),
'packageName': JSON.stringify(packageName),
}),
new ExtractTextPlugin(`${packageName}/${widgetFolder}/ui/[name].css`),
new CopyWebpackPlugin(copyFiles),
new XMLWebpackPlugin({
files: [packageXml]
}),
new webpack.LoaderOptionsPlugin({
options: {
postcss: () => [autoprefixer]
}
}),
new ZipPlugin({
entries: [{
src: path.join(__dirname, './build'),
dist: '/',
}],
output: path.join(__dirname, `./${mpkDir}/${packageName}`),
ext: 'mpk',
format: 'zip'
})
],
externals,
resolve: {
alias: {
'@': path.join(__dirname, 'src')
}
},
}
if (env !== 'production') {
//webpackConfig.devtool = 'source-map';
} else {
webpackConfig.plugins.push(new BabiliPlugin({}, {
test: /\.js$/,
}));
webpackConfig.module.loaders.push({
test: /\.js$/,
enforce: 'pre',
exclude: /(node_modules|bower_components|\.spec\.js)/,
use: [
{
loader: 'webpack-strip-block'
}
]
});
}
module.exports = webpackConfig;

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8" ?>
<package xmlns="http://www.mendix.com/package/1.0/">
<clientModule name="OpenLayers" version="<%= version %>" xmlns="http://www.mendix.com/clientModule/1.0/">
<widgetFiles>
<% files.forEach(function(file){ %><widgetFile path="<%= packageName %>/<%= file %>" />
<% }); %>
</widgetFiles>
<files>
<file path="<%= packageName %>/<%= widgetFolder %>/" />
</files>
</clientModule>
</package>