yui.jsPlumb-1.2-RC1.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. (function() {
  2. var Y;
  3. YUI().use('node', function(_Y) {
  4. Y = _Y;
  5. });
  6. jsPlumb.CurrentLibrary = {
  7. dragEvents : {
  8. 'start':'drag:start', 'stop':'drag:stop', 'drag':'drag:drag', 'step':'step',
  9. 'over':'over', 'out':'out', 'drop':'drop'
  10. },
  11. extend : function(o1, o2) {
  12. for (var i in o2)
  13. o1[i] = o2[i];
  14. return o1;
  15. },
  16. getElementObject : function(el) {
  17. return typeof el == 'string' ? Y.one('#' + el) : el;
  18. },
  19. getAttribute : function(el, attributeId) {
  20. return el.getAttribute(attributeId);
  21. },
  22. getSize : function(el) {
  23. //TODO must be a proper way to get this.
  24. var bcr = el._node.getBoundingClientRect();
  25. return [ bcr.width, bcr.height ];
  26. },
  27. getOffset : function(el) {
  28. var bcr = el._node.getBoundingClientRect();
  29. return { left:bcr.left, top:bcr.top };
  30. },
  31. setAttribute : function(el, attributeName, attributeValue) {
  32. el.setAttribute(attributeName, attributeValue);
  33. },
  34. isDragSupported : function(el) { return true; },
  35. isDropSupported : function(el) { return false; },
  36. initDraggable : function(el, options) {
  37. var drag = options['drag:drag'];
  38. new YUI().use('dd-drag', function(Y) {
  39. var dd = new Y.DD.Drag({
  40. node: '#' + el.getAttribute('id')
  41. });
  42. dd.on('drag:drag', drag);
  43. });
  44. },
  45. addClass : function(el, clazz) {
  46. el.addClass(clazz);
  47. },
  48. removeClass : function(el, clazz) {
  49. el.removeClass(clazz);
  50. },
  51. getUIPosition : function(args) {
  52. var t = args[0].target.nodeXY;
  53. return { left:t[0], top:t[1] };
  54. }
  55. };
  56. })();