Index: trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.value-filter.js |
— | — | @@ -18,39 +18,53 @@ |
19 | 19 | |
20 | 20 | var values = filtered.data('ext.srf.filtered')['values']; |
21 | 21 | var selectedInputs = filtercontrols.children('div.filtered-value-option').children('input:checked'); |
| 22 | + |
| 23 | + // show all if no value is checked |
| 24 | + if ( selectedInputs.length == 0 ) { |
| 25 | + for ( i in values ) { |
| 26 | + filtered.filtered( 'voteItemVisibilityAndUpdate', { |
| 27 | + 'filter': 'value', |
| 28 | + 'printout' : target, |
| 29 | + 'visible': true, |
| 30 | + 'item': i |
| 31 | + }); |
| 32 | + } |
22 | 33 | |
23 | | - for ( i in values ) { |
24 | | - |
25 | | - var printoutValues = values[i]['printouts'][target]['values']; |
26 | | - var useOr = filtered.filtered( 'getFilterData', {filter: 'value', printout: target, configvar: 'use or'} ); |
27 | | - |
28 | | - if ( useOr ) { |
29 | | - var selected = false; |
| 34 | + } else { |
| 35 | + |
| 36 | + for ( i in values ) { |
30 | 37 | |
31 | | - for ( var j in printoutValues ) { |
| 38 | + var printoutValues = values[i]['printouts'][target]['values']; |
| 39 | + var useOr = filtered.filtered( 'getFilterData', {filter: 'value', printout: target, configvar: 'use or'} ); |
32 | 40 | |
33 | | - selectedInputs.each(function(){ |
34 | | - selected = selected || ( printoutValues[j] == $(this).attr('value') ); |
35 | | - }); |
| 41 | + if ( useOr ) { |
| 42 | + var selected = false; |
| 43 | + |
| 44 | + for ( var j in printoutValues ) { |
| 45 | + |
| 46 | + selectedInputs.each(function(){ |
| 47 | + selected = selected || ( printoutValues[j] == $(this).attr('value') ); |
| 48 | + }); |
| 49 | + } |
| 50 | + } else { |
| 51 | + var selected = true; |
| 52 | + |
| 53 | + for ( var j in printoutValues ) { |
| 54 | + |
| 55 | + selectedInputs.each(function(){ |
| 56 | + selected = selected && ( printoutValues[j] == $(this).attr('value') ); |
| 57 | + }); |
| 58 | + } |
36 | 59 | } |
37 | | - } else { |
38 | | - var selected = true; |
39 | 60 | |
40 | | - for ( var j in printoutValues ) { |
| 61 | + filtered.filtered( 'voteItemVisibilityAndUpdate', { |
| 62 | + 'filter': 'value', |
| 63 | + 'printout' : target, |
| 64 | + 'visible': selected, |
| 65 | + 'item': i |
| 66 | + }); |
41 | 67 | |
42 | | - selectedInputs.each(function(){ |
43 | | - selected = selected && ( printoutValues[j] == $(this).attr('value') ); |
44 | | - }); |
45 | | - } |
46 | 68 | } |
47 | | - |
48 | | - filtered.filtered( 'voteItemVisibilityAndUpdate', { |
49 | | - 'filter': 'value', |
50 | | - 'printout' : target, |
51 | | - 'visible': selected, |
52 | | - 'item': i |
53 | | - }); |
54 | | - |
55 | 69 | } |
56 | 70 | } |
57 | 71 | |
— | — | @@ -75,7 +89,7 @@ |
76 | 90 | filtered.filtered( 'voteItemVisibility', { |
77 | 91 | 'filter': 'value', |
78 | 92 | 'printout' : target, |
79 | | - 'visible': printoutValues.length > 0, |
| 93 | + 'visible': true, |
80 | 94 | 'item': i |
81 | 95 | }); |
82 | 96 | } |
— | — | @@ -107,7 +121,7 @@ |
108 | 122 | andControl |
109 | 123 | .add( orControl ) |
110 | 124 | .change(function() { |
111 | | - filtered.filtered( 'setFilterData', {filter: 'value', printout: target, configvar: 'use or', configvalue: orControl.is(':checked') } ); |
| 125 | + filtered.filtered( 'setFilterData', {filter: 'value', printout: target, configvar: 'use or', configvalue: orControl.is(':checked')} ); |
112 | 126 | update( filtered, filtercontrols, target ); |
113 | 127 | }); |
114 | 128 | |
— | — | @@ -134,7 +148,7 @@ |
135 | 149 | // TODO: Do we need to wrap these in a form? |
136 | 150 | for ( var j in sortedDistinctValues ) { |
137 | 151 | var option = $('<div class="filtered-value-option">'); |
138 | | - var checkbox = $('<input type="checkbox" class="filtered-value-value" value="' + sortedDistinctValues[j] + '" checked >'); |
| 152 | + var checkbox = $('<input type="checkbox" class="filtered-value-value" value="' + sortedDistinctValues[j] + '" >'); |
139 | 153 | |
140 | 154 | // attach event handler |
141 | 155 | checkbox.change(function( evt ){ |