Index: branches/js2-work/phase3/js/mwEmbed/includes/languages/mwEmbed.i18n.php |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | 'mwe-ftype-unk' => 'Unknown file format', |
373 | 373 | 'rsd-wiki_commons-title' => 'Wikimedia Commons', |
374 | 374 | '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', |
376 | 376 | 'rsd-kaltura' => 'Kaltura agragated search for free-licenced media across multiple search providers', |
377 | 377 | 'rsd-this_wiki-title' => 'This wiki', |
378 | 378 | 'rsd-this_wiki-desc' => 'The local wiki install', |
Index: branches/js2-work/phase3/js/mwEmbed/skins/mvpcf/styles.css |
— | — | @@ -309,54 +309,88 @@ |
310 | 310 | #rsd_resource_edit{ |
311 | 311 | z-index:2; |
312 | 312 | } |
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; |
317 | 317 | font-size: x-small; |
318 | 318 | } |
319 | | -.rsd_import_button{ |
| 319 | +.rsd_import_button { |
320 | 320 | mergin-left: 5px; |
321 | 321 | } |
322 | 322 | |
| 323 | +.rsd_layout_select { |
| 324 | + float: left; |
| 325 | + top: 0px; |
| 326 | + font-style: italic; |
| 327 | +} |
| 328 | + |
323 | 329 | .rsd_linkback{ |
324 | 330 | position: absolute; |
325 | 331 | top: 0px; |
326 | 332 | right: 0px; |
327 | 333 | font-size: x-small; |
328 | 334 | } |
329 | | -.rsd_license{ |
330 | | - position : absolute; |
331 | | - bottom : 0px; |
332 | | - right : 0px; |
| 335 | +.rsd_license { |
| 336 | + position: absolute; |
| 337 | + bottom: 0px; |
| 338 | + right: 0px; |
333 | 339 | } |
334 | | -.rsd_license img{ |
335 | | - float:left; |
| 340 | +.rsd_license img { |
| 341 | + float: left; |
336 | 342 | } |
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; |
345 | 351 | } |
346 | | -.rsd_search_button{ |
| 352 | + |
| 353 | +.rsd_paging_control { |
| 354 | + float: right; |
| 355 | +} |
| 356 | + |
| 357 | +.rsd_search_button { |
347 | 358 | margin-left: 10px; |
348 | 359 | } |
349 | | -.rsd_upload_button{ |
| 360 | + |
| 361 | +.rsd_search_description { |
| 362 | + position: relative; |
| 363 | + top: 0px; |
| 364 | + font-style: italic; |
| 365 | +} |
| 366 | +.rsd_upload_button { |
350 | 367 | margin-left: 25px; |
351 | 368 | } |
352 | 369 | .rsd_res_item{ |
353 | 370 | cursor:pointer; |
354 | 371 | border: 1px solid black; |
355 | 372 | } |
356 | | -#rds_results_bar{ |
357 | | - margin:4px; |
358 | | - background:#DEF; |
359 | | - height:22px; |
| 373 | +.rsd_result_enumeration { |
| 374 | + margin: 0 1em; |
360 | 375 | } |
| 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 | + |
361 | 395 | .mv_clip_box_result{ |
362 | 396 | padding:10px; |
363 | 397 | float:left; |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js |
— | — | @@ -35,15 +35,16 @@ |
36 | 36 | */ |
37 | 37 | getSearchResults:function( search_query ) { |
38 | 38 | var _this = this; |
39 | | - mw.log( "Kaltura::getSearchResults" ); |
40 | 39 | |
41 | 40 | // call parent for common initialisation: |
42 | 41 | this.parent_getSearchResults(); |
43 | 42 | |
44 | 43 | // setup the flickr request: |
45 | 44 | var request = { |
46 | | - 's': search_query |
| 45 | + 's': search_query, |
| 46 | + 'page': this.provider.offset/this.provider.limit + 1 |
47 | 47 | } |
| 48 | + mw.log( "Kaltura::getSearchResults query: " + request['s'] + " page: " + request['page']); |
48 | 49 | $j.getJSON( this.provider.api_url + '?callback=?', request, function( data ) { |
49 | 50 | _this.addResults( data ); |
50 | 51 | _this.loading = false; |
— | — | @@ -53,7 +54,7 @@ |
54 | 55 | /** |
55 | 56 | * Adds results from kaltura api data response object |
56 | 57 | * |
57 | | - * @param {Object} data Fliker response data |
| 58 | + * @param {Object} response data |
58 | 59 | */ |
59 | 60 | addResults:function( data ) { |
60 | 61 | var _this = this; |
— | — | @@ -65,7 +66,12 @@ |
66 | 67 | //if ( this.num_results > this.provider.offset + this.provider.limit ) { |
67 | 68 | // this.more_results = true; |
68 | 69 | //} |
| 70 | + |
| 71 | + // Display option for more results as long as results are coming in |
| 72 | + this.more_results = ( data.length == this.limit ) |
| 73 | + |
69 | 74 | for ( var resource_id in data ) { |
| 75 | + |
70 | 76 | var result = data[ resource_id ]; |
71 | 77 | // Update mappings: |
72 | 78 | result['poster'] = result['thumbnail']; |
— | — | @@ -76,7 +82,8 @@ |
77 | 83 | //or gennerated at request time for mediaWiki |
78 | 84 | var ext = this.getMimeExtension( result['mime'] ); |
79 | 85 | result['titleKey'] = 'File:' + result['title'] + '.' + ext; |
80 | | - |
| 86 | + |
| 87 | + this.num_results++; |
81 | 88 | _this.resultsObj[ resource_id ] = result; |
82 | 89 | |
83 | 90 | } |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | "rsd-wiki_commons-title": "Wikimedia Commons", |
59 | 59 | "rsd-wiki_commons": "Wikimedia Commons, an archive of freely-licensed educational media content (images, sound and video clips)", |
60 | 60 | |
61 | | - "rsd-kaltura-title" : "Kaltura search", |
| 61 | + "rsd-kaltura-title" : "All Sources", |
62 | 62 | "rsd-kaltura" : "Kaltura agragated search for free-licenced media across multiple search providers", |
63 | 63 | |
64 | 64 | "rsd-this_wiki-title" : "This wiki", |
— | — | @@ -250,6 +250,19 @@ |
251 | 251 | }, |
252 | 252 | |
253 | 253 | /** |
| 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 | + /** |
254 | 267 | * Wikipedia Commons search provider configuration |
255 | 268 | */ |
256 | 269 | 'wiki_commons': { |
— | — | @@ -270,23 +283,9 @@ |
271 | 284 | // Specific to wiki commons config: |
272 | 285 | // If we should search the title |
273 | 286 | 'search_title': false |
274 | | - |
275 | 287 | }, |
276 | 288 | |
277 | 289 | /** |
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 | | - /** |
291 | 290 | * Internet archive search provider configuration |
292 | 291 | */ |
293 | 292 | 'archive_org': { |
— | — | @@ -801,19 +800,18 @@ |
802 | 801 | var _this = this; |
803 | 802 | mw.log( 'f::initDialog' ); |
804 | 803 | |
805 | | - var mainContainer = $j(this.target_container); |
| 804 | + var mainContainer = $j( this.target_container ); |
806 | 805 | |
807 | 806 | var controlContainer = this.createControlContainer(); |
808 | 807 | |
809 | | - mainContainer.append(controlContainer); |
| 808 | + mainContainer.append( controlContainer ); |
810 | 809 | |
811 | | - resultsContainer = $j('<div />').attr({ |
| 810 | + this.$resultsContainer = $j('<div />').attr({ |
812 | 811 | id: "rsd_results_container" |
813 | 812 | }); |
814 | | - mainContainer.append(resultsContainer); |
815 | 813 | |
816 | | - // Draw the tabs: |
817 | | - this.createTabs(); |
| 814 | + mainContainer.append( this.$resultsContainer ); |
| 815 | + |
818 | 816 | // run the default search: |
819 | 817 | if ( this.getDefaultQuery() ) |
820 | 818 | this.showCurrentTab(); |
— | — | @@ -853,38 +851,32 @@ |
854 | 852 | createControlContainer: function() { |
855 | 853 | var _this = this; |
856 | 854 | |
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({ |
859 | 857 | id : "rsd_form", |
860 | 858 | action : "javascript:return false" |
861 | 859 | }); |
862 | | - var $providerSelection = $j('<ul />').addClass("ui-provider-selection"); |
| 860 | + var $providerSelection = $j( '<ul />' ).addClass( "ui-provider-selection" ); |
863 | 861 | |
864 | 862 | // Add enabled search providers. |
865 | 863 | for ( var providerName in this.content_providers ) { |
866 | 864 | var content_providers = this.content_providers; |
867 | 865 | 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' ) ) |
871 | 869 | .attr({ |
872 | 870 | name: providerName |
873 | 871 | }); |
874 | 872 | if ( this.current_provider == providerName) { |
875 | | - $anchor.addClass('ui-selected'); |
| 873 | + $anchor.addClass( 'ui-selected' ); |
876 | 874 | } |
877 | 875 | |
878 | 876 | $anchor.click( function() { |
879 | 877 | $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' ); |
887 | 879 | $j( this ).addClass( 'ui-selected' ); |
888 | | - //TODO: set flag for provider selection |
| 880 | + _this.current_provider = $j( this ).attr( "name" ); |
889 | 881 | }); |
890 | 882 | |
891 | 883 | var $listItem = $j( '<li />' ); |
— | — | @@ -893,7 +885,7 @@ |
894 | 886 | } |
895 | 887 | } |
896 | 888 | |
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({ |
898 | 890 | type: "text", |
899 | 891 | tabindex: 1, |
900 | 892 | value: this.getDefaultQuery(), |
— | — | @@ -903,15 +895,17 @@ |
904 | 896 | size: 20, |
905 | 897 | autocomplete: "off" |
906 | 898 | }); |
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') }) |
908 | 902 | .addClass( 'rsd_search_button' ) |
909 | 903 | .buttonHover() |
910 | 904 | .click(function (){ |
911 | 905 | //TODO: Add search provider call. |
912 | | - _this.showCurrentTab(); |
| 906 | + _this.showSearchTab( _this.current_provider, true ); |
913 | 907 | }); |
914 | 908 | |
915 | | - //$searchForm.append( $providerSelection ); |
| 909 | + $searchForm.append( $providerSelection ); |
916 | 910 | $searchForm.append( $searchBox ); |
917 | 911 | $searchForm.append( $searchButton ); |
918 | 912 | /* |
— | — | @@ -1078,11 +1072,14 @@ |
1079 | 1073 | if ( !draw_direct_flag ) { |
1080 | 1074 | // See if we should reset the paging |
1081 | 1075 | 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 | + } |
1083 | 1080 | } |
1084 | 1081 | |
1085 | 1082 | // 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() ); |
1087 | 1084 | |
1088 | 1085 | // Make sure the search library is loaded and issue the search request |
1089 | 1086 | this.getLibSearchResults( provider ); |
— | — | @@ -1205,7 +1202,7 @@ |
1206 | 1203 | // combined results are harder to error handle just ignore that repo |
1207 | 1204 | provider.sObj.loading = false; |
1208 | 1205 | } else { |
1209 | | - $j( '#tab-' + this.current_provider ).html( |
| 1206 | + $j( '#rsd_results_container' ).html( |
1210 | 1207 | '<div style="padding:10px">' + |
1211 | 1208 | gM( 'mwe-no_import_by_url' ) + |
1212 | 1209 | '</div>' ); |
— | — | @@ -1256,6 +1253,7 @@ |
1257 | 1254 | // inherit defaults if not set: |
1258 | 1255 | provider.limit = provider.limit ? provider.limit : provider.sObj.limit; |
1259 | 1256 | provider.offset = provider.offset ? provider.offset : provider.sObj.offset; |
| 1257 | + |
1260 | 1258 | callback( provider ); |
1261 | 1259 | } ); |
1262 | 1260 | }, |
— | — | @@ -1304,72 +1302,6 @@ |
1305 | 1303 | }, |
1306 | 1304 | |
1307 | 1305 | /** |
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 | | - /** |
1374 | 1306 | * Get a resource object from a resource id |
1375 | 1307 | * |
1376 | 1308 | * NOTE: We could bind resource objects to html elements to avoid this lookup |
— | — | @@ -1400,8 +1332,11 @@ |
1401 | 1333 | mw.log( 'f:showResults::' + this.current_provider ); |
1402 | 1334 | var _this = this; |
1403 | 1335 | 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 | + /* |
1406 | 1341 | if ( this.current_provider == 'upload' ) { |
1407 | 1342 | tabSelector = '#upload_bin'; |
1408 | 1343 | var provider = _this.content_providers['this_wiki']; |
— | — | @@ -1410,14 +1345,13 @@ |
1411 | 1346 | tabSelector = '#tab-' + this.current_provider; |
1412 | 1347 | // Output the results bar / controls |
1413 | 1348 | } |
| 1349 | + */ |
1414 | 1350 | |
1415 | 1351 | // 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(); |
1421 | 1354 | |
| 1355 | + this.$resultsContainer.append( _this.createResultsHeader() ); |
1422 | 1356 | var numResults = 0; |
1423 | 1357 | |
1424 | 1358 | // Output all the results for the current current_provider |
— | — | @@ -1427,9 +1361,11 @@ |
1428 | 1362 | numResults++; |
1429 | 1363 | } ); |
1430 | 1364 | // 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"/>' ); |
1432 | 1366 | } |
1433 | 1367 | |
| 1368 | + this.$resultsContainer.append( _this.createResultsFooter() ); |
| 1369 | + |
1434 | 1370 | mw.log( 'did numResults :: ' + numResults + |
1435 | 1371 | ' append: ' + $j( '#rsd_q' ).val() ); |
1436 | 1372 | // Remove any old search res |
— | — | @@ -2574,23 +2510,20 @@ |
2575 | 2511 | }, 25 |
2576 | 2512 | ); |
2577 | 2513 | }, |
| 2514 | + |
2578 | 2515 | /** |
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 | + |
2583 | 2522 | var _this = this; |
2584 | 2523 | var darkBoxUrl = mw.getConfig( 'skin_img_path' ) + 'box_layout_icon_dark.png'; |
2585 | 2524 | var lightBoxUrl = mw.getConfig( 'skin_img_path' ) + 'box_layout_icon.png'; |
2586 | 2525 | var darkListUrl = mw.getConfig( 'skin_img_path' ) + 'list_layout_icon_dark.png'; |
2587 | 2526 | 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 | + |
2595 | 2528 | var defaultBoxUrl, defaultListUrl; |
2596 | 2529 | if ( _this.displayMode == 'box' ) { |
2597 | 2530 | defaultBoxUrl = darkBoxUrl; |
— | — | @@ -2599,31 +2532,13 @@ |
2600 | 2533 | defaultBoxUrl = lightBoxUrl; |
2601 | 2534 | defaultListUrl = darkListUrl; |
2602 | 2535 | } |
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 | + }) |
2628 | 2543 | .hover( |
2629 | 2544 | function() { |
2630 | 2545 | $j( this ).attr( "src", darkBoxUrl ); |
— | — | @@ -2632,12 +2547,16 @@ |
2633 | 2548 | $j( this ).attr( "src", defaultBoxUrl ); |
2634 | 2549 | } ) |
2635 | 2550 | .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 ); |
2638 | 2553 | _this.setDisplayMode( 'box' ); |
2639 | 2554 | } ); |
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 | + }) |
2642 | 2561 | .hover( |
2643 | 2562 | function() { |
2644 | 2563 | $j( this ).attr( "src", darkListUrl ); |
— | — | @@ -2646,63 +2565,150 @@ |
2647 | 2566 | $j( this ).attr( "src", defaultListUrl ); |
2648 | 2567 | } ) |
2649 | 2568 | .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 ); |
2652 | 2571 | _this.setDisplayMode( 'list' ); |
2653 | 2572 | } ); |
| 2573 | + |
| 2574 | + $layoutSelector = $j( '<span />' ) |
| 2575 | + .append( $boxLayout ) |
| 2576 | + .append( $listLayout ); |
| 2577 | + |
| 2578 | + return $layoutSelector; |
2654 | 2579 | }, |
| 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 | + }, |
2655 | 2625 | |
2656 | 2626 | /** |
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. |
2658 | 2645 | * |
2659 | | - * @param {String} target jQuery Selector for pagging Header output |
| 2646 | + * @return {jQuery element} paging control for current results |
2660 | 2647 | */ |
2661 | | - showPagingHeader: function( target ) { |
| 2648 | + createPagingControl: function( target ) { |
2662 | 2649 | 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 ]; |
2668 | 2651 | 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 ); |
2670 | 2654 | var to_num = ( provider.limit > search.num_results ) ? |
2671 | 2655 | ( parseInt( provider.offset ) + parseInt( search.num_results ) ) : |
2672 | 2656 | ( 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 = ''; |
2675 | 2664 | // @@todo we should instead support the wiki number format template system instead of inline calls |
2676 | 2665 | if ( search.num_results != 0 ) { |
2677 | 2666 | 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, |
2679 | 2668 | mw.lang.formatNumber( search.num_results )] ); |
2680 | 2669 | } else { |
2681 | | - out += gM( 'rsd_results_desc', [( provider.offset + 1 ), to_num] ); |
| 2670 | + resultEnumeration = gM( 'rsd_results_desc', [( provider.offset + 1 ), to_num] ); |
2682 | 2671 | } |
2683 | 2672 | } |
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 |
2685 | 2679 | 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 ); |
2687 | 2694 | } |
2688 | 2695 | |
| 2696 | + // Place the next results link |
2689 | 2697 | 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 ); |
2691 | 2710 | } |
2692 | 2711 | |
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; |
2707 | 2713 | }, |
2708 | 2714 | |
2709 | 2715 | /** |