0e46343668d7ea8c343472dc71f4c268f42f1c82
[MojoFacets.git] / templates / all_checkboxes.html.ep
1 <a id="all"  href="#">all</a>
2 <a id="none" href="#">none</a>
3
4 <label for=filter_regex>regex:
5 <input type=text name=filter_regex>
6 <span class=hint>tab or click outside to apply</span>
7 <a id="included" href="#">included</a>
8 <a id="excluded" href="#">excluded</a>
9 </label>
10
11
12 <script type="text/javascript">
13
14 $(document).ready( function(){
15
16 $('label span.hint').position({
17         my: 'left bottom',
18         at: 'left top',
19         of: $('label input'),
20 });
21
22 $('a#all').click( function(){
23     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
24 });
25
26 $('a#none').click( function(){
27     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', false);
28 });
29
30 $('a#included').click( function(){
31     $("label.included input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
32 }).hide();
33
34 $('a#excluded').click( function(){
35     $("label.excluded input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
36 }).hide();
37
38 $('input[name=filter_regex]').change( function(e) {
39         console.debug( this, e );
40         var r = new RegExp( this.value ,'i');
41         var included = 0;
42         var excluded = 0;
43     $("input[type='checkbox']:not([disabled='disabled'])").each( function(i,element){
44                 if ( r.test( this.value ) ) {
45                         $(this).parent().removeClass('excluded').addClass('included');
46                         included++;
47                 } else {
48                         $(this).parent().removeClass('included').addClass('excluded');
49                         excluded++;
50                 }
51         });
52
53         $('a#included').text('+' + included).show();
54         $('a#excluded').text('-' + excluded).show();
55 });
56
57 }); // document.ready
58
59 </script>
60