1var CProVideo = ''; 2 3(function( $ ) { 4 5 CProVideo = { 6 7 /** 8 * Initializes the all class variables. 9 * 10 * @return void 11 * @since 0.0.1 12 */ 13 init: function( e, element, event ) { 14 15 // events 16 $( window ).on( "cp_after_popup_open", this._playVideo ); 17 $( document ).on( "closePopup", this._stopVideo ); 18 }, 19 20 /** 21 * Play Video 22 * 23 * @since 1.0.0 24 */ 25 _playVideo: function( e, data, module_type, style_id ) { 26 27 var video_container = data.find( '.cpro-video-container' ); 28 29 video_container.each( function() { 30 31 var $this_field = jQuery(this).closest(".cp-field-html-data"); 32 var is_autoplay = $this_field.data('autoplay'); 33 var video_src = $this_field.data('src'); 34 var video_frame = $this_field.find("iframe"); 35 var video_url = video_frame.attr('src'); 36 var iframe_id = video_frame.attr('id'); 37 38 switch( video_src ) { 39 40 case "youtube": 41 if( is_autoplay ) { 42 video_url = video_url.replace( '&autoplay=0', '' ); 43 video_url = video_url + "&autoplay=1&mute=1"; 44 video_frame.attr( 'src', video_url ); 45 } 46 break; 47 48 case "vimeo": 49 50 if( is_autoplay ) { 51 video_url = video_url + "?autoplay=1"; 52 video_frame.attr( 'src', video_url ); 53 } 54 break; 55 56 case 'custom_url': 57 if( is_autoplay ) { 58 setTimeout(function() { 59 $this_field.find('.cpro-video-iframe')[0].play(); 60 }, 500 ); 61 } 62 break; 63 } 64 65 }); 66 }, 67 68 /* 69 * Stop video on close of popup 70 * @since 1.0.0 71 */ 72 _stopVideo: function( event, modal, id ) { 73 74 var videos = $( ".cp_style_" + id ).find( '.cp-video-wrap' ); 75 76 videos.each( function() { 77 78 var $this = $(this); 79 var video_src = $this.data("src"); 80 var video_frame = $this.find('iframe'); 81 var iframe_src = video_frame.attr("src"); 82 83 switch ( video_src ) { 84 85 case 'youtube': 86 var src_autoplay = iframe_src.replace( 'autoplay=1', 'autoplay=0' ); 87 video_frame.attr( 'src', src_autoplay ); 88 break; 89 case 'vimeo': 90 video_frame.prop( 'src', '' ).prop( 'src', iframe_src.replace( '?autoplay=1', '' ) ); 91 break; 92 93 case 'custom_url': 94 $this.find("video")[0].pause(); 95 break; 96 } 97 }); 98 }, 99 }; 100 101 CProVideo.init(); 102 103 104})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.