root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / glafkopis.js @ 78e2d3dd
History | View | Annotate | Download (2.8 kB)
1 |
$(document).ready(function(){ |
---|---|
2 |
var select_flavor =0; |
3 |
$('.select-flavor dl span').click(function(e){ |
4 |
e.preventDefault(); |
5 |
$(this).parents('dl').find('span').removeClass('current'); |
6 |
$(this).addClass('current'); |
7 |
if(select_flavor == 1){ |
8 |
if(!$(this).parents('dl').hasClass('storage')){ |
9 |
$('.lt-sidebar').find('a.chosen_flavor').removeClass('chosen_flavor'); |
10 |
select_flavor = 0;
|
11 |
} |
12 |
} |
13 |
}); |
14 |
|
15 |
// tba: function that determines which values are included to small, medium and large flavor
|
16 |
|
17 |
// if a predefined flavor has been selected from the user, it highlights the proper resources
|
18 |
|
19 |
$('.lt-sidebar li a.flavor_selection').click(function(e){ |
20 |
e.preventDefault(); |
21 |
select_flavor = 1;
|
22 |
var classes = $(this).attr('class').split(" "); |
23 |
// the second class is: 'small_flavor' or 'medium_flavor' or 'large_flavor'
|
24 |
|
25 |
$(this).parent('li').siblings('li').find('a.chosen_flavor').removeClass('chosen_flavor'); |
26 |
$(this).addClass('chosen_flavor'); |
27 |
$('.select-flavor').find('dl.cpus span.current, dl.ram span.current, dl.disk span.current').removeClass('current'); |
28 |
$('.select-flavor').find('.'+classes[1]).addClass('current'); |
29 |
|
30 |
}); |
31 |
|
32 |
|
33 |
|
34 |
// create network
|
35 |
// checkbox: basic reaction on click (checked, unchecked)
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
$('.network_options .check').click(function(e){ |
41 |
e.preventDefault(); |
42 |
var checkbox = $(this).find('.custom_checkbox'); |
43 |
var list = $(this).closest('ul'); |
44 |
|
45 |
checkAction(checkbox); //allazw to checkbox p pataw
|
46 |
if(list.hasClass('subnet_options')){ |
47 |
checkedBefore = $(this).closest('li').siblings('li').find('span.checkbox-checked'); |
48 |
if($(checkedBefore).closest('li').find('a').hasClass('manual')) |
49 |
{ |
50 |
$(checkedBefore).closest('li').find('.manual_sub').hide(); |
51 |
} |
52 |
checkAction(checkedBefore); //allazw ta alla checkboxes
|
53 |
|
54 |
if($(this).hasClass('manual')) { |
55 |
|
56 |
if($(checkbox).text()=='a') { |
57 |
$(this).closest('span').find('.manual_sub').hide(); |
58 |
} |
59 |
else {
|
60 |
$(this).closest('span').find('.manual_sub').show(); |
61 |
} |
62 |
|
63 |
//$(this).closest('span').find('.manual_sub').toggleClass('hidden');
|
64 |
|
65 |
} |
66 |
} |
67 |
else if($(this).closest('li').hasClass('dhcp_option')) { |
68 |
if($(checkbox).text()=='a') { |
69 |
$('.network_options').find('.subnet_options').hide(); |
70 |
} |
71 |
else {
|
72 |
$('.network_options').find('.subnet_options').show(); |
73 |
} |
74 |
} |
75 |
console.log(checkbox); |
76 |
}) |
77 |
|
78 |
}); |
79 |
|
80 |
|
81 |
function checkAction(checkbox) { |
82 |
var otherChecked = checkbox.closest('li').siblings('li').find('span.checkbox-checked').length; |
83 |
if(otherChecked!=0){ |
84 |
checkbox.toggleClass('checkbox-checked');
|
85 |
if(checkbox.hasClass('checkbox-checked')){ |
86 |
checkbox.html('b');
|
87 |
|
88 |
} |
89 |
else{
|
90 |
|
91 |
checkbox.html('a');
|
92 |
} |
93 |
} |
94 |
else{
|
95 |
console.log('Dn kanw tpt!');
|
96 |
} |
97 |
} |
98 |
|