adbanner-test/app/views/admin/ad_banners/_index_table.html.erb

83 lines
3.5 KiB
Plaintext

<% content_for :page_specific_css do %>
<style type="text/css">
.slide-img{
width: 100%;
height: 140px;
background-repeat: no-repeat;
}
</style>
<% end %>
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<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| %>
<% 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">
<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 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>
<% end %>
</tbody>
</table>
<div class="bottomnav clearfix" style="left: 81px;">
<% if user_has_rights %>
<div class="action pull-right">
<a class="btn btn-primary" href="<%= new_admin_ad_banner_path %>">
<%= t("ad_banner.new_banner") %>
</a>
</div>
<% end %>
<%= content_tag :div, paginate(@banners), class: "pagination pagination-centered" %>
</div>