Skip to content

Commit 8d3988b

Browse files
author
tliebeck
committed
Added pre-context menu selection support.
Fixed potential client-side null object bug.
1 parent 1c8586d commit 8d3988b

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/client/extras/Sync.FlowViewer.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
9393
return -1;
9494
},
9595

96-
_processClick: function(e) {
96+
_processClick: function(e, contextClick) {
9797
if (!this.client || !this.client.verifyInput(this.component)) {
9898
return;
9999
}
@@ -104,7 +104,8 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
104104
}
105105

106106
var time = new Date().getTime();
107-
if (this._lastClickIndex == index && time - this._lastClickTime < Extras.Sync.FlowViewer.DOUBLE_CLICK_TIME) {
107+
if (!contextClick && this._lastClickIndex == index &&
108+
time - this._lastClickTime < Extras.Sync.FlowViewer.DOUBLE_CLICK_TIME) {
108109
this._processDoubleClick(e);
109110
return;
110111
}
@@ -114,7 +115,7 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
114115

115116
if (e.ctrlKey || e.metaKey || e.altKey) {
116117
var selection = this.component.get("selection") || {};
117-
if (selection[index]) {
118+
if (!contextClick && selection[index]) {
118119
delete selection[index];
119120
} else {
120121
selection[index] = true;
@@ -139,6 +140,11 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
139140
}
140141
},
141142

143+
_processContextMenu: function(e) {
144+
this._processClick(e, true);
145+
return true;
146+
},
147+
142148
_processDoubleClick: function(e) {
143149
if (!this.client || !this.client.verifyInput(this.component)) {
144150
return;
@@ -182,6 +188,7 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
182188

183189
parentElement.appendChild(this._div);
184190

191+
Core.Web.Event.add(this._div, "contextmenu", Core.method(this, this._processContextMenu), false);
185192
Core.Web.Event.add(this._div, "mouseup", Core.method(this, this._processClick), false);
186193
Core.Web.Event.Selection.disable(this._div);
187194
},
@@ -250,7 +257,9 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
250257
for (y = 0; y < rowsToRemove; ++y) {
251258
for (x = 0; x < this._columnDivs.length; ++x) {
252259
contentDiv = this._columnDivs[x].firstChild;
253-
contentDiv.removeChild(contentDiv.lastChild);
260+
if (contentDiv.lastChild) {
261+
contentDiv.removeChild(contentDiv.lastChild);
262+
}
254263
}
255264
}
256265

@@ -273,7 +282,9 @@ Extras.Sync.FlowViewer = Core.extend(Echo.Render.ComponentSync, {
273282
for (y = 0; y < rowsToRemove; ++y) {
274283
for (x = 0; x < this._columnDivs.length; ++x) {
275284
contentDiv = this._columnDivs[x].firstChild;
276-
contentDiv.removeChild(contentDiv.firstChild);
285+
if (contentDiv.firstChild) {
286+
contentDiv.removeChild(contentDiv.firstChild);
287+
}
277288
}
278289
}
279290

0 commit comments

Comments
 (0)