r61202 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61201‎ | r61202 | r61203 >
Date:14:27, 18 January 2010
Author:shmichael
Status:resolved (Comments)
Tags:
Comment:
* Removed tab search model
* Added (functional!) provider selection prior to search
* Added paging support for Kaltura searches
* Continued major refactoring of RemoteSearchDriver.js
* Minor changes to look & feel of search dialog (paging controls etc.)
* Kaltura aggregated search is now called "All Sources" and appears as the default provider
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/includes/languages/mwEmbed.i18n.php (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/mvpcf/styles.css (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/includes/languages/mwEmbed.i18n.php
@@ -371,7 +371,7 @@
372372 'mwe-ftype-unk' => 'Unknown file format',
373373 'rsd-wiki_commons-title' => 'Wikimedia Commons',
374374 'rsd-wiki_commons' => 'Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)',
375 - 'rsd-kaltura-title' => 'Kaltura search',
 375+ 'rsd-kaltura-title' => 'All Sources',
376376 'rsd-kaltura' => 'Kaltura agragated search for free-licenced media across multiple search providers',
377377 'rsd-this_wiki-title' => 'This wiki',
378378 'rsd-this_wiki-desc' => 'The local wiki install',
Index: branches/js2-work/phase3/js/mwEmbed/skins/mvpcf/styles.css
@@ -309,54 +309,88 @@
310310 #rsd_resource_edit{
311311 z-index:2;
312312 }
313 -.rsd_file_type{
314 - position : absolute;
315 - bottom : 0px;
316 - left : 3px;
 313+.rsd_file_type {
 314+ position: absolute;
 315+ bottom: 0px;
 316+ left: 3px;
317317 font-size: x-small;
318318 }
319 -.rsd_import_button{
 319+.rsd_import_button {
320320 mergin-left: 5px;
321321 }
322322
 323+.rsd_layout_select {
 324+ float: left;
 325+ top: 0px;
 326+ font-style: italic;
 327+}
 328+
323329 .rsd_linkback{
324330 position: absolute;
325331 top: 0px;
326332 right: 0px;
327333 font-size: x-small;
328334 }
329 -.rsd_license{
330 - position : absolute;
331 - bottom : 0px;
332 - right : 0px;
 335+.rsd_license {
 336+ position: absolute;
 337+ bottom: 0px;
 338+ right: 0px;
333339 }
334 -.rsd_license img{
335 - float:left;
 340+.rsd_license img {
 341+ float: left;
336342 }
337 -.rsd_license span{
338 - float:left;
339 - background:#FFF;
340 - color:#200;
341 - font-size:x-small;
342 - filter:alpha(opacity=70);
343 - -moz-opacity:0.7;
344 - opacity:0.7;
 343+.rsd_license span {
 344+ float: left;
 345+ background: #FFF;
 346+ color: #200;
 347+ font-size: x-small;
 348+ filter: alpha(opacity=70);
 349+ -moz-opacity: 0.7;
 350+ opacity: 0.7;
345351 }
346 -.rsd_search_button{
 352+
 353+.rsd_paging_control {
 354+ float: right;
 355+}
 356+
 357+.rsd_search_button {
347358 margin-left: 10px;
348359 }
349 -.rsd_upload_button{
 360+
 361+.rsd_search_description {
 362+ position: relative;
 363+ top: 0px;
 364+ font-style: italic;
 365+}
 366+.rsd_upload_button {
350367 margin-left: 25px;
351368 }
352369 .rsd_res_item{
353370 cursor:pointer;
354371 border: 1px solid black;
355372 }
356 -#rds_results_bar{
357 - margin:4px;
358 - background:#DEF;
359 - height:22px;
 373+.rsd_result_enumeration {
 374+ margin: 0 1em;
360375 }
 376+#rsd_results_header {
 377+ margin: 4px;
 378+ background: #DEF;
 379+ height: 22px;
 380+}
 381+#rsd_results_footer {
 382+ margin: 4px;
 383+ background: #DEF;
 384+ height: 22px;
 385+ text-align: center;
 386+}
 387+
 388+img.layout_selector {
 389+ width: 20px;
 390+ height: 20px;
 391+ cursor: pointer;
 392+ float: right;
 393+}
 394+
361395 .mv_clip_box_result{
362396 padding:10px;
363397 float:left;
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js
@@ -35,15 +35,16 @@
3636 */
3737 getSearchResults:function( search_query ) {
3838 var _this = this;
39 - mw.log( "Kaltura::getSearchResults" );
4039
4140 // call parent for common initialisation:
4241 this.parent_getSearchResults();
4342
4443 // setup the flickr request:
4544 var request = {
46 - 's': search_query
 45+ 's': search_query,
 46+ 'page': this.provider.offset/this.provider.limit + 1
4747 }
 48+ mw.log( "Kaltura::getSearchResults query: " + request['s'] + " page: " + request['page']);
4849 $j.getJSON( this.provider.api_url + '?callback=?', request, function( data ) {
4950 _this.addResults( data );
5051 _this.loading = false;
@@ -53,7 +54,7 @@
5455 /**
5556 * Adds results from kaltura api data response object
5657 *
57 - * @param {Object} data Fliker response data
 58+ * @param {Object} response data
5859 */
5960 addResults:function( data ) {
6061 var _this = this;
@@ -65,7 +66,12 @@
6667 //if ( this.num_results > this.provider.offset + this.provider.limit ) {
6768 // this.more_results = true;
6869 //}
 70+
 71+ // Display option for more results as long as results are coming in
 72+ this.more_results = ( data.length == this.limit )
 73+
6974 for ( var resource_id in data ) {
 75+
7076 var result = data[ resource_id ];
7177 // Update mappings:
7278 result['poster'] = result['thumbnail'];
@@ -76,7 +82,8 @@
7783 //or gennerated at request time for mediaWiki
7884 var ext = this.getMimeExtension( result['mime'] );
7985 result['titleKey'] = 'File:' + result['title'] + '.' + ext;
80 -
 86+
 87+ this.num_results++;
8188 _this.resultsObj[ resource_id ] = result;
8289
8390 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -57,7 +57,7 @@
5858 "rsd-wiki_commons-title": "Wikimedia Commons",
5959 "rsd-wiki_commons": "Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)",
6060
61 - "rsd-kaltura-title" : "Kaltura search",
 61+ "rsd-kaltura-title" : "All Sources",
6262 "rsd-kaltura" : "Kaltura agragated search for free-licenced media across multiple search providers",
6363
6464 "rsd-this_wiki-title" : "This wiki",
@@ -250,6 +250,19 @@
251251 },
252252
253253 /**
 254+ * Kaltura aggregated search
 255+ */
 256+ 'kaltura': {
 257+ 'enabled': 1,
 258+ 'checked': 1,
 259+ 'homepage': 'http://kaltura.com',
 260+ 'api_url': 'http://kaldev.kaltura.com/michael/aggregator.php',
 261+ 'lib': 'kaltura',
 262+ 'resource_prefix' : '',
 263+ 'tab_image':false
 264+ },
 265+
 266+ /**
254267 * Wikipedia Commons search provider configuration
255268 */
256269 'wiki_commons': {
@@ -270,23 +283,9 @@
271284 // Specific to wiki commons config:
272285 // If we should search the title
273286 'search_title': false
274 -
275287 },
276288
277289 /**
278 - * Kaltura aggregated search
279 - */
280 - 'kaltura': {
281 - 'enabled': 1,
282 - 'checked': 1,
283 - 'homepage': 'http://kaltura.com',
284 - 'api_url': 'http://kaldev.kaltura.com/michael/aggregator.php',
285 - 'lib': 'kaltura',
286 - 'resource_prefix' : '',
287 - 'tab_image':false
288 - },
289 -
290 - /**
291290 * Internet archive search provider configuration
292291 */
293292 'archive_org': {
@@ -801,19 +800,18 @@
802801 var _this = this;
803802 mw.log( 'f::initDialog' );
804803
805 - var mainContainer = $j(this.target_container);
 804+ var mainContainer = $j( this.target_container );
806805
807806 var controlContainer = this.createControlContainer();
808807
809 - mainContainer.append(controlContainer);
 808+ mainContainer.append( controlContainer );
810809
811 - resultsContainer = $j('<div />').attr({
 810+ this.$resultsContainer = $j('<div />').attr({
812811 id: "rsd_results_container"
813812 });
814 - mainContainer.append(resultsContainer);
815813
816 - // Draw the tabs:
817 - this.createTabs();
 814+ mainContainer.append( this.$resultsContainer );
 815+
818816 // run the default search:
819817 if ( this.getDefaultQuery() )
820818 this.showCurrentTab();
@@ -853,38 +851,32 @@
854852 createControlContainer: function() {
855853 var _this = this;
856854
857 - var $controlContainer = $j('<div />').addClass("rsd_control_container");
858 - var $searchForm = $j('<form />').attr({
 855+ var $controlContainer = $j( '<div />' ).addClass( "rsd_control_container" );
 856+ var $searchForm = $j( '<form />' ).attr({
859857 id : "rsd_form",
860858 action : "javascript:return false"
861859 });
862 - var $providerSelection = $j('<ul />').addClass("ui-provider-selection");
 860+ var $providerSelection = $j( '<ul />' ).addClass( "ui-provider-selection" );
863861
864862 // Add enabled search providers.
865863 for ( var providerName in this.content_providers ) {
866864 var content_providers = this.content_providers;
867865 var provider = content_providers[ providerName ];
868 - if (provider.enabled && provider.checked && provider.api_url ) {
869 - var $anchor = $j('<div />')
870 - .text( gM('rsd-' + providerName + '-title') )
 866+ if ( provider.enabled && provider.checked && provider.api_url ) {
 867+ var $anchor = $j( '<div />' )
 868+ .text( gM( 'rsd-' + providerName + '-title' ) )
871869 .attr({
872870 name: providerName
873871 });
874872 if ( this.current_provider == providerName) {
875 - $anchor.addClass('ui-selected');
 873+ $anchor.addClass( 'ui-selected' );
876874 }
877875
878876 $anchor.click( function() {
879877 $j( this ).parent().parent().find( '.ui-selected' )
880 - .removeClass( 'ui-selected' )
881 - .each( function( index, domElement ) {
882 - /*var selectedProvider = $j(domElement).attr("name")
883 - if (selectedProvider)
884 - content_providers[ selectedProvider ].checked = false;*/
885 - //TODO: unset flag for provider selection
886 - });
 878+ .removeClass( 'ui-selected' );
887879 $j( this ).addClass( 'ui-selected' );
888 - //TODO: set flag for provider selection
 880+ _this.current_provider = $j( this ).attr( "name" );
889881 });
890882
891883 var $listItem = $j( '<li />' );
@@ -893,7 +885,7 @@
894886 }
895887 }
896888
897 - var $searchBox = $j('<input />').addClass('ui-widget-content ui-corner-all').attr({
 889+ var $searchBox = $j( '<input />' ).addClass( 'ui-widget-content ui-corner-all' ).attr({
898890 type: "text",
899891 tabindex: 1,
900892 value: this.getDefaultQuery(),
@@ -903,15 +895,17 @@
904896 size: 20,
905897 autocomplete: "off"
906898 });
907 - var $searchButton = $j.button({icon_id: 'search', text: gM('mwe-media_search') })
 899+ var $searchButton = $j.button({
 900+ icon_id: 'search',
 901+ text: gM('mwe-media_search') })
908902 .addClass( 'rsd_search_button' )
909903 .buttonHover()
910904 .click(function (){
911905 //TODO: Add search provider call.
912 - _this.showCurrentTab();
 906+ _this.showSearchTab( _this.current_provider, true );
913907 });
914908
915 - //$searchForm.append( $providerSelection );
 909+ $searchForm.append( $providerSelection );
916910 $searchForm.append( $searchBox );
917911 $searchForm.append( $searchButton );
918912 /*
@@ -1078,11 +1072,14 @@
10791073 if ( !draw_direct_flag ) {
10801074 // See if we should reset the paging
10811075 if ( resetPaging ) {
1082 - provider.sObj.offset = provider.offset = 0;
 1076+ provider.offset = 0;
 1077+ if (provider.sObj && provider.sObj.offset) {
 1078+ provider.sObj.offset = 0;
 1079+ }
10831080 }
10841081
10851082 // Set the content to loading while we do the search:
1086 - $j( '#tab-' + providerName ).html( mw.loading_spinner() );
 1083+ $j( '#rsd_results_container' ).html( mw.loading_spinner() );
10871084
10881085 // Make sure the search library is loaded and issue the search request
10891086 this.getLibSearchResults( provider );
@@ -1205,7 +1202,7 @@
12061203 // combined results are harder to error handle just ignore that repo
12071204 provider.sObj.loading = false;
12081205 } else {
1209 - $j( '#tab-' + this.current_provider ).html(
 1206+ $j( '#rsd_results_container' ).html(
12101207 '<div style="padding:10px">' +
12111208 gM( 'mwe-no_import_by_url' ) +
12121209 '</div>' );
@@ -1256,6 +1253,7 @@
12571254 // inherit defaults if not set:
12581255 provider.limit = provider.limit ? provider.limit : provider.sObj.limit;
12591256 provider.offset = provider.offset ? provider.offset : provider.sObj.offset;
 1257+
12601258 callback( provider );
12611259 } );
12621260 },
@@ -1304,72 +1302,6 @@
13051303 },
13061304
13071305 /**
1308 - * Creates the tabs based on the remote search configuration
1309 - */
1310 - createTabs: function() {
1311 - var _this = this;
1312 -
1313 - // Add the tabs to the rsd_results container:
1314 - var s = '<div id="rsd_tabs_container" style="width:100%;">';
1315 - var selected_tab = 0;
1316 - var index = 0;
1317 - s += '<ul>';
1318 - var content = '';
1319 - for ( var providerName in this.content_providers ) {
1320 - var provider = this.content_providers[ providerName ];
1321 - var tabImage = mw.getMwEmbedPath() + '/skins/common/remote_cp/' + providerName + '_tab.png';
1322 - if ( provider.enabled && provider.checked && provider.api_url ) {
1323 - // Add selected default if set
1324 - if ( this.current_provider == providerName )
1325 - selected_tab = index;
1326 -
1327 - s += '<li class="rsd_cp_tab">';
1328 - s += '<a id="rsd_tab_' + providerName + '" href="#tab-' + providerName + '">';
1329 - if ( provider.tab_img === true ) {
1330 - s += '<img alt="' + gM( 'rsd-' + providerName + '-title' ) + '" ' +
1331 - 'src="' + tabImage + '">';
1332 - } else {
1333 - s += gM( 'rsd-' + providerName + '-title' );
1334 - }
1335 - s += '</a>';
1336 - s += '</li>';
1337 - index++;
1338 - }
1339 - content += '<div id="tab-' + providerName + '" class="rsd_results"/>';
1340 - }
1341 -
1342 - // Do an upload tab if enabled:
1343 - if ( this.content_providers['upload'].enabled ) {
1344 - s += '<li class="rsd_cp_tab" >' +
1345 - '<a id="rsd_tab_upload" href="#tab-upload">' +
1346 - gM( 'mwe-upload_tab' ) +
1347 - '</a></li>';
1348 - content += '<div id="tab-upload" />';
1349 - if ( this.current_provider == 'upload' )
1350 - selected_tab = index++;
1351 - }
1352 - s += '</ul>';
1353 -
1354 - // Output the tab content containers:
1355 - s += content;
1356 - s += '</div>'; // close tab container
1357 -
1358 - // Output the respective results holders
1359 - $j( '#rsd_results_container' ).html( s );
1360 - // Setup bindings for tabs make them sortable: (@@todo remember order)
1361 - mw.log( 'selected tab is: ' + selected_tab );
1362 - $j( "#rsd_tabs_container" )
1363 - .tabs( {
1364 - selected: selected_tab,
1365 - select: function( event, ui ) {
1366 - _this.selectTab( $j( ui.tab ).attr( 'id' ).replace( 'rsd_tab_', '' ) );
1367 - }
1368 - })
1369 - // Add sorting support
1370 - .find( ".ui-tabs-nav" ).sortable( { axis: 'x' } );
1371 - },
1372 -
1373 - /**
13741306 * Get a resource object from a resource id
13751307 *
13761308 * NOTE: We could bind resource objects to html elements to avoid this lookup
@@ -1400,8 +1332,11 @@
14011333 mw.log( 'f:showResults::' + this.current_provider );
14021334 var _this = this;
14031335 var o = '';
1404 - var tabSelector = '';
1405 -
 1336+ var tabSelector = '#rsd_results_container';
 1337+ var provider = this.content_providers[ this.current_provider ];
 1338+
 1339+ // TODO: clean this up
 1340+ /*
14061341 if ( this.current_provider == 'upload' ) {
14071342 tabSelector = '#upload_bin';
14081343 var provider = _this.content_providers['this_wiki'];
@@ -1410,14 +1345,13 @@
14111346 tabSelector = '#tab-' + this.current_provider;
14121347 // Output the results bar / controls
14131348 }
 1349+ */
14141350
14151351 // Empty the existing results:
1416 - $j( tabSelector ).empty();
1417 -
1418 - if ( this.current_provider != 'upload' ) {
1419 - _this.showResultsHeader();
1420 - }
 1352+ // $j( tabSelector ).empty();
 1353+ this.$resultsContainer.empty();
14211354
 1355+ this.$resultsContainer.append( _this.createResultsHeader() );
14221356 var numResults = 0;
14231357
14241358 // Output all the results for the current current_provider
@@ -1427,9 +1361,11 @@
14281362 numResults++;
14291363 } );
14301364 // Put in the tab output (plus clear the output)
1431 - $j( tabSelector ).append( o + '<div style="clear:both"/>' );
 1365+ this.$resultsContainer.append( o + '<div style="clear:both"/>' );
14321366 }
14331367
 1368+ this.$resultsContainer.append( _this.createResultsFooter() );
 1369+
14341370 mw.log( 'did numResults :: ' + numResults +
14351371 ' append: ' + $j( '#rsd_q' ).val() );
14361372 // Remove any old search res
@@ -2574,23 +2510,20 @@
25752511 }, 25
25762512 );
25772513 },
 2514+
25782515 /**
2579 - * Show Results Header includes controls like box vs list view and
2580 - * issues a call to showPagingHeader
2581 - */
2582 - showResultsHeader: function() {
 2516+ * Create controls for selecting result display layout (e.g. box, list)
 2517+ *
 2518+ * @return {jQuery element} The layout element to embed in the page.
 2519+ */
 2520+ createLayoutSelector: function() {
 2521+
25832522 var _this = this;
25842523 var darkBoxUrl = mw.getConfig( 'skin_img_path' ) + 'box_layout_icon_dark.png';
25852524 var lightBoxUrl = mw.getConfig( 'skin_img_path' ) + 'box_layout_icon.png';
25862525 var darkListUrl = mw.getConfig( 'skin_img_path' ) + 'list_layout_icon_dark.png';
25872526 var lightListUrl = mw.getConfig( 'skin_img_path' ) + 'list_layout_icon.png';
2588 -
2589 - if ( !this.content_providers[ this.current_provider ] ) {
2590 - return;
2591 - }
2592 - var cp = this.content_providers[this.current_provider];
2593 - var resultsFromMsg = gM( 'mwe-results_from',
2594 - [ cp.homepage, gM( 'rsd-' + this.current_provider + '-title' ) ] );
 2527+
25952528 var defaultBoxUrl, defaultListUrl;
25962529 if ( _this.displayMode == 'box' ) {
25972530 defaultBoxUrl = darkBoxUrl;
@@ -2599,31 +2532,13 @@
26002533 defaultBoxUrl = lightBoxUrl;
26012534 defaultListUrl = darkListUrl;
26022535 }
2603 -
2604 - var about_desc = '<span style="position:relative;top:0px;font-style:italic;">' +
2605 - '<i>' + resultsFromMsg + '</i></span>';
2606 -
2607 - $j( '#tab-' + this.current_provider ).append( '<div id="rds_results_bar">' +
2608 - '<span style="float:left;top:0px;font-style:italic;">' +
2609 - gM( 'rsd_layout' ) + ' ' +
2610 - '<img id="msc_box_layout" ' +
2611 - 'title = "' + gM( 'rsd_box_layout' ) + '" ' +
2612 - 'src = "' + defaultBoxUrl + '" ' +
2613 - 'style="width:20px;height:20px;cursor:pointer;"> ' +
2614 - '<img id="msc_list_layout" ' +
2615 - 'title = "' + gM( 'rsd_list_layout' ) + '" ' +
2616 - 'src = "' + defaultListUrl + '" ' +
2617 - 'style="width:20px;height:20px;cursor:pointer;">' +
2618 - about_desc +
2619 - '</span>' +
2620 - '<span id="rsd_paging_ctrl" style="float:right;"></span>' +
2621 - '</div>'
2622 - );
2623 -
2624 - // Get paging with bindings:
2625 - this.showPagingHeader( '#rsd_paging_ctrl' );
2626 -
2627 - $j( '#msc_box_layout' )
 2536+
 2537+ $boxLayout = $j( '<img />' ).addClass( 'layout_selector' )
 2538+ .attr({
 2539+ id: 'msc_box_layout',
 2540+ title: gM( 'rsd_box_layout' ),
 2541+ src: defaultBoxUrl
 2542+ })
26282543 .hover(
26292544 function() {
26302545 $j( this ).attr( "src", darkBoxUrl );
@@ -2632,12 +2547,16 @@
26332548 $j( this ).attr( "src", defaultBoxUrl );
26342549 } )
26352550 .click( function() {
2636 - $j( this ).attr( "src", darkBoxUrl );
2637 - $j( '#msc_list_layout' ).attr( "src", lightListUrl );
 2551+ $boxLayout.attr( "src", darkBoxUrl );
 2552+ $listLayout.attr( "src", lightListUrl );
26382553 _this.setDisplayMode( 'box' );
26392554 } );
2640 -
2641 - $j( '#msc_list_layout' )
 2555+ $listLayout = $j( '<img />' ).addClass( 'layout_selector' )
 2556+ .attr({
 2557+ id: 'msc_list_layout',
 2558+ title: gM( 'rsd_list_layout' ),
 2559+ src: defaultListUrl
 2560+ })
26422561 .hover(
26432562 function() {
26442563 $j( this ).attr( "src", darkListUrl );
@@ -2646,63 +2565,150 @@
26472566 $j( this ).attr( "src", defaultListUrl );
26482567 } )
26492568 .click( function() {
2650 - $j( this ).attr( "src", darkListUrl );
2651 - $j( '#msc_box_layout' ).attr( "src", lightBoxUrl );
 2569+ $listLayout.attr( "src", darkListUrl );
 2570+ $boxLayout.attr( "src", lightBoxUrl );
26522571 _this.setDisplayMode( 'list' );
26532572 } );
 2573+
 2574+ $layoutSelector = $j( '<span />' )
 2575+ .append( $boxLayout )
 2576+ .append( $listLayout );
 2577+
 2578+ return $layoutSelector;
26542579 },
 2580+ /**
 2581+ * Create a string indicating the source of the results + link
 2582+ *
 2583+ * @param The current content provider.
 2584+ *
 2585+ * @return {jQuery element} A description element for embedding.
 2586+ */
 2587+ createSearchDescription: function(cp) {
 2588+
 2589+ var resultsFromMsg = gM( 'mwe-results_from',
 2590+ [ cp.homepage, gM( 'rsd-' + this.current_provider + '-title' ) ] );
 2591+
 2592+ var $searchContent = $j( '<span />' ).html(resultsFromMsg);
 2593+ var $searchDescription = $j( '<span />' ).addClass( 'rsd_search_description' )
 2594+ .attr({
 2595+ id: 'rsd_search_description'
 2596+ })
 2597+ .append( $searchContent );
 2598+
 2599+ return $searchDescription;
 2600+ },
 2601+ /**
 2602+ * Results Header controls like box vs list view
 2603+ * & search description
 2604+ *
 2605+ * @return {jQuery element} The header for embedding in the result set.
 2606+ */
 2607+ createResultsHeader: function() {
 2608+ var _this = this;
 2609+
 2610+ if ( !this.content_providers[ this.current_provider ] ) {
 2611+ return;
 2612+ }
 2613+ var cp = this.content_providers[ this.current_provider ];
 2614+
 2615+ var $header = $j( '<div />' )
 2616+ .attr({
 2617+ id: 'rsd_results_header'
 2618+ });
 2619+
 2620+ $header.append( this.createLayoutSelector() )
 2621+ .append( this.createSearchDescription( cp ) );
 2622+
 2623+ return $header;
 2624+ },
26552625
26562626 /**
2657 - * Shows pagging for a given target for a given current_provider
 2627+ * Creates the footer of the search results (paging).
 2628+ *
 2629+ * @return {jQuery element} The footer for embedding in the result set.
 2630+ */
 2631+ createResultsFooter: function() {
 2632+ var _this = this;
 2633+
 2634+ var $footer = $j( '<div />' )
 2635+ .attr({
 2636+ id: 'rsd_results_footer'
 2637+ })
 2638+ .append( this.createPagingControl() );
 2639+
 2640+ return $footer;
 2641+ },
 2642+
 2643+ /**
 2644+ * Generates an HTML control for paging between search results.
26582645 *
2659 - * @param {String} target jQuery Selector for pagging Header output
 2646+ * @return {jQuery element} paging control for current results
26602647 */
2661 - showPagingHeader: function( target ) {
 2648+ createPagingControl: function( target ) {
26622649 var _this = this;
2663 - if ( _this.current_provider == 'upload' ) {
2664 - var provider = _this.content_providers['this_wiki'];
2665 - } else {
2666 - var provider = _this.content_providers[ _this.current_provider ];
2667 - }
 2650+ var provider = _this.content_providers[ _this.current_provider ];
26682651 var search = provider.sObj;
2669 - mw.log( 'showPagingHeader:' + _this.current_provider + ' len: ' + search.num_results );
 2652+
 2653+ mw.log( 'Paging Control for ' + _this.current_provider + ' num of results: ' + search.num_results );
26702654 var to_num = ( provider.limit > search.num_results ) ?
26712655 ( parseInt( provider.offset ) + parseInt( search.num_results ) ) :
26722656 ( parseInt( provider.offset ) + parseInt( provider.limit ) );
2673 - var out = '';
2674 -
 2657+
 2658+ var $pagingControl = $j('<span />').attr({
 2659+ id: 'rsd_paging_control'
 2660+ });
 2661+
 2662+ // This puts enumeration text e.g. Results 1 to 30.
 2663+ var resultEnumeration = '';
26752664 // @@todo we should instead support the wiki number format template system instead of inline calls
26762665 if ( search.num_results != 0 ) {
26772666 if ( search.num_results > provider.limit ) {
2678 - out += gM( 'rsd_results_desc_total', [( provider.offset + 1 ), to_num,
 2667+ resultEnumeration = gM( 'rsd_results_desc_total', [( provider.offset + 1 ), to_num,
26792668 mw.lang.formatNumber( search.num_results )] );
26802669 } else {
2681 - out += gM( 'rsd_results_desc', [( provider.offset + 1 ), to_num] );
 2670+ resultEnumeration = gM( 'rsd_results_desc', [( provider.offset + 1 ), to_num] );
26822671 }
26832672 }
2684 - // check if we have more results (next prev link)
 2673+
 2674+ var $resultEnumeration = $j( '<span />' ).text( resultEnumeration )
 2675+ .addClass( 'rsd_result_enumeration' );
 2676+ $pagingControl.append( $resultEnumeration );
 2677+
 2678+ // Place the previous results link
26852679 if ( provider.offset >= provider.limit ) {
2686 - out += ' <a href="#" id="rsd_pprev">' + gM( 'rsd_results_prev' ) + ' ' + provider.limit + '</a>';
 2680+ var prevLinkText = gM( 'rsd_results_prev' ) + ' ' + provider.limit;
 2681+ var $prevLink = $j( '<a />' )
 2682+ .attr({
 2683+ href: '#',
 2684+ id: 'rsd_pprev'
 2685+ } )
 2686+ .text( prevLinkText )
 2687+ .click( function() {
 2688+ provider.offset -= provider.limit;
 2689+ if ( provider.offset < 0 )
 2690+ provider.offset = 0;
 2691+ _this.showCurrentTab();
 2692+ } );
 2693+ $pagingControl.prepend( $prevLink );
26872694 }
26882695
 2696+ // Place the next results link
26892697 if ( search.more_results ) {
2690 - out += ' <a href="#" id="rsd_pnext">' + gM( 'rsd_results_next' ) + ' ' + provider.limit + '</a>';
 2698+ var nextLinkText = gM( 'rsd_results_next' ) + ' ' + provider.limit;
 2699+ var $nextLink = $j( '<a />' )
 2700+ .attr({
 2701+ href: '#',
 2702+ id: 'rsd_pnext'
 2703+ } )
 2704+ .text( nextLinkText )
 2705+ .click( function() {
 2706+ provider.offset += provider.limit;
 2707+ _this.showCurrentTab();
 2708+ } );
 2709+ $pagingControl.append( $nextLink );
26912710 }
26922711
2693 - $j( target ).html( out );
2694 -
2695 - // set bindings
2696 - $j( '#rsd_pnext' ).click( function() {
2697 - provider.offset += provider.limit;
2698 - _this.showCurrentTab();
2699 - } );
2700 -
2701 - $j( '#rsd_pprev' ).click( function() {
2702 - provider.offset -= provider.limit;
2703 - if ( provider.offset < 0 )
2704 - provider.offset = 0;
2705 - _this.showCurrentTab();
2706 - } );
 2712+ return $pagingControl;
27072713 },
27082714
27092715 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r61211* followup to r61202 restoring upload support...dale19:57, 18 January 2010

Comments

#Comment by Mdale (talk | contribs)   21:06, 19 January 2010

marked ok with follow-up commit.

Status & tagging log