bc1c3de3cb9a597f691692a3dfba8b4c04451c3f
7 * Position fixe lors du scroll
9 actiongroup
.followScroll = function(){
10 var container
= $("#actiongroup").parents('.box.raccourcis');
11 var limite
= container
.offset().top
;
12 $(window
).scroll(function() {
13 if($(this).scrollTop() > limite
)
14 container
.css({'position': 'fixed', 'top': 0, 'width': container
.width()+'px'});
15 if($(this).scrollTop() < limite
)
16 container
.css({'position': 'static', 'width': 'auto'});
20 * Vider completement la selection
22 actiongroup
.emptySelection = function(){
23 actiongroup
.checkedItems
={};
24 actiongroup
.countchecked
=0;
25 actiongroup
.unselectAll();
28 * Selectionner les items de la page
30 actiongroup
.selectAll = function(sel
){
31 sel
= sel
|| document
;
32 $('input.actiongroup',sel
)
35 actiongroup
.updateChecklist($(this).attr('value'),true,false);
37 actiongroup
.updateChecklist(0,false);
40 * Deselectionner les items de la page
42 actiongroup
.unselectAll = function(sel
){
43 sel
= sel
|| document
;
44 $('input.actiongroup',sel
)
45 .prop('checked',false)
47 actiongroup
.updateChecklist($(this).attr('value'),false,false);
49 actiongroup
.updateChecklist(0,false);
52 * Mettre a jour la listes des donnees et la boite html #actiongroup
56 * @param bool|void update_status
58 actiongroup
.updateChecklist = function(value
,checked
,update_status
){
59 if (checked
&& !(actiongroup
.checkedItems
[value
] || false))
60 actiongroup
.countchecked
++;
61 if (!checked
&& (actiongroup
.checkedItems
[value
] || false))
62 actiongroup
.countchecked
--;
63 actiongroup
.checkedItems
[value
]=checked
;
64 if (update_status
|| typeof update_status
=="undefined") {
65 jQuery
.spip
.log(actiongroup
.countchecked
);
66 if (actiongroup
.countchecked
==0){
67 $('#actiongroup .shortcut.empty,#actiongroup .shortcut.unselectall')
69 $('#actiongroup .shortcut.selectall')
71 $('#actiongroup .status .zero')
75 $('#actiongroup .action')
77 if ($(".checkable").length
)
78 $('#actiongroup').closest('.box:hidden').show('fast');
80 $('#actiongroup').closest('.box:visible').hide('fast');
83 $('#actiongroup .action')
84 .removeClass('hidden');
85 if (actiongroup
.countchecked
==1)
86 $('#actiongroup .status .one')
91 $('#actiongroup .status .many b')
92 .html(actiongroup
.countchecked
);
93 $('#actiongroup .status .many')
98 var checked
= $('input.actiongroup:checked').length
;
100 $('#actiongroup .shortcut.unselectall')
101 .removeClass('none');
103 $('#actiongroup .shortcut.unselectall')
105 if (actiongroup
.countchecked
>checked
)
106 $('#actiongroup .shortcut.empty')
107 .removeClass('hidden');
109 $('#actiongroup .shortcut.empty')
111 if (actiongroup
.countCurrent
>checked
)
112 $('#actiongroup .shortcut.selectall')
113 .removeClass('none');
115 $('#actiongroup .shortcut.selectall')
119 .siblings('.success:visible')
124 * Remettre a jour les checkbox du html a partir de la liste en memoire
125 * apres un chargement ajax par exemple
127 actiongroup
.updateHtmlFromChecklist = function(){
128 actiongroup
.countCurrent
= $('input.actiongroup')
131 .prop('checked',actiongroup
.checkedItems
[$(this).attr('value')] || false);
134 // forcer la mise a jour des messages
135 actiongroup
.updateChecklist(0,false);
138 * Activer le traitement par lot sur une liste d'items
142 actiongroup
.activate = function(sel
){
146 var id
= parseInt($(this).attr('data-id'));
149 .append("<input type='checkbox' name='actiongroup[]' class='actiongroup checkbox' value='"+id
+"'/>");
152 var check
= $('input.actiongroup',this);
154 .prop('checked',!check
.prop('checked'))
157 .addClass('checkable')
158 .find('input.actiongroup, form, a')
162 .filter('input.actiongroup')
164 actiongroup
.updateChecklist($(this).attr('value'),$(this).prop('checked'));
167 $('#actiongroup .action')
170 var href
=$(this).attr('data-href');
172 for(var id
in actiongroup
.checkedItems
)
173 if (actiongroup
.checkedItems
[id
])
175 jQuery
.spip
.log(href
);
176 jQuery
.spip
.log(ids
);
177 if (href
&& ids
.length
) {
179 .siblings('.success')
188 // vider le cache car on a fait une operation en base
189 jQuery
.spip
.preloaded_urls
= {};
190 // recharger le bloc de la selection
191 $(sel
).eq(0).ajaxReload();
192 actiongroup
.checkedItems
={};
193 actiongroup
.countchecked
=0;
194 actiongroup
.countCurrent
=0;
195 actiongroup
.updateChecklist(0,false);
197 .css('opacity','1.0')
199 .css('opacity','1.0')
202 .parent().find('.image_loading').remove();
207 actiongroup
.updateHtmlFromChecklist();
208 actiongroup
.followScroll();