r114416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114415‎ | r114416 | r114417 >
Date:22:11, 21 March 2012
Author:foxtrott
Status:deferred
Tags:
Comment:
filtered format: printout parameter 'distance filter initial value'; cleaning up
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Filtered/filters/SRF_FF_Distance.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.distance-filter.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Filtered/filters/SRF_FF_Distance.php
@@ -165,7 +165,12 @@
166166 if ( array_key_exists( 'distance filter collapsible', $params ) ) {
167167 $ret['collapsible'] = trim($params['distance filter collapsible']);
168168 }
 169+
 170+ if ( array_key_exists( 'distance filter initial value', $params ) ) {
 171+ $ret['initial value'] = trim( $params['distance filter initial value'] );
 172+ }
169173
 174+
170175 return $ret;
171176 }
172177
Index: trunk/extensions/SemanticResultFormats/Filtered/libs/ext.srf.filtered.distance-filter.js
@@ -16,16 +16,12 @@
1717
1818 function update( filtered, filterDistance, target ) {
1919
20 - var values = filtered.data('ext.srf.filtered')['values'];
 20+ for ( i in filtered.data('ext.srf.filtered')['values'] ) {
2121
22 - for ( i in values ) {
23 -
24 - var distance = values[i]['data']['distance-filter'];
25 -
2622 filtered.filtered( 'voteItemVisibilityAndUpdate', {
2723 'filter': 'value',
2824 'printout' : target,
29 - 'visible': distance <= filterDistance,
 25+ 'visible': values[i]['data']['distance-filter'] <= filterDistance,
3026 'item': i
3127 });
3228
@@ -36,22 +32,29 @@
3733
3834 var filtered = this;
3935
40 -
41 -
4236 var target = args.printout;
4337 var values = this.data('ext.srf.filtered')['values'];
4438 var data = this.data('ext.srf.filtered')['data']['filterdata']['distance'][target];
4539
 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+
4653 // build filter controls
4754 var filtercontrols = this.children('.filtered-filters').children('.filtered-distance');
4855
49 - // insert the label of the printout this filter filters on
50 -
51 - for ( var i in values ) break;
52 -
5356 var readoutAndSlider = $('<tr>');
5457
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>' );
5659 var slider = $('<div class="filtered-distance-slider">');
5760
5861 var readoutTD = $('<td class="filtered-distance-readout-cell">');
@@ -75,7 +78,7 @@
7679 slider.slider({
7780 animate: true,
7881 max: data['max'],
79 - value: data['max'],
 82+ value: iniValue,
8083 slide: function(event, ui) {
8184 readout.empty().append( ui.value + data['unit'] );
8285 },
@@ -84,114 +87,6 @@
8588 }
8689 });
8790
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 -// }
19691
19792 return this;
19893 },

Status & tagging log