Revision 365af933 snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_icon_view.js

b/snf-cyclades-app/synnefo/ui/static/snf/js/ui/web/ui_icon_view.js
127 127
            this.view = view;
128 128
            this.vm_view = this.view.vm(vm);
129 129
            
130
            this.info_link = $(".toggler", this.vm_view);
131
            this.info_el = $("div.info-content", this.vm_view);
132
            this.details_toggler = $(".toggler", this.vm_view);
130
            this.info_toggle = $(".cont-toggler-wrapper.info .toggler", this.vm_view);
131
            this.ips_toggle = $(".cont-toggler-wrapper.ips .toggler", this.vm_view);
132
            this.info_el = $("div.info-content.vm-info", this.vm_view);
133
            this.ips_el = $("div.info-content.ips", this.vm_view);
133 134
            this.label = $(".label", this.vm_view);
134 135

  
135 136
            this.set_handlers();
136 137
        },
137 138

  
138 139
        set_handlers: function() {
139
            this.info_link.click(_.bind(function(){
140
            this.info_toggle.click(_.bind(function(){
141
                this.ips_el.slideUp();
142
                this.ips_toggle.removeClass("open");
143

  
140 144
                this.info_el.slideToggle();
141 145
                this.view.vm(this.vm).toggleClass("light-background");
142 146

  
143
                if (this.details_toggler.hasClass("open")) {
144
                    this.details_toggler.removeClass("open");
147
                if (this.info_toggle.hasClass("open")) {
148
                    this.info_toggle.removeClass("open");
145 149
                    this.vm.stop_stats_update();
146 150
                } else {
147
                    this.details_toggler.addClass("open");
151
                    this.info_toggle.addClass("open");
148 152
                    this.view.details_views[this.vm.id].update_layout();
149 153
                    this.view.tags_views[this.vm.id].update_layout();
150 154
                    this.view.stats_views[this.vm.id].update_layout();
......
154 158
                window.setTimeout(function() {$(self.view).trigger("resize")}, 300);
155 159
            }, this));
156 160

  
161
            this.ips_toggle.click(_.bind(function(){
162
                this.info_el.slideUp();
163
                this.info_toggle.removeClass("open");
164

  
165
                this.ips_el.slideToggle();
166
                this.view.vm(this.vm).toggleClass("light-background");
167
                var self = this;
168
                if (this.ips_toggle.hasClass("open")) {
169
                    this.ips_toggle.removeClass("open");
170
                } else {
171
                    this.ips_toggle.addClass("open");
172
                }
173
                window.setTimeout(function() {$(self.view).trigger("resize")}, 300);
174
            }, this));
175

  
176

  
157 177
            this.$(".stats-report").click(_.bind(function(e){
158 178
                e.preventDefault();
159 179
                snf.ui.main.show_vm_details(this.vm);
......
416 436
                this.parent.metadata_view.show(this.vm);
417 437
            }, this));
418 438

  
419
            // tags have show/hide control ? bind events for them
439
            // tags/ips have show/hide control ? bind events for them
420 440
            var self = this;
421 441
            if (this.toggle) {
422 442
                $(this.el).find(".tags-header").click(_.bind(function(){
423 443
                    $(self.el).find(".tags-content").slideToggle(600);
424
                    var details_toggler = $(this.el).find(".tags-header .cont-toggler");
444

  
445
                    var details_toggler = $(this.el).find(".tags-header " +
446
                                                          ".cont-toggler.info");
447
                    var ips_toggler = $(this.el).find(".tags-header " +
448
                                                      ".cont-toggler.ips");
425 449
                    
426 450
                    if (details_toggler.hasClass("open")) {
427 451
                        details_toggler.removeClass("open");
428 452
                    } else {
429 453
                        details_toggler.addClass("open");
430 454
                    }
455

  
456
                    if (ips_toggler.hasClass("open")) {
457
                        ips_toggler.removeClass("open");
458
                    } else {
459
                        ips_toggler.addClass("open");
460
                    }
431 461
                }, this));
432 462
                $(self.el).find(".tags-content").hide();
433 463
            }
......
716 746
            this.info_views = this.info_views || {};
717 747
            this.action_error_views = this.action_error_views || {};
718 748
            this.action_views = this.action_views || {};
749
            this.ports_views = this.ports_views || {};
719 750

  
720 751
            this.action_views[vm.id] = new views.VMActionsView(vm, this, this.vm(vm), this.hide_actions);
721 752
            this.rename_views[vm.id] = new views.IconRenameView(vm, this);
......
723 754
            this.connect_views[vm.id] = new views.IconVMConnectView(vm, this);
724 755
            this.tags_views[vm.id] = new views.VMTagsView(vm, this);
725 756
            this.details_views[vm.id] = new views.VMDetailsView(vm, this);
726
            this.info_views[vm.id] = new views.IconInfoView(vm, this);
727 757
            this.action_error_views[vm.id] = new views.VMActionErrorView(vm, this);
758
            
759
            var ports_container = this.vm(vm).find(".machine-data");
760
            var ports_view = new views.VMPortListView({
761
              collection: vm.ports, 
762
              container: ports_container,
763
              parent: this
764
            });
765
            this.ports_views[vm.id] = ports_view
766
            ports_view.show();
767
            ports_view.el.hide();
768

  
769
            this.info_views[vm.id] = new views.IconInfoView(vm, this);
728 770
        },
729 771
        
730 772
        // vm specific event handlers

Also available in: Unified diff