Index: trunk/extensions/SemanticResultFormats/Filtered/filters/SRF_FF_Distance.php |
— | — | @@ -165,7 +165,12 @@ |
166 | 166 | if ( array_key_exists( 'distance filter collapsible', $params ) ) { |
167 | 167 | $ret['collapsible'] = trim($params['distance filter collapsible']); |
168 | 168 | } |
| 169 | + |
| 170 | + if ( array_key_exists( 'distance filter initial value', $params ) ) { |
| 171 | + $ret['initial value'] = trim( $params['distance filter initial value'] ); |
| 172 | + } |
169 | 173 | |
| 174 | + |
170 | 175 | return $ret; |
171 | 176 | } |
172 | 177 | |
Index: trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.distance-filter.js |
— | — | @@ -16,16 +16,12 @@ |
17 | 17 | |
18 | 18 | function update( filtered, filterDistance, target ) { |
19 | 19 | |
20 | | - var values = filtered.data('ext.srf.filtered')['values']; |
| 20 | + for ( i in filtered.data('ext.srf.filtered')['values'] ) { |
21 | 21 | |
22 | | - for ( i in values ) { |
23 | | - |
24 | | - var distance = values[i]['data']['distance-filter']; |
25 | | - |
26 | 22 | filtered.filtered( 'voteItemVisibilityAndUpdate', { |
27 | 23 | 'filter': 'value', |
28 | 24 | 'printout' : target, |
29 | | - 'visible': distance <= filterDistance, |
| 25 | + 'visible': values[i]['data']['distance-filter'] <= filterDistance, |
30 | 26 | 'item': i |
31 | 27 | }); |
32 | 28 | |
— | — | @@ -36,22 +32,29 @@ |
37 | 33 | |
38 | 34 | var filtered = this; |
39 | 35 | |
40 | | - |
41 | | - |
42 | 36 | var target = args.printout; |
43 | 37 | var values = this.data('ext.srf.filtered')['values']; |
44 | 38 | var data = this.data('ext.srf.filtered')['data']['filterdata']['distance'][target]; |
45 | 39 | |
| 40 | + var iniValue = data['initial value']?data['initial value']:data['max']; |
| 41 | + |
| 42 | + for ( var i in values ) { |
| 43 | + |
| 44 | + filtered.filtered( 'voteItemVisibility', { |
| 45 | + 'filter': 'value', |
| 46 | + 'printout' : target, |
| 47 | + 'visible': values[i]['data']['distance-filter'] <= iniValue, |
| 48 | + 'item': i |
| 49 | + }); |
| 50 | + |
| 51 | + } |
| 52 | + |
46 | 53 | // build filter controls |
47 | 54 | var filtercontrols = this.children('.filtered-filters').children('.filtered-distance'); |
48 | 55 | |
49 | | - // insert the label of the printout this filter filters on |
50 | | - |
51 | | - for ( var i in values ) break; |
52 | | - |
53 | 56 | var readoutAndSlider = $('<tr>'); |
54 | 57 | |
55 | | - var readout = $('<div class="filtered-distance-readout">' + data['max'] + data['unit'] + '</div>' ); |
| 58 | + var readout = $('<div class="filtered-distance-readout">' + iniValue + data['unit'] + '</div>' ); |
56 | 59 | var slider = $('<div class="filtered-distance-slider">'); |
57 | 60 | |
58 | 61 | var readoutTD = $('<td class="filtered-distance-readout-cell">'); |
— | — | @@ -75,7 +78,7 @@ |
76 | 79 | slider.slider({ |
77 | 80 | animate: true, |
78 | 81 | max: data['max'], |
79 | | - value: data['max'], |
| 82 | + value: iniValue, |
80 | 83 | slide: function(event, ui) { |
81 | 84 | readout.empty().append( ui.value + data['unit'] ); |
82 | 85 | }, |
— | — | @@ -84,114 +87,6 @@ |
85 | 88 | } |
86 | 89 | }); |
87 | 90 | |
88 | | -// // insert the label of the printout this filter filters on |
89 | | -// filtercontrols.append('<div class="filtered-value-label"><span>' + values[i]['printouts'][target]['label'] + '</span></div>'); |
90 | | -// |
91 | | -// if ( collapsible != null && ( collapsible == 'collapsed' || collapsible == 'uncollapsed') ) { |
92 | | -// var showControl = $('<span class="filtered-value-show">[+]</span>'); |
93 | | -// var hideControl = $('<span class="filtered-value-hide">[-]</span>'); |
94 | | -// |
95 | | -// |
96 | | -// filtercontrols |
97 | | -// .prepend(showControl) |
98 | | -// .prepend(hideControl); |
99 | | -// |
100 | | -// filtercontrols = $('<div class="filtered-value-collapsible">') |
101 | | -// .appendTo(filtercontrols); |
102 | | -// |
103 | | -// showControl.click(function(){ |
104 | | -// filtercontrols.slideDown(); |
105 | | -// showControl.hide(); |
106 | | -// hideControl.show(); |
107 | | -// }); |
108 | | -// |
109 | | -// hideControl.click(function(){ |
110 | | -// filtercontrols.slideUp(); |
111 | | -// showControl.show(); |
112 | | -// hideControl.hide(); |
113 | | -// }); |
114 | | -// |
115 | | -// if ( collapsible == 'collapsed' ) { |
116 | | -// hideControl.hide(); |
117 | | -// filtercontrols.slideUp(0); |
118 | | -// } else { |
119 | | -// showControl.hide(); |
120 | | -// } |
121 | | -// |
122 | | -// } |
123 | | -// |
124 | | -// // set default config values |
125 | | -// filtered.filtered( 'setFilterData', {filter: 'value', printout: target, configvar: 'use or', configvalue: true} ); |
126 | | -// |
127 | | -// |
128 | | -// // insert switches |
129 | | -// if ( switches != null && switches.length > 0 ) { |
130 | | -// |
131 | | -// var switchControls = $('<div class="filtered-value-switches">'); |
132 | | -// |
133 | | -// if ( $.inArray('and or', switches) >= 0 ) { |
134 | | -// |
135 | | -// var andorControl = $('<div class="filtered-value-andor">'); |
136 | | -// var andControl = $('<input type="radio" name="filtered-value-andor ' + |
137 | | -// target + '" class="filtered-value-andor ' + target + '" value="and">'); |
138 | | -// |
139 | | -// var orControl = $('<input type="radio" name="filtered-value-andor ' + |
140 | | -// target + '" class="filtered-value-andor ' + target + '" value="or" checked>'); |
141 | | -// |
142 | | -// andControl |
143 | | -// .add( orControl ) |
144 | | -// .change(function() { |
145 | | -// filtered.filtered( 'setFilterData', {filter: 'value', printout: target, configvar: 'use or', configvalue: orControl.is(':checked')} ); |
146 | | -// update( filtered, filtercontrols, target ); |
147 | | -// }); |
148 | | -// |
149 | | -// andorControl |
150 | | -// .append( orControl ) |
151 | | -// .append(' OR ') |
152 | | -// .append( andControl ) |
153 | | -// .append(' AND ') |
154 | | -// .appendTo( switchControls ); |
155 | | -// |
156 | | -// } |
157 | | -// |
158 | | -// filtercontrols.append( switchControls ); |
159 | | -// } |
160 | | -// |
161 | | -// if ( height != null ) { |
162 | | -// filtercontrols = $( '<div class="filtered-value-scrollable">' ) |
163 | | -// .appendTo( filtercontrols ); |
164 | | -// |
165 | | -// filtercontrols.height( height ); |
166 | | -// } |
167 | | -// |
168 | | -// |
169 | | -// var sortedDistinctValues = []; |
170 | | -// |
171 | | -// for ( var i in distinctValues ) { |
172 | | -// sortedDistinctValues.push(i); |
173 | | -// } |
174 | | -// |
175 | | -// sortedDistinctValues.sort(); |
176 | | -// |
177 | | -// // insert options (checkboxes and labels) and attach event handlers |
178 | | -// // TODO: Do we need to wrap these in a form? |
179 | | -// for ( var j in sortedDistinctValues ) { |
180 | | -// var option = $('<div class="filtered-value-option">'); |
181 | | -// var checkbox = $('<input type="checkbox" class="filtered-value-value" value="' + sortedDistinctValues[j] + '" >'); |
182 | | -// |
183 | | -// // attach event handler |
184 | | -// checkbox.change(function( evt ){ |
185 | | -// update(filtered, filtercontrols, target); |
186 | | -// }); |
187 | | -// |
188 | | -// option |
189 | | -// .append(checkbox) |
190 | | -// .append(sortedDistinctValues[j]); |
191 | | -// |
192 | | -// filtercontrols |
193 | | -// .append(option); |
194 | | -// |
195 | | -// } |
196 | 91 | |
197 | 92 | return this; |
198 | 93 | }, |