draggableConnectorsDemo-mootools.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ;(function() {
  2. var _initialised = false;
  3. jsPlumbDemo.showConnectionInfo = function(s) {
  4. $("list").set('html', s);
  5. $("list").setStyle("display","block");
  6. };
  7. jsPlumbDemo.hideConnectionInfo = function() {
  8. $("list").setStyle("display","none");
  9. };
  10. jsPlumbDemo.attachBehaviour = function() {
  11. if (!_initialised) {
  12. $$(".hide").each(function(h) {
  13. h.addEvent('click', function() {
  14. jsPlumb.toggle(h.get("rel"));
  15. });
  16. });
  17. $$(".drag").each(function(d) {
  18. d.addEvent('click', function() {
  19. var s = jsPlumb.toggleDraggable(d.get("rel"));
  20. d.set('html', s ? 'disable dragging' : 'enable dragging');
  21. if (!s) $(d.get("rel")).addClass('drag-locked');
  22. else $(d.get("rel")).removeClass('drag-locked');
  23. $(d.get("rel")).setStyle("cursor", s ? "pointer" : "default");
  24. });
  25. });
  26. $$(".detach").each(function(d) {
  27. d.addEvent('click', function() {
  28. jsPlumb.detachAllConnections(d.get("rel"));
  29. });
  30. });
  31. $("clear").addEvent('click', function() { jsPlumb.detachEveryConnection(); jsPlumbDemo.showConnectionInfo(""); });
  32. _initialised = true;
  33. }
  34. };
  35. })();