r61196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61195‎ | r61196 | r61197 >
Date:02:37, 18 January 2010
Author:dale
Status:deferred (Comments)
Tags:
Comment:
* fix to archive.org k-search integration
* moved embedTypes to mw class
* some style updates to 61162
* hide non-working features
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/mwEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Playlist_Render.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/tests/Playlist_Render.html
@@ -25,17 +25,14 @@
2626 });
2727
2828 $j('#loading_text').hide();
 29+ $j('#info_control').show();
2930 if( foggRender.enabled ){
30 - $j('#info_control').show();
 31+
3132 }else{
 33+ var firefoggUrl = foggRender.myFogg.getFirefoggInstallUrl();
3234 $j('#info_control').html(
33 - foggRender.myFogg.getTargetHtml('target_please_install')
34 - );
35 - if(!($j.browser.mozilla && $j.browser.version >= '1.9.1')) {
36 - $j('#info_control').html(
37 - foggRender.myFogg.getTargetHtml('target_use_latest_fox')
38 - );
39 - }
 35+ gM( 'fogg-please_install', firefoggUrl )
 36+ )
4037 }
4138
4239 });
@@ -44,16 +41,16 @@
4542 </script>
4643 </head>
4744 <body>
48 - <!-- <playlist id="render_player" src="media/sample_smil.xml" controls="false" width="320" height="240"></playlist> -->
 45+ <playlist id="render_player" src="media/sample_smil.xml" controls="false" width="320" height="240"></playlist>
4946
5047
51 -<video id="render_player"
 48+ <!--<video id="render_player"
5249 durationHint="5"
5350 src="http://upload.wikimedia.org/wikipedia/commons/4/41/Panthera_tigris8.ogg"
5451 style="width:320px;height:240px;"
5552 controls="false"
5653 poster="http://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Panthera_tigris8.ogg/mid-Panthera_tigris8.ogg.jpg">
57 -</video>
 54+</video> -->
5855
5956
6057 <span id="loading_text" style="position:absolute; top:320px;">
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -330,7 +330,7 @@
331331 return false;
332332
333333 // See if we have native support for ogg:
334 - var supporting_players = embedTypes.players.getMIMETypePlayers( 'video/ogg' );
 334+ var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( 'video/ogg' );
335335 for ( var i = 0; i < supporting_players.length; i++ ) {
336336 if ( supporting_players[i].id == 'videoElement' ) {
337337 return false;
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedText.js
@@ -1130,10 +1130,8 @@
11311131 } );
11321132
11331133 return captions;
1134 - }
 1134+ }
11351135
1136 -
1137 -
11381136 /**
11391137 * Text Providers
11401138 *
Index: branches/js2-work/phase3/js/mwEmbed/modules/TimedText/mw.TimedTextEdit.js
@@ -293,7 +293,7 @@
294294 * Uploads the text content
295295 */
296296 uploadTextFile: function(){
297 - //put a dialog ontop
 297+ // Put a dialog ontop
298298 mw.addLoaderDialog( gM( 'mwe-uploading-text') );
299299
300300 // Get timed text target title
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/kalturaSearch.js
@@ -66,16 +66,17 @@
6767 // this.more_results = true;
6868 //}
6969 for ( var resource_id in data ) {
70 - var result = data[ resource_id ];
71 -
72 - // Update mapings:
 70+ var result = data[ resource_id ];
 71+ // Update mappings:
7372 result['poster'] = result['thumbnail'];
7473 result['pSobj'] = _this;
7574 result['link'] = result[ 'item_details_page' ];
7675
77 - if( !result['titleKey'] && result['src'] ){
78 - result['titleKey'] = 'File:' + result['src'].split('/').pop();
79 - }
 76+ //@@todo this should be refactored per search library
 77+ //or gennerated at request time for mediaWiki
 78+ var ext = this.getMimeExtension( result['mime'] );
 79+ result['titleKey'] = 'File:' + result['title'] + '.' + ext;
 80+
8081 _this.resultsObj[ resource_id ] = result;
8182
8283 }
@@ -96,7 +97,16 @@
9798 searchLib.getImageObj( resource, size, callback );
9899 });
99100 },
100 -
 101+ /*
 102+ * Get extra resource info via a library specific callback
 103+ * NOTE: this info should be included in the original kaltura search results
 104+ */
 105+ addResourceInfoCallback: function( resource, callback ){
 106+ mw.log('Kaltura: addResourceInfoCallback');
 107+ this.getSerachLib( resource.content_provider_id, function( searchLib ){
 108+ searchLib.addResourceInfoCallback( resource, callback );
 109+ });
 110+ },
101111 /**
102112 * Get and load provider via id
103113 * @param {String} provider_id The id of the content provider
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js
@@ -206,6 +206,7 @@
207207 getEmbedHTML: function( resource , options ) {
208208 if ( !options )
209209 options = { };
 210+
210211 // Set up the output var with the default values:
211212 if(! options.width )
212213 options.width = resource.width;
@@ -219,22 +220,23 @@
220221 }
221222
222223 options.style = '';
223 - if( options.height )
 224+ if( options.height ){
224225 options.style += 'height:' + options.height + 'px;';
225 -
226 - if( options.width )
 226+ }
 227+ if( options.width ){
227228 options.style += 'width:' + options.width + 'px;';
228 -
 229+ }
229230 if ( resource.mime.indexOf( 'image' ) != -1 )
230231 outHtml = this.getImageEmbedHTML( resource, options );
231232
232233 if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' || resource.mime == 'audio/ogg' ) {
233 - // Setup the attribute html:
 234+ // Setup the attribute html (can't use jQuery builder for video element in a cross browser friendly way.)
234235 var ahtml = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
235236 ahtml+= 'src="' + resource.src + '" ' +
236237 'style="' + options.style + '" ' +
237 - 'poster="' + resource.poster + '" ';
238 -
 238+ 'poster="' + resource.poster + '" '+
 239+ 'type="' + resource.mime + '" ';
 240+
239241 if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' ) {
240242 outHtml = '<video ' + ahtml + '></video>';
241243 }
@@ -430,5 +432,21 @@
431433 resource.target_resource_title = resource.titleKey.replace( /^(File:|Image:)/ , '' );
432434 resource.target_resource_title = this.provider.resource_prefix + resource.target_resource_title;
433435 }
 436+ },
 437+
 438+ /**
 439+ * Utily to convert from mime type to extension
 440+ */
 441+ getMimeExtension: function( mime ){
 442+ if( mime == 'video/ogg' || mime == 'application/ogg' )
 443+ return 'ogv';
 444+ if( mime == 'audio/ogg' )
 445+ return 'oga';
 446+ if( mime == 'image/jpeg' )
 447+ return 'jpg';
 448+ if( mime == 'image/png' )
 449+ return 'png';
 450+ if( mime == 'image/svg+xml' )
 451+ return 'svg';
434452 }
435453 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js
@@ -79,7 +79,7 @@
8080 var resource = {
8181 // @@todo we should add .ogv or oga if video or audio:
8282 'titleKey' : resource.identifier + '.ogv',
83 - 'resourceKey': resource.identifier,
 83+ 'id': resource.identifier,
8484 'link' : _this.detailsUrl + resource.identifier,
8585 'title' : resource.title,
8686 'poster' : _this.downloadUrl + resource.identifier + '/format=thumbnail',
@@ -104,11 +104,11 @@
105105 * @param {Object} resource Resource to add metadata to.
106106 * @param {Function} callbcak Function called once extra metadata is added.
107107 */
108 - addResourceInfoCallback: function( resource, callback ) {
 108+ addResourceInfoCallback: function( resource, callback ) {
109109 var _this = this;
110 - mw.log( 'addResourceInfoCallback' );
 110+ mw.log( 'archiveOrg: addResourceInfoCallback' );
111111 mw.getJSON(
112 - _this.downloadUrl + resource.resourceKey + '/format=Ogg+video?callback=?',
 112+ _this.downloadUrl + resource.id + '/format=Ogg+video?callback=?',
113113 { 'avinfo' : 1 },
114114 function( data ) {
115115 if ( data['length'] )
@@ -120,7 +120,7 @@
121121 callback();
122122 } );
123123 },
124 -
 124+
125125 /**
126126 * Returns html to embed a given result Object ( resource )
127127 * @param {Object} resource Resource to get embed HTML from.
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -22,7 +22,6 @@
2323 "rsd_resource_edit" : "Edit resource: $1",
2424 "mwe-resource_description_page" : "Resource description page",
2525 "mwe-link" : "link",
26 - "rsd_local_resource_title" : "Local resource title",
2726 "rsd_do_insert" : "Do insert",
2827 "mwe-cc_title" : "Creative Commons",
2928 "mwe-cc_by_title" : "Attribution",
@@ -283,6 +282,7 @@
284283 'homepage': 'http://kaltura.com',
285284 'api_url': 'http://kaldev.kaltura.com/michael/aggregator.php',
286285 'lib': 'kaltura',
 286+ 'resource_prefix' : '',
287287 'tab_image':false
288288 },
289289
@@ -853,47 +853,47 @@
854854 createControlContainer: function() {
855855 var _this = this;
856856
857 - var controlContainer = $j('<div />').addClass("rsd_control_container");
858 - var searchForm = $j('<form />').attr({
859 - id:"rsd_form",
860 - action:"javascript:return false"
 857+ var $controlContainer = $j('<div />').addClass("rsd_control_container");
 858+ var $searchForm = $j('<form />').attr({
 859+ id : "rsd_form",
 860+ action : "javascript:return false"
861861 });
862 - var providerSelection = $j('<ul />').addClass("ui-provider-selection");
 862+ var $providerSelection = $j('<ul />').addClass("ui-provider-selection");
863863
864864 // Add enabled search providers.
865 - for (var providerName in this.content_providers) {
 865+ for ( var providerName in this.content_providers ) {
866866 var content_providers = this.content_providers;
867867 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'))
 868+ if (provider.enabled && provider.checked && provider.api_url ) {
 869+ var $anchor = $j('<div />')
 870+ .text( gM('rsd-' + providerName + '-title') )
871871 .attr({
872872 name: providerName
873873 });
874 - if (this.current_provider == providerName) {
875 - anchor.addClass('ui-selected');
 874+ if ( this.current_provider == providerName) {
 875+ $anchor.addClass('ui-selected');
876876 }
877877
878 - anchor.click( function() {
879 - $j(this).parent().parent().find('.ui-selected')
880 - .removeClass('ui-selected')
881 - .each(function(index, domElement) {
 878+ $anchor.click( function() {
 879+ $j( this ).parent().parent().find( '.ui-selected' )
 880+ .removeClass( 'ui-selected' )
 881+ .each( function( index, domElement ) {
882882 /*var selectedProvider = $j(domElement).attr("name")
883883 if (selectedProvider)
884884 content_providers[ selectedProvider ].checked = false;*/
885885 //TODO: unset flag for provider selection
886886 });
887 - $j(this).addClass('ui-selected');
 887+ $j( this ).addClass( 'ui-selected' );
888888 //TODO: set flag for provider selection
889889 });
890890
891 - var listItem = $j('<li />');
892 - listItem.append(anchor);
893 - providerSelection.append(listItem);
 891+ var $listItem = $j( '<li />' );
 892+ $listItem.append( $anchor );
 893+ $providerSelection.append( $listItem );
894894 }
895895 }
896896
897 - var searchBox = $j('<input />').addClass('ui-widget-content ui-corner-all').attr({
 897+ var $searchBox = $j('<input />').addClass('ui-widget-content ui-corner-all').attr({
898898 type: "text",
899899 tabindex: 1,
900900 value: this.getDefaultQuery(),
@@ -903,29 +903,30 @@
904904 size: 20,
905905 autocomplete: "off"
906906 });
907 - var searchButton = $j.button({icon_id: 'search', text: 'search'})
908 - .addClass('rsd_search_button')
 907+ var $searchButton = $j.button({icon_id: 'search', text: gM('mwe-media_search') })
 908+ .addClass( 'rsd_search_button' )
909909 .buttonHover()
910910 .click(function (){
911911 //TODO: Add search provider call.
912912 _this.showCurrentTab();
913913 });
914 - searchForm.append(providerSelection);
915 - searchForm.append(searchBox);
916 - searchForm.append(searchButton);
917914
 915+ //$searchForm.append( $providerSelection );
 916+ $searchForm.append( $searchBox );
 917+ $searchForm.append( $searchButton );
 918+ /*
918919 // Add optional upload buttons.
919920 if ( this.content_providers['upload'].enabled) {
920 - uploadButton = $j.button({icon_id: 'upload', text: 'upload'})
 921+ $uploadButton = $j.button({icon_id: 'upload', text: 'upload'})
921922 .addClass("rsd_upload_button");
922 - importButton = $j.button({icon_id: 'import', text: 'import'})
 923+ $importButton = $j.button({icon_id: 'import', text: 'import'})
923924 .addClass("rsd_import_button");
924 - searchForm.append(uploadButton).append(importButton);
 925+ $searchForm.append( $uploadButton ).append( $importButton );
925926 }
 927+ */
 928+ $controlContainer.append( $searchForm );
926929
927 - controlContainer.append(searchForm);
928 -
929 - return controlContainer;
 930+ return $controlContainer;
930931 },
931932
932933 /**
@@ -2729,4 +2730,4 @@
27302731 // run /update search display:
27312732 this.showResults();
27322733 }
2733 -};
 2734+};
\ No newline at end of file
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/loader.js
@@ -123,7 +123,7 @@
124124 $j( '.videonojs' ).remove();
125125
126126 // Detect supported players:
127 - embedTypes.init();
 127+ mw.EmbedTypes.init();
128128
129129 //mw.log(" run callback: " + callback );
130130
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/mw.EmbedPlayer.js
@@ -238,7 +238,7 @@
239239 * @param {Function} callback Function to call once embeding is done
240240 */
241241 $.embedPlayers = function( attributes, callback){
242 - $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer( attributes, callbcak );
 242+ $j( mw.getConfig( 'rewritePlayerTags' ) ).embedPlayer( attributes, callback );
243243 }
244244
245245 /**
@@ -431,7 +431,7 @@
432432 }
433433
434434 if( waitForMeta ){
435 - mw.log(" WaitForMeta ( video missing height width info and has src )");
 435+ mw.log(" WaitForMeta ( video missing height, width or duration )");
436436 element.removeEventListener( "loadedmetadata", runPlayerSwap, true );
437437 element.addEventListener( "loadedmetadata", runPlayerSwap, true );
438438 // Time-out of 5 seconds ( maybe still playable but no timely metadata )
@@ -940,7 +940,7 @@
941941 if ( i == index ) {
942942 this.selected_source = playable_sources[i];
943943 // Update the user selected format:
944 - embedTypes.players.setFormatPreference( playable_sources[i].mime_type );
 944+ mw.EmbedTypes.players.setFormatPreference( playable_sources[i].mime_type );
945945 break;
946946 }
947947 }
@@ -963,7 +963,7 @@
964964 return true;
965965 }
966966 // Set via user-preference
967 - if ( embedTypes.players.preference['format_preference'] == mime_type ) {
 967+ if ( mw.EmbedTypes.players.preference['format_preference'] == mime_type ) {
968968 mw.log( 'set via preference: ' + playable_sources[source].mime_type );
969969 this.selected_source = playable_sources[source];
970970 return true;
@@ -976,8 +976,8 @@
977977 var mime_type = playable_sources[source].mime_type;
978978 // set source via player
979979 if ( mime_type == 'video/ogg' || mime_type == 'ogg/video' || mime_type == 'video/annodex' || mime_type == 'application/ogg' ) {
980 - for ( var i = 0; i < embedTypes.players.players.length; i++ ) { // for in loop on object oky
981 - var player = embedTypes.players.players[i];
 980+ for ( var i = 0; i < mw.EmbedTypes.players.players.length; i++ ) { // for in loop on object oky
 981+ var player = mw.EmbedTypes.players.players[i];
982982 if ( player.library == 'vlc' || player.library == 'native' ) {
983983 mw.log( 'set via ogg via order' );
984984 this.selected_source = playable_sources[source];
@@ -1042,7 +1042,7 @@
10431043 * Checks if media is a playable type
10441044 */
10451045 isPlayableType:function( mime_type ){
1046 - if ( embedTypes.players.defaultPlayer( mime_type ) ) {
 1046+ if ( mw.EmbedTypes.players.defaultPlayer( mime_type ) ) {
10471047 return true;
10481048 } else {
10491049 return false;
@@ -1431,12 +1431,12 @@
14321432 // debugger;
14331433 // do load player if just displaying innerHTML:
14341434 if ( this.pc.type == 'text/html' ) {
1435 - this.selected_player = embedTypes.players.defaultPlayer( 'text/html' );
 1435+ this.selected_player = mw.EmbedTypes.players.defaultPlayer( 'text/html' );
14361436 mw.log( 'set selected player:' + this.selected_player.mime_type );
14371437 }
14381438 }
14391439 } else {
1440 - this.selected_player = embedTypes.players.defaultPlayer( this.mediaElement.selected_source.mime_type );
 1440+ this.selected_player = mw.EmbedTypes.players.defaultPlayer( this.mediaElement.selected_source.mime_type );
14411441 }
14421442 if ( this.selected_player ) {
14431443 mw.log( "Playback system: " + this.selected_player.library );
@@ -2446,7 +2446,7 @@
24472447 o += '<h2>' + gM( 'mwe-chose_player' ) + '</h2>';
24482448 var _this = this;
24492449 $j.each( this.mediaElement.getPlayableSources(), function( source_id, source ) {
2450 - var playable = embedTypes.players.defaultPlayer( source.getMIMEType() );
 2450+ var playable = mw.EmbedTypes.players.defaultPlayer( source.getMIMEType() );
24512451
24522452 var is_selected = ( source == _this.mediaElement.selected_source );
24532453 var image_src = mw.getConfig( 'skin_img_path' ) ;
@@ -2456,7 +2456,7 @@
24572457 if ( playable ) {
24582458 o += '<ul>';
24592459 // output the player select code:
2460 - var supporting_players = embedTypes.players.getMIMETypePlayers( source.getMIMEType() );
 2460+ var supporting_players = mw.EmbedTypes.players.getMIMETypePlayers( source.getMIMEType() );
24612461
24622462 for ( var i = 0; i < supporting_players.length ; i++ ) {
24632463 if ( _this.selected_player.id == supporting_players[i].id && is_selected ) {
@@ -2491,7 +2491,7 @@
24922492 _this.closeDisplayedHTML();
24932493 _this.mediaElement.selectSource( source_id );
24942494
2495 - embedTypes.players.setPlayerPreference( default_player_id,
 2495+ mw.EmbedTypes.players.setPlayerPreference( default_player_id,
24962496 _this.mediaElement.sources[ source_id ].getMIMEType() );
24972497
24982498 // Issue a stop
@@ -3224,11 +3224,11 @@
32253225 };
32263226
32273227 /**
3228 - * embedTypes object handles setting and getting of supported embed types:
 3228+ * mw.EmbedTypes object handles setting and getting of supported embed types:
32293229 * closely mirrors OggHandler so that its easier to share efforts in this area:
32303230 * http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/OggHandler/OggPlayer.js
32313231 */
3232 -var embedTypes = {
 3232+mw.EmbedTypes = {
32333233
32343234 // List of players supported
32353235 players: null,
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js
@@ -76,7 +76,7 @@
7777
7878 // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
7979 // Doesn't work in MSIE or Safari/Mac or Opera 9.5
80 - if ( embedTypes.mozilla ) {
 80+ if ( $j.browser.mozilla ) {
8181 var iframe = document.createElement( 'iframe' );
8282 iframe.setAttribute( 'width', params.width );
8383 iframe.setAttribute( 'height', playerHeight );
@@ -182,7 +182,7 @@
183183 * Update the playerElement instance with a pointer to the embed object
184184 */
185185 getPlayerElement:function() {
186 - if ( embedTypes.mozilla ) {
 186+ if ( $j.browser.mozilla ) {
187187 this.playerElement = window.frames['cframe_' + this.id ].document.getElementById( this.pid );
188188 } else {
189189 this.playerElement = $j( '#' + this.pid ).get( 0 );
Index: branches/js2-work/phase3/js/mwEmbed/mwEmbed.js
@@ -2341,7 +2341,7 @@
23422342 return false;
23432343 }
23442344 // Flag to register the domReady has been called
2345 - var mwDomReadyFlag = false;
 2345+ var mwDomReadyFlag = false;
23462346
23472347 /**
23482348 * This will get called when the DOM is ready
@@ -2449,7 +2449,9 @@
24502450 } );
24512451
24522452
2453 -// Add the core mvEmbed Messages ( will be localized by script server )
 2453+/**
 2454+* Add the core mvEmbed Messages ( will be localized by script server )
 2455+*/
24542456 mw.addMessages( {
24552457 "mwe-loading_txt" : "Loading ...",
24562458 "mwe-size-gigabytes" : "$1 GB",
@@ -2522,10 +2524,9 @@
25232525 mwCheckBody();
25242526
25252527
2526 -/*
 2528+/**
25272529 * Utility jQuery bindings
2528 - * ( to be run after jQuery is available ).
2529 - *
 2530+ * Setup after jQuery is available ).
25302531 */
25312532 function mwDojQueryBindings() {
25322533 mw.log( 'mv_jqueryBindings' );

Comments

#Comment by Spamsplace (talk | contribs)   18:58, 18 January 2010

I don't see any editing of styles.css. Where did the fixes take place?

#Comment by Mdale (talk | contribs)   20:09, 19 January 2010

my bad.. the style updates where committed in the next commit r61202

Status & tagging log