This commit is contained in:
BoHung Chiu 2023-07-04 14:30:03 +08:00
parent c5add605f9
commit cfe0fd9c5a
2 changed files with 55 additions and 37 deletions

View File

@ -225,15 +225,21 @@
<% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<% if image.exchange_item == '1' %>
<div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div>
<% elsif image.video_snapshot %>
<% elsif image.video_snapshot.present? %>
<div class="slide-img" style=" background: url('<%= image.video_snapshot %>'); background-size: cover; background-position: center;"></div>
<% elsif image.exchange_item == '2' %>
<div class="slide-img" style=" background: url('<%= image.youtube_thumb %>'); background-size: cover; background-position: center;"></div>
<% end %>
<% end %>
<% else %>
<div class="slide-img" style="background: url('/annc_url?url=http://placehold.it/<%= banner.width %>x<%= banner.height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('/annc_url?url=http://placehold.it/<%= banner.width %>x<%= banner.height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<%
width = banner.width
height = banner.height
width = 200 if width.blank?
height = 80 if height.blank?
%>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<% end %>
</div>

View File

@ -1,10 +1,10 @@
<% content_for :page_specific_css do %>
<style type="text/css">
.slide-img{
width: 100%;
height: 140px;
background-repeat: no-repeat;
}
.slide-img{
width: 100%;
height: 140px;
background-repeat: no-repeat;
}
</style>
<% end %>
<table class="table main-list">
@ -18,43 +18,55 @@
<tbody>
<% user_has_rights = (current_user.is_admin? ? true : (current_user.is_manager?(@module_app) ? true : current_user.is_manager_with_role?(@module_app) ? true : false)) rescue false %>
<% @banners.each do |banner| %>
<tr>
<td class="span5">
<div class="cycle-slideshow ad-banner-images "
data-cycle-slides=".slide-img"
data-cycle-fx="<%= banner.ad_fx %>"
data-cycle-speed="<%= banner.speed %>"
data-cycle-timeout="<%= banner.timeout.to_i*1000 %>"
>
<% if !banner.ad_images.can_display.blank? %>
<% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<div class="slide-img" style=" background: url('<%= image.exchange_item == "1" ? image.file.thumb.url : image.youtube_thumb %>'); background-size: cover; background-position: center;"></div>
<% end %>
<% else %>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= banner.width %>x<%= banner.height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= banner.width %>x<%= banner.height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<% end %>
<tr>
<td class="span5">
<div class="cycle-slideshow ad-banner-images "
data-cycle-slides=".slide-img"
data-cycle-fx="<%= banner.ad_fx %>"
data-cycle-speed="<%= banner.speed %>"
data-cycle-timeout="<%= banner.timeout.to_i*1000 %>"
>
<% if !banner.ad_images.can_display.blank? %>
<% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<% if image.exchange_item == '1' %>
<div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div>
<% elsif image.video_snapshot.present? %>
<div class="slide-img" style=" background: url('<%= image.video_snapshot %>'); background-size: cover; background-position: center;"></div>
<% elsif image.exchange_item == '2' %>
<div class="slide-img" style=" background: url('<%= image.youtube_thumb %>'); background-size: cover; background-position: center;"></div>
<% end %>
<% end %>
<% else %>
<%
width = banner.width
height = banner.height
width = 200 if width.blank?
height = 80 if height.blank?
%>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/888&text=A'); background-size: cover; background-position: center;"></div>
<div class="slide-img" style="background: url('https://via.placeholder.com/<%= width %>x<%= height %>/666&text=B'); background-size: cover; background-position: center;"></div>
<% end %>
</div>
</td>
<td>
<a href="<%= admin_ad_banner_path(banner.id) %>"><%= banner.title rescue "" %> </a>
<div class="quick-edit">
</div>
</td>
<td>
<a href="<%= admin_ad_banner_path(banner.id) %>"><%= banner.title rescue "" %> </a>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if can_edit_or_delete?(banner) %>
<li><a href="<%= admin_ad_banner_path(banner.id) %>"><%= t("ad_banner.add") %></a></li>
<% end %>
<% if can_edit_or_delete?(banner) %>
<li><a href="<%= admin_ad_banner_path(banner.id) %>"><%= t("ad_banner.add") %></a></li>
<% end %>
<% if user_has_rights %>
<li><a href="<%= edit_admin_ad_banner_path(banner.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
<li><a href="<%= admin_ad_banner_path(banner.id, :page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?" ><%= t(:delete_) %></a></li>
<% end %>
</ul>
</div>
</td>
<td>
<%= banner.category.title rescue "" %>
</td>
</tr>
</td>
<td>
<%= banner.category.title rescue "" %>
</td>
</tr>
<% end %>
</tbody>
</table>