migrate bulletin carousels show functions to event_news and fix AAAAAA.png url
This commit is contained in:
parent
6ab35195dd
commit
be4280c4ae
Binary file not shown.
After Width: | Height: | Size: 182 B |
|
@ -672,6 +672,20 @@ class EventNewsModsController < ApplicationController
|
|||
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
||||
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
||||
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
||||
carousel_data = {
|
||||
"event_carousel_images" => event_carousel_images,
|
||||
"resume_btn_title" => resume_btn_title,
|
||||
"pause_btn_title" => pause_btn_title,
|
||||
"prev_btn_title" => prev_btn_title,
|
||||
"next_btn_title" => next_btn_title,
|
||||
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{event_news.carousel_image_width};margin: auto;"),
|
||||
"carousel_count" => event_carousel_images.count}
|
||||
carousel_html = ""
|
||||
if carousel_data["carousel_count"] != 0
|
||||
carousel_image_type = event_news.carousel_image_type
|
||||
ac = ActionController::Base.new()
|
||||
carousel_html = ac.render_to_string(:partial=>'event_news_mods/carousels',:locals=>{:data=>carousel_data,:carousel_image_type=>carousel_image_type})
|
||||
end
|
||||
begin
|
||||
event_time = event_news.event_time_formated_for_frontend
|
||||
rescue => e
|
||||
|
@ -692,7 +706,6 @@ class EventNewsModsController < ApplicationController
|
|||
"event_news_files" => files,
|
||||
"profiles" => profiles,
|
||||
"event_news_links" => links,
|
||||
"event_carousel_images" => event_carousel_images,
|
||||
"data" => {
|
||||
"title-head" => EventNewsCustomTitle.get_trans('title'),
|
||||
"speaker-head" => EventNewsCustomTitle.get_trans('speaker'),
|
||||
|
@ -724,7 +737,8 @@ class EventNewsModsController < ApplicationController
|
|||
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{event_news.carousel_image_width};margin: auto;"),
|
||||
"carousel_count" => event_carousel_images.count,
|
||||
"place_text" => (event_news.place.blank? ? "" : "#{EventNewsCustomTitle.get_trans("place")}: #{event_news.place}"),
|
||||
"place-css" => (event_news.place.blank? ? "display: none;" : "")
|
||||
"place-css" => (event_news.place.blank? ? "display: none;" : ""),
|
||||
"carousel_html" => carousel_html,
|
||||
},
|
||||
"impressionist" => (event_news.is_preview ? nil : event_news),
|
||||
"url_to_edit"=>url_to_edit
|
||||
|
@ -796,13 +810,26 @@ class EventNewsModsController < ApplicationController
|
|||
pause_btn_title = (I18n.locale.to_s =="zh_tw") ? "暫停播放" : "pause"
|
||||
prev_btn_title = (I18n.locale.to_s =="zh_tw") ? "上一張" : "prev"
|
||||
next_btn_title = (I18n.locale.to_s =="zh_tw") ? "下一張" : "next"
|
||||
carousel_data = {
|
||||
"event_carousel_images" => event_carousel_images,
|
||||
"resume_btn_title" => resume_btn_title,
|
||||
"pause_btn_title" => pause_btn_title,
|
||||
"prev_btn_title" => prev_btn_title,
|
||||
"next_btn_title" => next_btn_title,
|
||||
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{EventNewsSetting.last.carousel_image_width};margin: auto;"),
|
||||
"carousel_count" => event_carousel_images.count}
|
||||
carousel_html = ""
|
||||
if carousel_data["carousel_count"] != 0
|
||||
carousel_image_type = event_news["carousel_image_type"].to_i
|
||||
ac = ActionController::Base.new()
|
||||
carousel_html = ac.render_to_string(:partial=>'event_news_mods/carousels',:locals=>{:data=>carousel_data,:carousel_image_type=>carousel_image_type})
|
||||
end
|
||||
speaker = event_news["speaker_translations"][locale]
|
||||
host = event_news["host_translations"][locale]
|
||||
{
|
||||
"tags" => tags,
|
||||
"event_news_files" => files,
|
||||
"event_news_links" => links,
|
||||
"event_carousel_images" => event_carousel_images,
|
||||
"data" => {
|
||||
"title" => event_news["title_translations"][locale],
|
||||
"subtitle_ann" => subtitle_ann,
|
||||
|
@ -834,7 +861,8 @@ class EventNewsModsController < ApplicationController
|
|||
"carousel_display_style" => (event_carousel_images.count == 0 ? 'display: none' : "width: #{EventNewsSetting.last.carousel_image_width};margin: auto;"),
|
||||
"carousel_count" => event_carousel_images.count,
|
||||
"place_text" => (event_news["place"].blank? ? "" : "#{I18n.t("event_news.place")}: #{event_news["place"]}"),
|
||||
"place-css" => (event_news["place"].blank? ? "display: none;" : "")
|
||||
"place-css" => (event_news["place"].blank? ? "display: none;" : ""),
|
||||
"carousel_html" => carousel_html
|
||||
},
|
||||
"impressionist" => nil,
|
||||
"url_to_edit" => url_to_edit
|
||||
|
|
|
@ -500,58 +500,6 @@ module EventNewsHelper
|
|||
end
|
||||
layout_types
|
||||
end
|
||||
def render_ad_banner(event_carousel_images,data)
|
||||
("<div class=\"carousel_images\">
|
||||
<div class=\"w-ba-banner ba-banner-widget-1\">
|
||||
<div class=\"w-ba-banner__wrap cycle-slideshow\"
|
||||
data-list=\"event_carousel_images\"
|
||||
data-level=\"0\"
|
||||
data-cycle-slides=\".event_carousel_slide\"
|
||||
data-cycle-log=\"false\"
|
||||
data-cycle-auto-height=\"0\"
|
||||
data-cycle-speed=\"300\"
|
||||
data-cycle-timeout=\"5000\"
|
||||
data-cycle-fx=\"fade\"
|
||||
data-pager-active-class=\"active-slide\"
|
||||
data-cycle-swipe=true
|
||||
data-cycle-swipe-fx=\"scrollHorz\"
|
||||
>" +
|
||||
event_carousel_images.collect do |e|
|
||||
"<div class=\"w-ba-banner__slide event_carousel_slide\"
|
||||
data-cycle-title=\"#{e['description_text']}\"
|
||||
>
|
||||
<img class=\"w-ba-banner__image banner-responsive\" src=\"#{e['src']}\" alt=\"#{e['description_text']}\">
|
||||
<div class=\"ad-overlay w-ad-banner__overlay event_carousel__overlay\">
|
||||
<p><strong class=\"carousel__description\">#{e['description']}</strong></p>
|
||||
</div>
|
||||
<div class=\"transitionfade\"></div>
|
||||
</div>"
|
||||
end.join+
|
||||
"</div>
|
||||
<ul class=\"controlplay\"><a class=\"resume-slide\" title = \"#{data['resume_btn_title']}\"><i></i></a><a class=\"pause-slide\" title = \"#{data['pause_btn_title']}\"><i></i></a></ul>
|
||||
<ul class=\"button-mid\">
|
||||
<i class=\"fa fa-angle-left prev-button\" aria-hidden=\"true\" title = \"#{data['prev_btn_title']}\"></i>
|
||||
<i class=\"fa fa-angle-right next-button\" aria-hidden=\"true\" title = \"#{data['next_btn_title']}\"></i>
|
||||
</ul>
|
||||
</div>
|
||||
<div style=\"position: relative;\">
|
||||
<h4><span class=\"active_slide\">1</span>/#{data['carousel_count']}</h4>
|
||||
<ul class=\"carousel_images_slide w-annc__list row list-unstyled\" data-level=\"0\" data-list=\"event_carousel_images\">" +
|
||||
event_carousel_images.collect do |e|
|
||||
"<li class=\"carousel_img_item col-sm-3\">
|
||||
<div class=\"carousel_img-wrap\">
|
||||
<img class=\"carousel_img\" src=\"#{e['src']}\" alt=\"#{e['description_text']}\">
|
||||
</div>
|
||||
</li>"
|
||||
end.join +
|
||||
"</ul>
|
||||
<ul class=\"button-mid\">
|
||||
<i class=\"fa fa-angle-left prev-button prev_img\" aria-hidden=\"true\" title = \"#{data['prev_btn_title']}\"></i>
|
||||
<i class=\"fa fa-angle-right next-button next_img\" aria-hidden=\"true\" title = \"#{data['next_btn_title']}\"></i>
|
||||
</ul>
|
||||
</div>
|
||||
</div>").html_safe
|
||||
end
|
||||
|
||||
def complementaryColor(my_hex)
|
||||
if my_hex[0] == '#'
|
||||
|
|
|
@ -52,6 +52,7 @@ class EventNews
|
|||
field :hour_clock_24, type: Boolean, default: true
|
||||
field :is_edit, type: Boolean, default: false #use to check whether the preview record changed
|
||||
field :copy_id
|
||||
field :custom_carousel_image_type, :type => Integer, :default => 0 # 0: default, 1: carousel, 2: album
|
||||
field :custom_carousel_image_width, type: String, default: ""
|
||||
field :image_display_class, type: String, default: "full-size-img" #3 choices: full-size-img , pull-left , pull-right
|
||||
field :add_to_calendar,type: Boolean,default: false
|
||||
|
@ -399,8 +400,11 @@ class EventNews
|
|||
def hidden_text
|
||||
I18n.t("announcement.status.hidden")
|
||||
end
|
||||
def carousel_image_type
|
||||
(self.custom_carousel_image_type == 0 ? EventNewsSetting.last.carousel_image_type : self.custom_carousel_image_type - 1) rescue 0
|
||||
end
|
||||
def carousel_image_width
|
||||
(self.custom_carousel_image_width.blank? ? AnnouncementSetting.last.carousel_image_width : self.custom_carousel_image_width)
|
||||
(self.custom_carousel_image_width.blank? ? EventNewsSetting.last.carousel_image_width : self.custom_carousel_image_width)
|
||||
end
|
||||
|
||||
def self.agenda_events(agenda_start, agenda_end,read_more_url)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class EventNewsSetting
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
field :carousel_image_type, :type => Integer, :default => 0 # 0: carousel, 1: album
|
||||
field :carousel_image_width, type: String, :default => "75%"
|
||||
field :top_limit, type: Integer, :default => 0
|
||||
field :pro_enabled, type: Boolean, :default => false
|
||||
|
|
|
@ -287,7 +287,7 @@
|
|||
<% if @event_news.image.file %>
|
||||
<%= image_tag @event_news.image %>
|
||||
<% else %>
|
||||
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
|
||||
<img src="/assets/event_news/AAAAAA" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
|
@ -320,6 +320,13 @@
|
|||
|
||||
<!-- Images Module -->
|
||||
<div class="tab-pane fade" id="carousel_image_upload">
|
||||
<div class="control-group">
|
||||
<%= f.label :custom_carousel_image_type, t("event_news.default_carousel_image_type"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<% carousel_image_types = ["default","carousel","album"] %>
|
||||
<%= f.select :custom_carousel_image_type, options_for_select(carousel_image_types.map.with_index{|type,i| [t("event_news.carousel_image_types.#{type}"),i]}.to_h,:selected => f.object.custom_carousel_image_type) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted" for="carousel_image_width"><%= t("event_news.carousel_image_width") %></label>
|
||||
<div class="controls">
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<% if form_image.file.file %>
|
||||
<%= image_tag form_image.file %>
|
||||
<% else %>
|
||||
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
|
||||
<img src="/assets/event_news/AAAAAA" />
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||
|
|
|
@ -130,6 +130,13 @@
|
|||
<div id="notification"><%= t("event_news.click_on_submit") %></div>
|
||||
<%= form_for @setting, url: (@setting.new_record? ? admin_event_news_createsettings_path : admin_event_news_updatesettings_path), html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<div class="input-area">
|
||||
<div class="control-group">
|
||||
<%= f.label :carousel_image_type, t("event_news.default_carousel_image_type"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<% carousel_image_types = ["carousel","album"] %>
|
||||
<%= f.select :carousel_image_type, options_for_select(carousel_image_types.map.with_index{|type,i| [t("event_news.carousel_image_types.#{type}"),i]}.to_h,:selected => f.object.carousel_image_type) %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<%= f.label :carousel_image_width, t("event_news.default_carousel_image_width"), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<%= render(:partial=>"event_news_mods/carousels#{carousel_image_type}", :locals=>{:data=>data}) %>
|
|
@ -0,0 +1,283 @@
|
|||
<style type="text/css">
|
||||
strong.carousel__description {
|
||||
color: white;
|
||||
}
|
||||
.carousel_images{
|
||||
<%=data["carousel_display_style"]%>
|
||||
}
|
||||
@media (max-width: 767px){
|
||||
.carousel_images{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<div class="carousel_images">
|
||||
<div class="w-ba-banner ba-banner-widget-1">
|
||||
<div class="w-ba-banner__wrap cycle-slideshow"
|
||||
data-cycle-slides=".event_carousel_slide"
|
||||
data-cycle-log="false"
|
||||
data-cycle-auto-height="0"
|
||||
data-cycle-speed="300"
|
||||
data-cycle-timeout="5000"
|
||||
data-cycle-fx="fade"
|
||||
data-pager-active-class="active-slide"
|
||||
data-cycle-swipe=true
|
||||
data-cycle-swipe-fx="scrollHorz"
|
||||
>
|
||||
<%data["event_carousel_images"].each do |event_carousel_image|%>
|
||||
<div class="w-ba-banner__slide event_carousel_slide"
|
||||
data-cycle-title="<%=event_carousel_image["description_text"]%>"
|
||||
>
|
||||
<img class="w-ba-banner__image banner-responsive" src="<%=event_carousel_image["src"]%>" alt="<%=event_carousel_image["description_text"]%>">
|
||||
<div class="ad-overlay w-ad-banner__overlay event_carousel__overlay">
|
||||
<p><strong class="carousel__description"><%=event_carousel_image["description"]%></strong></p>
|
||||
</div>
|
||||
<div class="transitionfade"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<ul class="controlplay"><a class="resume-slide" title = "<%=data["resume_btn_title"]%>"><i></i></a><a class="pause-slide" title = "<%=data["pause_btn_title"]%>"><i></i></a></ul>
|
||||
<ul class="button-mid">
|
||||
<i class="fa fa-angle-left prev-button" aria-hidden="true" title = "<%=data["prev_btn_title"]%>"></i>
|
||||
<i class="fa fa-angle-right next-button" aria-hidden="true" title = "<%=data["next_btn_title"]%>"></i>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="position: relative;">
|
||||
<h4><span class="active_slide">1</span>/<%=data["carousel_count"]%></h4>
|
||||
<ul class="carousel_images_slide w-annc__list row list-unstyled">
|
||||
<%data["event_carousel_images"].each do |event_carousel_image|%>
|
||||
<li class="carousel_img_item col-sm-3">
|
||||
<div class="carousel_img-wrap">
|
||||
<img class="carousel_img" src="<%=event_carousel_image["src"]%>" alt="<%=event_carousel_image["description_text"]%>">
|
||||
</div>
|
||||
</li>
|
||||
<%end%>
|
||||
</ul>
|
||||
<ul class="button-mid">
|
||||
<i class="fa fa-angle-left prev-button prev_img" aria-hidden="true" title="<%=data["prev_btn_title"]%>"></i>
|
||||
<i class="fa fa-angle-right next-button next_img" aria-hidden="true" title="<%=data["next_btn_title"]%>"></i>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<style type="text/css">
|
||||
.carousel_img_item{
|
||||
display: none;
|
||||
float: left;
|
||||
}
|
||||
.controlplay {
|
||||
position: absolute;
|
||||
right: 1em;
|
||||
top: 3%;
|
||||
z-index: 200;
|
||||
}
|
||||
.controlplay a {
|
||||
display: inline-block;
|
||||
margin-right: 0.25em;
|
||||
cursor: pointer;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid rgba(255,255,255,0.5);
|
||||
background: rgba(0,0,0,0.2);
|
||||
}
|
||||
.controlplay a i {
|
||||
font-family: FontAwesome;
|
||||
position: relative;
|
||||
font-size: 1rem;
|
||||
line-height: 1;
|
||||
color: #FFF;
|
||||
vertical-align: middle;
|
||||
font-style: unset;
|
||||
}
|
||||
.controlplay .resume-slide i::before {
|
||||
content: "\f04b";
|
||||
}
|
||||
.controlplay .pause-slide i::before {
|
||||
content: "\f04c";
|
||||
}
|
||||
ul.button-mid .prev-button {
|
||||
transition: 0.4s;
|
||||
position: relative;
|
||||
float: left;
|
||||
left: 0.5rem;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
font-size: 2.2rem;
|
||||
color: #ffffff;
|
||||
background: rgba(0,0,0,0.2);
|
||||
text-align: center;
|
||||
line-height: 2.5rem;
|
||||
top: 50%;
|
||||
position: absolute;
|
||||
transform: translateY(-50%);
|
||||
z-index: 999;
|
||||
}
|
||||
ul.button-mid .next-button {
|
||||
float: right;
|
||||
transition: 0.4s;
|
||||
position: relative;
|
||||
right: 0.5rem;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
font-size: 2.2rem;
|
||||
color: #fff;
|
||||
background: rgba(0,0,0,0.2);
|
||||
text-align: center;
|
||||
line-height: 2.5rem;
|
||||
top: 50%;
|
||||
position: absolute;
|
||||
transform: translateY(-50%);
|
||||
z-index: 999;
|
||||
}
|
||||
.carousel_images_slide{
|
||||
padding: 3em;
|
||||
}
|
||||
.carousel_img_item img{
|
||||
cursor: pointer;
|
||||
}
|
||||
@media (max-width: 479px){
|
||||
.carousel_img_item:nth-child(-n+1){
|
||||
display: block;
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
.carousel_img_item{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 480px){
|
||||
.carousel_img_item:nth-child(-n+2){
|
||||
display: block;
|
||||
width: 50%;
|
||||
float: left;
|
||||
}
|
||||
.carousel_img_item{
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 768px){
|
||||
.carousel_img_item:nth-child(-n+3){
|
||||
display: block;
|
||||
width: 33%;
|
||||
float: left;
|
||||
}
|
||||
.carousel_img_item{
|
||||
width: 33%;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1280px){
|
||||
.carousel_img_item:nth-child(-n+4){
|
||||
display: block;
|
||||
width: 25%;
|
||||
float: left;
|
||||
}
|
||||
.carousel_img_item{
|
||||
width: 25%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
(function($) {
|
||||
$('.pause-slide').click(function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
|
||||
});
|
||||
$('.resume-slide').click(function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
|
||||
});
|
||||
$('.next-button').off('click').on('click',function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
|
||||
})
|
||||
$('.prev-button').off('click').on('click',function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
|
||||
})
|
||||
window.active_slide = 0;
|
||||
$('.prev_img').off('click').on('click',function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
if(carousel_images_slide.find(">li").length > content_size && active_slide > 0){
|
||||
active_slide -= content_size;
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
$('.next_img').off('click').on('click',function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
var li_length = carousel_images_slide.find(">li").length;
|
||||
if(li_length > content_size){
|
||||
active_slide += content_size;
|
||||
active_slide = Math.min(active_slide,li_length - 1);
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
$(".carousel_img_item img").off("click").on("click",function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle($(this).index(".carousel_img_item img"));
|
||||
})
|
||||
$(document).ready(function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle('pause');
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
$(".carousel_images .cycle-slideshow").cycle('resume');
|
||||
$('.cycle-slideshow').on('cycle-after',function(){
|
||||
$(".active_slide").text($('.event_carousel_slide.cycle-slide-active').index());
|
||||
})
|
||||
})
|
||||
$(window).on("load",function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle('pause');
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
$(".carousel_images .cycle-slideshow").cycle('resume');
|
||||
})
|
||||
$(window).resize(function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
var active_count = carousel_images_slide.find(">li").length - active_slide;
|
||||
if(active_count < content_size){
|
||||
active_slide -= (content_size - active_count);
|
||||
}
|
||||
active_slide = Math.max(active_slide,0);
|
||||
console.log(content_size)
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
$(".event_carousel_slide").css("height",'');
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
})
|
||||
}(jQuery));
|
||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||
<style>
|
||||
.carousel_image p{
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<div class="carousel_images">
|
||||
<%data["event_carousel_images"].each do |event_carousel_image|%>
|
||||
<div class="carousel_image col-sm-6">
|
||||
<a href="<%=event_carousel_image["src"]%>" title="<%=event_carousel_image["description_text"]%>"><img src="<%=event_carousel_image["src"]%>" alt="<%=event_carousel_image["description_text"]%>"></a>
|
||||
<p><strong class="carousel__description"><%=event_carousel_image["description"]%></strong></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
|
@ -2,7 +2,7 @@
|
|||
require 'event_news_helper'
|
||||
data = action_data
|
||||
params = OrbitHelper.params
|
||||
page = Page.where(url:params['url']).first
|
||||
page = @page || Page.where(url:params['url']).first
|
||||
@ad_banner_location = 2
|
||||
@show_back_and_next_flag = 0
|
||||
if Page.instance_methods.include?(:select_option_items) && ModuleApp.instance_methods.include?(:show_option_items)
|
||||
|
@ -58,13 +58,7 @@
|
|||
content = ''
|
||||
end
|
||||
end
|
||||
ad_banner_content = render_ad_banner(data['event_carousel_images'],data['data'])
|
||||
%>
|
||||
<style type="text/css">
|
||||
.carousel_images{
|
||||
<%= data['data']['carousel_display_style'] %>
|
||||
}
|
||||
</style>
|
||||
<%= stylesheet_link_tag 'event_news_front.css' %>
|
||||
<% if @show_back_and_next_flag!=0 %>
|
||||
<style type="text/css">
|
||||
|
@ -94,13 +88,13 @@
|
|||
<% end %>
|
||||
|
||||
<% if @ad_banner_location==1 %>
|
||||
<%= ad_banner_content %>
|
||||
<%= data["data"]["carousel_html"] %>
|
||||
<% end %>
|
||||
|
||||
<%= render_view %>
|
||||
|
||||
<% if @ad_banner_location==2 %>
|
||||
<%= ad_banner_content %>
|
||||
<%= data["data"]["carousel_html"] %>
|
||||
<% end %>
|
||||
|
||||
<% if @show_back_and_next_flag==2 %>
|
||||
|
@ -126,113 +120,5 @@
|
|||
// Links
|
||||
hideEmptyEl($('.s-annc__link-title'), $('.s-annc__related-link'));
|
||||
$("img[src='']").remove();
|
||||
$('.pause-slide').click(function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('pause');
|
||||
$(this).addClass('active');
|
||||
$(this).parents('.carousel_images').find('.resume-slide').removeClass('active');
|
||||
});
|
||||
$('.resume-slide').click(function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle('resume');
|
||||
$(this).addClass('active');
|
||||
$(this).parents('.carousel_images').find('.pause-slide').removeClass('active');
|
||||
});
|
||||
$('.next-button').off('click').on('click',function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("next");
|
||||
})
|
||||
$('.prev-button').off('click').on('click',function(){
|
||||
$(this).parent("ul").parent('.w-ba-banner').find(".cycle-slideshow").cycle("prev");
|
||||
})
|
||||
window.active_slide = 0;
|
||||
$('.prev_img').off('click').on('click',function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
if(carousel_images_slide.find(">li").length > content_size && active_slide > 0){
|
||||
active_slide -= content_size;
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
$('.next_img').off('click').on('click',function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
var li_length = carousel_images_slide.find(">li").length;
|
||||
if(li_length > content_size){
|
||||
active_slide += content_size;
|
||||
active_slide = Math.min(active_slide,li_length - 1);
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
$(".carousel_img_item img").off("click").on("click",function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle($(this).index(".carousel_img_item img"));
|
||||
})
|
||||
$(document).ready(function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle('pause');
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
$(".carousel_images .cycle-slideshow").cycle('resume');
|
||||
$('.carousel_images .resume-slide').addClass('active');
|
||||
$('.cycle-slideshow').on('cycle-after',function(){
|
||||
$(".active_slide").text($('.event_carousel_slide.cycle-slide-active').index());
|
||||
})
|
||||
})
|
||||
$(window).on("load",function(){
|
||||
$(".carousel_images .cycle-slideshow").cycle('pause');
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
$(".carousel_images .cycle-slideshow").cycle('resume');
|
||||
})
|
||||
$(window).resize(function(){
|
||||
var carousel_images_slide = $('.carousel_images_slide');
|
||||
var carousel_images_slide_first_child = carousel_images_slide.find(">li").eq(active_slide);
|
||||
if(carousel_images_slide_first_child.length > 0){
|
||||
var content_size = Math.floor((carousel_images_slide.outerWidth() - Number.parseInt(carousel_images_slide.css('font-size')) * 3) / carousel_images_slide_first_child.outerWidth(true));
|
||||
content_size = Math.max(content_size,1);
|
||||
carousel_images_slide.find(">li").css("display","none");
|
||||
var active_count = carousel_images_slide.find(">li").length - active_slide;
|
||||
if(active_count < content_size){
|
||||
active_slide -= (content_size - active_count);
|
||||
}
|
||||
active_slide = Math.max(active_slide,0);
|
||||
console.log(content_size)
|
||||
for(var i = active_slide; i < active_slide + content_size;i++){
|
||||
carousel_images_slide.find(">li").eq(i).css("display","block");
|
||||
}
|
||||
}
|
||||
var carousel_image_block_width = $('.carousel_images').width();
|
||||
$(".event_carousel_slide").css("height",'');
|
||||
var heights = $(".event_carousel_slide").map(function(i,v){
|
||||
return $(v).height() * carousel_image_block_width / $(v).width();
|
||||
})
|
||||
var max_height = Math.max.apply(null,heights);
|
||||
$(".event_carousel_slide").each(function(i,v){
|
||||
$(v).height(max_height);
|
||||
})
|
||||
})
|
||||
}(jQuery));
|
||||
</script>
|
|
@ -4,6 +4,12 @@ en:
|
|||
event_news_mod:
|
||||
event_news_mod: Event News
|
||||
event_news:
|
||||
carousel_image_types:
|
||||
default: Default
|
||||
carousel: Carousel
|
||||
album: Album
|
||||
default_carousel_image_type: Default carousel image type
|
||||
carousel_image_type: Carousel image type
|
||||
read_from_cache: "Read from cache!"
|
||||
manually_sort: Manually Sort
|
||||
enable_manually_sort: Enable Manually Sort
|
||||
|
|
|
@ -4,6 +4,12 @@ zh_tw:
|
|||
event_news_mod:
|
||||
event_news_mod: 活動公告
|
||||
event_news:
|
||||
carousel_image_types:
|
||||
default: 預設
|
||||
carousel: 輪播
|
||||
album: 相本排版
|
||||
default_carousel_image_type: 預設輪播樣式
|
||||
carousel_image_type: 預設輪播樣式
|
||||
read_from_cache: "從暫存中讀取!"
|
||||
manually_sort: 手動排序
|
||||
enable_manually_sort: 開啟手動排序
|
||||
|
|
Loading…
Reference in New Issue