r51709 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51708‎ | r51709 | r51710 >
Date:21:57, 10 June 2009
Author:dale
Status:deferred
Tags:
Comment:
Abstracted waterfall loading for Safari and IE (firefox execute JS in the order its added to the DOM)
Modified paths:
  • /branches/new-upload/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/vlcEmbed.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/libSequencer/mvPlayList.js (modified) (history)
  • /branches/new-upload/phase3/js2/mwEmbed/mv_embed.js (modified) (history)

Diff [purge]

Index: branches/new-upload/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html
@@ -2,7 +2,7 @@
33 "http://www.w3.org/TR/html4/loose.dtd">
44 <html>
55 <head>
6 - <title>Simple SMIL example</title>
 6+ <title>SMIL Sequence Editor example</title>
77 <script type="text/javascript" src="../mv_embed.js?debug=true"></script>
88 <script type="text/javascript">
99 mwAddOnloadHook(function(){
Index: branches/new-upload/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
@@ -3,7 +3,7 @@
44 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
55 <title>Firefogg - Make Ogg Video in your Browser</title>
66 <!-- <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed"></script> -->
7 - <script type="text/javascript" src="../jsScriptLoader.php?class=mv_embed"></script>
 7+ <script type="text/javascript" src="../mv_embed.js"></script>
88 <style type="text/css" media="all">@import "http://www.firefogg.org/css/style.css";</style>
99 <style type="text/css" media="all">
1010 .install{
Index: branches/new-upload/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -34,7 +34,11 @@
3535 "no_import_by_url": "This User or Wiki <b>can not</b> import assets from remote URLs. <br> If permissions are set you may have to enable $wgAllowCopyUploads, <a href=\"http://www.mediawiki.org/wiki/Manual:$wgAllowCopyUploads\">more info</a>"
3636 });
3737 var default_remote_search_options = {
38 - 'profile':'mediawiki_edit', 'target_container':null, //the div that will hold the search interface
 38+ 'profile':'mediawiki_edit',
 39+ 'target_container':null, //the div that will hold the search interface
 40+ //if using a modeal dialog (instead of target_container) how close to the edge of the window should we go:
 41+ 'modal_edge_padding':'20px',
 42+
3943 'target_invocation': null, //the button or link that will invoke the search interface
4044
4145 'default_provider_id':'all', //all or one of the content_providers ids
@@ -56,7 +60,8 @@
5761 'cFileNS':'File', //what is the cannonical namespace for images
5862 //@@todo (should get that from the api or inpage vars)
5963
60 - 'enable_upload_tab':true, // if we want to enable an uploads tab:
 64+ 'enable_upload_tab':true, // if we want to enable an uploads tab:
 65+
6166 }
6267 if(typeof wgServer == 'undefined')
6368 wgServer = '';
@@ -296,6 +301,7 @@
297302
298303 cUpLoader : null,
299304 cEdit : null,
 305+ dmodalCss : null,
300306
301307 init: function( iObj ){
302308 var _this = this;
@@ -320,7 +326,17 @@
321327 }
322328 }
323329 }
324 -
 330+ //set up the default model config:
 331+ this.dmodalCss = {
 332+ 'width':'auto',
 333+ 'height':'auto',
 334+ 'top' : this.modal_edge_padding,
 335+ 'left' : this.modal_edge_padding,
 336+ 'right' : this.modal_edge_padding,
 337+ 'bottom': this.modal_edge_padding
 338+ }
 339+
 340+
325341 //set up the target invocation:
326342 if( $j(this.target_invocation).length==0 ){
327343 js_error("RemoteSearchDriver:: no target invocation provided")
@@ -345,7 +361,7 @@
346362 if(_this.target_textbox)
347363 _this.getTexboxSelection();
348364
349 - $j(_this.target_container).dialog('open');
 365+ $j(_this.target_container).dialog('open').parent('.ui-dialog').css( _this.dmodalCss );
350366 });
351367 },
352368 //gets the in and out points for insert position or grabs the selected text for search
@@ -402,9 +418,7 @@
403419 layout = _this.getMaxModalLayout();
404420 $j(_this.target_container).dialog({
405421 bgiframe: true,
406 - autoOpen: true,
407 - width: 800,
408 - height: 600,
 422+ autoOpen: true,
409423 modal: true,
410424 buttons: {
411425 'Cancel': function() {
@@ -414,9 +428,27 @@
415429 close: function() {
416430 js_log('closed modal');
417431 }
 432+ }).parent('.ui-dialog').css( _this.dmodalCss )
 433+ //@@bind on resize to disable css dialog to update dmodelCss
 434+ .bind('resizestart', function(event, ui) {
 435+ _this.dmodalCss = {};
 436+ $j(this).css({});
 437+ })
 438+ //bind on drag to remove preset style as well
 439+ .bind('dragstart', function(event, ui) {
 440+ _this.dmodalCss = {};
 441+ $j(this).css({});
 442+ })
 443+ //update the child position: (some of this should be pushed up-stream via dialog config options
 444+ .children('.ui-dialog-buttonpane').css({
 445+ 'position':'abolute',
 446+ 'left':'0px',
 447+ 'right':'0px',
 448+ 'bottom':'0px'
418449 });
419 - //for some reaons the width does not "stick on init:
420 - //$j(_this.target_container).dialog('option', 'width', 800);
 450+
 451+
 452+
421453 /*var resizeTimer = false;
422454 $j(window).bind('resize', function() {
423455 var adjustModal = function(){
@@ -502,9 +534,10 @@
503535 doUploadInteface:function(){
504536 var _this = this;
505537 mv_set_loading('#tab-upload');
 538+ $j('#tab-upload').html('upload interface goes here ;)');
506539
507540 //todo include firefogg support:
508 - mvJsLoader.doLoad( [
 541+ /*mvJsLoader.doLoad( [
509542 'mvUploader'
510543 ],function(){
511544 _this.cUpLoader = new mvUploader({
@@ -519,13 +552,16 @@
520553 });
521554 }
522555 });
523 - });
 556+ }); */
524557 },
525558 runSearch: function(){
526559 js_log("f:runSearch::" + this.disp_item);
527560 //draw_direct_flag
528561 var draw_direct_flag = true;
529 -
 562+ if(!this.content_providers[this.disp_item]) {
 563+ js_log("can't run search for:" + this.disp_item);
 564+ return false;
 565+ }
530566 cp = this.content_providers[this.disp_item];
531567
532568 //check if we need to update:
Index: branches/new-upload/phase3/js2/mwEmbed/libSequencer/mvPlayList.js
@@ -128,7 +128,7 @@
129129 $j(this).dialog('close');
130130 }
131131 },
132 - }).css({
 132+ }).parent('.ui-dialog').css({
133133 'width':'auto',
134134 'height':'auto',
135135 'top' : '10px',
Index: branches/new-upload/phase3/js2/mwEmbed/mv_embed.js
@@ -116,7 +116,8 @@
117117 //setup normal replacement of j with jquery
118118 var jsName = ( gClasses[i].substr(0,3) == '$j.' ) ? opt['j_replace'] + gClasses[i].substr(3) : gClasses[i];
119119 mvClassPaths[ gClasses[i] ] = path + jsName + '.js';
120 - }else{
 120+ }else{
 121+ //assume object with key:path:
121122 mvClassPaths[i] = path + gClasses[ i ];
122123 }
123124 }
@@ -135,7 +136,7 @@
136137 lcPaths('',{
137138 'mv_embed' : 'mv_embed.js',
138139 'window.jQuery' : 'jquery/jquery-1.3.2.js',
139 - '$j.fn.pngFix' : 'jquery.pngFix.js',
 140+ '$j.fn.pngFix' : 'jquery/plugins/jquery.pngFix.js',
140141 '$j.fn.autocomplete': 'jquery/plugins/jquery.autocomplete.js',
141142 '$j.fn.hoverIntent' : 'jquery/plugins/jquery.hoverIntent.js',
142143 '$j.fn.datePicker' : 'jquery/plugins/jquery.datePicker.js',
@@ -176,7 +177,7 @@
177178 '$j.ui.selectable',
178179 ],
179180 {'j_replace':''});
180 -
 181+//add mediaLibs
181182 lcPaths('libAddMedia/', [
182183 'mvFirefogg',
183184 'mvAdvFirefogg',
@@ -196,7 +197,7 @@
197198 lcPaths( 'libClipEdit/', [
198199 'mvClipEdit'
199200 ])
200 -//libEmbedObj:
 201+//libEmbedObj (we could load all these clasess in embedVideo):
201202 lcPaths( 'libEmbedVideo/', [
202203 'embedVideo',
203204 'flashEmbed',
@@ -427,6 +428,27 @@
428429 }
429430 }
430431 this.ptime=this.ctime;
 432+ },
 433+ doLoadDepMode:function(loadChain, callback){
 434+ //firefox executes js ~in-order of it being included~ so just directly issue request:
 435+ if( $j.browser.firefox ){
 436+ var loadSet = [];
 437+ for(var i=0; i< loadChain.length;i++){
 438+ for(var j=0;j<loadChain[i].length;j++){
 439+ loadSet.push(loadChain[i][j]);
 440+ }
 441+ }
 442+ doLoad(loadSet, callback);
 443+ }else{
 444+ //safair and IE tend to execute out of order so load with dependenciy checks
 445+ mvJsLoader.doLoad(loadChain.shift(),function(){
 446+ if(loadChain.length!=0){
 447+ mvJsLoader.doLoadDepMode(loadChain, callback);
 448+ }else{
 449+ callback();
 450+ }
 451+ });
 452+ }
431453 },
432454 checkLoading:function(){
433455 var loading=0;
@@ -490,29 +512,22 @@
491513
492514 //make sure we have jQuery
493515 _this.jQueryCheck(function(){
494 - baseReq = [
 516+ var depReq = new Array();
 517+ depReq.push( [
495518 '$j.ui',
496519 'embedVideo',
497520 '$j.cookie'
498 - ];
499 - var secReq = new Array();
500 - //IE & safari appear to load things out of order running j.slider before j.ui is ready
501 - //load ui depenent scripts in a second request:
502 - if($j.browser.msie || $j.browser.safari){
503 - secReq.push( '$j.ui.slider' );
504 - //ie6 yay!
505 - if($j.browser.version <= 6){
506 - secReq.push( '$j.fn.pngFix' );
507 - }
508 - }else{
509 - baseReq.push('$j.ui.slider');
510 - }
511 - _this.doLoad(baseReq,function(){
512 - _this.doLoad(secReq,function(){
513 - embedTypes.init();
514 - callback();
515 - });
516 - });
 521+ ], [
 522+ '$j.ui.slider'
 523+ ]);
 524+ //add png fix if needed:
 525+ if($j.browser.msie || $j.browser.version < 7)
 526+ depReq[0].push( '$j.fn.pngFix' );
 527+
 528+ _this.doLoadDepMode(depReq,function(){
 529+ embedTypes.init();
 530+ callback();
 531+ });
517532 });
518533 },
519534 addLoadEvent:function(fn){
@@ -710,22 +725,24 @@
711726 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css' );
712727 //load all the req libs:
713728 mvJsLoader.jQueryCheck(function(){
714 - //load search specifc extra stuff
715 - mvJsLoader.doLoad([
716 - 'remoteSearchDriver',
717 - '$j.cookie',
718 - '$j.ui',
719 - '$j.ui.resizable',
720 - '$j.ui.draggable',
721 - '$j.ui.dialog',
722 - '$j.ui.tabs',
723 - '$j.ui.sortable'
 729+ //load with staged dependeinces (for ie and safari that don't execute in order)
 730+ mvJsLoader.doLoadDepMode([
 731+ ['remoteSearchDriver',
 732+ '$j.cookie',
 733+ '$j.ui'
 734+ ],[
 735+ '$j.ui.resizable',
 736+ '$j.ui.draggable',
 737+ '$j.ui.dialog',
 738+ '$j.ui.tabs',
 739+ '$j.ui.sortable'
 740+ ]
724741 ], function(){
725742 iObj['instance_name']= 'rsdMVRS';
726743 _global['rsdMVRS'] = new remoteSearchDriver( iObj );
727744 if( callback )
728745 callback();
729 - });
 746+ });
730747 });
731748 }
732749 $.fn.sequencer = function( iObj, callback){
@@ -735,15 +752,16 @@
736753 loadExternalCss( mv_jquery_skin_path + 'jquery-ui-1.7.1.custom.css');
737754 loadExternalCss( mv_embed_path+'skins/'+mv_skin_name+'/mv_sequence.css');
738755 //make sure we have the required mv_embed libs (they are not loaded when no video element is on the page)
739 - mvJsLoader.embedVideoCheck(function(){
740 - var firstLoadSet =[
 756+ mvJsLoader.embedVideoCheck(function(){
 757+ //load playlist object and then jquery ui stuff:
 758+ mvJsLoader.doLoadDepMode([
 759+ [
741760 'mvPlayList',
742761 '$j.ui',
743762 '$j.contextMenu',
744763 'mvSequencer'
745 - ];
746 - var secondLoadSet =[];
747 - var uiDepLibs = [
 764+ ],
 765+ [
748766 '$j.ui.dialog',
749767 '$j.ui.droppable',
750768 '$j.ui.draggable',
@@ -751,25 +769,15 @@
752770 '$j.ui.resizable',
753771 '$j.ui.slider',
754772 '$j.ui.tabs'
755 - ];
756 - if($j.browser.msie || $j.browser.safari){
757 - for(var i=0;i<uiDepLibs.length;i++)
758 - secondLoadSet.push( uiDepLibs[i]);
759 - }else{
760 - for(var i=0;i<uiDepLibs.length;i++)
761 - firstLoadSet.push( uiDepLibs[i]);
762 - }
763 - //load playlist object and drag,drop,resize,hoverintent,libs
764 - mvJsLoader.doLoad(firstLoadSet,function(){
765 - mvJsLoader.doLoad(secondLoadSet,function(){
766 - js_log('calling new mvSequencer');
767 - //init the sequence object (it will take over from there) no more than one mvSeq obj for now:
768 - if(!_global['mvSeq']){
769 - _global['mvSeq'] = new mvSequencer(iObj);
770 - }else{
771 - js_log('mvSeq already init');
772 - }
773 - });
 773+ ]
 774+ ], function(){
 775+ js_log('calling new mvSequencer');
 776+ //init the sequence object (it will take over from there) no more than one mvSeq obj for now:
 777+ if(!_global['mvSeq']){
 778+ _global['mvSeq'] = new mvSequencer(iObj);
 779+ }else{
 780+ js_log('mvSeq already init');
 781+ }
774782 });
775783 });
776784 }
@@ -781,39 +789,28 @@
782790 loadExternalCss( mv_embed_path + 'skins/'+mv_skin_name+'/styles.css' );
783791 // @@todo should refactor mvAdvFirefogg as jQuery plugin
784792 iObj['selector'] = this.selector;
785 - loadSet = [
786 - 'mvBaseUploadInterface',
787 - 'mvFirefogg',
788 - '$j.ui'
789 - ];
790 - var eiLoadSet = [
791 - 'mvAdvFirefogg',
792 - '$j.cookie',
793 - '$j.ui.accordion',
794 - '$j.ui.slider',
795 - '$j.ui.datepicker'
796 - ]
797 - var secondLoadSet = [];
798 - //IE* ~sometimes~ executes things out of order on DOM inserted scripts
799 - //*(kind of pointless anyway since IE does not support firefogg
800 - // but if you want firefog to drive the "is not supported" msg here you go ;)
801 - if($.browser.msie || $j.browser.safari){
802 - secondLoadSet = [
 793+ var loadSet = [
 794+ [
 795+ 'mvBaseUploadInterface',
 796+ 'mvFirefogg',
 797+ '$j.ui'
 798+ ],
 799+ [
803800 '$j.ui.progressbar',
804 - '$j.ui.dialog'
 801+ '$j.ui.dialog'
805802 ]
806 - for(var i=0;i < eiLoadSet.length; i++)
807 - secondLoadSet[i] = eiLoadSet[i];
808 - }else{
809 - loadSet.push( '$j.ui.progressbar' );
810 - loadSet.push( '$j.ui.dialog' );
811 - for(var i=0;i < eiLoadSet.length; i++)
812 - loadSet.push( eiLoadSet[i] );
813 - }
 803+ ];
 804+ if( iObj.encoder_interface ){
 805+ loadSet.push([
 806+ 'mvAdvFirefogg',
 807+ '$j.cookie',
 808+ '$j.ui.accordion',
 809+ '$j.ui.slider',
 810+ '$j.ui.datepicker'
 811+ ]);
 812+ }
814813 //make sure we have everything loaded that we need:
815 - mvJsLoader.doLoad( loadSet, function(){
816 - mvJsLoader.doLoad( secondLoadSet, function(){
817 - if(secondLoadSet)
 814+ mvJsLoader.doLoadDepMode( loadSet, function(){
818815 js_log('firefogg libs loaded. target select:' + iObj.selector);
819816 //select interface provicer based on if we want to include the encoder interface or not:
820817 if(iObj.encoder_interface){
@@ -823,7 +820,6 @@
824821 }
825822 if(myFogg)
826823 myFogg.doRewrite( callback );
827 - });
828824 });
829825 }
830826
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/vlcEmbed.js
@@ -10,7 +10,7 @@
1111 'stop':true,
1212 'fullscreen':true,
1313 'time_display':true,
14 - 'volume_control':false,
 14+ 'volume_control':true,
1515
1616 'playlist_driver':true, //if the object supports playlist functions
1717 'overlay':false
@@ -241,6 +241,12 @@
242242 this.vlc.playlist.togglePause();
243243 }
244244 },
 245+ toggleMute:function(){
 246+ this.parent_toggleMute();
 247+ this.getVLC();
 248+ if(this.vlc)
 249+ this.vlc.audio.toggleMute();
 250+ },
245251 fullscreen : function(){
246252 if(this.vlc){
247253 if(this.vlc.video)
Index: branches/new-upload/phase3/js2/mwEmbed/libEmbedVideo/embedVideo.js
@@ -164,12 +164,25 @@
165165 '$j.ui.dialog'
166166 ], function(){
167167 $j('playlist').each(function(){
168 - //create new playlist interface:
169 - var plObj = new mvPlayList( this );
170 - mvEmbed.swapEmbedVideoElement(this, plObj);
171 - var added_height = plObj.pl_layout.title_bar_height + plObj.pl_layout.control_height;
172 - //move into a blocking display container with height + controls + title height:
173 - $j('#'+plObj.id).wrap('<div style="display:block;height:' + (plObj.height + added_height) + 'px;"></div>');
 168+ //check if we are in sequence mode load sequence libs (if not already loaded)
 169+ if( $j(this).attr('sequencer')=="true" ){
 170+ var pl_element = this;
 171+ //load the mv_sequencer and the json util lib:
 172+ mvJsLoader.doLoad([
 173+ 'mvSeqPlayList'
 174+ ],function(){
 175+ var seqObj = new mvSeqPlayList( pl_element );
 176+ mvEmbed.swapEmbedVideoElement( pl_element, seqObj );
 177+ }
 178+ );
 179+ }else{
 180+ //create new playlist interface:
 181+ var plObj = new mvPlayList( this );
 182+ mvEmbed.swapEmbedVideoElement(this, plObj);
 183+ var added_height = plObj.pl_layout.title_bar_height + plObj.pl_layout.control_height;
 184+ //move into a blocking display container with height + controls + title height:
 185+ $j('#'+plObj.id).wrap('<div style="display:block;height:' + (plObj.height + added_height) + 'px;"></div>');
 186+ }
174187 });
175188 });
176189 }

Status & tagging log