chore(project): migrate to modularized lodash@3

* use specialized lodash utilities
* consistently apply 'use strict'

Related to #185
This commit is contained in:
Nico Rehwaldt 2015-02-02 14:46:21 +01:00
parent a899df2a12
commit 3996408404
28 changed files with 177 additions and 175 deletions

View File

@ -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
}
}

View File

@ -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']

View File

@ -1,5 +1,8 @@
'use strict';
var Viewer = require('./Viewer');
/**
* A viewer that includes mouse navigation facilities
*

View File

@ -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 = $('<img/>').attr('src', 'data:image/png;base64,' + logoData).appendTo(a);
$('<img/>').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
});

View File

@ -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);
});
}

View File

@ -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',

View File

@ -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

View File

@ -1,3 +1,4 @@
'use strict';
function getLabelAttr(semantic) {
if (semantic.$instanceOf('bpmn:FlowElement') ||

View File

@ -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));
};

View File

@ -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);
};

View File

@ -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);

View File

@ -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,

View File

@ -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
*

View File

@ -1,3 +1,4 @@
'use strict';
function AppendBehavior(eventBus, elementFactory) {

View File

@ -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) {

View File

@ -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;
};

View File

@ -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;

View File

@ -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'
),

View File

@ -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'];

View File

@ -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);

View File

@ -1,3 +1,5 @@
'use strict';
module.exports.elementToString = function(e) {
if (!e) {
return '<null>';

View File

@ -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);

View File

@ -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"

View File

@ -1,3 +1,5 @@
'use strict';
var TestHelper = module.exports = require('./helper');
var fs = require('fs');

View File

@ -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;

View File

@ -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;
});

View File

@ -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;
});

View File

@ -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' ]);
}