r62308 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62307‎ | r62308 | r62309 >
Date:15:23, 11 February 2010
Author:dale
Status:deferred
Tags:
Comment:
* fixed some sequencer regresions
* some initial clean up of add-media-wizard options
* updated loader paths for mediaWiki pages.
Modified paths:
  • /branches/js2-work/phase3/js/loader.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.SeqRemoteSearchDriver.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.Sequencer.js (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html (modified) (history)
  • /branches/js2-work/phase3/js/mwEmbed/tests/Sequence_Editor.html (modified) (history)

Diff [purge]

Index: branches/js2-work/phase3/js/mwEmbed/tests/Sequence_Editor.html
@@ -11,7 +11,9 @@
1212 'mv_pl_src':'media/sequence_transition_smil.xml',
1313 //set the add media wizard to only include commons:
1414 'amw_conf':{
15 - 'enabled_providers':['wiki_commons']
 15+ 'enabled_providers':[ 'wiki_commons', 'kaltura', 'archive_org', 'flickr', 'metavid' ],
 16+ 'import_url_mode' : 'remote_link',
 17+ 'default_query' : 'fish'
1618 }
1719 });
1820 });
Index: branches/js2-work/phase3/js/mwEmbed/tests/Add_Media_Wizard.html
@@ -33,10 +33,8 @@
3434 //we only enabled commons
3535 //(since javascript includes from other servers would be problamatic ) in a default install
3636 //** but you can set this to 'all' to pull from multiple repositories
37 - 'enabled_providers' : [ 'wiki_commons', 'kaltura', 'archive_org', 'flickr', 'metavid' ],
 37+ 'enabled_providers' : [ 'wiki_commons', 'kaltura', 'archive_org', 'flickr', 'metavid' ]
3838
39 - //the local wiki api url:
40 - 'local_wiki_api_url': 'none'
4139 } );
4240 } );
4341 });
Index: branches/js2-work/phase3/js/mwEmbed/modules/AddMedia/mw.RemoteSearchDriver.js
@@ -88,9 +88,6 @@
8989
9090 // The target button or link that will invoke the search interface
9191 'target_invoke_button': null,
92 -
93 - // The local wiki api url usually: wgServer + wgScriptPath + '/api.php'
94 - 'local_wiki_api_url': null,
9592
9693 /**
9794 * import_url_mode
@@ -99,8 +96,14 @@
10097 * autodetect: checks for api support before using the api to insert the media asset
10198 * remote_link: hot-links the media directly into the page as html
10299 */
103 - 'import_url_mode': 'api',
 100+ 'import_url_mode': 'api',
104101
 102+ // The api target can be "local" or the url or remote api entry point
 103+ 'upload_api_target': 'local',
 104+
 105+ // Name of the upload target
 106+ 'upload_api_name': null,
 107+
105108 // Target title used for previews of wiki page usually: wgPageName
106109 'target_title': null,
107110
@@ -117,17 +120,8 @@
118121 'default_query': null,
119122
120123 // Canonical namespace prefix for images/ files
121 - 'canonicalFileNS': 'File',
 124+ 'canonicalFileNS': 'File',
122125
123 - // The api target can be "local" or the url or remote api entry point
124 - 'upload_api_target': 'local',
125 -
126 - // Name of the upload target
127 - 'upload_api_name': null,
128 -
129 - // Name of the remote proxy page that will host the iframe api callback
130 - 'upload_api_proxy_frame': null,
131 -
132126 // Enabled providers can be keyword 'all' or an array of enabled content provider keys
133127 'enabled_providers': 'all',
134128
@@ -162,7 +156,7 @@
163157 }
164158
165159 $.addMediaWizard = function( options ){
166 - $.fn.addMediaWizard ( options, function( amwObj ) {
 160+ $.fn.addMediaWizard ( options, function( amwObj ) {
167161 // do the add-media-wizard display
168162 amwObj.createUI();
169163 } )
@@ -409,11 +403,8 @@
410404 displayMode : 'box', // box or list
411405
412406 // The ClipEdit Object
413 - clipEdit: null,
 407+ clipEdit: null,
414408
415 - // A flag for proxy setup.
416 - proxySetupDone: null,
417 -
418409 /**
419410 * The initialisation function
420411 *
@@ -475,24 +466,20 @@
476467 this.content_providers[ 'upload' ].enabled = false;
477468 }
478469
479 - // Set the target to "proxy" if a proxy frame is configured
480 - if ( _this.upload_api_proxy_frame )
481 - _this.upload_api_target = 'proxy';
482470
483471 // Set up the local API upload URL
484472 if ( _this.upload_api_target == 'local' ) {
485 - if ( ! _this.local_wiki_api_url ) {
486 - this.$resultsContainer.html( gM( 'rsd_config_error', 'missing_local_api_url' ) );
 473+ if ( ! mw.getLocalApiUrl() ) {
 474+ $j( this.target_container ).html( gM( 'rsd_config_error', 'missing_local_api_url' ) );
487475 return false;
488476 } else {
489 - _this.upload_api_target = _this.local_wiki_api_url;
 477+ _this.upload_api_target = mw.getLocalApiUrl();
490478 }
491479 }
492480
493481 // Set up the "add media wizard" button, which invokes this object
494482 if ( !this.target_invoke_button || $j( this.target_invoke_button ).length == 0 ) {
495 - mw.log( "RemoteSearchDriver:: no target invocation provided " +
496 - "(will have to run your own createUI() )" );
 483+ mw.log( "RemoteSearchDriver:: no target invocation provided " );
497484 } else {
498485 if ( this.target_invoke_button ) {
499486 $j( this.target_invoke_button )
@@ -669,12 +656,16 @@
670657 * Creates the remote search driver User Interface
671658 */
672659 createUI: function() {
673 - var _this = this;
674 -
 660+ var _this = this;
675661 this.clearTextboxCache();
676662
677 - // Setup the parent container:
678 - this.createDialogContainer();
 663+ // Setup the parent container (if not already created)
 664+ if( $j( _this.target_container ).length == 0 ){
 665+ this.createDialogContainer();
 666+ }else{
 667+ // Empty out the target
 668+ $j( _this.target_container ).empty();
 669+ }
679670
680671 // Setup remote search dialog & bindings
681672 this.initDialog();
@@ -699,11 +690,9 @@
700691 var _this = this;
701692 mw.log( "showDialog::" );
702693
703 - // Check if dialog target is present:
704 - if( $j( _this.target_container ).length == 0 ){
705 - this.createUI();
706 - return ;
707 - }
 694+ // Create the UI
 695+ this.createUI();
 696+
708697
709698 _this.clearTextboxCache();
710699 var query = _this.getDefaultQuery();
@@ -1525,7 +1514,11 @@
15261515 },
15271516
15281517 /**
1529 - * Get result html for box layout (see getResultHtml for params)
 1518+ * Get result html for box layout
 1519+ *
 1520+ * @param {Object} provider the content provider for result
 1521+ * @param {Number} resIndex the resource index to build unique ids
 1522+ * @param {Object} resource the resource object
15301523 */
15311524 getResultHtmlBox: function( provider, resIndex, resource ) {
15321525
@@ -1583,7 +1576,11 @@
15841577 },
15851578
15861579 /**
1587 - * Get result html for list layout (see getResultHtml for params)
 1580+ * Get result html for list layout
 1581+ *
 1582+ * @param {Object} provider the content provider for result
 1583+ * @param {Number} resIndex the resource index to build unique ids
 1584+ * @param {Object} resource the resource object
15881585 */
15891586 getResultHtmlList:function( provider, resIndex, resource ) {
15901587
@@ -2024,7 +2021,7 @@
20252022 return true;
20262023 } else {
20272024 // Check if we can embed the content locally per a domain name check:
2028 - var localHost = mw.parseUri( this.local_wiki_api_url ).host;
 2025+ var localHost = mw.parseUri( mw.getLocalApiUrl() ).host;
20292026 if ( provider.local_domains ) {
20302027 for ( var i = 0; i < provider.local_domains.length; i++ ) {
20312028 var domain = provider.local_domains[i];
@@ -2429,7 +2426,7 @@
24302427 'iiurlwidth': '400'
24312428 };
24322429 // First check the api for imagerepository
2433 - mw.getJSON( this.local_wiki_api_url, request, function( data ) {
 2430+ mw.getJSON( mw.getLocalApiUrl(), request, function( data ) {
24342431 if ( data.query.pages ) {
24352432 for ( var i in data.query.pages ) {
24362433 if( i == '-1' ){
@@ -2604,41 +2601,9 @@
26052602 } else {
26062603 return resource.pSobj.getEmbedWikiCode( resource );
26072604 }
2608 - },
 2605+ },
26092606
26102607 /**
2611 - * Get the preview text for a given resource
2612 - *
2613 - * builds the wikitext represnetation and
2614 - * issues an api call to gennerate a preview
2615 - *
2616 - * @param {Object} resource Resource to get preview text for.
2617 - */
2618 - /*getPreviewText: function( resource ) {
2619 - var _this = this;
2620 - var text;
2621 -
2622 - // Insert at start if textInput cursor has not been set (ie == length)
2623 - var insertPos = _this.getCaretPos();
2624 - var originalText = _this.getTextboxValue();
2625 - var embedCode = _this.getEmbedCode( resource );
2626 - if ( insertPos !== false && originalText ) {
2627 - if ( originalText.length == insertPos ) {
2628 - insertPos = 0;
2629 - }
2630 - text = originalText.substring( 0, insertPos ) +
2631 - embedCode + originalText.substring( insertPos );
2632 - } else {
2633 - text = $j( _this.target_textbox ).val() + embedCode;
2634 - }
2635 - // check for missing </references>
2636 - if ( text.indexOf( '<references/>' ) == -1 && text.indexOf( '<ref>' ) != -1 ) {
2637 - text = text + '<references/>';
2638 - }
2639 - return text;
2640 - },*/
2641 -
2642 - /**
26432608 * issues the wikitext parse call
26442609 *
26452610 * @param {String} wikitext Wiki Text to be parsed by mediaWiki api call
@@ -2646,7 +2611,7 @@
26472612 * @param {Function} callback Function called with api parser output
26482613 */
26492614 parse: function( wikitext, title, callback ) {
2650 - mw.getJSON( this.local_wiki_api_url,
 2615+ mw.getJSON( mw.getLocalApiUrl(),
26512616 {
26522617 'action': 'parse',
26532618 'title' : title,
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.SeqRemoteSearchDriver.js
@@ -16,7 +16,6 @@
1717 this.pSeq = mySequence;
1818 var options = {
1919 'target_container' : '#cliplib_ic',
20 - 'local_wiki_api_url': mySequence.getLocalApiUrl(),
2120 'instance_name' : mySequence.instance_name + '.mySearch',
2221 'default_query' : this.pSeq.plObj.title
2322 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.Sequencer.js
@@ -183,7 +183,7 @@
184184 'mw.SeqRemoteSearchDriver'
185185 ], function() {
186186 this_seq.mySearch = new mw.SeqRemoteSearchDriver( this_seq );
187 - this_seq.mySearch.createUI();
 187+ this_seq.mySearch.showDialog();
188188 } );
189189 }
190190 },
@@ -263,25 +263,9 @@
264264 ).css( {
265265 'min-width':'850px'
266266 } );
 267+
267268
268 - /*mw.log('set: '+this.target_sequence_container + ' html to:'+ "\n"+
269 - $j(this.target_sequence_container).html()
270 - );*/
271 -
272 - // first check if we got a cloned PL object:
273 - // (when the editor is invoked with the plalylist already on the page)
274 - /*if( this.plObj != 'null' ){
275 - mw.log('found plObj clone');
276 - //extend with mvSeqPlayList object:
277 - this.plObj = new mvSeqPlayList(this.plObj);
278 - mw.log('mvSeqPlayList added: ' + this.plObj.org_control_height );
279 - $j('#'+this.video_container_id).get(0).attachNode( this.plObj );
280 - this.plObj.getHTML();
281 - this.checkReadyPlObj();
282 - return ;
283 - }*/
284 -
285 - // else check for source based sequence editor (a clean page load of the editor)
 269+ // Check for source based sequence editor (a clean page load of the editor)
286270 if ( this.mv_pl_src != 'null' ) {
287271 mw.log( ' pl src:: ' + this.mv_pl_src );
288272 var src_attr = ' src="' + this.mv_pl_src + '" ';
@@ -307,7 +291,7 @@
308292 $j.btnHtml( gM( 'mwe-edit_cancel' ), 'seq_edit_cancel', 'close' )
309293 );
310294 } else {
311 - $j( this.target_sequence_container + ' .seq_save_cancel' ).html( cancel_button + gM( 'mwe-no_edit_permissions' ) );
 295+ $j( this.target_sequence_container + ' .seq_save_cancel' ).html( gM( 'mwe-no_edit_permissions' ) );
312296 }
313297 // assing bindings
314298 $j( this.target_sequence_container + ' .seq_edit_cancel' ).unbind().click( function() {
@@ -383,7 +367,7 @@
384368 if ( !dispCall )
385369 $j( "#seq_menu" ).tabs( 'select', this.menu_items[item].inx );
386370
387 - this.menu_items[item].default = 1;
 371+ this.menu_items[item]['default'] = 1;
388372 // do any click_js actions:getInsertControl
389373 if ( this.menu_items[item].click_js )
390374 this.menu_items[item].click_js( this );
@@ -535,7 +519,12 @@
536520 // propagate the edit tokens
537521 // if on an edit page just grab from the form:
538522 this.sequenceEditToken = $j( 'input[wpEditToken]' ).val();
539 -
 523+
 524+ // Update the buttons for no Api url (local editor)
 525+ if( !this.getLocalApiUrl() ){
 526+ _this.updateSeqSaveButtons();
 527+ }
 528+
540529 if ( typeof this.sequenceEditToken == 'undefined' && this.getLocalApiUrl() != null ) {
541530 mw.getToken( _this.getLocalApiUrl(), _this.plObj.mTitle, function( token ) {
542531 if ( token ) {
@@ -585,7 +574,7 @@
586575 for ( var tab_id in this.menu_items ) {
587576 menu_item = this.menu_items[tab_id];
588577 menu_item.inx = inx;
589 - if ( menu_item.default ) {
 578+ if ( menu_item['default'] ) {
590579 selected_tab = inx;
591580 _this.disp_menu_item = tab_id;
592581 }
Index: branches/js2-work/phase3/js/mwEmbed/modules/Sequencer/mw.PlayList.js
@@ -973,7 +973,8 @@
974974
975975 var cur_pixle = 0;
976976 // set up _this
977 -
 977+ //remove any old cl_status
 978+ _this.$interface.find( '.play_head' ).find('.cl_status').remove();
978979 // mw.log("do play head total dur: "+pl_duration );
979980 $j.each( this.default_track.clips, function( i, clip ) {
980981 // (use getSoloDuration to not include transitions and such)
@@ -996,8 +997,7 @@
997998
998999 barHtml += '</div>';
9991000
1000 - // background:#DDD +clip.getColor();
1001 -
 1001+ // background:#DDD +clip.getColor();
10021002 _this.$interface.find( '.play_head' ).append( barHtml );
10031003
10041004 // mw.log('offset:' + cur_pixle +' width:'+pwidth+' add clip'+ clip.id + ' is '+clip.embed.getDuration() +' = ' + perc +' of ' + _this.track_len);
Index: branches/js2-work/phase3/js/loader.js
@@ -5,8 +5,8 @@
66 mw.setConfig('loaderContext', wgScriptPath + '/js/');
77
88 mw.addClassFilePaths( {
9 - 'uploadPage' : 'js/uploadPage.js',
10 - 'editPage' : 'js/editPage.js',
11 - 'ajaxCategories': 'js/ajaxcategories.js',
12 - 'apiProxyPage' : 'js/apiProxyPage.js'
 9+ 'uploadPage' : 'uploadPage.js',
 10+ 'editPage' : 'editPage.js',
 11+ 'ajaxCategories': 'ajaxcategories.js',
 12+ 'apiProxyPage' : 'apiProxyPage.js'
1313 } );
\ No newline at end of file

Status & tagging log