r63017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63016‎ | r63017 | r63018 >
Date:20:00, 26 February 2010
Author:dale
Status:deferred
Tags:
Comment:
* some add-media-wizard search lib clean up in the wrap description output format.
* added double-click fullscreen binding
Modified paths:
  • /branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.textSelection.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/jquery.dragDropFile.js (modified) (history)
  • /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/flickrSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/metavidSearch.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/skins/mvpcf/EmbedPlayer.css (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/jquery/plugins/jquery.textSelection.js
@@ -372,7 +372,11 @@
373373 break;
374374 }
375375 var context = $(this).data( 'wikiEditor-context' );
376 - var hasIframe = context !== undefined && context.$iframe !== undefined;
 376+ if( ! context ){
 377+ var hasIframe = false;
 378+ } else{
 379+ var hasIframe = context !== undefined && context.$iframe !== undefined;
 380+ }
377381 // iframe functions have not been implemented yet, this is a temp hack
378382 //var hasIframe = false;
379383 return ( hasIframe ? context.fn : fn )[command].call( this, options );
Index: branches/js2-work/phase3/js/mwEmbed/skins/ctrlBuilder.js
@@ -29,8 +29,7 @@
3030 height: 31,
3131
3232 // Default supported components is merged with embedPlayer set of supported types
33 - supportedComponets: {
34 -
 33+ supportedComponets: {
3534 // All playback types support options
3635 'options': true
3736 },
@@ -1313,7 +1312,13 @@
13141313 */
13151314 'fullscreen': {
13161315 'w': 28,
1317 - 'o': function( ctrlObj ) {
 1316+ 'o': function( ctrlObj ) {
 1317+
 1318+ // Setup "dobuleclick" fullscreen binding to embedPlayer
 1319+ $j( ctrlObj.embedPlayer ).bind("dblclick", function(){
 1320+ ctrlObj.embedPlayer.fullscreen();
 1321+ });
 1322+
13181323 return $j( '<div />' )
13191324 .attr( 'title', gM( 'mwe-player_fullscreen' ) )
13201325 .addClass( "ui-state-default ui-corner-all ui-icon_link rButton fullscreen-btn" )
Index: branches/js2-work/phase3/js/mwEmbed/skins/mvpcf/EmbedPlayer.css
@@ -146,7 +146,7 @@
147147 width:10px;
148148 height:15px;
149149 margin-left:-5px;
150 - margin-top:0px;
 150+ margin-top: -1px;
151151 }
152152
153153 .mv-player .inOutSlider .ui-slider-handle{
@@ -175,6 +175,7 @@
176176 float:left;
177177 padding:2px 5px;
178178 }
 179+
179180 .mv-player .videoOptionsComplete div.ui-state-highlight a {
180181 color:#eee;
181182 font-weight:bold;
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/baseRemoteSearch.js
@@ -7,7 +7,7 @@
88 "mwe-import-description" : "$1, imported from $2"
99 } );
1010
11 -/*
 11+/**
1212 * rsd_default_rss_item_mapping
1313 *
1414 * @key is name of resource variable
@@ -95,7 +95,7 @@
9696 /**
9797 * Clears Results
9898 */
99 - clearResults:function() {
 99+ clearResults: function() {
100100 this.resultsObj = { };
101101 this.last_query = '';
102102 },
@@ -106,7 +106,7 @@
107107 * @param {XML Nodes} data the data to be parsed
108108 * @param {String} provider_url the source url (used to generate absolute links)
109109 */
110 - addRSSData:function( data , provider_url ) {
 110+ addRSSData: function( data , provider_url ) {
111111 mw.log( 'f:addRSSData' );
112112 var _this = this;
113113 var http_host = '';
@@ -150,6 +150,7 @@
151151 _this.num_results++;
152152 } );
153153 },
 154+
154155 /*
155156 * Maps a given attribute to a resource object per mapping defined in
156157 * rsd_default_rss_item_mapping
@@ -245,13 +246,13 @@
246247 var ahtml = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
247248 ahtml+= 'src="' + mw.escapeQuotesHTML( resource.src ) + '" ' +
248249 //'class="' + mw.getConfig( 'skinName' ) + '" ' +
249 - // mannualy set kskin (while mw.setConfig is not avaliable on all pages )
 250+ // mannualy set kskin (while mw.setConfig is not available on all pages )
250251 'class="kskin" '+
251252 'style="' + options.style + '" ' +
252253 'poster="' + mw.escapeQuotesHTML( resource.poster ) + '" '+
253254 'type="' + mw.escapeQuotesHTML( resource.mime ) + '" ';
254255
255 - // Add the api title key if avaliable:
 256+ // Add the api title key if available:
256257 if( resource.titleKey ) {
257258 'apiTitleKey="' + mw.escapeQuotesHTML( resource.titleKey ) + '" ';
258259 }
@@ -263,20 +264,26 @@
264265 if ( resource.mime == 'audio/ogg' ) {
265266 outHtml = '<audio ' + ahtml + '></audio>';
266267 }
267 - }
268 -
269 - // Return the output. Wrap with a description div if insert_description is on.
270 - if( outHtml != '') {
271 - return ( options['insert_description'] ) ?
272 - this.wrapHtmlDesc(resource, options, outHtml) :
273 - outHtml;
274 - }
 268+ }
 269+ return outHtml;
275270
276271 // No output give error:
277272 mw.log( "ERROR:: no embed code for mime type: " + resource.mime );
278273 return 'Error missing embed code for: ' + escape( resource.mime );
279274 },
280275
 276+ /*
 277+ * Wrap embed html with description div
 278+ */
 279+ getEmbedWithDescription: function( resource , options ){
 280+ // Return the output.
 281+ return this.wrapHtmlDesc(
 282+ resource,
 283+ options,
 284+ this.getEmbedHTML( resource, options )
 285+ );
 286+ },
 287+
281288 /**
282289 * Wrap output html with resource description links
283290 * @param {Object} resource Resource object
@@ -286,6 +293,14 @@
287294 wrapHtmlDesc: function( resource, options, outHtml ) {
288295 var stripedTitle = resource.title.replace( /File:|Image:|.jpg|.png|.ogg|.ogv|.oga|.svg/ig, '');
289296
 297+ if( !options ){
 298+ options = {};
 299+ }
 300+ // NOTE should add "size" to insert control
 301+ if( !options.width ){
 302+ options.width = ( resource.width > 600 )? 600 : resource.width;
 303+ }
 304+
290305 var $titleLink = $j( '<a />' )
291306 .attr({
292307 'title' : stripedTitle,
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/archiveOrgSearch.js
@@ -156,12 +156,14 @@
157157 //} else {
158158 //var src = resource.src;
159159 //}
160 - var o ='';
 160+ var embedHtml ='';
161161 if ( resource.mime == 'application/ogg' || resource.mime == 'video/ogg' ) {
162 - return '<video poster="' + resource.poster + '" ' + attributes +
 162+ embedHtml = '<video poster="' + resource.poster + '" ' + attributes +
163163 ' type="video/ogg"></video>';
164164 }else if( resource.mime == 'audio/ogg' ) {
165 - return '<audio ' + attributes + ' type="audio/ogg" ></audio>';
 165+ embedHtml = '<audio ' + attributes + ' type="audio/ogg" ></audio>';
166166 }
 167+
 168+ return embedHtml;
167169 }
168170 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/metavidSearch.js
@@ -59,7 +59,7 @@
6060 // Add the data xml payload with context url:
6161 _this.addRSSData( xmldata , url );
6262
63 - // Do some metavid specific pos processing on the resource data:
 63+ // Do some metavid specific pos processing on the resource data:
6464 for ( var i in _this.resultsObj ) {
6565 var resource = _this.resultsObj[i];
6666 var proe = mw.parseUri( resource['roe_url'] );
@@ -95,7 +95,10 @@
9696 *
9797 * @param {Object} resource Resource to get title key from
9898 */
99 - getTitleKey:function( resource ) {
 99+ getTitleKey: function( resource ) {
 100+ if( resource['titleKey'] ) {
 101+ return resource['titleKey'];
 102+ }
100103 return resource['stream_name'] + '_part_' + resource['start_time'].replace(/:/g, '.' ) + '_to_' + resource['end_time'].replace(/:/g, '.' ) + '.ogv';
101104 },
102105
@@ -195,7 +198,7 @@
196199 * @param {Object} resource Resource to be embed
197200 * @param {Object} options Resource Optiosn for embeind ( like max_width )
198201 */
199 - getEmbedHTML:function( resource , options ) {
 202+ getEmbedHTML: function( resource , options ) {
200203 if ( !options )
201204 options = { };
202205 var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/searchLibs/flickrSearch.js
@@ -167,7 +167,7 @@
168168 * Get the size key for a requested width
169169 *
170170 * @param {Object} resource Resource for sizeKey grab
171 - * @param {Number} width Requeste width for sizeKey lookup
 171+ * @param {Number} width Requested width for sizeKey lookup
172172 */
173173 getSizeKey:function( resource, width ) {
174174 if ( width <= 75 ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -2094,6 +2094,7 @@
20952095 if ( this.isProviderLocal( provider ) || this.import_url_mode == 'remote_link' ) {
20962096 // Local repo, jump directly to the callback:
20972097 myCallback( 'local' );
 2098+ return ;
20982099 } else {
20992100 // Check if the file is local ( can be shared repo )
21002101 if ( provider.check_shared ) {
@@ -2609,7 +2610,7 @@
26102611 */
26112612 getEmbedCode: function( resource ) {
26122613 if ( this.import_url_mode == 'remote_link' ) {
2613 - return resource.pSobj.getEmbedHTML( resource, { 'insert_description': true } );
 2614+ return resource.pSobj.getEmbedWithDescription( resource );
26142615 } else {
26152616 return resource.pSobj.getEmbedWikiCode( resource );
26162617 }
@@ -2644,7 +2645,14 @@
26452646 */
26462647 insertResource: function( resource ) {
26472648 mw.log( 'insertResource: ' + resource.title );
2648 - var _this = this;
 2649+ var _this = this;
 2650+
 2651+ // If doing a remote link jump directly to resource output:
 2652+ if( this.import_url_mode == 'remote_link' ){
 2653+ _this.insertResourceToOutput( resource );
 2654+ return ;
 2655+ }
 2656+
26492657 // Double check that the resource is present:
26502658 this.isFileLocallyAvailable( resource, function( status ) {
26512659 if ( status === 'missing' ) {
@@ -2656,20 +2664,26 @@
26572665 if ( status === 'local' || status === 'shared' || status === 'imported' ) {
26582666 _this.insertResourceToOutput( resource );
26592667 }
2660 - //NOTE: should hanndle errors or other status states?
 2668+ //NOTE: should handle errors or other status states?
26612669 } );
26622670 },
26632671
26642672 /**
2665 - * Finish up the insertResource request outputing the resource to output targets
 2673+ * Finish up the insertResource request by outputing the resource to output targets
26662674 *
26672675 * @param {Object} resource Resource to be inserted into the output targets
26682676 */
26692677 insertResourceToOutput: function( resource ) {
26702678 var _this = this;
 2679+
 2680+ // Get the embed code ( can be html remote refrence or wiki-text depending on import_url_mode )
26712681 var embed_code = _this.getEmbedCode( resource );
2672 - $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } );
26732682
 2683+ // If outputing to a text box
 2684+ if( _this.target_textbox ) {
 2685+ $j( _this.target_textbox ).textSelection( 'encapsulateSelection', { 'post' : embed_code } );
 2686+ }
 2687+
26742688 // Update the render area for HTML output of video tag with mwEmbed "player"
26752689 var embedCode = _this.getEmbedCode( resource );
26762690 if ( _this.target_render_area && embedCode ) {
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/jquery.dragDropFile.js
@@ -45,10 +45,19 @@
4646
4747 $j( '#multiple_file_input' ).remove();
4848
49 - $j( 'body' ).append( '<div title="' + gM( 'mwe-upload-multi', fileCount ) + '" ' +
50 - 'style="position:absolute;bottom:5em;top:3em;right:0px;left:0px" ' +
51 - 'id="multiple_file_input">' +
52 - '</div>'
 49+ $j( 'body' ).append(
 50+ $j('<div />')
 51+ .attr( {
 52+ 'title' : gM( 'mwe-upload-multi', fileCount )
 53+ 'id' : 'multiple_file_input'
 54+ } )
 55+ .css({
 56+ 'position' : 'absolute',
 57+ 'bottom' : '5em',
 58+ 'top' : '3em',
 59+ 'right' : '0px',
 60+ 'left' : '0px'
 61+ })
5362 );
5463
5564
@@ -73,19 +82,41 @@
7483 $j( '#multiple_file_input' ).dialogFitWindow();
7584 } );
7685 // add the inital table / title:
77 - $j( '#multiple_file_input' ).html( '<h3>' + gM( 'mwe-review-upload' ) + '</h3>' +
78 - '<table width="100%" border="1" class="table_list" style="border:none;"></table>' );
 86+ $j( '#multiple_file_input' ).empty().html(
 87+ $j('<h3 />')
 88+ .text( gM( 'mwe-review-upload' ) ),
 89+
 90+ $j( '<table />' )
 91+ .attr({
 92+ 'width' : "100%",
 93+ 'border' : "1",
 94+ 'border' : 'none'
 95+ })
 96+ .addClass( 'table_list' )
 97+ );
 98+
7999 $j.each( files, function( i, file ) {
80100 if ( file.fileSize < 64048576 ) {
81101 $j( '#multiple_file_input .table_list' ).append(
82 - '<tr>' +
83 - '<td width="300" style="padding:5px"><img width="250" src="' + file.getAsDataURL() + '">' + '</td>' +
84 - '<td valign="top">' +
 102+ $j('<tr />').append(
 103+ $j('<td />').css({
 104+ 'width': '300px',
 105+ 'padding' : '5px'
 106+ }).append(
 107+ $j('<img />').attr( {
 108+ 'width' : '250',
 109+ 'src' : file.getAsDataURL()
 110+ } )
 111+ ),
 112+
 113+ $j('<td />')
 114+ .attr('valign', 'top')
 115+ .append(
85116 'File Name: <input name="file[' + i + '][title]" value="' + file.name + '"><br>' +
86 - 'File Desc: <textarea style="width:300px;" name="file[' + i + '][desc]"></textarea><br>' +
87 - '</td>' +
88 - '</tr>'
89 - );
 117+ 'File Desc: <textarea style="width:300px;" name="file[' + i + '][desc]"></textarea><br>'
 118+ )
 119+ )
 120+ )
90121 /*mw.addDialog( "upload this image", '<img width="300" src="' + files[i].getAsDataURL() + '">' +
91122 '<br>name: ' + files[i].name + '</br>' +
92123 '<br>size: ' + files[i].fileSize + '</br>' +
Index: branches/js2-work/phase3/js/mwEmbed/modules/EmbedPlayer/javaEmbed.js
@@ -50,9 +50,10 @@
5151 '<param name="duration" value="' + this.duration + '" />' + "\n" +
5252 '<param name="bufferSize" value="4096" />' + "\n" +
5353 '</applet>';
54 -
 54+ $j( this ).html( appletCode );
 55+
5556 // Wrap it in an iframe to avoid hanging the event thread in FF 2/3 and similar
56 - // Doesn't work in MSIE or Safari/Mac or Opera 9.5
 57+ // NOTE: This breaks refrence to the applet so disabled for now:
5758 /*if ( $j.browser.mozilla ) {
5859 var iframe = document.createElement( 'iframe' );
5960 iframe.setAttribute( 'width', this.getWidth() );

Status & tagging log