view-sidebar.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //回评模块
  2. var view_sidebar = function(option, success) {
  3. var object = new ViewSidebar(option);
  4. success();
  5. return object;
  6. }
  7. function ViewSidebar(option) {
  8. this.markControl = option.markControl;
  9. this.list = option.list;
  10. this.init();
  11. }
  12. ViewSidebar.prototype.init = function() {
  13. var self = this;
  14. this.container = getDom(this.container_dom, this.markControl).prependTo(this.markControl.container);
  15. this.container.list = this.container.find('#view-list');
  16. this.container.content = this.container.find('#view-content');
  17. if (this.list.length > 0) {
  18. for (var i = 0; i < this.list.length; i++) {
  19. var option = this.list[i];
  20. if (option.url == undefined || option.url.length == 0) {
  21. continue;
  22. }
  23. this.container.list.append('<i style="cursor:pointer" data-url="' + option.url + '">' + option.title + '</i>');
  24. this.container.list.append('&nbsp;&nbsp;')
  25. }
  26. this.container.list.find('i').click(function() {
  27. self.container.list.find('i').removeClass('yellow');
  28. $(this).addClass('yellow');
  29. self.changeContent($(this).attr('data-url'));
  30. });
  31. this.container.list.find('i:first').trigger('click');
  32. this.markControl.initMarkFunction();
  33. this.toggleButton = getDom(this.toggle_button_dom, this.markControl).appendTo(this.markControl.container.assistant.functionList);
  34. this.toggleButton.click(this, function(event) {
  35. self.toggle(true);
  36. });
  37. }
  38. this.container.find('#view-close-button').click(this, function(event) {
  39. self.toggle(false);
  40. });
  41. }
  42. ViewSidebar.prototype.toggle = function(enable) {
  43. if (enable) {
  44. this.markControl.trigger('view.sidebar.open');
  45. this.container.removeClass('hide');
  46. } else {
  47. this.container.addClass('hide');
  48. this.markControl.trigger('view.sidebar.close');
  49. }
  50. }
  51. ViewSidebar.prototype.changeContent = function(url) {
  52. this.container.content.empty();
  53. var dom = $(this.content_dom);
  54. dom[0].width = this.container.width();
  55. dom[0].height = this.container.height() * 0.9;
  56. dom.find('object')[0].width = this.container.width();
  57. dom.find('object')[0].height = this.container.height() * 0.9;
  58. dom.find('#object-src').val(url);
  59. dom.find('object')[0].data = url;
  60. this.container.content.append(dom);
  61. }
  62. ViewSidebar.prototype.toggle_button_dom = '<a href="#">侧边栏</a>';
  63. ViewSidebar.prototype.container_dom = '<div class="mark-sidebar span5 hide">\
  64. <div class="header"><p class="fl" id="view-list"></p>\
  65. <a href="##" id="view-close-button"><img src="{staticServer}/mark-new/images/hp-close.png"></a>\
  66. </div>\
  67. <div id="view-content"></div>\
  68. </div>';
  69. ViewSidebar.prototype.content_dom = '<object classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="" height="" border="0">\
  70. <param name="_Version" value="65539">\
  71. <param name="_ExtentX" value="20108">\
  72. <param name="_ExtentY" value="10866">\
  73. <param name="_StockProps" value="0">\
  74. <param name="SRC" id="object-src" value="">\
  75. <object data="" type="application/pdf" width="" height=""></object>\
  76. </object>';