//回评模块 var view_sidebar = function(option, success) { var object = new ViewSidebar(option); success(); return object; } function ViewSidebar(option) { this.markControl = option.markControl; this.list = option.list; this.init(); } ViewSidebar.prototype.init = function() { var self = this; this.container = getDom(this.container_dom, this.markControl).prependTo(this.markControl.container); this.container.list = this.container.find('#view-list'); this.container.content = this.container.find('#view-content'); if (this.list.length > 0) { for (var i = 0; i < this.list.length; i++) { var option = this.list[i]; if (option.url == undefined || option.url.length == 0) { continue; } this.container.list.append('' + option.title + ''); this.container.list.append('  ') } this.container.list.find('i').click(function() { self.container.list.find('i').removeClass('yellow'); $(this).addClass('yellow'); self.changeContent($(this).attr('data-url')); }); this.container.list.find('i:first').trigger('click'); this.markControl.initMarkFunction(); this.toggleButton = getDom(this.toggle_button_dom, this.markControl).appendTo(this.markControl.container.assistant.functionList); this.toggleButton.click(this, function(event) { self.toggle(true); }); } this.container.find('#view-close-button').click(this, function(event) { self.toggle(false); }); } ViewSidebar.prototype.toggle = function(enable) { if (enable) { this.markControl.trigger('view.sidebar.open'); this.container.removeClass('hide'); } else { this.container.addClass('hide'); this.markControl.trigger('view.sidebar.close'); } } ViewSidebar.prototype.changeContent = function(url) { this.container.content.empty(); var dom = $(this.content_dom); dom[0].width = this.container.width(); dom[0].height = this.container.height() * 0.9; dom.find('object')[0].width = this.container.width(); dom.find('object')[0].height = this.container.height() * 0.9; dom.find('#object-src').val(url); dom.find('object')[0].data = url; this.container.content.append(dom); } ViewSidebar.prototype.toggle_button_dom = '侧边栏'; ViewSidebar.prototype.container_dom = '
\

\ \
\
\
'; ViewSidebar.prototype.content_dom = '\ \ \ \ \ \ \ ';