Revision 5e62e9c1 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js

b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
22 22
	$('.lt-sidebar').height(ltSidebarHeight);
23 23
}
24 24

  
25
ui.cntCheckbox = function(){ 
26
	var all = $('.options .checkbox-checked').length;
27
	var running = $('.options .checkbox-checked').parents('.container').find('.img.running').length;
28
	var stopped = $('.options .checkbox-checked').parents('.container').find('.img.stopped').length;
29
    $('.header .main-actions li a').removeClass('active');  
30
    if ( (running*stopped) > 0 ){          
31
         $('.header .main-actions li.both a').addClass('active');   
32
         $('.header .main-actions li.single a').removeClass('active');   
33
    } else {
34
        if (running > 0) {
35
         	$('.header .main-actions li.both a').addClass('active');   
36
         	$('.header .main-actions li.running a').addClass('active');   
37
        } else if (stopped>0) {
38
        	$('.header .main-actions li.both a').addClass('active');   
39
        	$('.header .main-actions li.stopped a').addClass('active');   
40

  
41
        } else {
42

  
43
        }
44
        if ( all > 1 ) {
45
        	$('.header .main-actions li.single a').removeClass('active');   
46
        }
47

  
48
    }
49
}
50
ui.VMactionsInit = function(){
51

  
52
	// if VM is stopped hide connect option 
53
	$('.vms li .container .stopped').parents('.container').find('.options .connect').hide();
54

  
55
	var vm_container = $('.vms li .container');
56
	var vm_img = vm_container.find('.img-wrap');
57

  
58
	vm_img.mouseenter(
59
      function (e) {
60
        $(this).parents('.container').find('.options').slideDown();
61
      }
62
    );
63

  
64
    $('li .container .options').mouseleave(
65
        function(e){
66
        	var checkbox = $(this).find('.custom_checkbox');
67

  
68
	        if (checkbox.hasClass('checkbox-checked')){
69
	            checkbox.parents('.container').find('.more_checkbox').html(checkbox.clone());
70
	            
71
	        } else {
72
	        	 checkbox.parents('.container').find('.more_checkbox').html('');
73
	        }
74
            $('li .container .options').hide();
75
            
76
            
77
        }
78
    );
79

  
80
    $('li .container .check').click(function(e){
81
        e.preventDefault();
82
        var checkbox = $(this).find('.custom_checkbox');
83

  
84
        checkbox.toggleClass('checkbox-checked');
85
        
86
        if(checkbox.hasClass('checkbox-checked')){
87
            checkbox.html('b');
88
        }
89
        else{
90
            checkbox.html('a'); 
91
      
92
        }
93
        ui.cntCheckbox();
94
    })
95
}
25 96

  
26 97

  
27 98
$(document).ready(function(){
......
55 126
		e.preventDefault();
56 127
	})
57 128

  
58
	
59

  
129
	ui.VMactionsInit();
130
	$('.main-actions li a').click(function(e){
131
		if (!($(this).hasClass('active'))) {
132
			e.preventDefault();
133
		}
134
	})
60 135

  
61 136
})
62 137

  

Also available in: Unified diff