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