Skip to content

Commit 752b90f

Browse files
interface buttons bug fix, code reorganization & improvements
1 parent be5be22 commit 752b90f

4 files changed

Lines changed: 55 additions & 73 deletions

File tree

web/css/interface.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,31 @@ html, body {
3232
padding: .5em;
3333
font-weight: 600;
3434
font-size: 18pt;
35+
z-index: 1;
3536
}
3637

3738
.ui-rightBottomToolBar {
3839
position: absolute;
3940
bottom: 0;
4041
right: 0;
4142
padding: .5em;
43+
z-index: 1;
4244
}
4345

4446
.ui-leftBottomToolBar {
4547
position: absolute;
4648
bottom: 0;
4749
left: 0;
4850
padding: .5em;
51+
z-index: 1;
4952
}
5053

5154
.ui-topRightToolBar {
5255
position: absolute;
5356
top: 0;
5457
right: 0;
5558
padding: .5em;
59+
z-index: 1;
5660
}
5761

5862
#className {

web/js/ClassView.js

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -127,65 +127,53 @@ ClassView.prototype.createClassInstance = function (name, classMetaData) {
127127
classMethods = classMetaData["methods"],
128128
self = this;
129129

130-
var insertString = function (array, string, extraString) {
131-
array.push({ text: string + (extraString ? extraString : "")});
132-
};
133-
134130
var classInstance = new joint.shapes.uml.Class({
135-
name: name,
131+
name: [{
132+
text: name,
133+
clickHandler: function () {
134+
self.openClassDoc(name, classMetaData["NAMESPACE"]);
135+
},
136+
styles: {
137+
cursor: "help"
138+
}
139+
}],
136140
params: (function (params) {
137141
var arr = [], n;
138142
for (n in params) {
139-
insertString(arr, n + (params[n]["type"] ? ": " + params[n]["type"] : ""));
143+
arr.push({
144+
text: n + (params[n]["type"] ? ": " + params[n]["type"] : "")
145+
});
140146
}
141147
return arr;
142148
})(classParams),
143149
attributes: (function (ps) {
144150
var arr = [], n;
145151
for (n in ps) {
146-
insertString(
147-
arr,
148-
(ps[n]["private"] ? "- " : "+ ") + n
152+
arr.push({
153+
text: (ps[n]["private"] ? "- " : "+ ") + n
149154
+ (ps[n]["type"] ? ": " + ps[n]["type"] : "")
150-
);
155+
});
151156
}
152157
return arr;
153158
})(classProps),
154159
methods: (function (met) {
155160
var arr = [], n;
156161
for (n in met) {
157-
insertString(
158-
arr,
159-
(met[n]["private"] ? "- " : "+ ") + n
162+
arr.push({
163+
text: (met[n]["private"] ? "- " : "+ ") + n
160164
+ (met[n]["returns"] ? ": " + met[n]["returns"] : ""),
161-
(met[n]["classMethod"] ?
162-
"\x1b" + JSON.stringify({STYLES:{
163-
textDecoration: "underline"
164-
}}) : "")
165-
);
165+
styles: (function (t) {
166+
return t ? {} : { textDecoration: "underline" }
167+
})(met[n]["classMethod"]),
168+
clickHandler: (function (n) {
169+
return function () { self.showMethodCode(name, n); }
170+
})(n)
171+
});
166172
}
167173
return arr;
168174
})(classMethods),
169-
directProps: {
170-
nameClickHandler: function () {
171-
self.openClassDoc(name, classMetaData["NAMESPACE"]);
172-
}
173-
},
174175
classSigns: this.getClassSigns(classMetaData),
175-
SYMBOL_12_WIDTH: self.SYMBOL_12_WIDTH,
176-
attrs: {
177-
".uml-class-methods-text": {
178-
lineClickHandlers: (function (ps) {
179-
var arr = [], p;
180-
for (p in ps) {
181-
arr.push((function (p) { return function () {
182-
self.showMethodCode(name, p)
183-
}})(p));
184-
}
185-
return arr;
186-
})(classMethods)
187-
}
188-
}
176+
SYMBOL_12_WIDTH: self.SYMBOL_12_WIDTH
189177
});
190178

191179
this.objects.push(classInstance);

web/jsLib/joint.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17138,7 +17138,7 @@ if ( typeof window === "object" && typeof window.document === "object" ) {
1713817138
text: function(content, opt) {
1713917139

1714017140
opt = opt || {};
17141-
var lines = content.split('\n');
17141+
var lines = content/*.split('\n')*/;
1714217142
var i = 0;
1714317143
var tspan;
1714417144

@@ -17201,11 +17201,6 @@ if ( typeof window === "object" && typeof window.document === "object" ) {
1720117201
textNode = textPath.node;
1720217202
}
1720317203

17204-
//if (lines.length === 1) {
17205-
// textNode.textContent = content;
17206-
// return this;
17207-
//}
17208-
1720917204
for (; i < lines.length; i++) {
1721017205

1721117206
var jj, setup;
@@ -17216,28 +17211,22 @@ if ( typeof window === "object" && typeof window.document === "object" ) {
1721617211
if (!lines[i]) {
1721717212
tspan.addClass('empty-line');
1721817213
}
17219-
if (lines[i].indexOf("\x1b") !== -1) {
17220-
jj = lines[i].split("\x1b");
17221-
lines[i] = jj[0];
17222-
setup = JSON.parse(jj[1]);
17223-
if (setup["STYLES"]) {
17224-
for (var j in setup["STYLES"]) {
17225-
tspan.node.style[j] = setup["STYLES"][j];
17226-
}
17214+
if (lines[i]["styles"]) {
17215+
for (var j in lines[i]["styles"]) {
17216+
tspan.node.style[j] = lines[i]["styles"][j];
1722717217
}
1722817218
}
17229-
if (opt.clickHandler) {
17230-
tspan.node.onclick = opt.clickHandler;
17231-
}
17232-
17233-
if (opt.lineClickHandlers && opt.lineClickHandlers[i]) {
17234-
tspan.node.addEventListener("click", opt.lineClickHandlers[i]);
17235-
tspan.node.setAttribute("class", tspan.node.getAttribute("class") + " line-clickable");
17219+
if (typeof lines[i]["clickHandler"] === "function") {
17220+
tspan.node.addEventListener("click", lines[i]["clickHandler"]);
17221+
tspan.node.setAttribute(
17222+
"class",
17223+
tspan.node.getAttribute("class") + " line-clickable"
17224+
);
1723617225
}
1723717226
// Make sure the textContent is never empty. If it is, add an additional
1723817227
// space (an invisible character) so that following lines are correctly
1723917228
// relatively positioned. `dy=1em` won't work with empty lines otherwise.
17240-
tspan.node.textContent = lines[i] || ' ';
17229+
tspan.node.textContent = lines[i].text || ' ';
1724117230

1724217231
V(textNode).append(tspan);
1724317232
}
@@ -20952,7 +20941,7 @@ joint.dia.ElementView = joint.dia.CellView.extend({
2095220941
// to rewrite them, if needed. (i.e display: 'none')
2095320942
if (!_.isUndefined(attrs.text)) {
2095420943
$selected.each(function() {
20955-
V(this).text(attrs.text + '', attrs);
20944+
V(this).text(attrs.text, attrs);
2095620945
});
2095720946
specialAttributes.push('lineHeight','textPath');
2095820947
}

web/jsLib/joint.shapes.uml.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
8888
var o,
8989
rects = [
9090
{ type: 'name', text: this.getClassName() },
91-
{ type: 'params', text: (o = this.get('params')) .map(function (e) { return e.text; }), o: o },
92-
{ type: 'attrs', text: (o = this.get('attributes')).map(function (e) { return e.text; }), o: o },
93-
{ type: 'methods', text: (o = this.get('methods')) .map(function (e) { return e.text; }), o: o }
91+
{ type: 'params', text: (o = this.get('params')) , o: o },
92+
{ type: 'attrs', text: (o = this.get('attributes')), o: o },
93+
{ type: 'methods', text: (o = this.get('methods')) , o: o }
9494
],
9595
self = this,
9696
classSigns = this.get('classSigns'),
@@ -109,8 +109,8 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
109109

110110
this.defaults.size.width = Math.max(this.defaults.MIN_WIDTH, Math.min(w, 250));
111111
_.each(rects, function (rect) {
112-
(rect.text instanceof Array ? rect.text : [rect.text]).forEach(function (s) {
113-
var t = s.split("\x1b")[0].length*SYMBOL_12_WIDTH + 8;
112+
rect.text.forEach(function (s) {
113+
var t = s.text.length*SYMBOL_12_WIDTH + 8;
114114
if (t > self.defaults.size.width) {
115115
self.defaults.size.width = t;
116116
}
@@ -157,7 +157,8 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
157157
},
158158

159159
getClassName: function () {
160-
return this.get('name');
160+
var n = this.get('name');
161+
return n instanceof Array ? n : [{ text: n }];
161162
},
162163

163164
updateRectangles: function () {
@@ -168,20 +169,19 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
168169

169170
var rects = [
170171
{ type: 'name', text: this.getClassName() },
171-
{ type: 'params', text: this.get('params').map(function (e) { return e.text; }) },
172-
{ type: 'attrs', text: this.get('attributes').map(function (e) { return e.text; }) },
173-
{ type: 'methods', text: this.get('methods').map(function (e) { return e.text; }) }
172+
{ type: 'params', text: this.get('params') },
173+
{ type: 'attrs', text: this.get('attributes') },
174+
{ type: 'methods', text: this.get('methods') }
174175
];
175-
176+
console.log("METHODS: ", this.get('methods'));
176177
var offsetY = 0;
177178

178179
var dp = self.get("directProps") || {},
179180
nameClickHandler = dp.nameClickHandler;
180181

181182
_.each(rects, function(rect) {
182183

183-
var lines = _.isArray(rect.text) ? rect.text : [rect.text];
184-
184+
var lines = _.isArray(rect.text) ? rect.text : [{ text: rect.text }];
185185
if (rect.type === "name") {
186186
if (self.HEAD_EMPTY_LINES) lines.unshift("");
187187
for (var i = 0; i < self.HEAD_EMPTY_LINES; i++) lines.unshift("");
@@ -192,7 +192,8 @@ joint.shapes.uml.Class = joint.shapes.basic.Generic.extend({
192192
rectRect = attrs['.uml-class-' + rect.type + '-rect'],
193193
rectLabel = attrs['.uml-class-' + rect.type + '-label'];
194194

195-
rectText.text = lines.join('\n');
195+
rectText.text = lines;
196+
196197
if (nameClickHandler) {
197198
if (rect.type === "name") {
198199
rectText.clickHandler = nameClickHandler;

0 commit comments

Comments
 (0)