remove javascript positioning of regex filter hint
[MojoFacets.git] / templates / all_checkboxes.html.ep
1 <span id=column_selection>
2 <a id="all"  href="#">all</a>
3 <a id="toggle" href="#">toggle</a>
4 <a id="none" href="#">none</a>
5
6 <label for=filter_regex>regex:
7 <input type=text name=filter_regex>
8 <span class=hint>tab or click outside to apply</span>
9 <a id="included" href="#" style="display:none">included</a>
10 <a id="excluded" href="#" style="display:none">excluded</a>
11 </label>
12 </span>
13
14
15 <script type="text/javascript">
16
17 $(document).ready( function(){
18
19 $('a#all').click( function(){
20     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
21          $('#checked-count').text( $('#facet-count').text() );
22 });
23
24 $('a#none').click( function(){
25     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', false);
26         $('#checked-count').text( 0 );
27 });
28
29 $('a#toggle').click( function(){
30         var count = 0;
31     $("input[type='checkbox']:not([disabled='disabled'])").each( function() {
32                 this.checked = ! this.checked;
33                 if ( this.checked ) count++;
34         });
35         $('#checked-count').text( count );
36 });
37
38 function update_checked_count(full) {
39         var count = $('#checked-count');
40         var nr = -1;
41         if ( full ) {
42                 nr = $("label input[type='checkbox']:checked").length;
43         } else {
44                 nr = parseInt( count.text() );
45                 if ( this.checked ) {
46                         nr++;
47                 } else {
48                         nr--;
49                 }
50         }
51         count.text( nr );
52 }
53
54 $("input[type='checkbox']").bind( 'click', update_checked_count );
55
56 var toggle_checkbox = function() {
57                 this.checked = ! this.checked;
58 };
59
60 $('a#included').click( function(){
61     $("label.included input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox );
62         update_checked_count(1);
63 });
64
65 $('a#excluded').click( function(){
66     $("label.excluded input[type='checkbox']:not([disabled='disabled'])").each( toggle_checkbox );
67         update_checked_count(1);
68 });
69
70 $('input[name=filter_regex]').focusout( function(e) {
71         console.debug( this, e );
72         var r = new RegExp( this.value ,'i');
73         var included = 0;
74         var excluded = 0;
75     $("input[type='checkbox']:not([disabled='disabled'])").each( function(i,element){
76                 if ( r.test( this.value ) ) {
77                         $(this).parent().removeClass('excluded').addClass('included');
78                         included++;
79                 } else {
80                         $(this).parent().removeClass('included').addClass('excluded');
81                         excluded++;
82                 }
83         });
84
85         $('a#included').text(included).show();
86         $('a#excluded').text(excluded).show();
87 });
88
89 update_checked_count(1);
90
91 }); // document.ready
92
93 </script>
94