comment out debug
[MojoFacets.git] / templates / all_checkboxes.html.ep
index 0e034d3..1300336 100644 (file)
@@ -1,27 +1,60 @@
 <a id="all"  href="#">all</a>
 <a id="none" href="#">none</a>
 
+<label for=filter_regex>regex:
 <input type=text name=filter_regex>
+<span class=hint>tab or click outside to apply</span>
 <a id="included" href="#">included</a>
 <a id="excluded" href="#">excluded</a>
+</label>
 
 
 <script type="text/javascript">
 
+$(document).ready( function(){
+
+$('label span.hint').position({
+       my: 'left bottom',
+       at: 'left top',
+       of: $('label input'),
+});
+
 $('a#all').click( function(){
     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
+        $('#checked-count').text( $('#facet-count').text() );
 });
 
 $('a#none').click( function(){
     $("input[type='checkbox']:not([disabled='disabled'])").attr('checked', false);
+       $('#checked-count').text( 0 );
 });
 
+function update_checked_count(full) {
+       var count = $('#checked-count');
+       var nr = -1;
+       if ( full ) {
+               nr = $("label input[type='checkbox']:checked").length;
+       } else {
+               nr = parseInt( count.text() );
+               if ( this.checked ) {
+                       nr++;
+               } else {
+                       nr--;
+               }
+       }
+       count.text( nr );
+}
+
+$("input[type='checkbox']").bind( 'click', update_checked_count );
+
 $('a#included').click( function(){
     $("label.included input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
+       update_checked_count(1);
 }).hide();
 
 $('a#excluded').click( function(){
     $("label.excluded input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
+       update_checked_count(1);
 }).hide();
 
 $('input[name=filter_regex]').change( function(e) {
@@ -39,9 +72,13 @@ $('input[name=filter_regex]').change( function(e) {
                }
        });
 
-       $('a#included').text('+' + included).show();
-       $('a#excluded').text('-' + excluded).show();
+       $('a#included').text(included).show();
+       $('a#excluded').text(excluded).show();
 });
 
+update_checked_count(1);
+
+}); // document.ready
+
 </script>