root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / glafkopis.js @ 5b99bf0a
History | View | Annotate | Download (3.1 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 |
placementByUser(); |
79 |
|
80 |
}); |
81 |
|
82 |
|
83 |
function checkAction(checkbox) { |
84 |
var otherChecked = checkbox.closest('li').siblings('li').find('span.checkbox-checked').length; |
85 |
if(otherChecked!=0){ |
86 |
checkbox.toggleClass('checkbox-checked');
|
87 |
if(checkbox.hasClass('checkbox-checked')){ |
88 |
checkbox.html('b');
|
89 |
|
90 |
} |
91 |
else{
|
92 |
|
93 |
checkbox.html('a');
|
94 |
} |
95 |
} |
96 |
else{
|
97 |
console.log('Dn kanw tpt!');
|
98 |
} |
99 |
} |
100 |
|
101 |
function placementByUser() { |
102 |
$( ".sortable" ).sortable({ |
103 |
items: "> li:not(:last)", |
104 |
stop: function(event, ui) { |
105 |
$.map($(this).find('li'), function(el) { |
106 |
return $(el).attr('data-order', $(el).index()); |
107 |
}); |
108 |
} |
109 |
}); |
110 |
$( ".sortable" ).disableSelection(); //i think unnecessary |
111 |
} |
112 |
|