ImageViewer.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Created by CXY on 2017/6/13.
  3. */
  4. o2.widget = o2.widget || {};
  5. o2.widget.ImageViewer = o2.ImageViewer = new Class({
  6. Implements: [Options, Events],
  7. Extends: o2.widget.Common,
  8. options: {
  9. "style": "default",
  10. "path": o2.session.path + "/widget/$ImageViewer/",
  11. "imageUrl": ""
  12. },
  13. initialize: function (node, options) {
  14. this.node = node;
  15. this.setOptions(options);
  16. this.path = this.options.path || (o2.session.path + "/widget/$ImageViewer/");
  17. this.cssPath = this.path + this.options.style + "/css.wcss";
  18. this._loadCss();
  19. this.fireEvent("init");
  20. },
  21. load: function (imageBase64) {
  22. this.container = new Element("div.container", {styles: this.css.container}).inject(this.node);
  23. this.container.addEvent("selectstart", function (e) {
  24. e.preventDefault();
  25. e.stopPropagation();
  26. });
  27. if (!this.checkBroswer())return;
  28. this.lastPoint = null;
  29. this.loadToolBar();
  30. this.contentNode = new Element("div.contentNode", {styles: this.css.contentNode}).inject(this.container);
  31. this.loadEditorNode();
  32. this.loadResultNode();
  33. if (this.options.description) {
  34. this.loadDescriptionNode();
  35. }
  36. if (this.options.imageUrl) {
  37. this.loadImageAsUrl(this.options.imageUrl);
  38. }
  39. if (imageBase64) {
  40. this.loadImageAsFile(this.base64ToBlob(imageBase64));
  41. }
  42. }
  43. });