flash-image-view.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. var flashImageView;
  2. var flash_image_view = function(option, success) {
  3. flashImageView = new FlashImageView(option);
  4. flashImageView.createSuccess = success;
  5. return flashImageView;
  6. }
  7. function FlashImageView(option) {
  8. this.markControl = option.markControl;
  9. this.init();
  10. this.markControl.on('task.get.before', this, function(event, context, eventObject) {
  11. this.task = undefined;
  12. });
  13. this.markControl.on('task.get.success', this, function(event, context, eventObject) {
  14. this.task = context.task;
  15. this.imageCount = this.task.pictureUrls.length;
  16. this.imageServer = context.imageServer;
  17. //refreshPictureConfig(this.task.pictureConfig, this.task.pictureUrls, this.imageServer);
  18. getSwfObject('ImageViewer').setJson(this.task.pictureConfig);
  19. });
  20. }
  21. FlashImageView.prototype.init = function() {
  22. this.container = getDom(this.container_dom, this.markControl).appendTo(this.markControl.container.center);
  23. var path = this.markControl.context.staticServer + '/plugin/';
  24. var container = this.container;
  25. $.getScript(path + 'swfobject.js', function() {
  26. $.getScript(path + 'swfplugin.js', function() {
  27. initImageViewPluginDefault(path, "viewer", container.width(), container.height());
  28. });
  29. });
  30. }
  31. function refreshPictureConfig(config, urls, imageServer) {
  32. if (urls != undefined && urls.length > 0 && config != undefined && config != '') {
  33. for (var i = 0; i < urls.length; i++) {
  34. eval('config=config.replace(/\\{' + i + '\\}/, "' + (imageServer + urls[i]) + '")');
  35. }
  36. getSwfObject('ImageViewer').setJson(config);
  37. }
  38. }
  39. function creationComplete() {
  40. flashImageView.createSuccess();
  41. }
  42. function loadComplete() {}
  43. FlashImageView.prototype.container_dom = '<div id="viewer"></div>';