UrlLibrary.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. UrlLibrary = function(ui, data, title)
  14. {
  15. StorageFile.call(this, ui, data, title);
  16. var fname = title;
  17. var last = fname.lastIndexOf('/');
  18. if (last >= 0)
  19. {
  20. fname = fname.substring(last + 1);
  21. }
  22. this.fname = fname;
  23. };
  24. //Extends mxEventSource
  25. mxUtils.extend(UrlLibrary, StorageFile);
  26. /**
  27. * Translates this point by the given vector.
  28. *
  29. * @param {number} dx X-coordinate of the translation.
  30. * @param {number} dy Y-coordinate of the translation.
  31. */
  32. UrlLibrary.prototype.getHash = function()
  33. {
  34. return 'U' + encodeURIComponent(this.title);
  35. };
  36. /**
  37. * Translates this point by the given vector.
  38. *
  39. * @param {number} dx X-coordinate of the translation.
  40. * @param {number} dy Y-coordinate of the translation.
  41. */
  42. UrlLibrary.prototype.getTitle = function()
  43. {
  44. return this.fname;
  45. };
  46. /**
  47. * Translates this point by the given vector.
  48. *
  49. * @param {number} dx X-coordinate of the translation.
  50. * @param {number} dy Y-coordinate of the translation.
  51. */
  52. UrlLibrary.prototype.isAutosave = function()
  53. {
  54. return false;
  55. };
  56. /**
  57. * Overridden to avoid updating data with current file.
  58. */
  59. UrlLibrary.prototype.isEditable = function(title, success, error)
  60. {
  61. return false;
  62. };
  63. /**
  64. * Overridden to avoid updating data with current file.
  65. */
  66. UrlLibrary.prototype.saveAs = function(title, success, error)
  67. {
  68. // Cannot be saved
  69. };
  70. /**
  71. * Returns the location as a new object.
  72. * @type mx.Point
  73. */
  74. UrlLibrary.prototype.open = function()
  75. {
  76. // Do nothing - this should never be called
  77. };