class Editor.PanelEditor.Dock extends Editor.EditorModule.DockBase tagName: 'div' className: 'dock' initialize: (options) -> super(options) @root_bay = new Editor.EditorModule.DockModule.RootBay({ parent: this, index: 0, name: 'panel' }) @add_tab( @root_bay, new Editor.EditorModule.DockModule.TabModule.RootBayLabel({ parent: @root_bay, caption: 'panel' }), new Editor.EditorModule.DockModule.TabModule.RootBayBody({ parent: @root_bay }) ) @element_bay = new Editor.EditorModule.DockModule.ElementBay({ parent: this, index: 1, name: 'elements' }) @add_tab( @element_bay, new Editor.EditorModule.DockModule.TabModule.ElementBayLabel({ parent: @element_bay, caption: 'elements' }), new Editor.EditorModule.DockModule.TabModule.ElementBayBody({ parent: @element_bay }) ) @scenario_bay = new Editor.EditorModule.DockModule.ScenarioBay({ parent: this, index: 2, name: 'scenario' }) @add_tab( @scenario_bay, new Editor.EditorModule.DockModule.TabModule.ScenarioBayLabel({ parent: @scenario_bay, caption: 'scenario' }), new Editor.EditorModule.DockModule.TabModule.ScenarioBayBody({ parent: @scenario_bay }) ) @listenTo(@root_bay.body, 'http_post', @http_post) @listenTo(@root_bay.body, 'save:success', @post_success) @listenTo(@root_bay.body, 'save:fail', @post_fail) @listenTo(@element_bay, 'add:credit', @add_credit) @listenTo(@element_bay, 'pick', @pick) render: () -> this.$el.html('') l = _.map @tabs, (tab) -> tab.label labels = new Tag.Ul({contents: l, class_name: @dom_labels_class()}) this.$el.append(labels.render().el) _.each @tabs, (tab) => this.$el.append(tab.render().el) this init_tabs: () -> @element_bay.init_tabs() @scenario_bay.init_tabs() this.$el.tabs({ activate: (e, ui) -> ui.newPanel.trigger('activate') }) editor: () -> @parent dom_id: () -> @editor().dom_id() + '-dock' dom_class: () -> @editor().dom_class() + '-dock' dom_labels_class: () -> @dom_class() + '-labels' http_post: (url, root_form) -> @trigger('http_post', url, this) # send dock false post_success: (model, response) -> @trigger('save:success', model, response) post_fail: (model, response) -> @trigger('save:fail', response) add_credit: (element) -> @trigger('add:credit', element) save: () -> # merge panel and elements attrs = @root_bay.save_data() _.extend(attrs, @element_bay.save_data()) # save json data by panel form @root_bay.body.form.save(attrs) pick: (new_item) -> t = @scenario_bay.length() z = @element_bay.new_tab.label.z() + 1 new_item.set({z: z, t: t}, {silent: true}) @scenario_bay.add_element(new_item) @trigger('add:element', new_item) quit: () -> @root_bay.body.form.quit()