X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=templates%2Fall_checkboxes.html.ep;h=262c84726a6e63c34762305cc03de08d99e17c04;hb=add6d343a92cd01879d1d822bf78bb9a4a3ae8ff;hp=11cfbe90bb5cb32bc79095301ce27b99a8b4f2bb;hpb=ce74603c028f03f54f9ff4c7e9a88903c66a477b;p=MojoFacets.git
diff --git a/templates/all_checkboxes.html.ep b/templates/all_checkboxes.html.ep
index 11cfbe9..262c847 100644
--- a/templates/all_checkboxes.html.ep
+++ b/templates/all_checkboxes.html.ep
@@ -1,11 +1,12 @@
all
+toggle
none
@@ -26,28 +27,47 @@ $('a#all').click( function(){
$('a#none').click( function(){
$("input[type='checkbox']:not([disabled='disabled'])").attr('checked', false);
- $('#checked-count').text( '-' );
+ $('#checked-count').text( 0 );
});
-$('a#included').click( function(){
+$('a#toggle').click( function(){
var count = 0;
- $("label.included input[type='checkbox']:not([disabled='disabled'])").each( function() {
- this.checked = true;
- count++;
+ $("input[type='checkbox']:not([disabled='disabled'])").each( function() {
+ this.checked = ! this.checked;
+ if ( this.checked ) count++;
});
$('#checked-count').text( count );
-}).hide();
+});
+
+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);
+});
$('a#excluded').click( function(){
- var count = 0;
- $("label.excluded input[type='checkbox']:not([disabled='disabled'])").each( function() {
- this.checked = true;
- count++;
- });
- $('#checked-count').text( count );
-}).hide();
+ $("label.excluded input[type='checkbox']:not([disabled='disabled'])").attr('checked', true);
+ update_checked_count(1);
+});
-$('input[name=filter_regex]').change( function(e) {
+$('input[name=filter_regex]').focusout( function(e) {
console.debug( this, e );
var r = new RegExp( this.value ,'i');
var included = 0;
@@ -62,10 +82,12 @@ $('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