mxDefaultPopupMenuCodec.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2006-2015, JGraph Ltd
  3. * Copyright (c) 2006-2015, Gaudenz Alder
  4. */
  5. mxCodecRegistry.register(function()
  6. {
  7. /**
  8. * Class: mxDefaultPopupMenuCodec
  9. *
  10. * Custom codec for configuring <mxDefaultPopupMenu>s. This class is created
  11. * and registered dynamically at load time and used implicitly via
  12. * <mxCodec> and the <mxCodecRegistry>. This codec only reads configuration
  13. * data for existing popup menus, it does not encode or create menus. Note
  14. * that this codec only passes the configuration node to the popup menu,
  15. * which uses the config to dynamically create menus. See
  16. * <mxDefaultPopupMenu.createMenu>.
  17. */
  18. var codec = new mxObjectCodec(new mxDefaultPopupMenu());
  19. /**
  20. * Function: encode
  21. *
  22. * Returns null.
  23. */
  24. codec.encode = function(enc, obj)
  25. {
  26. return null;
  27. };
  28. /**
  29. * Function: decode
  30. *
  31. * Uses the given node as the config for <mxDefaultPopupMenu>.
  32. */
  33. codec.decode = function(dec, node, into)
  34. {
  35. var inc = node.getElementsByTagName('include')[0];
  36. if (inc != null)
  37. {
  38. this.processInclude(dec, inc, into);
  39. }
  40. else if (into != null)
  41. {
  42. into.config = node;
  43. }
  44. return into;
  45. };
  46. // Returns the codec into the registry
  47. return codec;
  48. }());
  49. __mxOutput.mxDefaultPopupMenuCodec = typeof mxDefaultPopupMenuCodec !== 'undefined' ? mxDefaultPopupMenuCodec : undefined;