root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / common.js @ c9655064
History | View | Annotate | Download (4.9 kB)
1 |
ui = {}; |
---|---|
2 |
|
3 |
|
4 |
ui.closeDiv = function(closeEl, divToCloseClass) { |
5 |
closeEl.click(function(e){
|
6 |
e.preventDefault(); |
7 |
$(this).parents(divToCloseClass).slideUp('slow'); |
8 |
}); |
9 |
} |
10 |
|
11 |
|
12 |
// set lt-sidebar height
|
13 |
ui.setSidebarHeight = function(){ |
14 |
var WindowHeight = $(window).height(); |
15 |
var h1= WindowHeight - $('.header').outerHeight(); |
16 |
var h2= $('.main.details').outerHeight(); |
17 |
if (h2>h1) {
|
18 |
var ltSidebarHeight = h2;
|
19 |
} else {
|
20 |
var ltSidebarHeight = h1;
|
21 |
} |
22 |
$('.lt-sidebar').height(ltSidebarHeight); |
23 |
} |
24 |
|
25 |
ui.cntCheckbox = function(){ |
26 |
var all = $('.checkbox-checked').length; |
27 |
var running = $('.checkbox-checked').parents('.container').find('.img.running').length; |
28 |
var stopped = $('.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 |
|
51 |
ui.setCheckedVMBgColor = function(){ |
52 |
console.log('test');
|
53 |
if ($('.check span').length >0) { |
54 |
$('.more_checkbox .checkbox-checked').parents('.container').addClass('set-bg'); |
55 |
} else {
|
56 |
$('.more_checkbox').parents('.container').removeClass('set-bg'); |
57 |
} |
58 |
|
59 |
} |
60 |
|
61 |
|
62 |
ui.VMactionsInit = function(){ |
63 |
|
64 |
// if VM is stopped hide connect option
|
65 |
$('.vms .container .stopped').parents('.container').find('.options .connect').hide(); |
66 |
|
67 |
$('.vms li .container').mouseenter( |
68 |
function (e) {
|
69 |
$(this).find('.img').stop(true, true).fadeOut({ |
70 |
'duration':200, |
71 |
}); |
72 |
$(this).find('.options, .check').stop(true, true).addClass('active'); |
73 |
$(this).find('.options').stop(true, true).fadeIn(500); |
74 |
$(this).stop(true, true).addClass('set-border'); |
75 |
$(this).find('.visible-info em').stop(true, true).each(function(){ |
76 |
var emLeft = $(this).position(); |
77 |
$(this).animate({ |
78 |
left: -emLeft.left,
|
79 |
}, 300);
|
80 |
}) |
81 |
} |
82 |
); |
83 |
|
84 |
$('.vms li .container').mouseleave( |
85 |
function(e){
|
86 |
$(this).stop(true, true).removeClass('set-border'); |
87 |
$(this).find('.options').stop(true, true).fadeOut(200); |
88 |
$(this).find('.img').stop(true, true).fadeIn('slow'); |
89 |
$(this).find('.custom_checkbox:not(.checkbox-checked)').parents('.check').stop(true, true).removeClass('active'); |
90 |
$(this).find('.visible-info em').stop(true, true).each(function(){ |
91 |
$(this).removeAttr('style'); |
92 |
}) |
93 |
} |
94 |
); |
95 |
|
96 |
$('.vms .container .check').click(function(e){ |
97 |
e.preventDefault(); |
98 |
|
99 |
var checkbox = $(this).find('.custom_checkbox'); |
100 |
|
101 |
checkbox.toggleClass('checkbox-checked');
|
102 |
|
103 |
if(checkbox.hasClass('checkbox-checked')){ |
104 |
checkbox.html('b');
|
105 |
$(this).parents('.container').addClass('set-bg'); |
106 |
$(this).addClass('active'); |
107 |
} |
108 |
else{
|
109 |
checkbox.html('a');
|
110 |
$(this).parents('.container').removeClass('set-bg'); |
111 |
$(this).removeClass('active'); |
112 |
|
113 |
} |
114 |
|
115 |
// in any case, hide extra options and reset positions to normal
|
116 |
$(this).parents('.container').removeClass('set-border'); |
117 |
$(this).parents('.container').find('.img').fadeIn(200); |
118 |
$(this).parents('.container').find('.options').hide(); |
119 |
$(this).parents('.container').find('.visible-info em').removeAttr('style'); |
120 |
|
121 |
ui.cntCheckbox(); |
122 |
}) |
123 |
|
124 |
} |
125 |
|
126 |
|
127 |
$(document).ready(function(){ |
128 |
|
129 |
ui.closeDiv($('.info .close'), '.info'); |
130 |
ui.closeDiv($('.dummy-navigation .close'), '.dummy-navigation'); |
131 |
|
132 |
$('.dummy-navigation .our').click(function(e){ |
133 |
e.preventDefault(); |
134 |
$('.ours.'+$(this).data('our')).toggle(); |
135 |
$(this).toggleClass('open'); |
136 |
}); |
137 |
|
138 |
ui.setSidebarHeight(); |
139 |
$('.select-os li').click(function(e){ |
140 |
$('.select-os li').removeClass('selected'); |
141 |
$(this).addClass('selected'); |
142 |
}) |
143 |
|
144 |
|
145 |
if ($('.overlay').length >0 ){ |
146 |
$('body').addClass('with-overlay'); |
147 |
} |
148 |
|
149 |
$('.new-btn a.current').click(function(e){ |
150 |
e.preventDefault(); |
151 |
}) |
152 |
|
153 |
ui.VMactionsInit(); |
154 |
|
155 |
$('.main-actions li a').click(function(e){ |
156 |
if (!($(this).hasClass('active'))) { |
157 |
e.preventDefault(); |
158 |
} |
159 |
}) |
160 |
|
161 |
}) |
162 |
|
163 |
$(window).resize(function(e){ |
164 |
ui.setSidebarHeight(); |
165 |
|
166 |
}) |