r113243 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113242‎ | r113243 | r113244 >
Date:16:19, 7 March 2012
Author:foxtrott
Status:deferred
Tags:
Comment:
turn off filtering if nothing selected
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.value-filter.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.value-filter.js
@@ -18,39 +18,53 @@
1919
2020 var values = filtered.data('ext.srf.filtered')['values'];
2121 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+ }
2233
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 ) {
3037
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'} );
3240
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+ }
3659 }
37 - } else {
38 - var selected = true;
3960
40 - for ( var j in printoutValues ) {
 61+ filtered.filtered( 'voteItemVisibilityAndUpdate', {
 62+ 'filter': 'value',
 63+ 'printout' : target,
 64+ 'visible': selected,
 65+ 'item': i
 66+ });
4167
42 - selectedInputs.each(function(){
43 - selected = selected && ( printoutValues[j] == $(this).attr('value') );
44 - });
45 - }
4668 }
47 -
48 - filtered.filtered( 'voteItemVisibilityAndUpdate', {
49 - 'filter': 'value',
50 - 'printout' : target,
51 - 'visible': selected,
52 - 'item': i
53 - });
54 -
5569 }
5670 }
5771
@@ -75,7 +89,7 @@
7690 filtered.filtered( 'voteItemVisibility', {
7791 'filter': 'value',
7892 'printout' : target,
79 - 'visible': printoutValues.length > 0,
 93+ 'visible': true,
8094 'item': i
8195 });
8296 }
@@ -107,7 +121,7 @@
108122 andControl
109123 .add( orControl )
110124 .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')} );
112126 update( filtered, filtercontrols, target );
113127 });
114128
@@ -134,7 +148,7 @@
135149 // TODO: Do we need to wrap these in a form?
136150 for ( var j in sortedDistinctValues ) {
137151 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] + '" >');
139153
140154 // attach event handler
141155 checkbox.change(function( evt ){