diff --git a/.jshintrc b/.jshintrc
index ae31974f..3ba65dd5 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -1,36 +1,17 @@
{
- "bitwise" : true,
- "curly" : true,
- "eqeqeq" : true,
- "forin" : true,
- "freeze" : true,
- "immed" : true,
- "latedef" : false,
- "newcap" : true,
- "noarg" : true,
- "noempty" : false,
- "nonew" : true,
- "quotmark" : true,
- "undef" : true,
- "strict" : true,
- "trailing" : true,
- "maxdepth" : 5,
- "maxstatements" : 50,
- "maxcomplexity" : 13,
- "maxlen" : 120,
- "browser" : true,
- "node" : true,
- "strict": false,
+ "browser": true,
+ "node": true,
+ "strict": true,
+ "unused": "vars",
+ "maxlen": 120,
"globals": {
- "console": true,
- "require": false,
- "module": false,
"describe": false,
"it": false,
- "jasmine": true,
"expect": true,
- "fail": true,
"beforeEach": true,
- "afterEach": true
+ "afterEach": true,
+ "console": true,
+ "spyOn": true,
+ "jasmine": true
}
}
diff --git a/Gruntfile.js b/Gruntfile.js
index a4270da3..05e537e2 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,9 +1,11 @@
+'use strict';
+
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
require('time-grunt')(grunt);
- /* global Buffer,process*/
+ /* global process */
// configures browsers to run test against
// any of [ 'PhantomJS', 'Chrome', 'Firefox', 'IE']
diff --git a/lib/NavigatedViewer.js b/lib/NavigatedViewer.js
index 5a98791b..2b50086c 100644
--- a/lib/NavigatedViewer.js
+++ b/lib/NavigatedViewer.js
@@ -1,5 +1,8 @@
+'use strict';
+
var Viewer = require('./Viewer');
+
/**
* A viewer that includes mouse navigation facilities
*
diff --git a/lib/Viewer.js b/lib/Viewer.js
index 522dade6..c1188072 100644
--- a/lib/Viewer.js
+++ b/lib/Viewer.js
@@ -1,9 +1,11 @@
'use strict';
+var assign = require('lodash/object/assign'),
+ omit = require('lodash/object/omit');
+
var Diagram = require('diagram-js'),
BpmnModdle = require('bpmn-moddle'),
- $ = require('jquery'),
- _ = require('lodash');
+ $ = require('jquery');
var Importer = require('./import/Importer');
@@ -56,7 +58,7 @@ var DEFAULT_OPTIONS = {
*/
function Viewer(options) {
- this.options = options = _.extend({}, DEFAULT_OPTIONS, options || {});
+ this.options = options = assign({}, DEFAULT_OPTIONS, options || {});
var parent = options.container || $('body');
@@ -93,7 +95,7 @@ function Viewer(options) {
zIndex: 100
});
- var logo = $('').attr('src', 'data:image/png;base64,' + logoData).appendTo(a);
+ $('').attr('src', 'data:image/png;base64,' + logoData).appendTo(a);
a.appendTo(container);
@@ -220,9 +222,9 @@ Viewer.prototype._createDiagram = function(options) {
moddle: [ 'value', this.moddle ]
});
- options = _.omit(options, 'additionalModules');
+ options = omit(options, 'additionalModules');
- options = _.extend(options, {
+ options = assign(options, {
canvas: { container: this.container },
modules: modules
});
diff --git a/lib/draw/BpmnRenderer.js b/lib/draw/BpmnRenderer.js
index 8900d6fc..96382650 100644
--- a/lib/draw/BpmnRenderer.js
+++ b/lib/draw/BpmnRenderer.js
@@ -1,11 +1,16 @@
'use strict';
-var _ = require('lodash');
+var isArray = require('lodash/lang/isArray'),
+ isObject = require('lodash/lang/isObject'),
+ assign = require('lodash/object/assign'),
+ forEach = require('lodash/collection/forEach'),
+ every = require('lodash/collection/every'),
+ includes = require('lodash/collection/includes'),
+ some = require('lodash/collection/some');
-var DefaultRenderer = require('diagram-js/lib/draw/Renderer');
-var TextUtil = require('diagram-js/lib/util/Text');
-
-var DiUtil = require('../util/Di');
+var DefaultRenderer = require('diagram-js/lib/draw/Renderer'),
+ TextUtil = require('diagram-js/lib/util/Text'),
+ DiUtil = require('../util/Di');
var createLine = DefaultRenderer.createLine;
@@ -40,7 +45,7 @@ function BpmnRenderer(events, styles, pathMap) {
function initMarkers(svg) {
function createMarker(id, options) {
- var attrs = _.extend({
+ var attrs = assign({
fill: 'black',
strokeWidth: 1,
strokeLinecap: 'round',
@@ -124,17 +129,17 @@ function BpmnRenderer(events, styles, pathMap) {
}
function computeStyle(custom, traits, defaultStyles) {
- if (!_.isArray(traits)) {
+ if (!isArray(traits)) {
defaultStyles = traits;
traits = [];
}
- return styles.style(traits || [], _.extend(defaultStyles, custom || {}));
+ return styles.style(traits || [], assign(defaultStyles, custom || {}));
}
function drawCircle(p, width, height, offset, attrs) {
- if (_.isObject(offset)) {
+ if (isObject(offset)) {
attrs = offset;
offset = 0;
}
@@ -155,7 +160,7 @@ function BpmnRenderer(events, styles, pathMap) {
function drawRect(p, width, height, r, offset, attrs) {
- if (_.isObject(offset)) {
+ if (isObject(offset)) {
attrs = offset;
offset = 0;
}
@@ -378,7 +383,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var path = drawPath(p, pathData, {
+ drawPath(p, pathData, {
strokeWidth: 2,
strokeLinecap: 'square'
});
@@ -399,7 +404,7 @@ function BpmnRenderer(events, styles, pathMap) {
var width = element.width / 2;
var height = element.height / 2;
- var linePath = drawPath(p, linePathData, {
+ drawPath(p, linePathData, {
strokeWidth: 1,
strokeLinecap: 'square',
transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
@@ -589,7 +594,7 @@ function BpmnRenderer(events, styles, pathMap) {
},
'bpmn:IntermediateEvent': function(p, element) {
var outer = renderer('bpmn:Event')(p, element, { strokeWidth: 1 });
- var inner = drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
+ /* inner */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
renderEventContent(element, p);
@@ -618,7 +623,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var servicePathBG = drawPath(p, pathDataBG, {
+ /* service bg */ drawPath(p, pathDataBG, {
strokeWidth: 1,
fill: 'none'
});
@@ -630,7 +635,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var serviceFillPath = drawPath(p, fillPathData, {
+ /* service fill */ drawPath(p, fillPathData, {
strokeWidth: 0,
stroke: 'none',
fill: 'white'
@@ -643,7 +648,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var servicePath = drawPath(p, pathData, {
+ /* service */ drawPath(p, pathData, {
strokeWidth: 1,
fill: 'white'
});
@@ -663,7 +668,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var userPath = drawPath(p, pathData, {
+ /* user path */ drawPath(p, pathData, {
strokeWidth: 0.5,
fill: 'none'
});
@@ -675,7 +680,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var userPath2 = drawPath(p, pathData2, {
+ /* user2 path */ drawPath(p, pathData2, {
strokeWidth: 0.5,
fill: 'none'
});
@@ -687,7 +692,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var userPath3 = drawPath(p, pathData3, {
+ /* user3 path */ drawPath(p, pathData3, {
strokeWidth: 0.5,
fill: 'black'
});
@@ -704,7 +709,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var userPath = drawPath(p, pathData, {
+ /* manual path */ drawPath(p, pathData, {
strokeWidth: 0.25,
fill: 'white',
stroke: 'black'
@@ -726,7 +731,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var sendPath = drawPath(p, pathData, {
+ /* send path */ drawPath(p, pathData, {
strokeWidth: 1,
fill: 'black',
stroke: 'white'
@@ -763,7 +768,7 @@ function BpmnRenderer(events, styles, pathMap) {
});
}
- var sendPath = drawPath(p, pathData, {
+ /* receive path */ drawPath(p, pathData, {
strokeWidth: 1
});
@@ -779,7 +784,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var scriptPath = drawPath(p, pathData, {
+ /* script path */ drawPath(p, pathData, {
strokeWidth: 1
});
@@ -818,8 +823,7 @@ function BpmnRenderer(events, styles, pathMap) {
'bpmn:SubProcess': function(p, element, attrs) {
var rect = renderer('bpmn:Activity')(p, element, attrs);
- var semantic = getSemantic(element),
- di = getDi(element);
+ var semantic = getSemantic(element);
var expanded = DiUtil.isExpanded(semantic);
@@ -847,7 +851,8 @@ function BpmnRenderer(events, styles, pathMap) {
var outer = renderer('bpmn:SubProcess')(p, element);
var innerAttrs = styles.style([ 'no-fill', 'no-events' ]);
- var inner = drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
+
+ /* inner path */ drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
return outer;
},
@@ -900,7 +905,7 @@ function BpmnRenderer(events, styles, pathMap) {
'bpmn:InclusiveGateway': function(p, element) {
var diamond = drawDiamond(p, element.width, element.height);
- var circle = drawCircle(p, element.width, element.height, element.height * 0.24, {
+ /* circle path */ drawCircle(p, element.width, element.height, element.height * 0.24, {
strokeWidth: 2.5,
fill: 'none'
});
@@ -944,7 +949,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var complexPath = drawPath(p, pathData, {
+ /* complex path */ drawPath(p, pathData, {
strokeWidth: 1,
fill: 'black'
});
@@ -965,7 +970,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var parallelPath = drawPath(p, pathData, {
+ /* parallel path */ drawPath(p, pathData, {
strokeWidth: 1,
fill: 'black'
});
@@ -978,7 +983,7 @@ function BpmnRenderer(events, styles, pathMap) {
var diamond = drawDiamond(p, element.width, element.height);
- var outerCircle = drawCircle(p, element.width, element.height, element.height * 0.20, {
+ /* outer circle path */ drawCircle(p, element.width, element.height, element.height * 0.20, {
strokeWidth: 1,
fill: 'none'
});
@@ -999,7 +1004,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var eventPath = drawPath(p, pathData, {
+ /* event path */ drawPath(p, pathData, {
strokeWidth: 2,
fill: 'none'
});
@@ -1069,7 +1074,7 @@ function BpmnRenderer(events, styles, pathMap) {
},
'bpmn:Association': function(p, element, attrs) {
- attrs = _.extend({
+ attrs = assign({
strokeDasharray: '1,6',
strokeLinecap: 'round'
}, attrs || {});
@@ -1155,8 +1160,7 @@ function BpmnRenderer(events, styles, pathMap) {
// page
var elementObject = renderer('bpmn:DataObject')(p, element);
- // arrow
- var elementInput = drawPath(p, arrowPathData, { strokeWidth: 1 });
+ /* input arrow path */ drawPath(p, arrowPathData, { strokeWidth: 1 });
return elementObject;
},
@@ -1166,8 +1170,7 @@ function BpmnRenderer(events, styles, pathMap) {
// page
var elementObject = renderer('bpmn:DataObject')(p, element);
- // arrow
- var elementInput = drawPath(p, arrowPathData, {
+ /* output arrow path */ drawPath(p, arrowPathData, {
strokeWidth: 1,
fill: 'black'
});
@@ -1208,7 +1211,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
var outer = renderer('bpmn:Event')(p, element, attrs);
- var inner = drawCircle(p, element.width, element.height, INNER_OUTER_DIST, attrs);
+ /* inner path */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, attrs);
renderEventContent(element, p);
@@ -1364,7 +1367,7 @@ function BpmnRenderer(events, styles, pathMap) {
function attachTaskMarkers(p, element, taskMarkers) {
var obj = getSemantic(element);
- var subprocess = _.contains(taskMarkers, 'SubProcessMarker');
+ var subprocess = includes(taskMarkers, 'SubProcessMarker');
var position;
if (subprocess) {
@@ -1385,7 +1388,7 @@ function BpmnRenderer(events, styles, pathMap) {
};
}
- _.forEach(taskMarkers, function(marker) {
+ forEach(taskMarkers, function(marker) {
renderer(marker)(p, element, position);
});
@@ -1448,7 +1451,7 @@ function BpmnRenderer(events, styles, pathMap) {
}
});
- var collectionPath = drawPath(p, pathData, {
+ /* collection path */ drawPath(p, pathData, {
strokeWidth: 2
});
}
@@ -1474,7 +1477,7 @@ function BpmnRenderer(events, styles, pathMap) {
function isTypedEvent(event, eventDefinitionType, filter) {
function matches(definition, filter) {
- return _.all(filter, function(val, key) {
+ return every(filter, function(val, key) {
// we want a == conversion here, to be able to catch
// undefined == false and friends
@@ -1483,7 +1486,7 @@ function BpmnRenderer(events, styles, pathMap) {
});
}
- return _.any(event.eventDefinitions, function(definition) {
+ return some(event.eventDefinitions, function(definition) {
return definition.$type === eventDefinitionType && matches(event, filter);
});
}
diff --git a/lib/features/context-pad/ContextPadProvider.js b/lib/features/context-pad/ContextPadProvider.js
index ca9681bc..6862f238 100644
--- a/lib/features/context-pad/ContextPadProvider.js
+++ b/lib/features/context-pad/ContextPadProvider.js
@@ -1,6 +1,6 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign');
/**
@@ -32,9 +32,7 @@ ContextPadProvider.$inject = [
ContextPadProvider.prototype.getContextPadEntries = function(element) {
- var directEditing = this._directEditing,
- modeling = this._modeling,
- selection = this._selection,
+ var modeling = this._modeling,
elementFactory = this._elementFactory,
connect = this._connect,
create = this._create;
@@ -72,7 +70,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
if (!bpmnElement.$instanceOf('bpmn:EndEvent')) {
- _.extend(actions, {
+ assign(actions, {
'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event'),
'append.gateway': appendAction('bpmn:ExclusiveGateway', 'icon-gateway'),
'append.append-task': appendAction('bpmn:Task', 'icon-task'),
@@ -88,7 +86,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
});
}
- _.extend(actions, {
+ assign(actions, {
'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation')
});
}
@@ -101,7 +99,7 @@ ContextPadProvider.prototype.getContextPadEntries = function(element) {
}
}
- _.extend(actions, {
+ assign(actions, {
'delete': {
group: 'edit',
className: 'icon-trash',
diff --git a/lib/features/label-editing/LabelEditingProvider.js b/lib/features/label-editing/LabelEditingProvider.js
index 364f2713..956bc06c 100644
--- a/lib/features/label-editing/LabelEditingProvider.js
+++ b/lib/features/label-editing/LabelEditingProvider.js
@@ -1,15 +1,11 @@
'use strict';
-var _ = require('lodash');
-
var UpdateLabelHandler = require('./cmd/UpdateLabelHandler');
var LabelUtil = require('./LabelUtil'),
DiUtil = require('../../util/Di');
-var PADDING = 4;
-
var MIN_BOUNDS = {
width: 150,
height: 50
diff --git a/lib/features/label-editing/LabelUtil.js b/lib/features/label-editing/LabelUtil.js
index 8ba39932..132119af 100644
--- a/lib/features/label-editing/LabelUtil.js
+++ b/lib/features/label-editing/LabelUtil.js
@@ -1,3 +1,4 @@
+'use strict';
function getLabelAttr(semantic) {
if (semantic.$instanceOf('bpmn:FlowElement') ||
diff --git a/lib/features/modeling/BpmnFactory.js b/lib/features/modeling/BpmnFactory.js
index fd2aa3aa..d74103bf 100644
--- a/lib/features/modeling/BpmnFactory.js
+++ b/lib/features/modeling/BpmnFactory.js
@@ -1,6 +1,8 @@
'use strict';
-var _ = require('lodash');
+var map = require('lodash/collection/map'),
+ assign = require('lodash/object/assign'),
+ pick = require('lodash/object/pick');
function BpmnFactory(moddle) {
@@ -50,7 +52,7 @@ BpmnFactory.prototype.createDiLabel = function() {
BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) {
- return this.create('bpmndi:BPMNShape', _.extend({
+ return this.create('bpmndi:BPMNShape', assign({
bpmnElement: semantic,
bounds: this.createDiBounds(bounds)
}, attrs));
@@ -63,18 +65,18 @@ BpmnFactory.prototype.createDiBounds = function(bounds) {
BpmnFactory.prototype.createDiWaypoints = function(waypoints) {
- return _.map(waypoints, function(pos) {
+ return map(waypoints, function(pos) {
return this.createDiWaypoint(pos);
}, this);
};
BpmnFactory.prototype.createDiWaypoint = function(point) {
- return this.create('dc:Point', _.pick(point, [ 'x', 'y' ]));
+ return this.create('dc:Point', pick(point, [ 'x', 'y' ]));
};
BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
- return this.create('bpmndi:BPMNEdge', _.extend({
+ return this.create('bpmndi:BPMNEdge', assign({
bpmnElement: semantic
}, attrs));
};
diff --git a/lib/features/modeling/BpmnUpdater.js b/lib/features/modeling/BpmnUpdater.js
index e918c216..b969d823 100644
--- a/lib/features/modeling/BpmnUpdater.js
+++ b/lib/features/modeling/BpmnUpdater.js
@@ -1,10 +1,11 @@
'use strict';
-var _ = require('lodash');
+var isArray = require('lodash/lang/isArray'),
+ assign = require('lodash/object/assign'),
+ forEach = require('lodash/collection/forEach');
-var Collections = require('diagram-js/lib/util/Collections');
-
-var Model = require('diagram-js/lib/model');
+var Collections = require('diagram-js/lib/util/Collections'),
+ Model = require('diagram-js/lib/model');
/**
@@ -155,7 +156,7 @@ BpmnUpdater.prototype.updateBounds = function(shape) {
var bounds = (shape instanceof Model.Label) ? this._getLabel(di).bounds : di.bounds;
- _.extend(bounds, {
+ assign(bounds, {
x: shape.x,
y: shape.y,
width: shape.width,
@@ -312,9 +313,9 @@ BpmnUpdater.prototype.reverted = function(commands, callback) {
};
BpmnUpdater.prototype.on = function(commands, suffix, callback) {
- commands = _.isArray(commands) ? commands : [ commands ];
+ commands = isArray(commands) ? commands : [ commands ];
- _.forEach(commands, function(c) {
+ forEach(commands, function(c) {
this._eventBus.on('commandStack.' + c + '.' + suffix, callback);
}, this);
};
diff --git a/lib/features/modeling/ElementFactory.js b/lib/features/modeling/ElementFactory.js
index 48ecfceb..fa3049b9 100644
--- a/lib/features/modeling/ElementFactory.js
+++ b/lib/features/modeling/ElementFactory.js
@@ -1,10 +1,9 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign');
-var BaseElementFactory = require('diagram-js/lib/core/ElementFactory');
-
-var LabelUtil = require('../../util/Label');
+var BaseElementFactory = require('diagram-js/lib/core/ElementFactory'),
+ LabelUtil = require('../../util/Label');
/**
@@ -30,7 +29,7 @@ ElementFactory.prototype.create = function(elementType, attrs) {
// we assume their businessObjects have already been created
// and wired via attrs
if (elementType === 'label') {
- return this.baseCreate(elementType, _.extend({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));
+ return this.baseCreate(elementType, assign({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));
}
attrs = attrs || {};
@@ -64,7 +63,7 @@ ElementFactory.prototype.create = function(elementType, attrs) {
size = this._getDefaultSize(businessObject);
- attrs = _.extend({
+ attrs = assign({
businessObject: businessObject,
id: businessObject.id
}, size, attrs);
diff --git a/lib/features/modeling/LabelSupport.js b/lib/features/modeling/LabelSupport.js
index 1a5be7e5..d4a913c0 100644
--- a/lib/features/modeling/LabelSupport.js
+++ b/lib/features/modeling/LabelSupport.js
@@ -1,6 +1,7 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign'),
+ forEach = require('lodash/collection/forEach');
var LabelUtil = require('../../util/Label');
@@ -47,7 +48,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
var labels = [];
- _.forEach(shapes, function(element) {
+ forEach(shapes, function(element) {
var label = element.label;
if (label && !label.hidden && context.shapes.indexOf(label) === -1) {
@@ -55,7 +56,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
}
});
- _.forEach(labels, function(label) {
+ forEach(labels, function(label) {
shapes.push(label);
});
});
@@ -74,7 +75,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
// ensure we move all labels with their respective elements
// if they have not been moved already
- _.forEach(enclosedElements, function(e) {
+ forEach(enclosedElements, function(e) {
if (e.label && !enclosedElements[e.label.id]) {
modeling.moveShape(e.label, context.delta, e.parent);
}
@@ -104,7 +105,7 @@ function LabelSupport(eventBus, modeling, bpmnFactory) {
});
}
- _.extend(di.label.bounds, {
+ assign(di.label.bounds, {
x: element.x,
y: element.y,
width: element.width,
diff --git a/lib/features/modeling/Modeling.js b/lib/features/modeling/Modeling.js
index 2d7f5d30..db50ecb0 100644
--- a/lib/features/modeling/Modeling.js
+++ b/lib/features/modeling/Modeling.js
@@ -1,11 +1,10 @@
'use strict';
-var _ = require('lodash');
-
var BaseModeling = require('diagram-js/lib/features/modeling/Modeling');
var UpdatePropertiesHandler = require('./cmd/UpdatePropertiesHandler');
+
/**
* BPMN 2.0 modeling features activator
*
diff --git a/lib/features/modeling/behavior/Append.js b/lib/features/modeling/behavior/Append.js
index aa803ca7..08c67379 100644
--- a/lib/features/modeling/behavior/Append.js
+++ b/lib/features/modeling/behavior/Append.js
@@ -1,3 +1,4 @@
+'use strict';
function AppendBehavior(eventBus, elementFactory) {
diff --git a/lib/features/modeling/behavior/Drop.js b/lib/features/modeling/behavior/Drop.js
index 8e800deb..e8c4dc67 100644
--- a/lib/features/modeling/behavior/Drop.js
+++ b/lib/features/modeling/behavior/Drop.js
@@ -1,4 +1,6 @@
-var _ = require('lodash');
+'use strict';
+
+var forEach = require('lodash/collection/forEach');
function DropBehavior(eventBus, modeling) {
@@ -11,10 +13,9 @@ function DropBehavior(eventBus, modeling) {
var context = e.context,
closure = context.closure,
- allConnections = closure.allConnections,
- allShapes = closure.allShapes;
+ allConnections = closure.allConnections;
- _.forEach(allConnections, function(c) {
+ forEach(allConnections, function(c) {
// remove sequence flows having source / target on different parents
if (c.businessObject.$instanceOf('bpmn:SequenceFlow') && c.source.parent !== c.target.parent) {
diff --git a/lib/features/modeling/cmd/UpdatePropertiesHandler.js b/lib/features/modeling/cmd/UpdatePropertiesHandler.js
index 296a780e..cf1b64ea 100644
--- a/lib/features/modeling/cmd/UpdatePropertiesHandler.js
+++ b/lib/features/modeling/cmd/UpdatePropertiesHandler.js
@@ -1,10 +1,13 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign'),
+ pick = require('lodash/object/pick'),
+ keys = require('lodash/object/keys');
var DEFAULT_FLOW = 'default',
NAME = 'name';
+
/**
* A handler that implements a BPMN 2.0 property update.
*
@@ -48,7 +51,7 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
var businessObject = element.businessObject,
properties = context.properties,
- oldProperties = context.oldProperties || _.pick(businessObject, _.keys(properties));
+ oldProperties = context.oldProperties || pick(businessObject, keys(properties));
// correctly indicate visual changes on default flow updates
if (DEFAULT_FLOW in properties) {
@@ -67,7 +70,7 @@ UpdatePropertiesHandler.prototype.execute = function(context) {
}
// update properties
- _.assign(businessObject, properties);
+ assign(businessObject, properties);
// store old values
@@ -90,7 +93,7 @@ UpdatePropertiesHandler.prototype.revert = function(context) {
var element = context.element,
businessObject = element.businessObject;
- _.assign(businessObject, context.oldProperties);
+ assign(businessObject, context.oldProperties);
return context.changed;
};
\ No newline at end of file
diff --git a/lib/features/modeling/rules/ModelingRules.js b/lib/features/modeling/rules/ModelingRules.js
index 65ef1e2e..f413cd86 100644
--- a/lib/features/modeling/rules/ModelingRules.js
+++ b/lib/features/modeling/rules/ModelingRules.js
@@ -1,9 +1,11 @@
'use strict';
-var _ = require('lodash');
+var groupBy = require('lodash/collection/groupBy'),
+ size = require('lodash/collection/size');
var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider');
+
function ModelingRules(eventBus) {
RuleProvider.call(this, eventBus);
}
@@ -147,7 +149,7 @@ ModelingRules.prototype.init = function() {
shapes = context.shapes;
// only move if they have the same parent
- var sameParent = _.size(_.groupBy(shapes, function(s) { return s.parent && s.parent.id; })) === 1;
+ var sameParent = size(groupBy(shapes, function(s) { return s.parent && s.parent.id; })) === 1;
if (!sameParent) {
return false;
diff --git a/lib/features/palette/PaletteProvider.js b/lib/features/palette/PaletteProvider.js
index da15f9d6..c925816f 100644
--- a/lib/features/palette/PaletteProvider.js
+++ b/lib/features/palette/PaletteProvider.js
@@ -1,5 +1,6 @@
-var _ = require('lodash');
+'use strict';
+var assign = require('lodash/object/assign');
/**
* A palette provider for BPMN 2.0 elements.
@@ -22,7 +23,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
function createAction(type, group, className, title, options) {
function createListener(event) {
- var shape = elementFactory.createShape(_.extend({ type: type }, options));
+ var shape = elementFactory.createShape(assign({ type: type }, options));
if (options) {
shape.businessObject.di.isExpanded = options.isExpanded;
@@ -47,7 +48,7 @@ PaletteProvider.prototype.getPaletteEntries = function(element) {
elementFactory = this._elementFactory;
- _.extend(actions, {
+ assign(actions, {
'create.start-event': createAction(
'bpmn:StartEvent', 'event', 'icon-start-event'
),
diff --git a/lib/import/BpmnImporter.js b/lib/import/BpmnImporter.js
index 88f491ae..3fba3152 100644
--- a/lib/import/BpmnImporter.js
+++ b/lib/import/BpmnImporter.js
@@ -1,6 +1,7 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign'),
+ map = require('lodash/collection/map');
var LabelUtil = require('../util/Label');
@@ -11,7 +12,7 @@ var hasExternalLabel = LabelUtil.hasExternalLabel,
function elementData(semantic, attrs) {
- return _.extend({
+ return assign({
id: semantic.id,
type: semantic.$type,
businessObject: semantic
@@ -19,7 +20,7 @@ function elementData(semantic, attrs) {
}
function collectWaypoints(waypoints) {
- return _.collect(waypoints, function(p) {
+ return map(waypoints, function(p) {
return { x: p.x, y: p.y };
});
}
@@ -144,7 +145,6 @@ BpmnImporter.prototype._getEnd = function(semantic, side) {
var element,
refSemantic,
- refIsParent,
type = semantic.$type;
refSemantic = semantic[side + 'Ref'];
diff --git a/lib/import/BpmnTreeWalker.js b/lib/import/BpmnTreeWalker.js
index 2ab53130..bfbd46e3 100644
--- a/lib/import/BpmnTreeWalker.js
+++ b/lib/import/BpmnTreeWalker.js
@@ -1,6 +1,8 @@
'use strict';
-var _ = require('lodash');
+var filter = require('lodash/collection/filter'),
+ find = require('lodash/collection/find'),
+ forEach = require('lodash/collection/forEach');
var Refs = require('object-refs');
@@ -14,7 +16,7 @@ var diRefs = new Refs({ name: 'bpmnElement', enumerable: true }, { name: 'di' })
* correctly specify one.
*/
function findDisplayCandidate(definitions) {
- return _.find(definitions.rootElements, function(e) {
+ return find(definitions.rootElements, function(e) {
return e.$instanceOf('bpmn:Process') || e.$instanceOf('bpmn:Collaboration');
});
}
@@ -97,7 +99,7 @@ function BpmnTreeWalker(handler) {
function handlePlane(plane) {
registerDi(plane);
- _.forEach(plane.planeElement, handlePlaneElement);
+ forEach(plane.planeElement, handlePlaneElement);
}
function handlePlaneElement(planeElement) {
@@ -174,7 +176,7 @@ function BpmnTreeWalker(handler) {
}
function handleDeferred(deferred) {
- _.forEach(deferred, function(d) { d(); });
+ forEach(deferred, function(d) { d(); });
}
function handleProcess(process, context) {
@@ -192,7 +194,7 @@ function BpmnTreeWalker(handler) {
// walk through all processes that have not yet been drawn and draw them
// if they contain lanes with DI information.
// we do this to pass the free-floating lane test cases in the MIWG test suite
- var processes = _.filter(rootElements, function(e) {
+ var processes = filter(rootElements, function(e) {
return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1;
});
@@ -204,7 +206,7 @@ function BpmnTreeWalker(handler) {
}
function handleMessageFlows(messageFlows, context) {
- _.forEach(messageFlows, contextual(handleMessageFlow, context));
+ forEach(messageFlows, contextual(handleMessageFlow, context));
}
function handleDataAssociation(association, context) {
@@ -230,7 +232,7 @@ function BpmnTreeWalker(handler) {
function handleArtifacts(artifacts, context) {
- _.forEach(artifacts, function(e) {
+ forEach(artifacts, function(e) {
if (is(e, 'bpmn:Association')) {
deferred.push(function() {
handleArtifact(e, context);
@@ -247,8 +249,8 @@ function BpmnTreeWalker(handler) {
return;
}
- _.forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
- _.forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
+ forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
+ forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
}
function handleSubProcess(subProcess, context) {
@@ -282,7 +284,7 @@ function BpmnTreeWalker(handler) {
if (lane.childLaneSet) {
handleLaneSet(lane.childLaneSet, newContext || context);
} else {
- var filterList = _.filter(lane.flowNodeRef, function(e) {
+ var filterList = filter(lane.flowNodeRef, function(e) {
return e.$type !== 'bpmn:BoundaryEvent';
});
handleFlowElements(filterList, newContext || context);
@@ -290,11 +292,11 @@ function BpmnTreeWalker(handler) {
}
function handleLaneSet(laneSet, context) {
- _.forEach(laneSet.lanes, contextual(handleLane, context));
+ forEach(laneSet.lanes, contextual(handleLane, context));
}
function handleLaneSets(laneSets, context) {
- _.forEach(laneSets, contextual(handleLaneSet, context));
+ forEach(laneSets, contextual(handleLaneSet, context));
}
function handleFlowElementsContainer(container, context) {
@@ -308,7 +310,7 @@ function BpmnTreeWalker(handler) {
}
function handleNonFlowNodes(flowElements, context) {
- _.forEach(flowElements, function(e) {
+ forEach(flowElements, function(e) {
if (is(e, 'bpmn:SequenceFlow')) {
deferred.push(function() {
handleSequenceFlow(e, context);
@@ -328,7 +330,7 @@ function BpmnTreeWalker(handler) {
}
function handleFlowElements(flowElements, context) {
- _.forEach(flowElements, function(e) {
+ forEach(flowElements, function(e) {
if (is(e, 'bpmn:SequenceFlow')) {
deferred.push(function() {
handleSequenceFlow(e, context);
@@ -346,8 +348,8 @@ function BpmnTreeWalker(handler) {
// defer handling of associations
deferred.push(function() {
- _.forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
- _.forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
+ forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
+ forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
});
}
} else if (is(e, 'bpmn:DataObject')) {
@@ -376,7 +378,7 @@ function BpmnTreeWalker(handler) {
function handleCollaboration(collaboration) {
- _.forEach(collaboration.participants, contextual(handleParticipant));
+ forEach(collaboration.participants, contextual(handleParticipant));
handleArtifacts(collaboration.artifacts);
diff --git a/lib/import/Util.js b/lib/import/Util.js
index a011a36a..ed57adc2 100644
--- a/lib/import/Util.js
+++ b/lib/import/Util.js
@@ -1,3 +1,5 @@
+'use strict';
+
module.exports.elementToString = function(e) {
if (!e) {
return '';
diff --git a/lib/util/Label.js b/lib/util/Label.js
index 76c6fced..254d7f3d 100644
--- a/lib/util/Label.js
+++ b/lib/util/Label.js
@@ -1,6 +1,6 @@
'use strict';
-var _ = require('lodash');
+var assign = require('lodash/object/assign');
var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = {
@@ -92,7 +92,7 @@ module.exports.getExternalLabelBounds = function(semantic, element) {
size = DEFAULT_LABEL_SIZE;
}
- return _.extend({
+ return assign({
x: mid.x - size.width / 2,
y: mid.y - size.height / 2
}, size);
diff --git a/package.json b/package.json
index 9d283daf..eee19c22 100644
--- a/package.json
+++ b/package.json
@@ -60,10 +60,10 @@
"bpmn-moddle": "^0.5.0",
"diagram-js-direct-editing": "^0.7.0",
"didi": "^0.0.4",
+ "ids": "^0.1.0",
"jquery": "^2.1.0",
- "lodash": "^2.4.0",
- "object-refs": "^0.1.0",
- "ids": "^0.1.0"
+ "lodash": "^3.0.1",
+ "object-refs": "^0.1.0"
},
"peerDependencies": {
"diagram-js": "^0.8.0"
diff --git a/test/TestHelper.js b/test/TestHelper.js
index 3e7f90fc..718a644f 100644
--- a/test/TestHelper.js
+++ b/test/TestHelper.js
@@ -1,3 +1,5 @@
+'use strict';
+
var TestHelper = module.exports = require('./helper');
var fs = require('fs');
diff --git a/test/helper/index.js b/test/helper/index.js
index 39a68bbd..fffaf330 100644
--- a/test/helper/index.js
+++ b/test/helper/index.js
@@ -1,5 +1,3 @@
-'use strict';
-
/**
* A helper file that may be used in test cases for bpmn-js and extensions.
*
@@ -28,7 +26,10 @@
* ```
*/
-var _ = require('lodash');
+var unique = require('lodash/array/unique'),
+ isFunction = require('lodash/lang/isFunction'),
+ assign = require('lodash/object/assign'),
+ forEach = require('lodash/collection/forEach');
var Modeler = require('../../lib/Modeler'),
Viewer = require('../../lib/Viewer');
@@ -43,7 +44,7 @@ try {
var OPTIONS, BPMN_JS;
function options(opts) {
- if (_.isFunction(opts)) {
+ if (isFunction(opts)) {
opts = opts();
}
@@ -67,32 +68,32 @@ function bootstrapBpmnJS(BpmnJS, options, locals) {
var _options = options,
_locals = locals;
- if (_locals === undefined && _.isFunction(_options)) {
+ if (_locals === undefined && isFunction(_options)) {
_locals = _options;
_options = null;
}
- if (_.isFunction(_options)) {
+ if (isFunction(_options)) {
_options = _options();
}
- if (_.isFunction(_locals)) {
+ if (isFunction(_locals)) {
_locals = _locals();
}
- _options = _.extend({ container: testContainer, width: '100%', height: '100%' }, OPTIONS || {}, _options || {});
+ _options = assign({ container: testContainer, width: '100%', height: '100%' }, OPTIONS || {}, _options || {});
if (_locals) {
var mockModule = {};
- _.forEach(_locals, function(v, k) {
+ forEach(_locals, function(v, k) {
mockModule[k] = ['value', v];
});
_options.modules = [].concat(_options.modules || [], [ mockModule ]);
}
- _options.modules = _.unique(_options.modules);
+ _options.modules = unique(_options.modules);
if (!_options.modules.length) {
_options.modules = undefined;
diff --git a/test/spec/features/modeling/AppendShapeSpec.js b/test/spec/features/modeling/AppendShapeSpec.js
index 9cbecda8..e50de7a3 100644
--- a/test/spec/features/modeling/AppendShapeSpec.js
+++ b/test/spec/features/modeling/AppendShapeSpec.js
@@ -4,7 +4,7 @@ var TestHelper = require('../../../TestHelper');
/* global bootstrapModeler, inject */
-var _ = require('lodash');
+var find = require('lodash/collection/find');
var fs = require('fs');
@@ -149,7 +149,7 @@ describe('features/modeling - append shape', function() {
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
target = targetShape.businessObject;
- var connection = _.find(subProcess.get('flowElements'), function(e) {
+ var connection = find(subProcess.get('flowElements'), function(e) {
return e.sourceRef === startEvent && e.targetRef === target;
});
@@ -196,7 +196,7 @@ describe('features/modeling - append shape', function() {
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:EndEvent' }),
target = targetShape.businessObject;
- var connection = _.find(subProcess.get('flowElements'), function(e) {
+ var connection = find(subProcess.get('flowElements'), function(e) {
return e.sourceRef === startEvent && e.targetRef === target;
});
@@ -226,7 +226,7 @@ describe('features/modeling - append shape', function() {
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
target = targetShape.businessObject;
- var connection = _.find(subProcess.get('flowElements'), function(e) {
+ var connection = find(subProcess.get('flowElements'), function(e) {
return e.sourceRef === startEvent && e.targetRef === target;
});
@@ -259,7 +259,7 @@ describe('features/modeling - append shape', function() {
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
target = targetShape.businessObject;
- var connection = _.find(subProcess.get('flowElements'), function(e) {
+ var connection = find(subProcess.get('flowElements'), function(e) {
return e.sourceRef === startEvent && e.targetRef === target;
});
@@ -322,7 +322,7 @@ describe('features/modeling - append shape', function() {
var targetShape = modeling.appendShape(startEventShape, { type: 'bpmn:Task' }),
target = targetShape.businessObject;
- var connection = _.find(subProcess.get('flowElements'), function(e) {
+ var connection = find(subProcess.get('flowElements'), function(e) {
return e.sourceRef === startEvent && e.targetRef === target;
});
diff --git a/test/spec/features/modeling/append/TextAnnotationSpec.js b/test/spec/features/modeling/append/TextAnnotationSpec.js
index b7df0ab9..0f57bb89 100644
--- a/test/spec/features/modeling/append/TextAnnotationSpec.js
+++ b/test/spec/features/modeling/append/TextAnnotationSpec.js
@@ -5,7 +5,7 @@ var Matchers = require('../../../../Matchers'),
/* global bootstrapModeler, inject */
-var _ = require('lodash');
+var find = require('lodash/collection/find');
var fs = require('fs');
@@ -42,7 +42,7 @@ describe('features/modeling - append text-annotation', function() {
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
annotation = annotationShape.businessObject;
- var connectingConnection = _.find(annotationShape.incoming, function(c) {
+ var connectingConnection = find(annotationShape.incoming, function(c) {
return c.target === annotationShape;
});
@@ -74,7 +74,7 @@ describe('features/modeling - append text-annotation', function() {
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
annotation = annotationShape.businessObject;
- var connectingConnection = _.find(annotationShape.incoming, function(c) {
+ var connectingConnection = find(annotationShape.incoming, function(c) {
return c.target === annotationShape;
});
@@ -107,7 +107,7 @@ describe('features/modeling - append text-annotation', function() {
var annotationShape = modeling.appendShape(eventShape, { type: 'bpmn:TextAnnotation' }),
annotation = annotationShape.businessObject;
- var connectingConnection = _.find(annotationShape.incoming, function(c) {
+ var connectingConnection = find(annotationShape.incoming, function(c) {
return c.target === annotationShape;
});
diff --git a/test/spec/import/elements/LabelSpec.js b/test/spec/import/elements/LabelSpec.js
index cf9a6edd..def96598 100644
--- a/test/spec/import/elements/LabelSpec.js
+++ b/test/spec/import/elements/LabelSpec.js
@@ -4,14 +4,13 @@ var TestHelper = require('../../../TestHelper');
/* global bootstrapViewer, inject */
-
-var _ = require('lodash');
+var pick = require('lodash/object/pick');
var fs = require('fs');
function bounds(element) {
- return _.pick(element, [ 'x', 'y', 'width', 'height' ]);
+ return pick(element, [ 'x', 'y', 'width', 'height' ]);
}