1 class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.DockModule.BoardBay
\r
3 initialize: (options) ->
\r
5 @boards = new Editor.EditorModule.DockModule.ElementBay.Boards({
\r
8 @listenTo(@boards, 'sorted', @sorted)
\r
10 add_element: (element) ->
\r
11 index = @tabs.length
\r
13 tab = new Editor.EditorModule.DockModule.ElementBoard({
\r
14 parent: this, index: index, name: element.item_name(), element: element
\r
16 bb = new Editor.EditorModule.DockModule.TabModule.ElementBoardBody({parent: tab})
\r
19 new Editor.EditorModule.DockModule.TabModule.ElementBoardLabel({
\r
21 name: element.item_name()
\r
25 @boards.add_element_tab(tab)
\r
26 @boards.$el.tabs('refresh')
\r
27 if element.constructor.has_picture()
\r
28 @trigger('add:credit', element)
\r
31 new_tab_z = @new_tab.label.z()
\r
32 _.each @tabs, (tab) ->
\r
34 tab.label.$el.attr('data-z', z + 1) if z >= new_tab_z # new tab too
\r
37 @new_tab = new Editor.EditorModule.DockModule.NewElementBoard({
\r
38 parent: this, index: 0, name: 'new'
\r
40 bb = new Editor.EditorModule.DockModule.TabModule.NewElementBoardBody({parent: @new_tab})
\r
43 new Editor.EditorModule.DockModule.TabModule.NewElementBoardLabel({
\r
48 @listenTo(bb, 'pick', @pick)
\r
49 @boards.add_element_tab(@new_tab)
\r
53 @delegateEvents({'activate': 'activate'})
\r
54 this.$el.attr('id', @body.dom_id())
\r
55 this.$el.append(@boards.render().el)
\r
58 activate: (e, ui) ->
\r
59 ui.newPanel.trigger('activate')
\r
65 list = @root_item().zorderd_elements()
\r
66 _.each list, (element) =>
\r
67 @add_element(element)
\r
70 _.each @tabs, (tab) ->
\r
71 return if not tab.element # without new element tab
\r
72 if tab.body.$el.css('display') != 'none'
\r
76 # data-z copy to model
\r
77 new_tab_z = @new_tab.label.z()
\r
78 _.each @tabs, (tab) ->
\r
79 if tab.element # without new_tab
\r
81 z-- if z > new_tab_z # from 0, 1, new tab, 3... to 1, 2, 3...
\r
85 tab.element.trigger('sort')
\r
88 @dock().editor().body
\r
92 _.each @tabs, (tab) ->
\r
93 return if not tab.element # without new element tab
\r
94 form = tab.body.form
\r
95 name = form.item.table_name() + '_attributes'
\r
97 attrs[name].push(form.save_data())
\r
100 pick: (new_item) ->
\r
101 @add_element(new_item)
\r
102 @trigger('pick', new_item)
\r
104 class Editor.EditorModule.DockModule.TabModule.ElementBayLabel extends Editor.EditorModule.DockModule.TabModule.BayLabel
\r
106 class Editor.EditorModule.DockModule.TabModule.ElementBayBody extends Editor.EditorModule.DockModule.TabModule.BayBody
\r