7 * Vider completement la selection
9 actiongroup
.emptySelection = function(){
10 actiongroup
.checkedItems
={};
11 actiongroup
.countchecked
=0;
12 actiongroup
.unselectAll();
15 * Selectionner les items de la page
17 actiongroup
.selectAll = function(sel
){
18 sel
= sel
|| document
;
19 $('input.actiongroup',sel
)
22 actiongroup
.updateChecklist($(this).attr('value'),true,false);
24 actiongroup
.updateChecklist(0,false);
27 * Deselectionner les items de la page
29 actiongroup
.unselectAll = function(sel
){
30 sel
= sel
|| document
;
31 $('input.actiongroup',sel
)
32 .attr('checked',false)
34 actiongroup
.updateChecklist($(this).attr('value'),false,false);
36 actiongroup
.updateChecklist(0,false);
39 * Mettre a jour la listes des donnees et la boite html #actiongroup
43 * @param bool|void update_status
45 actiongroup
.updateChecklist = function(value
,checked
,update_status
){
46 if (checked
&& !(actiongroup
.checkedItems
[value
] || false))
47 actiongroup
.countchecked
++;
48 if (!checked
&& (actiongroup
.checkedItems
[value
] || false))
49 actiongroup
.countchecked
--;
50 actiongroup
.checkedItems
[value
]=checked
;
51 if (update_status
|| typeof update_status
=="undefined") {
52 jQuery
.spip
.log(actiongroup
.countchecked
);
53 if (actiongroup
.countchecked
==0){
54 $('#actiongroup .shortcut.empty,#actiongroup .shortcut.unselectall')
56 $('#actiongroup .shortcut.selectall')
57 .removeClass('hidden');
58 $('#actiongroup .status .zero')
62 $('#actiongroup .action')
64 if ($(".checkable").length
)
65 $('#actiongroup').closest('.box:hidden').show('fast');
67 $('#actiongroup').closest('.box:visible').hide('fast');
70 $('#actiongroup .action')
71 .removeClass('hidden');
72 if (actiongroup
.countchecked
==1)
73 $('#actiongroup .status .one')
78 $('#actiongroup .status .many b')
79 .html(actiongroup
.countchecked
);
80 $('#actiongroup .status .many')
85 var checked
= $('input.actiongroup:checked').length
;
87 $('#actiongroup .shortcut.unselectall')
88 .removeClass('hidden');
90 $('#actiongroup .shortcut.unselectall')
92 if (actiongroup
.countchecked
>checked
)
93 $('#actiongroup .shortcut.empty')
94 .removeClass('hidden');
96 $('#actiongroup .shortcut.empty')
98 if (actiongroup
.countCurrent
>checked
)
99 $('#actiongroup .shortcut.selectall')
100 .removeClass('hidden');
102 $('#actiongroup .shortcut.selectall')
106 .siblings('.success:visible')
111 * Remettre a jour les checkbox du html a partir de la liste en memoire
112 * apres un chargement ajax par exemple
114 actiongroup
.updateHtmlFromChecklist = function(){
115 actiongroup
.countCurrent
= $('input.actiongroup')
118 .attr('checked',actiongroup
.checkedItems
[$(this).attr('value')] || false);
121 // forcer la mise a jour des messages
122 actiongroup
.updateChecklist(0,false);
125 * Activer le traitement par lot sur une liste d'items
129 actiongroup
.activate = function(sel
){
133 var id
= parseInt($(this).attr('data-id'));
136 .append("<input type='checkbox' name='actiongroup[]' class='actiongroup checkbox' value='"+id
+"'/>");
139 var check
= $('input.actiongroup',this);
141 .prop('checked',!check
.prop('checked'))
144 .addClass('checkable')
145 .find('input.actiongroup, form, a')
149 .filter('input.actiongroup')
151 actiongroup
.updateChecklist($(this).attr('value'),$(this).prop('checked'));
154 $('#actiongroup .action')
157 var href
=$(this).attr('data-href');
159 for(var id
in actiongroup
.checkedItems
)
160 if (actiongroup
.checkedItems
[id
])
162 jQuery
.spip
.log(href
);
163 jQuery
.spip
.log(ids
);
164 if (href
&& ids
.length
) {
166 .siblings('.success')
175 // vider le cache car on a fait une operation en base
176 jQuery
.spip
.preloaded_urls
= {};
177 // recharger le bloc de la selection
178 $(sel
).eq(0).ajaxReload();
179 actiongroup
.checkedItems
={};
180 actiongroup
.countchecked
=0;
181 actiongroup
.countCurrent
=0;
182 actiongroup
.updateChecklist(0,false);
184 .css('opacity','1.0')
186 .css('opacity','1.0')
189 .parent().find('.image_loading').remove();
194 actiongroup
.updateHtmlFromChecklist();