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