StorageLibrary.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * Copyright (c) 2006-2017, JGraph Ltd
  3. * Copyright (c) 2006-2017, Gaudenz Alder
  4. */
  5. /**
  6. * Constructs a new point for the optional x and y coordinates. If no
  7. * coordinates are given, then the default values for <x> and <y> are used.
  8. * @constructor
  9. * @class Implements a basic 2D point. Known subclassers = {@link mxRectangle}.
  10. * @param {number} x X-coordinate of the point.
  11. * @param {number} y Y-coordinate of the point.
  12. */
  13. StorageLibrary = function(ui, data, title)
  14. {
  15. StorageFile.call(this, ui, data, title);
  16. };
  17. //Extends mxEventSource
  18. mxUtils.extend(StorageLibrary, StorageFile);
  19. /**
  20. * A differentiator of the stored object type (file or lib)
  21. */
  22. StorageLibrary.prototype.type = 'L';
  23. /**
  24. * Translates this point by the given vector.
  25. *
  26. * @param {number} dx X-coordinate of the translation.
  27. * @param {number} dy Y-coordinate of the translation.
  28. */
  29. StorageLibrary.prototype.isAutosave = function()
  30. {
  31. return true;
  32. };
  33. /**
  34. * Overridden to avoid updating data with current file.
  35. */
  36. StorageLibrary.prototype.saveAs = function(title, success, error)
  37. {
  38. this.saveFile(title, false, success, error);
  39. };
  40. /**
  41. * Translates this point by the given vector.
  42. *
  43. * @param {number} dx X-coordinate of the translation.
  44. * @param {number} dy Y-coordinate of the translation.
  45. */
  46. StorageLibrary.prototype.getHash = function()
  47. {
  48. return 'L' + encodeURIComponent(this.title);
  49. };
  50. /**
  51. * Translates this point by the given vector.
  52. *
  53. * @param {number} dx X-coordinate of the translation.
  54. * @param {number} dy Y-coordinate of the translation.
  55. */
  56. StorageLibrary.prototype.getTitle = function()
  57. {
  58. return (this.title == '.scratchpad') ? mxResources.get('scratchpad') : this.title;
  59. };
  60. /**
  61. * Overridden to avoid updating data with current file.
  62. */
  63. StorageLibrary.prototype.isRenamable = function(title, success, error)
  64. {
  65. return this.title != '.scratchpad';
  66. };
  67. /**
  68. * Returns the location as a new object.
  69. * @type mx.Point
  70. */
  71. StorageLibrary.prototype.open = function()
  72. {
  73. // Do nothing - this should never be called
  74. };