Show More
@@ -83,6 +83,7 function(WidgetManager, _, Backbone){ | |||||
83 | break; |
|
83 | break; | |
84 | case 'display': |
|
84 | case 'display': | |
85 | this.widget_manager.display_view(msg, this); |
|
85 | this.widget_manager.display_view(msg, this); | |
|
86 | this.trigger('displayed'); | |||
86 | break; |
|
87 | break; | |
87 | } |
|
88 | } | |
88 | }, |
|
89 | }, |
@@ -35,16 +35,21 define(["widgets/js/widget"], function(WidgetManager){ | |||||
35 | this.model.on('change:_titles', function(model, value, options) { |
|
35 | this.model.on('change:_titles', function(model, value, options) { | |
36 | this.update_titles(value); |
|
36 | this.update_titles(value); | |
37 | }, this); |
|
37 | }, this); | |
|
38 | this.model.on('displayed', function() { | |||
|
39 | this.update_titles(); | |||
|
40 | }, this); | |||
38 | }, |
|
41 | }, | |
39 |
|
42 | |||
40 | update_titles: function(titles) { |
|
43 | update_titles: function(titles) { | |
41 | // Set tab titles |
|
44 | // Set tab titles | |
|
45 | if (!titles) { | |||
|
46 | titles = this.model.get('_titles'); | |||
|
47 | } | |||
|
48 | ||||
42 | var that = this; |
|
49 | var that = this; | |
43 | console.log('update titles'); |
|
|||
44 | _.each(titles, function(title, page_index) { |
|
50 | _.each(titles, function(title, page_index) { | |
45 | var accordian = that.containers[page_index]; |
|
51 | var accordian = that.containers[page_index]; | |
46 | if (accordian !== undefined) { |
|
52 | if (accordian !== undefined) { | |
47 | console.log('setting child title'); |
|
|||
48 | accordian |
|
53 | accordian | |
49 | .find('.accordion-heading') |
|
54 | .find('.accordion-heading') | |
50 | .find('.accordion-toggle') |
|
55 | .find('.accordion-toggle') | |
@@ -56,9 +61,7 define(["widgets/js/widget"], function(WidgetManager){ | |||||
56 | update_selected_index: function(old_index, new_index, options) { |
|
61 | update_selected_index: function(old_index, new_index, options) { | |
57 | // Only update the selection if the selection wasn't triggered |
|
62 | // Only update the selection if the selection wasn't triggered | |
58 | // by the front-end. It must be triggered by the back-end. |
|
63 | // by the front-end. It must be triggered by the back-end. | |
59 | console.log('try update selected_index'); |
|
|||
60 | if (options === undefined || options.updated_view != this) { |
|
64 | if (options === undefined || options.updated_view != this) { | |
61 | console.log('update selected_index'); |
|
|||
62 | this.containers[old_index].find('.accordion-body').collapse('hide'); |
|
65 | this.containers[old_index].find('.accordion-body').collapse('hide'); | |
63 | if (0 <= new_index && new_index < this.containers.length) { |
|
66 | if (0 <= new_index && new_index < this.containers.length) { | |
64 | this.containers[new_index].find('.accordion-body').collapse('show'); |
|
67 | this.containers[new_index].find('.accordion-body').collapse('show'); | |
@@ -75,7 +78,6 define(["widgets/js/widget"], function(WidgetManager){ | |||||
75 | }, |
|
78 | }, | |
76 |
|
79 | |||
77 | remove_child_model: function(model) { |
|
80 | remove_child_model: function(model) { | |
78 | console.log('rm child'); |
|
|||
79 | // Called when a child is removed from children list. |
|
81 | // Called when a child is removed from children list. | |
80 | var accordion_group = this.model_containers[model.id]; |
|
82 | var accordion_group = this.model_containers[model.id]; | |
81 | this.containers.splice(accordion_group.container_index, 1); |
|
83 | this.containers.splice(accordion_group.container_index, 1); | |
@@ -85,7 +87,6 define(["widgets/js/widget"], function(WidgetManager){ | |||||
85 | }, |
|
87 | }, | |
86 |
|
88 | |||
87 | add_child_model: function(model) { |
|
89 | add_child_model: function(model) { | |
88 | console.log('add child'); |
|
|||
89 | // Called when a child is added to children list. |
|
90 | // Called when a child is added to children list. | |
90 | var view = this.create_child_view(model); |
|
91 | var view = this.create_child_view(model); | |
91 | var index = this.containers.length; |
|
92 | var index = this.containers.length; | |
@@ -123,12 +124,7 define(["widgets/js/widget"], function(WidgetManager){ | |||||
123 | accordion_inner.append(view.$el); |
|
124 | accordion_inner.append(view.$el); | |
124 |
|
125 | |||
125 | this.update(); |
|
126 | this.update(); | |
126 |
|
127 | this.update_titles(); | ||
127 | // // Stupid workaround to close the bootstrap accordion tabs which |
|
|||
128 | // // open by default even though they don't have the `in` class |
|
|||
129 | // // attached to them. For some reason a delay is required. |
|
|||
130 | // // TODO: Better fix. |
|
|||
131 | // setTimeout(function(){ that.update(); }, 500); |
|
|||
132 | }, |
|
128 | }, | |
133 | }); |
|
129 | }); | |
134 | WidgetManager.register_widget_view('AccordionView', AccordionView); |
|
130 | WidgetManager.register_widget_view('AccordionView', AccordionView); |
General Comments 0
You need to be logged in to leave comments.
Login now