Fix jplayer video height missing define bug.

This commit is contained in:
BoHung Chiu 2022-03-07 12:20:09 +08:00
parent ec0dfbc25c
commit d3e1b55840
1 changed files with 18 additions and 0 deletions

View File

@ -231,6 +231,23 @@
<% if @hide_video_tools %>
ad_audio_button(this,false);
<% end %>
var is_frontend = <%= @is_frontend ? true : false %>;
if(is_frontend){
var cyclediv = $(this).parents("div.cycle-slideshow").eq(0);
if(cyclediv.height() == 0 || cyclediv.data("auto-height")){
cyclediv.data("auto-height",true);
var video_block = cyclediv.find('video')[0];
if(video_block != undefined){
cyclediv.height(cyclediv.width() * video_block.videoHeight / video_block.videoWidth);
if(!(cyclediv.data("bind-resize"))){
cyclediv.data("bind-resize",true);
$(window).resize(function(){
cyclediv.height(cyclediv.width() * video_block.videoHeight / video_block.videoWidth);
})
}
}
}
}
},
click: function(){
click_jplayer_<%= i %>();
@ -257,6 +274,7 @@
<% if @apply_autoplay_script %>
var is_frontend = <%= @is_frontend ? true : false %>;
var cyclediv = $(this).parents("div.cycle-slideshow").eq(0);
var autoHeight = cyclediv.data("auto-height");
if(!is_frontend || (is_frontend && cyclediv.find('[data-autoplay=1]').length != 0)){
cyclediv.cycle("pause").cycle("next");
var current_cycle = cyclediv.find(".cycle-slide-active");