show number of facet values after submit button
[MojoFacets.git] / templates / all_checkboxes.html.ep
1 <a id="all"  href="#">all</a>
2 <a id="none" href="#">none</a>
3
4 <input type=text name=filter_regex>
5 <a id="included" href="#">included</a>
6 <a id="excluded" href="#">excluded</a>
7
8
9 <script type="text/javascript">
10
11 $('a#all').click( function(){
12     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
13 });
14
15 $('a#none').click( function(){
16     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', false);
17 });
18
19 $('a#included').click( function(){
20     $("label.included input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
21 }).hide();
22
23 $('a#excluded').click( function(){
24     $("label.excluded input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
25 }).hide();
26
27 $('input[name=filter_regex]').change( function(e) {
28         console.debug( this, e );
29         var r = new RegExp( this.value ,'i');
30         var included = 0;
31         var excluded = 0;
32     $("input[type='checkbox']:not([disabled='disabled'])").each( function(i,element){
33                 if ( r.test( this.value ) ) {
34                         $(this).parent().removeClass('excluded').addClass('included');
35                         included++;
36                 } else {
37                         $(this).parent().removeClass('included').addClass('excluded');
38                         excluded++;
39                 }
40         });
41
42         $('a#included').text('+' + included).show();
43         $('a#excluded').text('-' + excluded).show();
44 });
45
46 </script>
47