function trx_addons_resize_video(cont) {
    if (cont===undefined) cont = jQuery('body');
    cont.find('video').each(function() {
        "use strict";
        var video = jQuery(this).eq(0);
        var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
        ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
        var mejs_cont = video.parents('.mejs-video');
        var w_attr = video.data('width');
        var h_attr = video.data('height');
        if (!w_attr || !h_attr) {
            w_attr = video.attr('width');
            h_attr = video.attr('height');
            if (!w_attr || !h_attr) return;
            video.data({'width': w_attr, 'height': h_attr});
        }
        var percent = (''+w_attr).substr(-1)=='%';
        w_attr = parseInt(w_attr, 0);
        h_attr = parseInt(h_attr, 0);
        var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()),
            h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
        if (parseInt(video.attr('data-last-width'), 0)==w_real) return;
        if (mejs_cont.length > 0 && mejs) {
            trx_addons_set_mejs_player_dimensions(video, w_real, h_real);
        }
        if (percent) {
            video.height(h_real);
        } else {
            video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
        }
        video.attr('data-last-width', w_real);
    });
    cont.find('.video_frame iframe').each(function() {
        "use strict";
        var iframe = jQuery(this).eq(0);
        if (iframe.attr('src').indexOf('soundcloud')>0) return;
        var ratio = (iframe.data('ratio')!=undefined 
                     ? iframe.data('ratio').split(':') 
                     : (iframe.parent().data('ratio')!=undefined 
                        ? iframe.parent().data('ratio').split(':') 
                        : (iframe.find('[data-ratio]').length>0 
                           ? iframe.find('[data-ratio]').data('ratio').split(':') 
                           : [16,9]
                          )
                       )
                    );
        ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
        var w_attr = iframe.attr('width');
        var h_attr = iframe.attr('height');
        if (!w_attr || !h_attr) {
            return;
        }
        var percent = (''+w_attr).substr(-1)=='%';
        w_attr = parseInt(w_attr, 0);
        h_attr = parseInt(h_attr, 0);
        var pw = iframe.parent().width(),
            ph = iframe.parent().height(),
            w_real = pw,
            h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
        if (iframe.parent().css('position') == 'absolute' && h_real > ph) {
            h_real = ph;
            w_real = Math.round(percent ? h_real*ratio : h_real*w_attr/h_attr)
        }
        if (parseInt(iframe.attr('data-last-width'), 0)==w_real) return;
        iframe.css({'width': w_real+'px', 'height': h_real+'px'});
        iframe.attr('data-last-width', w_real);
    });
}
// Fit video frames to document width
Fit video frames to document width
Fit video frames to document width
function trx_addons_resize_video(cont) {
    if (cont===undefined) cont = jQuery('body');
    cont.find('video').each(function() {
        "use strict";
        var video = jQuery(this).eq(0);
        var ratio = (video.data('ratio')!=undefined ? video.data('ratio').split(':') : [16,9]);
        ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
        var mejs_cont = video.parents('.mejs-video');
        var w_attr = video.data('width');
        var h_attr = video.data('height');
        if (!w_attr || !h_attr) {
            w_attr = video.attr('width');
            h_attr = video.attr('height');
            if (!w_attr || !h_attr) return;
            video.data({'width': w_attr, 'height': h_attr});
        }
        var percent = (''+w_attr).substr(-1)=='%';
        w_attr = parseInt(w_attr, 0);
        h_attr = parseInt(h_attr, 0);
        var w_real = Math.round(mejs_cont.length > 0 ? Math.min(percent ? 10000 : w_attr, mejs_cont.parents('div,article').width()) : video.width()),
            h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
        if (parseInt(video.attr('data-last-width'), 0)==w_real) return;
        if (mejs_cont.length > 0 && mejs) {
            trx_addons_set_mejs_player_dimensions(video, w_real, h_real);
        }
        if (percent) {
            video.height(h_real);
        } else {
            video.attr({'width': w_real, 'height': h_real}).css({'width': w_real+'px', 'height': h_real+'px'});
        }
        video.attr('data-last-width', w_real);
    });
    cont.find('.video_frame iframe').each(function() {
        "use strict";
        var iframe = jQuery(this).eq(0);
        if (iframe.attr('src').indexOf('soundcloud')>0) return;
        var ratio = (iframe.data('ratio')!=undefined 
                     ? iframe.data('ratio').split(':') 
                     : (iframe.parent().data('ratio')!=undefined 
                        ? iframe.parent().data('ratio').split(':') 
                        : (iframe.find('[data-ratio]').length>0 
                           ? iframe.find('[data-ratio]').data('ratio').split(':') 
                           : [16,9]
                          )
                       )
                    );
        ratio = ratio.length!=2 || ratio[0]==0 || ratio[1]==0 ? 16/9 : ratio[0]/ratio[1];
        var w_attr = iframe.attr('width');
        var h_attr = iframe.attr('height');
        if (!w_attr || !h_attr) {
            return;
        }
        var percent = (''+w_attr).substr(-1)=='%';
        w_attr = parseInt(w_attr, 0);
        h_attr = parseInt(h_attr, 0);
        var pw = iframe.parent().width(),
            ph = iframe.parent().height(),
            w_real = pw,
            h_real = Math.round(percent ? w_real/ratio : w_real/w_attr*h_attr);
        if (iframe.parent().css('position') == 'absolute' && h_real > ph) {
            h_real = ph;
            w_real = Math.round(percent ? h_real*ratio : h_real*w_attr/h_attr)
        }
        if (parseInt(iframe.attr('data-last-width'), 0)==w_real) return;
        iframe.css({'width': w_real+'px', 'height': h_real+'px'});
        iframe.attr('data-last-width', w_real);
    });
}
function trx_addons_resize_video ( cont ) { if ( cont === undefined ) cont = jQuery ( 'body' ) ; cont . find ( 'video' ) . each ( function ( ) { "use strict" ; var video = jQuery ( this ) . eq ( 0 ) ; var ratio = ( video . data ( 'ratio' ) != undefined ? video . data ( 'ratio' ) . split ( ':' ) : [ 16 , 9 ] ) ; ratio = ratio . length != 2 || ratio [ 0 ] == 0 || ratio [ 1 ] == 0 ? 16 / 9 : ratio [ 0 ] / ratio [ 1 ] ; var mejs_cont = video . parents ( '.mejs-video' ) ; var w_attr = video . data ( 'width' ) ; var h_attr = video . data ( 'height' ) ; if ( ! w_attr || ! h_attr ) { w_attr = video . attr ( 'width' ) ; h_attr = video . attr ( 'height' ) ; if ( ! w_attr || ! h_attr ) return ; video . data ( { 'width' : w_attr , 'height' : h_attr } ) ; } var percent = ( '' + w_attr ) . substr ( - 1 ) == '%' ; w_attr = parseInt ( w_attr , 0 ) ; h_attr = parseInt ( h_attr , 0 ) ; var w_real = Math . round ( mejs_cont . length > 0 ? Math . min ( percent ? 10000 : w_attr , mejs_cont . parents ( 'div,article' ) . width ( ) ) : video . width ( ) ) , h_real = Math . round ( percent ? w_real / ratio : w_real / w_attr * h_attr ) ; if ( parseInt ( video . attr ( 'data-last-width' ) , 0 ) == w_real ) return ; if ( mejs_cont . length > 0 && mejs ) { trx_addons_set_mejs_player_dimensions ( video , w_real , h_real ) ; } if ( percent ) { video . height ( h_real ) ; } else { video . attr ( { 'width' : w_real , 'height' : h_real } ) . css ( { 'width' : w_real + 'px' , 'height' : h_real + 'px' } ) ; } video . attr ( 'data-last-width' , w_real ) ; } ) ; cont . find ( '.video_frame iframe' ) . each ( function ( ) { "use strict" ; var iframe = jQuery ( this ) . eq ( 0 ) ; if ( iframe . attr ( 'src' ) . indexOf ( 'soundcloud' ) > 0 ) return ; var ratio = ( iframe . data ( 'ratio' ) != undefined ? iframe . data ( 'ratio' ) . split ( ':' ) : ( iframe . parent ( ) . data ( 'ratio' ) != undefined ? iframe . parent ( ) . data ( 'ratio' ) . split ( ':' ) : ( iframe . find ( '[data-ratio]' ) . length > 0 ? iframe . find ( '[data-ratio]' ) . data ( 'ratio' ) . split ( ':' ) : [ 16 , 9 ] ) ) ) ; ratio = ratio . length != 2 || ratio [ 0 ] == 0 || ratio [ 1 ] == 0 ? 16 / 9 : ratio [ 0 ] / ratio [ 1 ] ; var w_attr = iframe . attr ( 'width' ) ; var h_attr = iframe . attr ( 'height' ) ; if ( ! w_attr || ! h_attr ) { return ; } var percent = ( '' + w_attr ) . substr ( - 1 ) == '%' ; w_attr = parseInt ( w_attr , 0 ) ; h_attr = parseInt ( h_attr , 0 ) ; var pw = iframe . parent ( ) . width ( ) , ph = iframe . parent ( ) . height ( ) , w_real = pw , h_real = Math . round ( percent ? w_real / ratio : w_real / w_attr * h_attr ) ; if ( iframe . parent ( ) . css ( 'position' ) == 'absolute' && h_real > ph ) { h_real = ph ; w_real = Math . round ( percent ? h_real * ratio : h_real * w_attr / h_attr ) } if ( parseInt ( iframe . attr ( 'data-last-width' ) , 0 ) == w_real ) return ; iframe . css ( { 'width' : w_real + 'px' , 'height' : h_real + 'px' } ) ; iframe . attr ( 'data-last-width' , w_real ) ; } ) ; }
Fit video frames to document width
Fit video frames to document width