* some updates for less round trips for remoteMwEmbed.js / mwEmbed gadget
authorMichael Dale <dale@users.mediawiki.org>
Mon, 16 Nov 2009 19:14:27 +0000 (19:14 +0000)
committerMichael Dale <dale@users.mediawiki.org>
Mon, 16 Nov 2009 19:14:27 +0000 (19:14 +0000)
* some more IE fixes

js2/mwEmbed/libAddMedia/remoteSearchDriver.js
js2/mwEmbed/libAddMedia/searchLibs/baseRemoteSearch.js
js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js
js2/mwEmbed/libClipEdit/mvClipEdit.js
js2/mwEmbed/libEmbedVideo/nativeEmbed.js
js2/mwEmbed/libSequencer/mvPlayList.js
js2/mwEmbed/mv_embed.js
js2/remoteMwEmbed.js

index 82678c0..0154c62 100644 (file)
@@ -564,16 +564,15 @@ remoteSearchDriver.prototype = {
                var o = '<div class="rsd_control_container" style="width:100%">' +
                                        '<form id="rsd_form" action="javascript:return false;" method="GET">' +
                                                '<input class="ui-widget-content ui-corner-all" type="text" tabindex="1" value="' + dq + '" maxlength="512" id="rsd_q" name="rsd_q" ' +
-                                                       'size="20" autocomplete="off"/> ' +
-                                               $j.btnHtml( gM( 'mwe-media_search' ), 'rms_search_button', 'search' ) +
+                                                       'size="20" autocomplete="off" />' +
+                                                       $j.btnHtml( gM( 'mwe-media_search' ), 'rms_search_button', 'search' ) +
                                        '</form>';
                // close up the control container:
                o += '</div>';
-
+               
                // search provider tabs based on "checked" and "enabled" and "combined tab"
                o += '<div id="rsd_results_container" style="top:0px;bottom:0px;left:0px;right:0px;"></div>';
                $j( this.target_container ).html( o );
-
                // add simple styles:
                $j( this.target_container + ' .rms_search_button' ).btnBind().click( function() {
                        _this.runSearch();
@@ -1081,17 +1080,22 @@ remoteSearchDriver.prototype = {
                if ( !overflow_style )overflow_style = 'overflow:auto;';
                // Remove any old instance:
                $j( _this.target_container ).find( '#rsd_resource_edit' ).remove();
+               
+               // Hide the results container
+               $j( '#rsd_results_container' ).hide();
+               
+               var pt = $j( _this.target_container ).html();
                // Add the edit layout window with loading place holders
                $j( _this.target_container ).append( '<div id="rsd_resource_edit" ' +
-                       'style="position:absolute;top:0px;left:0px;bottom:0px;right:4px;background-color:#FFF;">' +
+                       'style="position:absolute;top:0px;left:0px;bottom:0px;right:4px;background-color:#FFF;"> ' +
                                '<div id="clip_edit_ctrl" class="ui-widget ui-widget-content ui-corner-all" style="position:absolute;' +
-                                       'left:2px;top:5px;bottom:10px;width:' + ( maxWidth + 5 ) + 'px;overflow:auto;padding:5px;">' +
-                               '</div>' +
+                                       'left:2px;top:5px;bottom:10px;width:' + ( maxWidth + 5 ) + 'px;overflow:auto;padding:5px;" >' +
+                               '</div>' +      
                                '<div id="clip_edit_disp" class="ui-widget ui-widget-content ui-corner-all"' +
-                                       'style="position:absolute;' + overflow_style + ';left:' + ( maxWidth + 20 ) + 'px;right:0px;top:5px;bottom:10px;padding:5px;>' +
+                                       'style="position:absolute;' + overflow_style + ';left:' + ( maxWidth + 20 ) + 'px;right:0px;top:5px;bottom:10px;padding:5px;>' +
                                                mv_get_loading_img( 'position:absolute;top:30px;left:30px' ) +
-                               '</div>' +
-               '</div>' );
+                               '</div>' +                      
+               '</div>' );             
        },
        resourceEdit:function( rObj, rsdElement ) {
                js_log( 'f:resourceEdit:' + rObj.title );
@@ -1287,7 +1291,7 @@ remoteSearchDriver.prototype = {
                                        );
                                        js_log( "about to call rewrite_by_id::embed_vid" );
                                        // Rewrite by id
-                                       rewrite_by_id( 'embed_vid', function() {
+                                       rewrite_by_id( 'embed_vid', function() {                                                
                                                // Grab any information that we got from the ROE xml or parsed from the media file
                                                rObj.pSobj.getEmbedObjParsedInfo( rObj, 'embed_vid' );
                                                // Add the re-sizable to the doLoad request:
@@ -1424,8 +1428,7 @@ remoteSearchDriver.prototype = {
 
                // @@ show user dialog to import the resource
                $j( _this.target_container ).append( '<div id="rsd_resource_import" ' +
-               'class="ui-widget-content" ' +
-               'style="position:absolute;top:0px;left:0px;right:0px;bottom:0px;z-index:5">' +
+               'class="ui-widget-content" style="position:absolute;top:0px;left:0px;right:0px;bottom:0px;z-index:5">' +
                        '<h3 style="color:red;padding:5px;">' + gM( 'mwe-resource-needs-import', [rObj.title, _this.upload_api_name] ) + '</h3>' +
                                '<div id="rsd_preview_import_container" style="position:absolute;width:50%;bottom:0px;left:5px;overflow:auto;top:30px;">' +
                                        rObj.pSobj.getEmbedHTML( rObj, {
@@ -1433,7 +1436,7 @@ remoteSearchDriver.prototype = {
                                                'max_height':'220',
                                                'only_poster':true
                                        } ) + // get embedHTML with small thumb:
-                                       '<br style="clear both">' +
+                                       '<br style="clear both"/>' +
                                        '<strong>' + gM( 'mwe-resource_page_desc' ) + '</strong>' +
                                        '<div id="rsd_import_desc" style="display:inline;">' +
                                                mv_get_loading_img( 'position:absolute;top:5px;left:5px' ) +
@@ -1442,13 +1445,13 @@ remoteSearchDriver.prototype = {
                                '<div id="rds_edit_import_container" style="position:absolute;left:50%;' +
                                        'bottom:0px;top:30px;right:0px;overflow:auto;">' +
                                        '<strong>' + gM( 'mwe-local_resource_title' ) + '</strong><br>' +
-                                       '<input type="text" size="30" value="' + rObj.target_resource_title + '" /><br>' +
+                                       '<input type="text" size="30" value="' + rObj.target_resource_title + '" /></br>' +
                                        '<strong>' + gM( 'mwe-edit_resource_desc' ) + '</strong>' +
                                        '<textarea id="rsd_import_ta" id="mv_img_desc" style="width:90%;" rows="8" cols="50">' +
                                                wt +
-                                       '</textarea><br>' +
-                                       '<input type="checkbox" value="true" id="wpWatchthis" name="wpWatchthis" tabindex="7"/>' +
-                                       '<label for="wpWatchthis">' + gM( 'mwe-watch_this_page' ) + '</label><br><br><br>' +
+                                       '</textarea></br>' +
+                                       '<input type="checkbox" value="true" id="wpWatchthis" name="wpWatchthis" tabindex="7" />' +
+                                       '<label for="wpWatchthis">' + gM( 'mwe-watch_this_page' ) + '</label></br></br></br>' +
                                        $j.btnHtml( gM( 'mwe-update_preview' ), 'rsd_import_apreview', 'refresh' ) + ' ' +
                                '</div>' +
                                // output the rendered and non-rendered version of description for easy switching:
index 1c05cf8..969ab76 100644 (file)
@@ -150,25 +150,44 @@ baseRemoteSearch.prototype = {
        getEmbedHTML: function( rObj , options ) {
                if ( !options )
                        options = { };
-               // set up the output var with the default values: 
-               var outOpt = { 'width': rObj.width, 'height': rObj.height };
+               // Set up the output var with the default values: 
+               var eWidth = rObj.width;
+               var eHeight = rObj.height;
                if ( options['max_height'] ) {
-                       outOpt.height = ( options.max_height > rObj.height ) ? rObj.height : options.max_height;
-                       outOpt.width = ( rObj.width / rObj.height ) * outOpt.height;
+                       eHeight = ( options.max_height > rObj.height ) ? rObj.height : options.max_height;
+                       eWidth = ( rObj.width / rObj.height ) * outOpt.height;
                }
-               options.style_attr = 'style="width:' + outOpt.width + 'px;height:' + outOpt.height + 'px"';
-               options.id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
+               var style_attr = 'style="';
+               if( eWidth )
+                       style_attr += 'width:' + eWidth + 'px;';
+                       
+               if( eHeight )
+                       style_attr += 'height:' + eHeight + 'px;';                      
                
-               if ( rObj.mime.indexOf( 'image' ) != -1 ) {
+               var id_attr = ( options['id'] ) ? ' id = "' + options['id'] + '" ': '';
+               
+               if ( rObj.mime.indexOf( 'image' ) != -1 )
                        return this.getImageEmbedHTML( rObj, options );
-               } else {
-                       js_log( "ERROR:: no embed code for mime type: " + rObj.mime );
-                       return ' Error missing embed code ';
+                       
+               if ( rObj.mime == 'application/ogg' || rObj.mime == 'video/ogg' || rObj.mime == 'audio/ogg' ) {
+                       var ahtml = id_attr +
+                                       ' src="' + rObj.src + '" ' +
+                                       style_attr +
+                                       ' poster="' +  rObj.poster + '" ';
+                       if (  rObj.mime == 'application/ogg' || rObj.mime == 'video/ogg'  ) {
+                               return '<video ' + ahtml + '></video>';
+                       }
+                                       
+                       if ( rObj.mime.indexOf( 'audio/ogg' ) != -1 ) {
+                               return '<audio ' + ahtml + '></audio>';
+                       }
                }
+               js_log( "ERROR:: no embed code for mime type: " + rObj.mime );  
+               return 'Error missing embed code for: ' + escape( rObj.mime );
        },
        getImageEmbedHTML:function( rObj, options ) {
                // if crop is null do base output: 
-               var imgHtml = '<img ' + options.id_attr + ' src="' + rObj.edit_url  + '"' + options.style_attr + ' >';
+               var imgHtml = '<img ' + options.id_attr + ' src="' + rObj.edit_url  + '"' + options.style_attr + ' ></img>';
                if ( rObj.crop == null )
                        return imgHtml
                // else do crop output: 
@@ -180,7 +199,9 @@ baseRemoteSearch.prototype = {
        },
        // by default just return the existing image with callback
        getImageObj:function( rObj, size, callback ) {
-               callback( { 'url':rObj.poster } );
+               callback( { 
+                       'url' : rObj.poster 
+               } );
        },
        // by default just return the rObj.desc
        getInlineDescWiki:function( rObj ) {
index 7c2047c..7de90cd 100644 (file)
@@ -66,14 +66,14 @@ mediaWikiSearch.prototype = {
        getUserRecentUploads:function( wgUser, callback ) {
                var _this = this;
                do_api_req( {
+                       'url':this.cp.api_url,
                        'data': {
                                'action':'query',
                                'list':'recentchanges',
                                'rcnamespace':6, // only files
                                'rcuser': wgUser,
-                               'rclimit':15, // get last 15 uploaded files                             
-                       },
-                       'url':this.cp.api_url
+                               'rclimit':15 // get last 15 uploaded files                              
+                       }                       
                }, function( data ) {
                        var titleSet = { };
                        var titleStr = ''
@@ -306,37 +306,12 @@ mediaWikiSearch.prototype = {
        insertImage:function( cEdit ) {
                if ( !cEdit )
                        var cEdit = _this.cEdit;
-       },
-       getEmbedHTML: function( rObj , options ) {
-               if ( !options )
-                       options = { };
-               this.parent_getEmbedHTML( rObj, options );
-               // check for image output:
-               if ( rObj.mime.indexOf( 'image' ) != -1 ) {
-                       return this.getImageEmbedHTML( rObj, options );
-               }
-               // for video and audio output:          
-               var ahtml = '';
-               if ( rObj.mime == 'application/ogg' || rObj.mime == 'audio/ogg' ) {
-                       ahtml = options.id_attr +
-                                               ' src="' + rObj.src + '" ' +
-                                               options.style_attr +
-                                               ' poster="' +  rObj.poster + '" '
-                       if ( rObj.mime.indexOf( 'application/ogg' ) != -1 ) {
-                               return '<video ' + ahtml + '></video>';
-                       }
-                                       
-                       if ( rObj.mime.indexOf( 'audio/ogg' ) != -1 ) {
-                               return '<audio ' + ahtml + '></audio>';
-                       }
-               }
-               js_log( 'ERROR:unsupored mime type: ' + rObj.mime );
-       },
+       },      
        getInlineDescWiki:function( rObj ) {
                var desc = this.parent_getInlineDescWiki( rObj );
                
                // strip categories for inline Desc: (should strip license tags too but not as easy)
-               desc = desc.replace( /\[\[Category\:[^\]]*\]\]/, '' );
+               desc = desc.replace( /\[\[Category\:[^\]]*\]\]/gi, '' );
                
                // just grab the description tag for inline desc:
                var descMatch = new RegExp( /Description=(\{\{en\|)?([^|]*|)/ );
@@ -347,6 +322,13 @@ mediaWikiSearch.prototype = {
                        desc = ( desc.substr( 0, 2 ) == '1=' ) ? desc.substr( 2 ): desc;
                        return desc;
                }
+               // Hackish attempt to strip templates
+               desc = desc.replace( /\{\{[^\}]*\}\}/gi, '' );
+               // strip any nexted template closures
+               desc = desc.replace( /\}\}/gi, '' );
+               // strip titles
+               desc = desc.replace( /\=\=[^\=]*\=\=/gi, '' );
+                               
                // else return the title since we could not find the desc:
                js_log( 'Error: No Description Tag, Using::' + desc );
                return desc;
index 9d00d08..31fdaf1 100644 (file)
@@ -532,9 +532,11 @@ mvClipEdit.prototype = {
                        case 'layout':
                                $target.append( '' +
                                        '<span style="float:left;">Layout:</span>' +
-                                               '<input type="radio" name="mv_layout" id="mv_layout_left" style="float:left"><div id="mv_layout_left_img" title="' + gM( 'mwe-layout_left' ) + '"/>' +
-                                               '<input type="radio" name="mv_layout" id="mv_layout_right" style="float:left"><div id="mv_layout_right_img" title="' + gM( 'mwe-layout_left' ) + '"/>' +
-                                       '<hr style="clear:both" /><br>'
+                                               '<input type="radio" name="mv_layout" id="mv_layout_left" style="float:left"></input>'+
+                                                       '<div id="mv_layout_left_img" title="' + gM( 'mwe-layout_left' ) + '"></div>' +
+                                               '<input type="radio" name="mv_layout" id="mv_layout_right" style="float:left"></input>'+
+                                                       '<div id="mv_layout_right_img" title="' + gM( 'mwe-layout_left' ) + '"></div>' +
+                                       '<hr style="clear:both" /><br/>'
                                );
                                // make sure the default is reflected:
                                if ( ! _this.rObj.layout )
index 4d1f457..9bb1632 100644 (file)
@@ -213,7 +213,9 @@ var nativeEmbed = {
                }
                //fire "onLoaded" flags if set
                while( this.onLoadedCallback.length ){
-                       this.onLoadedCallback.pop()();
+                       func = this.onLoadedCallback.pop()
+                       if( typeof func == 'function' )
+                               func();
                }
        },
        onprogress: function( e ) {
@@ -279,13 +281,13 @@ var nativeEmbed = {
        load:function( callback ) {
                this.getVID();          
                if ( !this.vid ) {
-                       // no vid loaded
+                       // No vid loaded
                        js_log( 'native::load() ... doEmbed' );
                        this.onlyLoadFlag = true;
                        this.doEmbedHTML();
                        this.onLoadedCallback.push( callback );
                } else {
-                       // should not happen offten
+                       // Should not happen offten
                        this.vid.load();
                        if( callback)
                                callback();
index 12472a9..c50e17a 100644 (file)
@@ -24,14 +24,14 @@ var mv_default_playlist_attributes = {
        // enable sequencer? (only display top frame no navigation or accompanying text
        "sequencer":false
 }
-// the call back rate for animations and internal timers in ms: 33 is about 30 frames a second: 
+// The call back rate for animations and internal timers in ms: 33 is about 30 frames a second: 
 var MV_ANIMATION_CB_RATE = 33;
 
 // globals:
 // 10 possible colors for clips: (can be in hexadecimal)
 var mv_clip_colors = new Array( 'aqua', 'blue', 'fuchsia', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red' );
 
-// the base url for requesting stream metadata 
+// The base url for requesting stream metadata 
 if ( typeof wgServer == 'undefined' ) {
        var defaultMetaDataProvider = 'http://metavid.org/overlay/archive_browser/export_cmml?stream_name=';
 } else {
@@ -57,6 +57,8 @@ mvPlayList.prototype = {
        userSlide:false,
        loading:true,
        loading_external_data:true, // if we are loading external data (set to loading by default)
+       //set initial state to "paused"
+       paused:true,
 
        activeClipList:null,
        playlist_buffer_time: 20, // how many seconds of future clips we should buffer
@@ -179,7 +181,7 @@ mvPlayList.prototype = {
                                                        embed_code += 'src=&quot;' + this.src + '&quot; /&gt;';
                                                } else {
                                                        embed_code += '&gt;' + "\n";
-                                                       embed_code += this.data.htmlEntities();
+                                                       embed_code += escape( this.data );
                                                        embed_code += '&lt;playlist/&gt;';
                                                }
                this.cur_clip.embed.showShare( embed_code );
@@ -448,7 +450,7 @@ mvPlayList.prototype = {
                                                
                // update the title and status bar
                this.updateBaseStatus();
-               this.doSmilActions( true );
+               this.doSmilActions();
        },
        setupClipDisplay:function() {
                js_log( 'mvPlaylist:setupClipDisplay:: clip len:' + this.default_track.clips.length );
@@ -517,7 +519,7 @@ mvPlayList.prototype = {
                this.cur_clip.embed.seek_time_sec = ( float_sec - pl_sum_time );
                
                // render effects ontop: (handled by doSmilActions)             
-               this.doSmilActions( true );
+               this.doSmilActions();
        },
        updateBaseStatus:function() {
                var _this = this;
@@ -879,8 +881,8 @@ mvPlayList.prototype = {
                var relative_perc = _this.updateClipByTime();   
                var clip_time = relative_perc * _this.cur_clip.embed.getDuration();             
                _this.cur_clip.embed.setCurrentTime( clip_time, function() {
-                       //update the smil actions: 
-                       _this.doSmilActions( true );
+                       //update the smil actions now that the seek is done 
+                       _this.doSmilActions();
                        //say we are "ready"
                        if ( callback )
                                callback();
@@ -1541,9 +1543,11 @@ mvPlayList.prototype.monitor = function() {
                }
        }
 }
+
 // handles the rendering of overlays load of future clips (if necessary)
 // @@todo could be lazy loaded if necessary 
-mvPlayList.prototype.doSmilActions = function( single_frame ) {
+mvPlayList.prototype.doSmilActions = function( callback ) {
+       var _this = this;
        // js_log('f:doSmilActions: ' + this.cur_clip.id + ' tid: ' + this.cur_clip.transOut );
        var offSetTime = 0; // offset time should let us start a transition later on if we have to. 
        var _clip = this.cur_clip;      // setup a local pointer to cur_clip
@@ -1551,9 +1555,9 @@ mvPlayList.prototype.doSmilActions = function( single_frame ) {
        
        // do any smil time actions that may change the current clip
        if ( this.userSlide ) {
-               // current clip set is set via updateThumbTime function                  
+               // current clip set is updated mannually outside the scope of smil Actions 
        } else {
-               // assume playing and go to next: 
+               // Assume playing and go to next: 
                if ( _clip.dur <= _clip.embed.currentTime
                         && _clip.order != _clip.pp.getClipCount() - 1 ) {
                        // force next clip
@@ -1565,46 +1569,58 @@ mvPlayList.prototype.doSmilActions = function( single_frame ) {
        }
        // @@todo could maybe generalize transIn with trasOut into one "flow" with a few scattered if statements        
        // update/setup all transitions (will render current transition state)  
-       var in_range = false;
-       // pretty similar actions per transition types so group into a loop:
-       var tran_types = { 
-               'transIn' : true, 
-               'transOut':true 
-       };
-       for ( var tid in tran_types ) {
-               eval( 'var tObj =  _clip.' + tid );
-               if ( !tObj )
-                       continue;
-               // js_log('f:doSmilActions: ' + _clip.id + ' tid:'+tObj.id + ' tclip_id:'+ tObj.pClip.id);                                      
-               // make sue we are in range: 
-               if ( tid == 'transIn' )
-                       in_range = ( _clip.embed.currentTime <= tObj.dur ) ? true:false;
-               
-               if ( tid == 'transOut' )
-                       in_range = ( _clip.embed.currentTime >= ( _clip.dur - tObj.dur ) ) ? true:false;
-               
-               if ( in_range ) {
-                       if ( this.userSlide || single_frame ) {
-                               if ( tid == 'transIn' )
-                                       mvTransLib.doUpdate( tObj, ( _clip.embed.currentTime / tObj.dur ) );
-                                       
-                               if ( tid == 'transOut' )
-                                       mvTransLib.doUpdate( tObj, ( _clip.embed.currentTime - ( _clip.dur - tObj.dur ) ) / tObj.dur );
-                                       
-                       } else {
-                               if ( tObj.animation_state == 0 ) {
-                                       js_log( 'init/run_transition ' );
-                                       tObj.run_transition();
-                               }
-                       }
-               } else {
-                       // close up transition if done & still onDispaly
-                       if ( tObj.overlay_selector_id ) {
-                               js_log( 'close up transition :' + tObj.overlay_selector_id );
-                               mvTransLib.doCloseTransition( tObj );
+
+       // process actions per transition types:
+       _this.procTranType( 'transIn', callback);
+       _this.procTranType( 'transOut', callback);
+}
+
+/*
+* procTranType
+* @param {string} tid the transition type [transIn|transOut]
+* @param {function} callback the callback function passed onto doUPdate
+*/
+mvPlayList.prototype.procTranType = function( tid, callback){
+       // Setup local clip pointer:
+       var _clip = this.cur_clip;      
+       
+       eval( 'var tObj =  _clip.' + tid );
+       if ( !tObj )
+               return;
+       // js_log('f:doSmilActions: ' + _clip.id + ' tid:'+tObj.id + ' tclip_id:'+ tObj.pClip.id);                                      
+       // Check if we are in range: 
+       if ( tid == 'transIn' )
+               in_range = ( _clip.embed.currentTime <= tObj.dur ) ? true : false;
+       
+       if ( tid == 'transOut' )
+               in_range = ( _clip.embed.currentTime >= ( _clip.dur - tObj.dur ) ) ? true : false;
+       
+       if ( in_range ) {
+               if ( this.userSlide || this.paused ) {
+                       if ( tid == 'transIn' ){
+                               mvTransLib.doUpdate( tObj, 
+                                       ( _clip.embed.currentTime / tObj.dur ), 
+                                       callback );     
+                       }               
+                       if ( tid == 'transOut' ){
+                               mvTransLib.doUpdate( tObj, 
+                                       ( ( _clip.embed.currentTime - ( _clip.dur - tObj.dur ) ) / tObj.dur ), 
+                                       callback );
                        }
+               } else if ( tObj.animation_state == 0 ) {
+                       js_log( 'init/run_transition ' );
+                       tObj.run_transition();
+               }
+       } else {
+               // Close up transition if done & still onDispaly
+               if ( tObj.overlay_selector_id ) {
+                       js_log( 'close up transition :' + tObj.overlay_selector_id );
+                       mvTransLib.doCloseTransition( tObj );
                }
        }
+       // Run the callback:: 
+       if( callback ) 
+               callback();
 }
 
 /*
@@ -1624,7 +1640,7 @@ var mvTransLib = {
         * @param offSetTime default value 0 if we need to start rendering from a given time 
         */
        doInitTransition:function( tObj ) {
-               js_log( 'mvTransLib:f:doInitTransition' );
+               js_log( 'mvTransLib:f:doInitTransition' );              
                if ( !tObj.type ) {
                        js_log( 'transition is missing type attribute' );
                        return false;
@@ -1655,11 +1671,14 @@ var mvTransLib = {
                        if ( typeof( other_pClip ) == 'undefined' || other_pClip === false || other_pClip.id == tObj.pClip.pp.cur_clip.id )
                                js_log( 'Error: crossfade without target media asset' );
                        // if not sliding start playback: 
-                       if ( !tObj.pClip.pp.userSlide ) {
-                               other_pClip.embed.play();
-                               // manualy ad the extra layer to the activeClipList
-                               tObj.pClip.pp.activeClipList.add( other_pClip );
+                       if ( !tObj.pClip.pp.userSlide && !tObj.pClip.pp.paused) {
+                               other_pClip.embed.play();                       
+                       }else{
+                               //issue a load request: 
+                               other_pClip.embed.load(); 
                        }
+                       // manualy ad the extra layer to the activeClipList
+                       tObj.pClip.pp.activeClipList.add( other_pClip );
                        tObj.overlay_selector_id = 'clipDesc_' + other_pClip.id;
                } else {
                        tObj.overlay_selector_id = this.getOverlaySelector( tObj );
@@ -1694,7 +1713,7 @@ var mvTransLib = {
                }
                return overlay_selector_id;
        },
-       doUpdate:function( tObj, percent ) {
+       doUpdate:function( tObj, percent, callback ) {
                // init the transition if necessary:
                if ( !tObj.overlay_selector_id )
                        this.doInitTransition( tObj );
@@ -1702,15 +1721,15 @@ var mvTransLib = {
                // @@todo we should ensure viability outside of doUpate loop                    
                if ( !$j( '#' + tObj.overlay_selector_id ).is( ':visible' ) )
                        $j( '#' + tObj.overlay_selector_id ).show();
-                       
+               
                // do update:
-               /*js_log('doing update for: '+ tObj.pClip.id + 
+               /*      js_log('doing update for: '+ tObj.pClip.id + 
                        ' type:' + tObj.transAttrType +
                        ' t_type:'+ tObj.type +
                        ' subypte:'+ tObj.subtype  + 
                        ' percent:' + percent);*/
                        
-               this['type'][tObj.type][tObj.subtype].u( tObj, percent );
+               this[ 'type' ][ tObj.type ][ tObj.subtype ].u( tObj, percent, callback);
        },
        getTransitionIcon:function( type, subtype ) {
                return mv_embed_path + '/skins/common/transition_images/' + type + '_' + subtype + '.png';
@@ -1719,11 +1738,11 @@ var mvTransLib = {
         * mvTransLib: functional library mapping:
         */
        type: {
-               // types:
+               // Types:
                fade: {
                        fadeFromColor: {
-                               'attr':['fadeColor'],
-                               'init':function( tObj ) {
+                               'attr' : ['fadeColor'],
+                               'init' : function( tObj ) {
                                        // js_log('f:fadeFromColor: '+tObj.overlay_selector_id +' to color: '+ tObj.fadeColor);
                                        if ( !tObj.fadeColor )
                                                js_log( 'missing fadeColor' );
@@ -1736,7 +1755,7 @@ var mvTransLib = {
                                                'opacity':"1"
                                        } );
                                },
-                               'u':function( tObj, percent ) {
+                               'u' : function( tObj, percent ) {
                                        // js_log(':fadeFromColor:update: '+ percent);
                                        // fade from color (invert the percent)
                                        var percent = 1 - percent;
@@ -1747,8 +1766,8 @@ var mvTransLib = {
                        },
                        // corssFade
                        crossfade: {
-                               "attr":[],
-                               "init":function( tObj ) {
+                               "attr" : [],
+                               "init" : function( tObj ) {
                                        js_log( 'f:crossfade: ' + tObj.overlay_selector_id );
                                        if ( $j( '#' + tObj.overlay_selector_id ).length == 0 )
                                                js_log( "ERROR overlay selector not found: " + tObj.overlay_selector_id );
@@ -1757,6 +1776,7 @@ var mvTransLib = {
                                        $j( '#' + tObj.overlay_selector_id ).css( { 'opacity':0 } ).show();
                                },
                                'u':function( tObj, percent ) {
+                                       // Do the relative seek:
                                        $j( '#' + tObj.overlay_selector_id ).css( {
                                                "opacity" : percent
                                        } );
@@ -1814,8 +1834,8 @@ transitionObj.prototype = {
                var elmObj = { };
                for ( var i in this.supported_attributes ) {
                        var attr = this.supported_attributes[i];
-                       if ( this[attr] )
-                               elmObj[ attr ] = this[attr];
+                       if ( this[ attr ] )
+                               elmObj[ attr ] = this[ attr ];
                }
                return elmObj;
        },
@@ -1838,14 +1858,15 @@ transitionObj.prototype = {
                //              this.interValCount=0;
                //      }
                // }            
-               // start_time =asigned by doSmilActions
+               
+               // start_time =assigned by doSmilActions
                // base_cur_time = pClip.embed.currentTime;
-               // dur = asigned by attribute           
+               // dur = assigned by attribute          
                if ( this.animation_state == 0 ) {
                        mvTransLib.doInitTransition( this );
                        this.animation_state = 1;
                }
-               // set percentage include difrence of currentTime to prev_curTime 
+               // set percentage include diffrence of currentTime to prev_curTime 
                // ie updated in-between currentTime updates) 
 
                if ( this.transAttrType == 'transIn' )
@@ -2267,37 +2288,3 @@ function getAbsolutePos( objectId ) {
        }
        return { x:oLeft, y:oTop };
 }
-String.prototype.htmlEntities = function() {
-  var chars = new Array ( '&', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é',
-                                                'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô',
-                                                'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', 'À',
-                                                'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë',
-                                                'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö',
-                                                'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', '€', '\"', 'ß', '<',
-                                                '>', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«',
-                                                '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶',
-                                                '·', '¸', '¹', 'º', '»', '¼', '½', '¾' );
-
-  var entities = new Array ( 'amp', 'agrave', 'aacute', 'acirc', 'atilde', 'auml', 'aring',
-                                                       'aelig', 'ccedil', 'egrave', 'eacute', 'ecirc', 'euml', 'igrave',
-                                                       'iacute', 'icirc', 'iuml', 'eth', 'ntilde', 'ograve', 'oacute',
-                                                       'ocirc', 'otilde', 'ouml', 'oslash', 'ugrave', 'uacute', 'ucirc',
-                                                       'uuml', 'yacute', 'thorn', 'yuml', 'Agrave', 'Aacute', 'Acirc',
-                                                       'Atilde', 'Auml', 'Aring', 'AElig', 'Ccedil', 'Egrave', 'Eacute',
-                                                       'Ecirc', 'Euml', 'Igrave', 'Iacute', 'Icirc', 'Iuml', 'ETH', 'Ntilde',
-                                                       'Ograve', 'Oacute', 'Ocirc', 'Otilde', 'Ouml', 'Oslash', 'Ugrave',
-                                                       'Uacute', 'Ucirc', 'Uuml', 'Yacute', 'THORN', 'euro', 'quot', 'szlig',
-                                                       'lt', 'gt', 'cent', 'pound', 'curren', 'yen', 'brvbar', 'sect', 'uml',
-                                                       'copy', 'ordf', 'laquo', 'not', 'shy', 'reg', 'macr', 'deg', 'plusmn',
-                                                       'sup2', 'sup3', 'acute', 'micro', 'para', 'middot', 'cedil', 'sup1',
-                                                       'ordm', 'raquo', 'frac14', 'frac12', 'frac34' );
-
-  newString = this;
-  for ( var i = 0; i < chars.length; i++ )
-  {
-       myRegExp = new RegExp();
-       myRegExp.compile( chars[i], 'g' )
-       newString = newString.replace ( myRegExp, '&' + entities[i] + ';' );
-  }
-  return newString;
-};
index 28c8e82..66b1551 100644 (file)
@@ -1227,8 +1227,8 @@ function mwdomReady( force ) {
                        for ( var k in e[j] ) {
                                if ( e[j][k] && typeof( e[j][k] ) == 'object' ) {
                                        var     sn = e[j][k].getAttribute( 'class' );
-                                       // Try "className" for good ol IE                               
-                                       if(!sn){
+                                       // Try "className" for good old IE                              
+                                       if( !sn ){
                                                var     sn = e[j][k].getAttribute( 'className' );
                                        }                                       
                                        if ( sn && sn != '' ) {
@@ -1577,8 +1577,8 @@ function mv_jqueryBindings() {
                        var style_attr = ( opt.style ) ? ' style="' + opt.style + '" ' : '';
                        return '<a href="' + href + '" ' + target_attr + style_attr +
                                ' class="ui-state-default ui-corner-all ui-icon_link ' +
-                               className + '"><span class="ui-icon ui-icon-' + iconId + '" />' +
-                               '<span class="btnText">' + msg + '<span></a>';
+                               className + '"><span class="ui-icon ui-icon-' + iconId + '" ></span>' +
+                               '<span class="btnText">' + msg + '</span></a>';
                }
                // Shortcut to bind hover state
                $.fn.btnBind = function() {
index 48f4924..8f2b896 100644 (file)
@@ -5,7 +5,7 @@
  
 var urlparts = getRemoteEmbedPath();
 var mwEmbedHostPath = urlparts[0];
-var mwRemoteVersion = '1.08';
+var mwRemoteVersion = '1.09';
 var mwUseScriptLoader = true;
 
 // setup up request Params: 
@@ -24,27 +24,30 @@ addOnloadHook( function() {
        }
 } );
 
-function doPageSpecificRewrite() {
+function doPageSpecificRewrite() {             
        // Add media wizard
-       if ( wgAction == 'edit' || wgAction == 'submit' ) {
-               load_mv_embed( function() {
+       if ( wgAction == 'edit' || wgAction == 'submit' ) {     
+               var jsSetEdit = [ 'remoteSearchDriver', '$j.fn.textSelection', '$j.ui', '$j.ui.sortable' ]
+               mwr_load_mv_embed( jsSetEdit, function() {
                        loadExternalJs( mwEmbedHostPath + '/editPage.js?' + mwGetReqArgs() );
                } );
        }
        
        // Timed text display:
        if ( wgPageName.indexOf( "TimedText" ) === 0 ) {
-               load_mv_embed( function() {
+               mwr_load_mv_embed( function() {
                        // Load with mw loader to get localized interface:
                        mw.load( ['mvTimeTextEdit'], function() {
-                               // could run init here (but mvTimeTextEdit included onLoad actions)
+                               // could run init here (but mvTimeTextEdit already included onLoad actions)
                        } );
                } );
        }
        
        // Firefogg integration
-       if ( wgPageName == "Special:Upload" ) {
-               load_mv_embed( function() {
+       if ( wgPageName == "Special:Upload" ) { 
+               var jsSetUpload = [ 'mvBaseUploadInterface', 'mvFirefogg' , '$j.ui',
+                                                       '$j.ui.progressbar', '$j.ui.dialog', '$j.ui.draggable' ]; 
+               mwr_load_mv_embed( jsSetUpload, function() {
                        loadExternalJs( mwEmbedHostPath + '/uploadPage.js?' + mwGetReqArgs() );
                } );
        }
@@ -52,8 +55,7 @@ function doPageSpecificRewrite() {
        // Special api proxy page
        if ( wgPageName == 'MediaWiki:ApiProxy' ) {
                var wgEnableIframeApiProxy = true;
-               load_mv_embed( function() {
-                       js_log( "Wiki:ApiProxy::" );
+               mwr_load_mv_embed( [ 'mw.proxy' ], function() {                 
                        loadExternalJs( mwEmbedHostPath + '/apiProxyPage.js?' + mwGetReqArgs() );
                } );
        }
@@ -67,7 +69,18 @@ function doPageSpecificRewrite() {
                }
        }
        if ( vidIdList.length > 0 ) {
-               load_mv_embed( function() {
+       
+               var jsSetVideo = [ 'embedVideo', '$j.ui', 'ctrlBuilder', '$j.cookie', '$j.ui.slider' ];
+               
+               // Quick sniff use java if IE and native if firefox 
+               // ( other browsers will run detect and get on-demand )         
+               if (navigator.userAgent.indexOf("MSIE") != -1)
+                       jsSetVideo.push( 'javaEmbed' );
+                       
+               if ( navigator.userAgent &&  navigator.userAgent.indexOf("Firefox") != -1 )
+                       jsSetVideo.push( 'nativeEmbed' );
+       
+               mwr_load_mv_embed( jsSetVideo, function() {
                        mvJsLoader.embedVideoCheck( function() {
                                // Do utility rewrite of OggHandler content:
                                rewrite_for_OggHandler( vidIdList );
@@ -87,8 +100,10 @@ function rewrite_for_OggHandler( vidIdList ) {
                var pimg = $j( '#' + vidId + ' img' );
                var poster_attr = 'poster = "' + pimg.attr( 'src' ) + '" ';
                var pwidth = $j( '#' + vidId ).width();
-               var pheight = $j( '#' + vidId + ' img' ).height();
-               var tag_type = 'video';
+               var pheight = $j( '#' + vidId + ' img :first' ).attr( 'height' );
+               if(!pheight)
+                       pheight = parseInt( pwidth * .75 );
+               var tag_type = 'video';         
                                
                // Check for audio
                if ( pheight == '22' || pheight == '52' ) {
@@ -182,31 +197,68 @@ function mwGetReqArgs() {
        }
        return rurl;
 }
-function load_mv_embed( callback ) {
+/**
+* @param {mixed} function or classSet to preload
+* classSet saves round trips to the server by grabbing things we will likely need in the first request. 
+* ( this is essentially a shortcut to mv_jqueryBindings in mv_embed.js )   
+* @param {callback} function callback to be called once mv_embed is ready
+*/
+function mwr_load_mv_embed( classSet, callback ) {
+       if( typeof classSet == 'function')
+               callback = classSet;
        // Inject mv_embed if needed
        if ( typeof mw == 'undefined' ) {
                if ( ( mwReqParam['uselang'] || mwReqParam['useloader'] ) && mwUseScriptLoader ) {
                        var rurl = mwEmbedHostPath + '/mwEmbed/jsScriptLoader.php?class=mv_embed';
+                       
                        // Add jQuery too if we need it: 
                        if ( typeof window.jQuery == 'undefined' ) {
                                rurl += ',window.jQuery';
+                       }       
+                                                               
+                       // Add requested classSet
+                       for( var i=0; i < classSet.length; i++ ){
+                               var cName =  classSet[i];
+                               if( !mwr_check_obj_path( cName ) ){
+                                       rurl +=  ',' + cName;
+                               }
                        }
+                       
+                       // Add the remaining arguments
                        rurl += '&' + mwGetReqArgs();
                                                        
                        importScriptURI( rurl );
-               } else {
+               } else { 
+                       // Ingore classSet (will be loaded onDemand )
                        importScriptURI( mwEmbedHostPath + '/mwEmbed/mv_embed.js?' + mwGetReqArgs() );
                }
        }
-       check_for_mv_embed( callback );
+       mwr_check_for_mv_embed( callback );
 }
 
-function check_for_mv_embed( callback ) {
+function mwr_check_for_mv_embed( callback ) {
        if ( typeof mw == 'undefined' ) {
                setTimeout( function() {
-                       check_for_mv_embed( callback );
+                       mwr_check_for_mv_embed( callback );
                }, 25 );
        } else {
                callback();
        }
 }
+
+function mwr_check_obj_path ( libVar ) {
+       if ( !libVar )
+               return false;
+       var objPath = libVar.split( '.' )
+       var cur_path = '';
+       for ( var p = 0; p < objPath.length; p++ ) {
+               cur_path = ( cur_path == '' ) ? cur_path + objPath[p] : cur_path + '.' + objPath[p];
+               eval( 'var ptest = typeof ( ' + cur_path + ' ); ' );
+               if ( ptest == 'undefined' ) {
+                       this.missing_path = cur_path;
+                       return false;
+               }
+       }
+       this.cur_path = cur_path;
+       return true;
+};