Skip to content

Commit 292ecbd

Browse files
committed
Re-introduced Raphael, and refactored the rendering code into theme-{snap,raphael}.js, for Snapsvg, and Raphael. This included changing and cleaning up the theme interface.
1 parent 22afc13 commit 292ecbd

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

src/diagram.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ Diagram.prototype.getActorWithAlias = function(input) {
4040
} else {
4141
name = alias = input;
4242
}
43-
44-
return this.getActor(alias, name);
43+
return this.getActor(alias, name);
4544
};
4645

4746
Diagram.prototype.setTitle = function(title) {
@@ -145,7 +144,6 @@ Diagram.ParseError = ParseError;
145144

146145
Diagram.parse = function(input) {
147146
// TODO jison v0.4.17 changed their API slightly, so parser is no longer defined:
148-
149147
// Create the object to track state and deal with errors
150148
parser.yy = new Diagram();
151149
parser.yy.parseError = function(message, hash) {

src/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,4 @@
4040
} else {
4141
root.Diagram = Diagram;
4242
}
43-
4443
}());

src/sequence-diagram.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ Diagram.prototype.drawSVG = function (container, options) {
4040
throw new Error("Invalid container: " + container);
4141
}
4242

43-
new Diagram.themes[options.theme](this, options, function(drawing) {
44-
drawing.draw(div);
45-
});
43+
var themeFunc = new Diagram.themes[options.theme];
44+
themeFunc(this, options, function(drawing) {
45+
drawing.draw(div);
46+
});
4647

4748
}; // end of drawSVG

src/theme-raphael.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ if (typeof Raphael != 'undefined') {
2727
return this.path("M{0},{1} L{2},{3}", x1, y1, x2, y2);
2828
};
2929

30-
3130
/******************
3231
* RaphaelTheme
3332
******************/
@@ -170,7 +169,6 @@ if (typeof Raphael != 'undefined') {
170169

171170
// Take the standard RaphaelTheme and make all the lines wobbly
172171
_.extend(RaphaelHandTheme.prototype, RaphaelTheme.prototype, {
173-
174172
setup_paper : function(container) {
175173
RaphaelTheme.prototype.setup_paper.call(this, container);
176174
this._font._obj = this._paper.getFont('daniel');

src/theme-snap.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ if (typeof Snap != 'undefined') {
258258

259259
// Take the standard SnapTheme and make all the lines wobbly
260260
_.extend(SnapHandTheme.prototype, SnapTheme.prototype, {
261-
262261
draw_line : function(x1, y1, x2, y2, linetype, arrowhead) {
263262
var line = this._paper.path(handLine(x1, y1, x2, y2)).attr(LINE);
264263
if (arrowhead !== undefined) {

src/theme.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,9 @@ _.extend(BaseTheme.prototype, {
317317

318318
draw_title : function() {
319319
var title = this._title;
320-
if (title)
321-
this.draw_text_box(title, title.message, TITLE_MARGIN, TITLE_PADDING, this._font, ALIGN_LEFT);
320+
if (title) {
321+
this.draw_text_box(title, title.message, TITLE_MARGIN, TITLE_PADDING, this._font, ALIGN_LEFT);
322+
}
322323
},
323324

324325
draw_actors : function(offsetY) {

test/test.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
<script src="../bower_components/raphael/raphael-min.js"></script>
5454
<script src="../bower_components/snap.svg/dist/snap.svg.js"></script>
5555
<script src="../bower_components/bower-webfontloader/webfont.js"></script>
56+
<script src="../bower_components/raphael/raphael-min.js"></script>
57+
5658

5759
<!--
5860
<script src="../build/diagram-grammar.js"></script>

0 commit comments

Comments
 (0)