r61743 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61742‎ | r61743 | r61744 >
Date:13:43, 31 January 2010
Author:shmichael
Status:deferred
Tags:
Comment:
* Addressed issues in r61513 and follow up to r61518 .
* Spinner appears when changing filters
* Performing multiple filter changes before results are returned will wait for the most recent results to return.
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/common/common.css (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/skins/common/common.css
@@ -95,8 +95,9 @@
9696 z-index:3;
9797 }
9898 #rsd_filters_container {
99 - float:left;
100 - width:150px;
 99+ float: left;
 100+ width: 150px;
 101+ overflow: auto;
101102 }
102103
103104 .ui-filter-title {
@@ -194,6 +195,10 @@
195196 .rsd_result_enumeration {
196197 margin: 0 1em;
197198 }
 199+.rsd_results_body {
 200+ height: 100%;
 201+ width: 100%;
 202+}
198203 #rsd_results_header {
199204 margin: 4px;
200205 background: #DEF;
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -1230,16 +1230,48 @@
12311231 }
12321232 },
12331233
 1234+ /**
 1235+ * Callback for performing a search, given to providers for provider-activated
 1236+ * searches e.g. filter state changes. This is probably also the future way to
 1237+ * implement "pushing" results.
 1238+ *
 1239+ * The returned callback accepts two arguements.
 1240+ *
 1241+ * The first, mandatory, is the
 1242+ * provider object. This should be curried with the current provider object
 1243+ * before handing over. (i.e. this.curry(this.getProviderCallback(), provider).
 1244+ *
 1245+ * The second, optional, is the current results list to be replaced by a spinner.
 1246+ */
12341247 getProviderCallback: function() {
12351248
12361249 var _this = this;
1237 - return function ( provider ) {
 1250+
 1251+ return function ( provider, $location ) {
12381252
12391253 var d = new Date();
12401254 var searchTime = d.getMilliseconds();
12411255
 1256+ // If we are given a result location, we hide them.
 1257+ if ($location) {
 1258+ $location.html( mw.loading_spinner("float: left") );
 1259+ }
 1260+
 1261+ var d = new Date();
 1262+ var context = _this.storeContext( d.getTime() );
 1263+ _this.currentRequest = context();
 1264+ mw.log( "ProviderCallBack Generated " + context() )
12421265 provider.sObj.getSearchResults( $j( '#rsd_q' ).val() ,
12431266 function( resultStatus ) {
 1267+
 1268+ mw.log( "ProviderCallBack Received " + context() );
 1269+ if( _this.currentRequest != context() ) {
 1270+ // do not update the results this.currentRequest
 1271+ // does not match the interface request state.
 1272+ return false;
 1273+ }
 1274+
 1275+ //else update search results
12441276 _this.showResults();
12451277 });
12461278
@@ -1250,6 +1282,22 @@
12511283 },
12521284
12531285 /**
 1286+ * Persists an object via closure to enable later context checking.
 1287+ * This can be used e.g. when sending multiple getJSON requests and
 1288+ * wanting to act only on the last request sent.
 1289+ *
 1290+ * @param {Object} Object to store in context.
 1291+ *
 1292+ * @return {function} A callback to retrieve the context.
 1293+ */
 1294+ storeContext: function( contextObject ) {
 1295+ var context = contextObject;
 1296+ return function() {
 1297+ return context;
 1298+ }
 1299+ },
 1300+
 1301+ /**
12541302 * Loads a providers search library
12551303 *
12561304 * @param {Object} provider content provider to be loaded
@@ -1327,8 +1375,22 @@
13281376 var _this = this;
13291377 var o = '';
13301378 var provider = this.content_providers[ this.current_provider ];
1331 -
13321379
 1380+ // Result page structure:
 1381+ //
 1382+ // resultContainer
 1383+ // header
 1384+ // resultBody
 1385+ // filter form
 1386+ // filters...
 1387+ // resultList
 1388+ // results...
 1389+ // footer
 1390+
 1391+ var $resultsContainer;
 1392+ var $resultsBody = $j( '<div />' ).addClass( 'rsd_results_body' );
 1393+ var $resultsList = $j( '<div />' ).addClass( 'rsd_results_list' );
 1394+
13331395 // The "upload" tab has special results output target rather than top level
13341396 // resutls container.
13351397 if ( this.current_provider == 'upload' ) {
@@ -1344,16 +1406,13 @@
13451407 // Enable search filters, if the provider supports them.
13461408 if ( provider.sObj.filters && !(provider.disable_filters) ) {
13471409 provider.sObj.filters.filterChangeCallBack =
1348 - this.curry( this.getProviderCallback(), provider );
1349 - $resultsContainer.append( provider.sObj.filters.getHTML().attr ({
 1410+ this.curry( this.getProviderCallback(), provider, $resultsList );
 1411+ $resultsBody.append( provider.sObj.filters.getHTML().attr ({
13501412 id: 'rsd_filters_container'
13511413 }));
13521414 }
13531415 }
13541416
1355 - // Empty the existing results:
1356 - // $j( tabSelector ).empty();
1357 -
13581417 var numResults = 0;
13591418
13601419 // Output all the results for the current current_provider
@@ -1363,8 +1422,12 @@
13641423 numResults++;
13651424 } );
13661425 // Put in the tab output (plus clear the output)
1367 - $resultsContainer.append( o + '<div style="clear:both"/>' );
 1426+ $resultsList.append( o + '<div style="clear: both" />' );
13681427 }
 1428+
 1429+ $resultsBody.append( $resultsList );
 1430+ $resultsContainer.append( $resultsBody );
 1431+
13691432 // @@TODO should abstract footer and header ~outside~ of search results
13701433 // to have less leakgege with upload tab
13711434 if ( this.current_provider != 'upload' ) {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61513* Moved authority of search filters to searchLibs....shmichael09:39, 26 January 2010
r61518* followup to r61513...shmichael15:44, 26 January 2010

Status & tagging log