Index: branches/js2-work/phase3/js/mwEmbed/skins/common/common.css |
— | — | @@ -96,9 +96,7 @@ |
97 | 97 | } |
98 | 98 | #rsd_filters_container { |
99 | 99 | float:left; |
100 | | - padding-top:12px; |
101 | 100 | width:150px; |
102 | | - height: 100%; |
103 | 101 | } |
104 | 102 | |
105 | 103 | .ui-filter-title { |
— | — | @@ -451,4 +449,4 @@ |
452 | 450 | |
453 | 451 | .interface_wrap{ |
454 | 452 | position:relative; |
455 | | -} |
\ No newline at end of file |
| 453 | +} |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js |
— | — | @@ -2,6 +2,95 @@ |
3 | 3 | * Kaltura aggregated search: |
4 | 4 | */ |
5 | 5 | |
| 6 | +var kalturaFilters = function ( options ) { |
| 7 | + return this.init( options ); |
| 8 | +} |
| 9 | + |
| 10 | +kalturaFilters.prototype = { |
| 11 | + |
| 12 | + init: function( options ) { |
| 13 | + var mediaTypes = { |
| 14 | + video: 'Videos', |
| 15 | + image: 'Images' |
| 16 | + }; |
| 17 | + |
| 18 | + var providers = { |
| 19 | + wiki_commons: 'Wikipedia Commons', |
| 20 | + archive_org: 'The Internet Archive', |
| 21 | + metavid: 'Metavid', |
| 22 | + flickr: 'Flickr' |
| 23 | + }; |
| 24 | + |
| 25 | + this.filterList = { |
| 26 | + media: { title: 'Media', options: mediaTypes }, |
| 27 | + providers: { title: 'Providers', options: providers } |
| 28 | + }; |
| 29 | + |
| 30 | + return this; |
| 31 | + }, |
| 32 | + |
| 33 | + |
| 34 | + /** |
| 35 | + * Create an HTML representation of the available search filters and append |
| 36 | + * them to the given element. |
| 37 | + * |
| 38 | + * @param {jQuery element} The base element to which HTML items should be |
| 39 | + * appended. |
| 40 | + */ |
| 41 | + |
| 42 | + getHTML: function() { |
| 43 | + var _this = this; |
| 44 | + mw.log( 'f: populateFilterContainer ' ); |
| 45 | + |
| 46 | + $filtersContainer = $j( '<div />' ); |
| 47 | + |
| 48 | + for (filter in this.filterList) { |
| 49 | + $filtersContainer.append( |
| 50 | + this.getFilterBox( 'rsd_' + filter + '_filter', |
| 51 | + this.filterList[ filter ].title, |
| 52 | + this.filterList[ filter ].options )); |
| 53 | + } |
| 54 | + |
| 55 | + return $filtersContainer; |
| 56 | + }, |
| 57 | + |
| 58 | + /** |
| 59 | + * Creates a single filter box with given selection options |
| 60 | + * |
| 61 | + * @id {string} unique id for this filter box an residing elements |
| 62 | + * @title {string} title of the filter box |
| 63 | + * @options {array} array of strings describing the options in the filter box |
| 64 | + * |
| 65 | + */ |
| 66 | + |
| 67 | + getFilterBox: function( id, title, filterOptions ) { |
| 68 | + $box = $j( '<div />' ).addClass( 'ui-filter-box' ).attr({ |
| 69 | + 'id': id |
| 70 | + }); |
| 71 | + |
| 72 | + $title = $j( '<div />' ).addClass( 'ui-filter-title' ).text( title ); |
| 73 | + $box.append( $title ); |
| 74 | + |
| 75 | + for (filterID in filterOptions) { |
| 76 | + $option = $j( '<div />' ).addClass( 'ui-filter-option' ).text( filterOptions[ filterID ] ); |
| 77 | + |
| 78 | + $checkbox = $j( '<input />' ) |
| 79 | + .attr( { |
| 80 | + type: 'checkbox', |
| 81 | + name: id + '_' + title + '_' + filterID, |
| 82 | + value: filterID, |
| 83 | + checked: true |
| 84 | + } ); |
| 85 | + |
| 86 | + $option.prepend( $checkbox ); |
| 87 | + $box.append( $option ); |
| 88 | + } |
| 89 | + |
| 90 | + return $box; |
| 91 | + }, |
| 92 | + |
| 93 | +}; |
| 94 | + |
6 | 95 | var kalturaSearch = function ( options ) { |
7 | 96 | return this.init( options ); |
8 | 97 | } |
— | — | @@ -12,12 +101,13 @@ |
13 | 102 | searchLibs: { }, |
14 | 103 | |
15 | 104 | /** |
16 | | - * Initialize the flickr Search with provided options |
| 105 | + * Initialize the Search with provided options |
17 | 106 | * |
18 | 107 | * @param {Object} options Initial options for the kalturaSearch class |
19 | 108 | */ |
20 | 109 | init:function( options ) { |
21 | 110 | this.options = options; |
| 111 | + this.filters = new kalturaFilters( options ); |
22 | 112 | var baseSearch = new baseRemoteSearch( options ); |
23 | 113 | for ( var i in baseSearch ) { |
24 | 114 | if ( typeof this[i] == 'undefined' ) { |
— | — | @@ -26,6 +116,8 @@ |
27 | 117 | this['parent_' + i] = baseSearch[i]; |
28 | 118 | } |
29 | 119 | } |
| 120 | + |
| 121 | + return this; |
30 | 122 | }, |
31 | 123 | |
32 | 124 | /** |
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js |
— | — | @@ -255,13 +255,7 @@ |
256 | 256 | 'lib': 'kaltura', |
257 | 257 | 'resource_prefix' : '', |
258 | 258 | 'tab_image':false, |
259 | | - show_filters: true, |
260 | | - aggregated_providers:{ |
261 | | - 'Wikipedia Commons': 'wiki_commons', |
262 | | - 'The Internet Archive': 'archive_org', |
263 | | - 'Metavid': 'metavid', |
264 | | - 'Flickr': 'flickr' |
265 | | - } |
| 259 | + disable_filters: true |
266 | 260 | }, |
267 | 261 | |
268 | 262 | /** |
— | — | @@ -668,7 +662,7 @@ |
669 | 663 | this.current_provider == 'upload' ) |
670 | 664 | { |
671 | 665 | $j( '#rsd_q' ).val( query ); |
672 | | - _this.UpdateResults(); |
| 666 | + _this.updateResults(); |
673 | 667 | } |
674 | 668 | // $j(_this.target_container).dialog("open"); |
675 | 669 | $j( _this.target_container ).parents( '.ui-dialog' ).fadeIn( 'slow' ); |
— | — | @@ -807,11 +801,6 @@ |
808 | 802 | var controlContainer = this.createControlContainer(); |
809 | 803 | |
810 | 804 | mainContainer.append( controlContainer ); |
811 | | - |
812 | | - this.$filtersContainer = $j('<form />').hide() |
813 | | - .attr({ |
814 | | - id: "rsd_filters_container" |
815 | | - }); |
816 | 805 | |
817 | 806 | this.$resultsContainer = $j('<div />').attr({ |
818 | 807 | id: "rsd_results_container" |
— | — | @@ -822,7 +811,7 @@ |
823 | 812 | |
824 | 813 | // Run the default search: |
825 | 814 | if ( this.getDefaultQuery() ) |
826 | | - this.UpdateResults(); |
| 815 | + this.updateResults(); |
827 | 816 | |
828 | 817 | // Add bindings |
829 | 818 | $j( '#mso_selprovider,#mso_selprovider_close' ) |
— | — | @@ -846,7 +835,7 @@ |
847 | 836 | $j( '#rsd_form' ) |
848 | 837 | .unbind() |
849 | 838 | .submit( function() { |
850 | | - _this.UpdateResults(); |
| 839 | + _this.updateResults(); |
851 | 840 | // Don't submit the form |
852 | 841 | return false; |
853 | 842 | } ); |
— | — | @@ -875,7 +864,7 @@ |
876 | 865 | .addClass( 'rsd_search_button' ) |
877 | 866 | .buttonHover() |
878 | 867 | .click(function (){ |
879 | | - _this.UpdateResults( _this.current_provider, true ); |
| 868 | + _this.updateResults( _this.current_provider, true ); |
880 | 869 | }); |
881 | 870 | var $searchBox = $j( '<input />' ).addClass( 'ui-widget-content ui-corner-all' ).attr({ |
882 | 871 | type: "text", |
— | — | @@ -917,7 +906,7 @@ |
918 | 907 | $j( this ).addClass( 'ui-selected' ); |
919 | 908 | _this.current_provider = $j( this ).attr( "name" ); |
920 | 909 | // Update the search results on provider selection |
921 | | - _this.UpdateResults( _this.current_provider, true ); |
| 910 | + _this.updateResults( _this.current_provider, true ); |
922 | 911 | }); |
923 | 912 | |
924 | 913 | var $listItem = $j( '<li />' ); |
— | — | @@ -935,7 +924,7 @@ |
936 | 925 | .addClass("rsd_upload_button") |
937 | 926 | .click(function(){ |
938 | 927 | _this.current_provider = 'upload'; |
939 | | - _this.UpdateUploadResults( ); |
| 928 | + _this.updateUploadResults( ); |
940 | 929 | }); |
941 | 930 | $searchForm.append( $uploadButton ); |
942 | 931 | /* |
— | — | @@ -954,8 +943,8 @@ |
955 | 944 | /** |
956 | 945 | * Shows the upload tab loader and issues a call to showUploadForm |
957 | 946 | */ |
958 | | - UpdateUploadResults: function() { |
959 | | - mw.log( "UpdateUploadResults::" ); |
| 947 | + updateUploadResults: function() { |
| 948 | + mw.log( "updateUploadResults::" ); |
960 | 949 | var _this = this; |
961 | 950 | // set it to loading: |
962 | 951 | this.$resultsContainer.loadingSpinner(); |
— | — | @@ -1046,12 +1035,11 @@ |
1047 | 1036 | /** |
1048 | 1037 | * Refresh the results container ( based on current_provider var ) |
1049 | 1038 | */ |
1050 | | - UpdateResults: function() { |
1051 | | - this.$filtersContainer.hide(); |
| 1039 | + updateResults: function() { |
1052 | 1040 | if ( this.current_provider == 'upload' ) { |
1053 | | - this.UpdateUploadResults(); |
| 1041 | + this.updateUploadResults(); |
1054 | 1042 | } else { |
1055 | | - this.UpdateSearchResults( this.current_provider, false ); |
| 1043 | + this.updateSearchResults( this.current_provider, false ); |
1056 | 1044 | } |
1057 | 1045 | }, |
1058 | 1046 | |
— | — | @@ -1061,8 +1049,8 @@ |
1062 | 1050 | * @param {String} providerName name of the content provider |
1063 | 1051 | * @param {Bollean} resetPaging if the pagging should be reset |
1064 | 1052 | */ |
1065 | | - UpdateSearchResults: function( providerName, resetPaging ) { |
1066 | | - mw.log( "f:UpdateSearchResults::" + providerName ); |
| 1053 | + updateSearchResults: function( providerName, resetPaging ) { |
| 1054 | + mw.log( "f:updateSearchResults::" + providerName ); |
1067 | 1055 | |
1068 | 1056 | var draw_direct_flag = true; |
1069 | 1057 | var provider = this.content_providers[ providerName ]; |
— | — | @@ -1098,7 +1086,7 @@ |
1099 | 1087 | this.$resultsContainer.html( mw.loading_spinner() ); |
1100 | 1088 | |
1101 | 1089 | // Make sure the search library is loaded and issue the search request |
1102 | | - this.PerformProviderSearch( provider ); |
| 1090 | + this.performProviderSearch( provider ); |
1103 | 1091 | }, |
1104 | 1092 | |
1105 | 1093 | /* |
— | — | @@ -1194,74 +1182,22 @@ |
1195 | 1183 | } ); |
1196 | 1184 | }, |
1197 | 1185 | |
1198 | | - |
1199 | | - createSearchFilters: function( current_provider ) { |
1200 | | - var _this = this; |
1201 | | - mw.log( 'f: CreateSearchFilters ' ); |
1202 | | - |
1203 | | - this.CreateFilterBox( 'rsd_media_type_filter', |
1204 | | - 'Media', |
1205 | | - { Video: 'video', |
1206 | | - Image: 'image', |
1207 | | - Audio: 'audio' } ); |
1208 | | - |
1209 | | - this.CreateFilterBox( 'rsd_provider_filter', |
1210 | | - 'Provider', |
1211 | | - current_provider.aggregated_providers ); |
1212 | | - |
1213 | | - }, |
1214 | | - |
1215 | 1186 | /** |
1216 | | - * Creates a single filter box with given options and appends it to the filter container. |
1217 | | - * |
1218 | | - * @id {string} unique id for this filter box an residing elements |
1219 | | - * @title {string} title of the filter box |
1220 | | - * @options {array} array of strings describing the options in the filter box |
1221 | | - * |
1222 | | - */ |
1223 | | - |
1224 | | - CreateFilterBox: function( id, title, options ) { |
1225 | | - $box = $j( '<div />' ).addClass( 'ui-filter-box' ).attr({ |
1226 | | - 'id': id |
1227 | | - }); |
1228 | | - |
1229 | | - $title = $j( '<div />' ).addClass( 'ui-filter-title' ).text( title ); |
1230 | | - $box.append( $title ); |
1231 | | - |
1232 | | - for (option in options) { |
1233 | | - $option = $j( '<div />' ).addClass( 'ui-filter-option' ).text( option ); |
1234 | | - |
1235 | | - $checkbox = $j( '<input />' ) |
1236 | | - .attr( { |
1237 | | - type: 'checkbox', |
1238 | | - name: id + '_' + title + '_' + options.option, |
1239 | | - value: options.option, |
1240 | | - checked: true |
1241 | | - } ); |
1242 | | - |
1243 | | - $option.prepend( $checkbox ); |
1244 | | - $box.append( $option ); |
1245 | | - } |
1246 | | - |
1247 | | - this.$filtersContainer.append($box); |
1248 | | - }, |
1249 | | - |
1250 | | - /** |
1251 | 1187 | * Performs the search for a given content provider |
1252 | 1188 | * |
1253 | 1189 | * Calls showResults once search results are ready |
1254 | 1190 | * |
1255 | 1191 | * @param {Object} provider the provider to be searched. |
1256 | 1192 | */ |
1257 | | - PerformProviderSearch: function( provider ) { |
| 1193 | + performProviderSearch: function( provider ) { |
1258 | 1194 | var _this = this; |
1259 | | - mw.log( 'f: PerformProviderSearch ' ); |
| 1195 | + mw.log( 'f: performProviderSearch ' ); |
1260 | 1196 | // First check if we should even run the search at all (can we import / insert |
1261 | 1197 | // into the page? ) |
1262 | 1198 | if ( !this.isProviderLocal( provider ) && this.import_url_mode == 'autodetect' ) { |
1263 | 1199 | // provider is not local check if we can support the import mode: |
1264 | 1200 | this.checkForCopyURLSupport( function() { |
1265 | | - _this.PerformProviderSearch( provider ); |
| 1201 | + _this.performProviderSearch( provider ); |
1266 | 1202 | } ); |
1267 | 1203 | return false; |
1268 | 1204 | } else if ( !this.isProviderLocal( provider ) && this.import_url_mode == 'none' ) { |
— | — | @@ -1378,9 +1314,10 @@ |
1379 | 1315 | $resultsContainer.empty().append( this.createResultsHeader() ) |
1380 | 1316 | |
1381 | 1317 | // Enable search filters, if the provider supports them. |
1382 | | - if ( provider.show_filters ) { |
1383 | | - // this.$filtersContainer.show(); |
1384 | | - this.createSearchFilters( provider ); |
| 1318 | + if ( provider.sObj.filters && !(provider.disable_filters) ) { |
| 1319 | + $resultsContainer.append( provider.sObj.filters.getHTML().attr ({ |
| 1320 | + id: 'rsd_filters_container' |
| 1321 | + })); |
1385 | 1322 | } |
1386 | 1323 | } |
1387 | 1324 | |
— | — | @@ -2861,7 +2798,7 @@ |
2862 | 2799 | provider.offset -= provider.limit; |
2863 | 2800 | if ( provider.offset < 0 ) |
2864 | 2801 | provider.offset = 0; |
2865 | | - _this.UpdateResults(); |
| 2802 | + _this.updateResults(); |
2866 | 2803 | } ); |
2867 | 2804 | $pagingControl.prepend( $prevLink ); |
2868 | 2805 | } |
— | — | @@ -2877,7 +2814,7 @@ |
2878 | 2815 | .text( nextLinkText ) |
2879 | 2816 | .click( function() { |
2880 | 2817 | provider.offset += provider.limit; |
2881 | | - _this.UpdateResults(); |
| 2818 | + _this.updateResults(); |
2882 | 2819 | } ); |
2883 | 2820 | $pagingControl.append( $nextLink ); |
2884 | 2821 | } |
— | — | @@ -2893,10 +2830,10 @@ |
2894 | 2831 | mw.log( 'select tab: ' + provider_id ); |
2895 | 2832 | this.current_provider = provider_id; |
2896 | 2833 | if ( this.current_provider == 'upload' ) { |
2897 | | - this.UpdateUploadResults(); |
| 2834 | + this.updateUploadResults(); |
2898 | 2835 | } else { |
2899 | 2836 | // update the search results: |
2900 | | - this.UpdateResults(); |
| 2837 | + this.updateResults(); |
2901 | 2838 | } |
2902 | 2839 | }, |
2903 | 2840 | |