OSDN Git Service

fix editor event
[pettanr/pettanr.git] / app / assets / javascripts / editor / panel_editor / dock.js.coffee
index 508fc95..73f3b81 100644 (file)
@@ -4,40 +4,40 @@ class Editor.PanelEditor.Dock extends Editor.EditorModule.DockBase
   \r
   initialize: (options) ->\r
     super(options)\r
-    @root = new Editor.EditorModule.DockModule.RootBay({\r
+    @root_bay = new Editor.EditorModule.DockModule.RootBay({\r
       parent: this, index: 0, name: 'panel'\r
     })\r
     @add_tab(\r
-      @root, \r
+      @root_bay\r
       new Editor.EditorModule.DockModule.TabModule.RootBayLabel({\r
-        parent: @root, caption: 'panel'\r
+        parent: @root_bay, caption: 'panel'\r
       }), \r
       new Editor.EditorModule.DockModule.TabModule.RootBayBody({\r
-        parent: @root\r
+        parent: @root_bay\r
       })\r
     )\r
-    @element = new Editor.EditorModule.DockModule.ElementBay({\r
+    @element_bay = new Editor.EditorModule.DockModule.ElementBay({\r
       parent: this, index: 1, name: 'elements'\r
     })\r
     @add_tab(\r
-      @element, \r
+      @element_bay\r
       new Editor.EditorModule.DockModule.TabModule.ElementBayLabel({\r
-        parent: @element, caption: 'elements'\r
+        parent: @element_bay, caption: 'elements'\r
       }), \r
       new Editor.EditorModule.DockModule.TabModule.ElementBayBody({\r
-        parent: @element\r
+        parent: @element_bay\r
       })\r
     )\r
-    @scenario = new Editor.EditorModule.DockModule.ScenarioBay({\r
+    @scenario_bay = new Editor.EditorModule.DockModule.ScenarioBay({\r
       parent: this, index: 2, name: 'scenario'\r
     })\r
     @add_tab(\r
-      @scenario, \r
+      @scenario_bay\r
       new Editor.EditorModule.DockModule.TabModule.ScenarioBayLabel({\r
-        parent: @scenario, caption: 'scenario'\r
+        parent: @scenario_bay, caption: 'scenario'\r
       }), \r
       new Editor.EditorModule.DockModule.TabModule.ScenarioBayBody({\r
-        parent: @scenario\r
+        parent: @scenario_bay\r
       })\r
     )\r
   \r
@@ -52,7 +52,7 @@ class Editor.PanelEditor.Dock extends Editor.EditorModule.DockBase
     this\r
   \r
   add_element: (element) ->\r
-    @element.add_element(element)\r
+    @element_bay.add_element(element)\r
   \r
   editor: () ->\r
     @parent\r
@@ -107,6 +107,8 @@ class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.Dock
   \r
   initialize: (options) ->\r
     super(options)\r
+    @elements_tabs = new Editor.EditorModule.DockModule.ElementBay.ElementsTabs({\r
+    })\r
   \r
   add_element: (element) ->\r
     index = element.get('z') - 1\r
@@ -119,62 +121,54 @@ class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.Dock
       new Editor.EditorModule.DockModule.TabModule.ElementBoardLabel({parent: tab, name: element.item_name()}), \r
       bb\r
     )\r
-    bb\r
+    @elements_tabs.add_element_tab(tab)\r
+    @elements_tabs.$el.tabs('refresh')\r
+    bb.form\r
   \r
   add_new_tab: () ->\r
   \r
   render: () ->\r
     this.$el.html('')\r
     this.$el.attr('id', @body.dom_id())\r
-    elements_tabs = new Editor.EditorModule.DockModule.ElementBay.ElementsTabs({\r
-      tabs: @tabs\r
-    })\r
-    this.$el.append(elements_tabs.render().el)\r
-    elements_tabs.$el.tabs()\r
-    elements_tabs.$el.addClass('ui-tabs-vertical ui-helper-clearfix')\r
-    $("li", elements_tabs.$el).removeClass('ui-corner-top')\r
-    $("li", elements_tabs.$el).addClass('ui-corner-left')\r
+    this.$el.append(@elements_tabs.render().el)\r
+    @elements_tabs.$el.tabs()\r
     this\r
   \r
   panel_body: () ->\r
     @dock().editor().body\r
   \r
-  elements: () ->\r
-    @root_item().scenario_elements()\r
-  \r
 class Editor.EditorModule.DockModule.ElementBay.ElementsTabs extends Backbone.View\r
   tagName: 'div'\r
   className: 'elements_tabs ui-tabs-vertical ui-helper-clearfix'\r
   \r
   initialize: (options) ->\r
     super(options)\r
-    @tabs = options.tabs\r
+    @inner_elements_tabs = new Editor.EditorModule.DockModule.ElementBay.InnerElementsTabs({\r
+    })\r
   \r
   render: () ->\r
     this.$el.html('')\r
-    labels = _.map @tabs, (tab) =>\r
-      tab.label\r
-    inner_elements_tabs = new Editor.EditorModule.DockModule.ElementBay.InnerElementsTabs({\r
-      labels: labels\r
-    })\r
-    this.$el.append(inner_elements_tabs.render().el)\r
-    _.each @tabs, (tab) =>\r
-      this.$el.append(tab.body.render().el)\r
+    this.$el.append(@inner_elements_tabs.render().$el)\r
     this\r
   \r
+  add_element_tab: (tab) ->\r
+    @inner_elements_tabs.add_label(tab.label)\r
+    this.$el.append(tab.body.render().$el)\r
+  \r
 class Editor.EditorModule.DockModule.ElementBay.InnerElementsTabs extends Backbone.View\r
   tagName: 'ul'\r
   \r
   initialize: (options) ->\r
     super(options)\r
-    @labels = options.labels\r
   \r
   render: () ->\r
     this.$el.html('')\r
-    _.each @labels, (label) =>\r
-      this.$el.append(label.render().el)\r
     this\r
   \r
+  add_label: (label) ->\r
+    this.$el.append(label.render().$el)\r
+    label.add_label()\r
+  \r
 class Editor.EditorModule.DockModule.TabModule.ElementBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel\r
   \r
 class Editor.EditorModule.DockModule.TabModule.ElementBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody\r
@@ -193,6 +187,15 @@ class Editor.EditorModule.DockModule.ElementBoard extends Editor.EditorModule.Do
   \r
 class Editor.EditorModule.DockModule.TabModule.ElementBoardLabel extends Editor.EditorModule.DockModule.TabModule.BoardLabel\r
   \r
+  render: () ->\r
+    super()\r
+    this.$el.removeClass('ui-corner-top')\r
+    this.$el.addClass('ui-corner-left')\r
+    this\r
+  \r
+  add_label: () ->\r
+    this.$el.attr('id', @dom_id())\r
+  \r
 class Editor.EditorModule.DockModule.TabModule.ElementBoardBody extends Editor.EditorModule.DockModule.TabModule.BoardBody\r
   \r
   initialize: (options) ->\r