-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
|
||
------------------------------------------ | ||
|
||
Endpoint detachAll (301): (detach all connections) | ||
|
||
this.detach(this.connections[0], false, true, fireEvent !== false, originalEvent, this, 0); | ||
|
||
|
||
it is unclear to me whether this should destroy connections after detaching them. in theory, once a connection no longer has two endpoints it should be destroyed, i would think. | ||
|
||
|
||
------------------------------------------- | ||
|
||
Endpoint.detachFrom (316): (detach from some other element) | ||
|
||
this.detach(c[i], false, true, fireEvent, originalEvent); | ||
|
||
again, unclear what should happen. the connection now has only one endpoint and so should probably be blown away, i suppose. | ||
|
||
|
||
---------------------------------------------- | ||
|
||
jsPlumb-endpoint.js (629). drag options stop event. | ||
|
||
unclear to me what the jpc._forceDetach is doing in this test (it was not commented out when i first started messing with this stuff) - surely it says the opposite of what it is being used to test! | ||
|
||
if (jpc.isReattach() || jpc._forceReattach /*|| jpc._forceDetach*/ || !jpc.endpoints[idx == 0 ? 1 : 0].detach(jpc, false, false, true, originalEvent)) { | ||
|
||
we get here if the connection was existing (ie. it has a suspendedEndpoint). if the connection should be reattached then we do so, otherwise we ask the other endpoint if its ok to detach). | ||
|
||
i think this needs cleaning up really. if the other endpoint were to nuke the connection during detach then this method would fail quite spectacularly. | ||
|
||
|
||
------------------------------------------------------------------- | ||
|
||
jsPlumb.js (1630). The jsPlumb.detach method when you provided a Connection: | ||
|
||
|
||
conn.endpoints[0].detach(conn, false, true, fireEvent); | ||
|
||
|
||
In this case, the connection should be cleaned up and destroyed. It is what the user asked for. | ||
|
||
----------------------------------------------------------------------- | ||
|
||
jsPlumb.js (1646). Detach function - detaches a connection/some connections. this is in a loop of the connections for the case that a source and/or target was provided: | ||
|
||
jpc.endpoints[0].detach(jpc, false, true, fireEvent); | ||
|
||
In this case, the connections should be cleaned up and destroyed. It is what the user asked for. | ||
|
||
-------------------- | ||
|
||
|
||
jsPlumb.js (1850). in the connection select handler; this is for the select handler's detach method, and loops through a list of connections: | ||
|
||
_currentInstance.detach(list[i]); | ||
|
||
So this should behave the same way as jsPlumb.detach, which is to destroy a connection after it has been detached. | ||
|
||
|
||
-------------------- | ||
|
||
|
||
jsPlumb.js (2276). the drop handler in makeTarget. detaches the current connection from its source, because a new connection is actually created, and this one is thrown away. | ||
|
||
source.detach(jpc, false, true, false); | ||
|
||
|
||
----------------- | ||
|
||
|
||
jsPlumb.js (2292). in the makeTarget drop code, when the user was "not allowed" to drop and the connection had no suspended endpoint. i am not entirely sure what case this is for, in fact, and i'd like to know: | ||
|
||
source.detach(jpc, false, true, true, originalEvent); // otherwise, detach the connection and tell everyone about it. | ||
|
||
|
||
|
||
WHAT TO DO! | ||
----------- | ||
|
||
- firstly, the detach method in Endpoint needs to take a params object instead of a million arguments. | ||
- secondly, the code that deals with a connection's endpointsToDeleteOnDetach needs to be separated out of the endpoint's detach method. that is not the place to deal with it. it should be the jsplumb instance that is responsible for cleaning up a connection and destroying any endpoints it has marked for deletion. and endpoints should only be deleted after all the detaching has been done | ||
|
||
|
||
|
||
METHODS | ||
|
||
jsPlumb | ||
------- | ||
|
||
- detach | ||
|
||
detaches a connection from its endpoints, deleting the endpoints if necessary, then discards the connection. | ||
|
||
- detachConnectionFromEndpoint | ||
|
||
detaches a connectio | ||
|
||
|
||
Endpoint | ||
-------- | ||
|
||
- detachFrom(element) | ||
|
||
- detachFromConnection(connection) | ||
|
||
- detach(connection) | ||
|
||
Connection | ||
---------- | ||
|
||
- detach | ||
|
||
detaches the connection from its endpoints, deleting the endpoints if necessary, then discards the connection. this just needs to hand off to the jsPlumb.detach method, in fact. | ||
|
||
the problem here is that if we want to delete all the connections from some endpoint, we cannot honour | ||
the first one's endpointsToDeleteOnDetach, in case we delete the very endpoint we are still working on. So we need in fact to take an array of connections, and to add the endpointsToDeleteOnDetach to a hashset as we go along. | ||
|
||
function detach(conns) { | ||
var endpointsToDelete = {}; // keyed by id | ||
if (!isArray(conns)) conns = []; | ||
for (var i = 0; i < conns.length; i++) { | ||
conns[i].endpoints[0].detachFromConnection(conns[i]); | ||
conns[i].endpoints[1].detachFromConnection(conns[i]); | ||
if (conns[i].endpointsToDeleteOnDetach) { | ||
for (var j = 0; j < conns[i].endpointsToDeleteOnDetach.length; j++) | ||
endpointsToDelete[conns[i].endpointsToDeleteOnDetach[j].id] = conns[i].endpointsToDeleteOnDetach[j]; | ||
} | ||
} | ||
// now we have a hashset of endpoints to delete on detach. but what if one or more of these endpoints has connections? they have to be detached too, which could result in more endpoints to delete, and more connections etc. and we still do not want to delete the endpoints until the end. | ||
|
||
|
||
} | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
-rw-r--r-- 1 simon staff 172043 8 Jul 11:16 jquery.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 452298 8 Jul 11:16 jquery.jsPlumb-1.4.2-all.js | ||
drwxr-xr-x 2 simon staff 68 8 Jul 11:16 lib | ||
-rw-r--r-- 1 simon staff 173823 8 Jul 11:16 mootools.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 451698 8 Jul 11:16 mootools.jsPlumb-1.4.2-all.js | ||
-rw-r--r-- 1 simon staff 173615 8 Jul 11:16 yui.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 450813 8 Jul 11:16 yui.jsPlumb-1.4.2-all.js | ||
|
||
-rw-r--r-- 1 simon staff 156528 8 Jul 11:17 jquery.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 431642 8 Jul 11:17 jquery.jsPlumb-1.4.2-all.js | ||
drwxr-xr-x 2 simon staff 68 8 Jul 11:17 lib | ||
-rw-r--r-- 1 simon staff 158520 8 Jul 11:17 mootools.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 431285 8 Jul 11:17 mootools.jsPlumb-1.4.2-all.js | ||
-rw-r--r-- 1 simon staff 158292 8 Jul 11:17 yui.jsPlumb-1.4.2-all-min.js | ||
-rw-r--r-- 1 simon staff 430346 8 Jul 11:17 yui.jsPlumb-1.4.2-all.js | ||
|
||
|
||
|
||
jquery: no diff (410) | ||
|
||
anchors: 23 lines (999) | ||
|
||
connection: -33 lines (493) | ||
|
||
connectors-default: no diff (1437) | ||
|
||
connectors-flowchart: +2 lines (364) | ||
|
||
- class extension stuff | ||
|
||
connectors-statemachine +1 line (268) | ||
|
||
- class extension stuff | ||
|
||
defaults +26 (1463) | ||
|
||
- mostly class extension stuff | ||
|
||
dom adapter +34 (270) | ||
|
||
- added getAttribute/setAttribute functions | ||
|
||
endpoint -14 (974) | ||
|
||
canvas renderer -19 (542) | ||
|
||
svg +17 (610) | ||
|
||
- added svg component cleanup | ||
|
||
vml +10 (504) | ||
|
||
- added vml component cleanup | ||
|
||
jsplumb +221 (3183) | ||
|
||
util +105 (502) | ||
|
||
- added Function.prototype.bind | ||
|
||
mootools -15 (434) | ||
yui -8 (394) | ||
|
||
|
||
jsPlumb | ||
------- | ||
makeSource: 202 lines | ||
makeTarget: 184 lines | ||
|
||
+44 lines of supporting stuff. 430 lines in total - 1/7th the size of the file. | ||
|
||
actually its 534 lines of code all up, with the set enabled stuff etc. | ||
is it possible to pull that into a module that plugs in to jsPlumb via the prototype? | ||
|