root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / checkboxes-radiobuttons.js @ 65635b1b
History | View | Annotate | Download (4.3 kB)
1 |
/*
|
---|---|
2 |
* functions concerning checkboxes and radiobuttons links
|
3 |
*/
|
4 |
|
5 |
|
6 |
|
7 |
ui.checkbox = { |
8 |
changeState : function(checkbox_link) { |
9 |
$(checkbox_link).find('.snf-checkbox-unchecked, .snf-checkbox-checked').toggleClass('snf-checkbox-unchecked snf-checkbox-checked'); |
10 |
$(checkbox_link).closest('li').toggleClass('selected'); |
11 |
}, |
12 |
check : function(checkbox_link) { |
13 |
$(checkbox_link).find('span').removeClass('snf-checkbox-unchecked').addClass('snf-checkbox-checked'); |
14 |
$(checkbox_link).closest('li').addClass('selected'); |
15 |
}, |
16 |
uncheck : function(checkbox_link) { |
17 |
$(checkbox_link).find('span').removeClass('snf-checkbox-checked').addClass('snf-checkbox-unchecked'); |
18 |
$(checkbox_link).closest('li').removeClass('selected'); |
19 |
}, |
20 |
|
21 |
reset: function(area) { |
22 |
$(area).find('.snf-radio-checked').not('.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
23 |
$(area).find('.snf-radio-unchecked.prechecked').toggleClass('snf-radio-checked snf-radio-unchecked'); |
24 |
} |
25 |
|
26 |
} |
27 |
|
28 |
ui.radiobtn = { |
29 |
changeState: function(radiobtn_link) { |
30 |
$(radiobtn_link).find('span.snf-radio-unchecked, span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked'); |
31 |
$(radiobtn_link).closest('li').addClass('selected'); |
32 |
}, |
33 |
obtainOneChecked : function(radiobtn_link) { |
34 |
$(radiobtn_link).closest('ul').find('li').removeClass('selected'); |
35 |
$(radiobtn_link).closest('ul').find('span.snf-radio-checked').toggleClass('snf-radio-unchecked snf-radio-checked'); |
36 |
}, |
37 |
reset : function(area) { |
38 |
$(area).find('.snf-checkbox-checked').not('.prechecked').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
39 |
$(area).find('.snf-checkbox-unchecked.prechecked').toggleClass('snf-checkbox-checked snf-checkbox-unchecked'); |
40 |
} |
41 |
|
42 |
} |
43 |
|
44 |
$(document).ready(function(){ |
45 |
|
46 |
// checkboxes binds
|
47 |
|
48 |
$('.check').click(function(e) { |
49 |
e.preventDefault(); |
50 |
e.stopPropagation(); |
51 |
ui.checkbox.changeState(this);
|
52 |
ui.entitiesActionsEnabled(); |
53 |
}); |
54 |
|
55 |
$('.lt-bar .select .check').click(function(e) { |
56 |
$(this).siblings('em').toggle(); |
57 |
if ( $(this).find('span').hasClass('snf-checkbox-unchecked')){ |
58 |
ui.checkbox.uncheck($('.list-view li:not(".not-selectable") .check')); |
59 |
} else {
|
60 |
ui.checkbox.check($('.list-view li:not(".not-selectable") .check')); |
61 |
} |
62 |
}); |
63 |
|
64 |
$('.trigger-checkbox.has-more .check').click(function(e) { |
65 |
ui.slideHiddenArea(this, $(this).parent().next('.more')); |
66 |
}); |
67 |
|
68 |
$('.dhcp-option .check').click(function(e) { |
69 |
$(this).parents('li').siblings().find('ul.subnet-options').parent('li').toggle(); |
70 |
}) |
71 |
|
72 |
// for lis that we want to change the checkbox state
|
73 |
$('.trigger-checkbox').click(function(e){ |
74 |
$(this).find('.check').trigger('click'); |
75 |
}); |
76 |
|
77 |
$('.trigger-checkbox').find('a').click(function(e){ |
78 |
e.stopPropagation(); |
79 |
}); |
80 |
|
81 |
// for checkboxes created after document.ready
|
82 |
$('.items-list').on('click','.check', function(e){ |
83 |
e.preventDefault(); |
84 |
e.stopPropagation(); |
85 |
ui.changeCheckboxState(this);
|
86 |
}); |
87 |
|
88 |
// radiobuttons binds
|
89 |
|
90 |
$('.radiobtn').click(function(e) { |
91 |
e.stopPropagation(); |
92 |
e.preventDefault(); |
93 |
if($(this).find('span').hasClass('snf-radio-unchecked')) { |
94 |
ui.radiobtn.obtainOneChecked(this);
|
95 |
ui.radiobtn.changeState(this);
|
96 |
} |
97 |
}); |
98 |
|
99 |
$('.subnet-options .radiobtn').click(function(e) { |
100 |
if($(this).closest('li').hasClass('manual')) { |
101 |
$(this).siblings('.input').show(); |
102 |
} |
103 |
else {
|
104 |
$(this).closest('li').siblings('.manual').find('.input').hide(); |
105 |
} |
106 |
}); |
107 |
|
108 |
$('.trigger-radiobtn').click(function(e) { |
109 |
$(this).find('.radiobtn').trigger('click'); |
110 |
}); |
111 |
|
112 |
$('.firewall .more .radiobtn').click(function(e){ |
113 |
$(this).parents('.firewall').removeAttr('data-firewall'); |
114 |
$(this).parents('.firewall').data('firewall', $(this).parent().attr('class')); |
115 |
ui.firewallSetup(); |
116 |
}); |
117 |
|
118 |
}) |