new interface with order
This commit is contained in:
parent
64497cbd37
commit
a3f14ed9a0
|
@ -8,9 +8,6 @@ function slideshow (element, bannerEffect, bannerTime, bannerSpeed) {
|
|||
});
|
||||
};
|
||||
function setSlideshow(element, data) {
|
||||
$("#pageslide .ad_banner_ad_fx").children('option:selected').each(function(index, el) {
|
||||
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
|
||||
});
|
||||
slideshow(element, data['fx'], 2000, 1000);
|
||||
}
|
||||
|
||||
|
@ -63,7 +60,7 @@ $(function() {
|
|||
bannerSpeed = null,
|
||||
bannerW = null,
|
||||
bannerH = null,
|
||||
$preview = $('#pageslide .preview');
|
||||
$preview = $('.main-forms .preview');
|
||||
|
||||
$(".ad_banner_ad_fx").change(function () {
|
||||
var suckIE = false;
|
||||
|
@ -72,9 +69,6 @@ $(function() {
|
|||
|
||||
bannerTime = parseInt(bannerTime) || 300;
|
||||
bannerSpeed = parseInt(bannerSpeed) || 300;
|
||||
$(this).children('option:selected').each(function(index, el) {
|
||||
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
|
||||
});
|
||||
slideshow($preview, $(this).val(), 2000, 1000);
|
||||
});
|
||||
preview();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class AdBannersController < ApplicationController
|
||||
def widget
|
||||
adbanner = Banner.find(OrbitHelper.widget_custom_value)
|
||||
adbanner = Banner.find(OrbitHelper.widget_custom_value)
|
||||
widget = OrbitHelper.get_current_widget
|
||||
if widget.widget_type == "ad_banner_widget2_video"
|
||||
return video_widget(adbanner)
|
||||
|
@ -13,7 +13,7 @@ class AdBannersController < ApplicationController
|
|||
|
||||
def image_widget(adbanner)
|
||||
images = []
|
||||
adbanner.ad_images.can_display.desc(:created_at).each_with_index do |b,i|
|
||||
adbanner.ad_images.can_display.asc(:sort_number).each_with_index do |b,i|
|
||||
if b.language_enabled.include?(I18n.locale.to_s)
|
||||
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
|
||||
klass = i == 0 ? "active" : ""
|
||||
|
@ -52,7 +52,7 @@ class AdBannersController < ApplicationController
|
|||
|
||||
def video_widget(adbanner)
|
||||
images = []
|
||||
adbanner.ad_images.can_display.each_with_index do |ad_b,i|
|
||||
adbanner.ad_images.can_display.asc(:sort_number).each_with_index do |ad_b,i|
|
||||
if ad_b.language_enabled.include?(I18n.locale.to_s)
|
||||
image_link = OrbitHelper.is_mobile_view ? ad_b.file.mobile.url : ad_b.file.url
|
||||
alt_text = (ad_b.title.nil? || ad_b.title == "" ? "ad-banner image" : ad_b.title)
|
||||
|
|
|
@ -2,56 +2,78 @@ class Admin::AdBannersController < OrbitAdminController
|
|||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
|
||||
def index
|
||||
@table_fields = ["ad_banner.banner", :title, :category]
|
||||
@categories = @module_app.categories.enabled
|
||||
@filter_fields = filter_fields(@categories, [])
|
||||
@filter_fields.delete(:status)
|
||||
@filter_fields.delete(:tags)
|
||||
@banners = Banner.all
|
||||
@categories = @module_app.categories.enabled.collect{|c|[c.title, c.id]}
|
||||
.order_by(sort)
|
||||
.with_categories(filters("category"))
|
||||
|
||||
@banners = search_data(@banners,[:title]).page(params[:page]).per(6)
|
||||
if request.xhr?
|
||||
render :partial => "index_table"
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@ad_banners = Banner.all
|
||||
@active = Banner.find(params[:id])
|
||||
render :action => 'index'
|
||||
@banner = Banner.find(params[:id])
|
||||
if params[:show] == "expired"
|
||||
@images = @banner.ad_images.is_expired.asc(:sort_number).page(params[:page]).per(10)
|
||||
else
|
||||
@images = @banner.ad_images.not_expired.asc(:sort_number).page(params[:page]).per(10)
|
||||
end
|
||||
@table_fields = [:banner, :title, "ad_banner.duration", :link]
|
||||
end
|
||||
|
||||
def new
|
||||
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
|
||||
@ad_banner = Banner.new
|
||||
render layout: false
|
||||
render_401 if !user_has_rights
|
||||
end
|
||||
|
||||
def create
|
||||
@ad_banner = Banner.new(banner_params)
|
||||
if @ad_banner.save
|
||||
redirect_to admin_ad_banners_url
|
||||
else
|
||||
@ad_banner = Banner.new(params[:ad_banner])
|
||||
render :new
|
||||
end
|
||||
ad_banner = Banner.new(banner_params)
|
||||
ad_banner.save
|
||||
redirect_to admin_ad_banners_url
|
||||
end
|
||||
|
||||
def edit
|
||||
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
|
||||
@ad_banner = Banner.find(params[:id])
|
||||
render layout: false
|
||||
render_401 if !user_has_rights
|
||||
end
|
||||
|
||||
def update
|
||||
@ad_banner = Banner.find(params[:id])
|
||||
if @ad_banner.update_attributes(banner_params)
|
||||
redirect_to admin_ad_banners_url, :status => 303
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
ad_banner = Banner.find(params[:id])
|
||||
ad_banner.update_attributes(banner_params)
|
||||
redirect_to params[:referer_url]
|
||||
end
|
||||
|
||||
def destroy
|
||||
@ad_banner = Banner.find(params[:id])
|
||||
@ad_banner.destroy
|
||||
redirect_to admin_ad_banners_url
|
||||
ad_banner = Banner.find(params[:id])
|
||||
ad_banner.destroy
|
||||
redirect_to admin_ad_banners_path(:page => params[:page])
|
||||
end
|
||||
|
||||
def save_image_order
|
||||
ids = params[:ids]
|
||||
ids.each_with_index do |id,index|
|
||||
image = AdImage.find(id) rescue nil
|
||||
if !image.nil?
|
||||
image.sort_number = index
|
||||
image.save
|
||||
end
|
||||
end
|
||||
render :json => {"success" => true}.to_json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def banner_params
|
||||
params.require(:ad_banner).permit!
|
||||
params.require(:banner).permit!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,42 +21,34 @@ class Admin::AdImagesController < Admin::AdBannersController
|
|||
end
|
||||
|
||||
def update
|
||||
@ad_image = AdImage.find(params[:id])
|
||||
if @ad_image.update_attributes(ad_image_params)
|
||||
redirect_to params['referer_url']
|
||||
else
|
||||
@ad_banners = Banner.all
|
||||
@tags = @module_app.tags || []
|
||||
render action: :edit
|
||||
end
|
||||
ad_image = AdImage.find(params[:id])
|
||||
ad_image.update_attributes(ad_image_params)
|
||||
redirect_to params[:referer_url]
|
||||
end
|
||||
|
||||
def new
|
||||
@ad_image = AdImage.new
|
||||
@ad_banner = Banner.find(params[:banner_id])
|
||||
@item = [[t('image'),"1"],[t('video'),"2"]]
|
||||
@ad_banner = Banner.find(params[:banner])
|
||||
@tags = @module_app.tags || []
|
||||
|
||||
@ad_image.postdate = Date.today
|
||||
if can_edit_or_delete?(@ad_banner)
|
||||
@tags = @module_app.tags || []
|
||||
@ad_image.postdate = Date.today
|
||||
else
|
||||
render_401
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@ad_image = AdImage.new(ad_image_params)
|
||||
if @ad_image.save
|
||||
redirect_to params['referer_url']
|
||||
else
|
||||
@ad_banners = Banner.all
|
||||
@tags = @module_app.tags || []
|
||||
@ad_image = AdImage.new(ad_image_params)
|
||||
render action: :new
|
||||
end
|
||||
@ad_image.save
|
||||
redirect_to params[:referer_url]
|
||||
end
|
||||
|
||||
def destroy
|
||||
@ad_image = AdImage.find params[:id]
|
||||
if @ad_image.destroy
|
||||
redirect_to admin_ad_banners_url
|
||||
end
|
||||
ad_image = AdImage.find params[:id]
|
||||
banner = ad_image.banner
|
||||
ad_image.destroy
|
||||
redirect_to admin_ad_banner_path(banner.id, :page => params[:page])
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -14,6 +14,7 @@ class AdImage
|
|||
field :postdate , :type => DateTime, :default => Time.now
|
||||
field :deadline , :type => DateTime
|
||||
field :youtube , :type => String
|
||||
field :sort_number, :type => Integer
|
||||
field :language_enabled, :type => Array, :default => ["en","zh_tw"]
|
||||
field :exchange_item, :default => "1"
|
||||
LINK_OPEN_TYPES = ["local", "new_window"]
|
||||
|
@ -26,11 +27,35 @@ class AdImage
|
|||
# validates :title, presence: true
|
||||
|
||||
scope :can_display, ->{self.and(AdImage.or({:postdate.lte=>Time.now},{:postdate=>nil}).selector,AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)}
|
||||
scope :is_expired, ->{self.and(AdImage.or({:deadline.lte=>Time.now}).selector)}
|
||||
scope :not_expired, ->{self.and(AdImage.or({:deadline.gte=>Time.now},{:deadline=>nil}).selector)}
|
||||
|
||||
def expired?
|
||||
self.deadline<Time.now rescue false
|
||||
end
|
||||
|
||||
def embed_url
|
||||
uri = URI.parse(self.youtube) rescue nil
|
||||
if !uri.nil?
|
||||
params = CGI.parse(uri.query)
|
||||
v = params['v'].first
|
||||
return "http://www.youtube.com/embed/#{v}"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
def youtube_thumb
|
||||
uri = URI.parse(self.youtube) rescue nil
|
||||
if !uri.nil?
|
||||
params = CGI.parse(uri.query)
|
||||
v = params['v'].first
|
||||
return "http://img.youtube.com/vi/#{v}/0.jpg"
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def add_http
|
||||
|
|
|
@ -6,18 +6,18 @@ class Banner
|
|||
|
||||
field :ad_fx, type: String
|
||||
field :height, type: Integer
|
||||
field :speed, type: Integer
|
||||
field :speed, type: Integer, default: 500
|
||||
field :title, type: String
|
||||
field :timeout, type: Integer
|
||||
field :timeout, type: Integer, default: 5
|
||||
field :width, type: Integer
|
||||
field :base_image, type: Integer, default: 1
|
||||
|
||||
has_many :ad_images , dependent: :delete
|
||||
|
||||
validates_uniqueness_of :title
|
||||
validates :title, :length => { :minimum => 2 }
|
||||
validates :height, :width, :presence => true
|
||||
|
||||
FX_TYPES = %w(fade fadeout flipHorz flipVert scrollHorz scrollVert tileSlide tileBlind)
|
||||
|
||||
FX_TYPES = %w(fade scrollHorz scrollVert tileSlide tileBlind)
|
||||
|
||||
def size
|
||||
"#{self.width} x #{self.height}"
|
||||
|
@ -32,6 +32,6 @@ class Banner
|
|||
end
|
||||
|
||||
def data_attribute_hash
|
||||
{'width'=> self.width,'height'=> self.height,'ad_fx'=> self.ad_fx,'name'=>self.title,'timeout'=>self.timeout,'speed'=>self.speed}.to_json
|
||||
{'width'=> self.width,'height'=> self.height,'ad_fx'=> self.ad_fx,'name'=>self.title,'timeout'=>self.timeout,'speed'=>self.speed, 'base_image' => self.base_image}.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,97 @@
|
|||
<%#= flash_messages %>
|
||||
<%#= f.error_messages %>
|
||||
<% content_for :page_specific_css do %>
|
||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "validator" %>
|
||||
<%= javascript_include_tag "cycle2" %>
|
||||
<%= javascript_include_tag "ad_banner/banner_preview" %>
|
||||
<% end %>
|
||||
|
||||
<%= f.label :title, t('ad_banner.banner_name') %>
|
||||
<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name'), id: 'name' %>
|
||||
<span class="help-block"><%= t('ad_banner.name_only_english') %></span>
|
||||
<style type="text/css">
|
||||
.preview{
|
||||
margin-top: 15px;
|
||||
}
|
||||
</style>
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
<div class="nav-name"><strong><%= t(:module) %></strong></div>
|
||||
<ul class="nav nav-pills module-nav">
|
||||
<li class="active"><a href="#basic" data-toggle="tab"><%= t(:basic) %></a></li>
|
||||
</ul>
|
||||
<!-- Module -->
|
||||
<div class="tab-content module-area">
|
||||
|
||||
<%= f.label :size, t('ad_banner.size') %>
|
||||
<span class="banner_set">W:</span>
|
||||
<%= f.number_field :width, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %>
|
||||
<span class="banner_set">H:</span>
|
||||
<%= f.number_field :height, in: 10..1000, step: 10, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %>
|
||||
|
||||
<%= f.label :category_id, t('ad_banner.categories') %>
|
||||
<%= f.select :category_id, @categories, {} %>
|
||||
<!-- Basic Module -->
|
||||
<div class="tab-pane fade in active" id="basic">
|
||||
<!-- Title-->
|
||||
<div class="control-group">
|
||||
<%= f.label :title, t('ad_banner.banner_name'), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name') %>
|
||||
<span class="help-block"><%= t('ad_banner.name_only_english') %></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- timeout -->
|
||||
<div class="control-group">
|
||||
<%= f.label :timeout, t('ad_banner.transition_interval'), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.number_field :timeout, in: 0..60, step: 1, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %>
|
||||
<span class="help-block"><%= t('ad_banner.number_seconds') %></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- transition speed -->
|
||||
<div class="control-group">
|
||||
<%= f.label :speed, t('ad_banner.transition_speed'), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.number_field :speed, in: 0..1000, step: 100, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %>
|
||||
<span class="help-block"><%= t('ad_banner.number_milliseconds') %></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- size -->
|
||||
<div class="control-group">
|
||||
<%= f.label :size, t('ad_banner.size'), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.number_field :base_image, in: 1..(@ad_banner.new_record? ? 1 : (@ad_banner.ad_images.count == 0 ? 1 : @ad_banner.ad_images.count)), class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %>
|
||||
<span class="help-block">Base Image</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Category -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:category) %></label>
|
||||
<div class="controls">
|
||||
<%= select_category(f, @module_app) %>
|
||||
</div>
|
||||
</div>
|
||||
<!-- effect -->
|
||||
<div class="control-group">
|
||||
<%= f.label :size, t('ad_banner.effect'), :class => "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.select :ad_fx, Banner::FX_TYPES, {}, {class: 'ad_banner_ad_fx', id: 'ad_fx'} %>
|
||||
<p class="suckIE hide"><i class="icons-warning"></i> <%= t('ad_banner.no_ie_10_effect_support') %></p>
|
||||
<div class="preview">
|
||||
<%= image_tag "slideshow_preview_A.png", width: "400", height: 80 %>
|
||||
<%= image_tag "slideshow_preview_B.png", width: "400", height: 80 %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Form Actions -->
|
||||
<div class="form-actions">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<input type="hidden" name="referer_url" value="<%= admin_ad_banners_path(:page => params[:page]) %>">
|
||||
<%= link_to t('cancel'), admin_ad_banners_path(:page => params[:page]), :class=>"btn" %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
<% if @ad_banner.new_record? %>
|
||||
slideshow($(".preview"), "fade" , 2000, 1000);
|
||||
<% else %>
|
||||
slideshow($(".preview"), "<%= @ad_banner.ad_fx %>" , <%= @ad_banner.timeout * 1000 rescue 2000 %>, <%= @ad_banner.speed %>);
|
||||
<% end %>
|
||||
</script>
|
||||
|
|
|
@ -86,17 +86,6 @@
|
|||
position: absolute;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.ad-banner-subtitle{
|
||||
color: #FFF;
|
||||
background: #000;
|
||||
font-size: 1.5em;
|
||||
padding: 3px 15px;
|
||||
margin-top: 10px;
|
||||
z-index: 998;
|
||||
position: absolute;
|
||||
opacity: 0.7;
|
||||
left: 15px;
|
||||
}
|
||||
.ad-banner-info{
|
||||
display: none;
|
||||
width: 100%;
|
||||
|
@ -132,8 +121,8 @@
|
|||
margin: 0px auto 70px auto;
|
||||
}
|
||||
.ad-banner-images-wrap-arrow{
|
||||
width: 0;
|
||||
height: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-bottom: 5px solid #000;
|
||||
|
@ -164,8 +153,8 @@
|
|||
.ad-banner-image{
|
||||
width: 100%;
|
||||
height: 120px;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 10px #000;
|
||||
}
|
||||
|
@ -185,13 +174,6 @@
|
|||
margin-top: 94px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.ad-image-item{
|
||||
padding: 2px 20px;
|
||||
line-height: 22px;
|
||||
color: #FFF;
|
||||
background: #000;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.ad-image-new-btn{
|
||||
padding: 4px 10px;
|
||||
border-radius: 3px;
|
||||
|
@ -224,7 +206,7 @@
|
|||
@media all and (max-width: 767px) {
|
||||
.ad-banner-detail{
|
||||
position: relative;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
@ -235,9 +217,9 @@
|
|||
<div class="ad-banner-title"><%= banner.title %></div>
|
||||
<div class="cycle-slideshow ad-banner-images "
|
||||
data-cycle-slides=".slide-img"
|
||||
data-cycle-fx="fade"
|
||||
data-cycle-speed="1"
|
||||
data-cycle-timeout="5000"
|
||||
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| %>
|
||||
|
@ -256,11 +238,12 @@
|
|||
|
||||
<% if can_edit_or_delete?(banner) %>
|
||||
<div class="ad-banner-edit">
|
||||
<a data-title="<%= t("ad_banner.setting") %>"
|
||||
data-id="<%= banner.id.to_s %>"
|
||||
data-fx="<%= banner.ad_fx %>"
|
||||
<a data-title="<%= t("ad_banner.setting") %>"
|
||||
data-id="<%= banner.id.to_s %>"
|
||||
data-fx="<%= banner.ad_fx %>"
|
||||
data-form="<%= banner.data_attribute_hash.to_s %>"
|
||||
class="open-slide"
|
||||
data-max="<%= (banner.ad_images.blank? ? "1" : banner.ad_images.count) %>"
|
||||
class="open-slide"
|
||||
href="#">
|
||||
<div class="ad-banner-edit-btn">
|
||||
<i class="icons-cog"></i>
|
||||
|
@ -289,16 +272,22 @@
|
|||
<tr>
|
||||
<th><%= t("ad_banner.size") %> : </th>
|
||||
<td><%= banner.size %></td>
|
||||
<th><%= t("ad_banner.effect") %> : </th>
|
||||
<td><%= banner.ad_fx %></td>
|
||||
<th><%= t("ad_banner.transition_interval") %> : </th>
|
||||
<td><%= banner.timeout %></td>
|
||||
<th><%= t("ad_banner.transition_speed") %> : </th>
|
||||
<td><%= banner.speed %></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<% if can_edit_or_delete?(banner) %>
|
||||
<% if can_edit_or_delete?(banner) && current_user.is_admin? or current_user.is_manager?(@module_app) or current_user.is_sub_manager?(@module_app) %>
|
||||
<div id="ad-banner-<%= banner.id.to_s %>" class="ad-banner-detail">
|
||||
<div class="ad-banner-images-wrap-arrow"></div>
|
||||
<div class="ad-banner-images-wrap">
|
||||
<a href="<%= new_admin_ad_image_path(banner: banner.id.to_s) %>" class="ad-image-new-btn">
|
||||
<i class="icon-plus"></i> <%= t("new_image") %>
|
||||
<i class="icon-plus"></i> <%= t("ad.new_image") %>
|
||||
</a>
|
||||
<% banner.ad_images.desc(:created_at).each_with_index do |image,idx| %>
|
||||
<div class="ad-banner-image-wrap">
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<% 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| %>
|
||||
<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('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('http://placehold.it/<%= banner.width %>x<%= banner.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>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @ad_banner, url: admin_ad_banner_path(@ad_banner), html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -3,44 +3,12 @@
|
|||
<%= javascript_include_tag "cycle2" %>
|
||||
<%= javascript_include_tag "ad_banner/banner_preview" %>
|
||||
<% end %>
|
||||
|
||||
<div id="banner_index">
|
||||
<%= render 'index' %>
|
||||
</div>
|
||||
|
||||
<% if current_user.is_admin? or current_user.is_manager?(@module_app) %>
|
||||
<div class="bottomnav clearfix" style="left: 81px;">
|
||||
<div class="action pull-right">
|
||||
<a data-title="<%= t("ad_banner.new_banner") %>" data-id="new" data-fx="fade" class="btn btn-primary open-slide" href="#">
|
||||
<i class="icon-plus"></i><%= t("ad_banner.new_banner") %>
|
||||
</a>
|
||||
</div>
|
||||
<div class="pagination pagination-centered"></div>
|
||||
</div>
|
||||
|
||||
<div id="pageslide">
|
||||
<div class="page-title clearfix">
|
||||
<a class="pull-right" href="javascript:$.pageslide.close()">
|
||||
<i class="icons-arrow-left-2"></i>
|
||||
</a>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="view-page">
|
||||
<div class="nano">
|
||||
<div class="content">
|
||||
<%= form_for :ad_banner, url: nil, remote: true do |f| %>
|
||||
<fieldset>
|
||||
<%= render :partial => "form", :locals => { :f => f } %>
|
||||
<div class="form-actions">
|
||||
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
|
||||
<%= f.submit t(:submit), class: 'btn btn-primary btn-small' %>
|
||||
</div>
|
||||
</fieldset>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<%= render 'layouts/delete_modal', delete_options: @delete_options %>
|
||||
<%= render_filter @filter_fields, "index_table" %>
|
||||
<span id="index_table">
|
||||
<%= render 'index_table'%>
|
||||
</span>
|
||||
<script type="text/javascript">
|
||||
$(document).on("ajaxSuccess",function(event, xhr, settings){
|
||||
$(".cycle-slideshow").cycle();
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,5 @@
|
|||
<%= form_for @ad_banner, url: admin_ad_banners_path, html: {class: "form-horizontal main-forms"} do |f| %>
|
||||
<fieldset>
|
||||
<%= render partial: 'form', locals: {f: f} %>
|
||||
</fieldset>
|
||||
<% end %>
|
|
@ -0,0 +1,155 @@
|
|||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/jquery-ui-sortable.min" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_css do %>
|
||||
<style type="text/css">
|
||||
.banner-image{
|
||||
height: 140px;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.order-list{
|
||||
list-style: none;
|
||||
}
|
||||
.order-list-image i{
|
||||
font-size: 20px;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.order-list-image h4{
|
||||
display: inline-block;
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
#sort-images-modal .modal-body {
|
||||
max-height: 60vh;
|
||||
}
|
||||
|
||||
#sort-images-modal .modal-body .order-list-image img {
|
||||
width: 150px;
|
||||
margin: 0 0 10px 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
<% end %>
|
||||
<h3>
|
||||
<%= @banner.title %>
|
||||
<div class="pull-right btn-group">
|
||||
<a class="btn btn-small <%= params[:show] == "expired" ? "" : "active" %>" href="<%= admin_ad_banner_path(@banner.id) %>">Not Expired</a>
|
||||
<a class="btn btn-small <%= params[:show] == "expired" ? "active" : "" %>" href="<%= admin_ad_banner_path(@banner.id, :show => "expired") %>">Expired</a>
|
||||
</div>
|
||||
</h3>
|
||||
|
||||
<table class="table main-list">
|
||||
<thead>
|
||||
<tr class="sort-header">
|
||||
<% @table_fields.each do |f| %>
|
||||
<%= thead(f) %>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @images.each do |image| %>
|
||||
<tr>
|
||||
<td>
|
||||
<% if image.exchange_item == "1" %>
|
||||
<%= image_tag image.file.thumb, :class => "banner-image" %>
|
||||
<% else %>
|
||||
<iframe height="140" src="<%= image.embed_url %>"></iframe>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<%= image.title rescue "" %>
|
||||
<% if can_edit_or_delete?(@banner) %>
|
||||
<div class="quick-edit">
|
||||
<ul class="nav nav-pills">
|
||||
<li><a href="<%= edit_admin_ad_image_path(image.id, :page => params[:page]) %>"><%= t(:edit) %></a></li>
|
||||
<li><a href="<%= admin_ad_image_path(image.id, :page => params[:page]) %>" class="delete text-error" data-method="delete" data-confirm="Are you sure?" ><%= t(:delete_) %></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="span3">
|
||||
<% if !image.postdate.nil? %>
|
||||
<%= image.postdate.strftime("%Y-%m-%d %H:%M") rescue "" %>
|
||||
<% if !image.deadline.nil? %>
|
||||
~ <%= image.deadline.strftime("%Y-%m-%d %H:%M") rescue "" %>
|
||||
<% if image.expired? %>
|
||||
<span class="label"><%= t("ad_banner.expired") %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if image.out_link != "" %>
|
||||
<a href="<%= image.out_link rescue "#" %>" target="_blank">Link</a>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if can_edit_or_delete?(@banner) %>
|
||||
<div class="bottomnav clearfix" style="left: 81px;">
|
||||
<div class="action pull-right">
|
||||
<a class="btn btn-primary" href="<%= new_admin_ad_image_path(:page => params[:page], :banner_id => @banner.id) %>">
|
||||
<%= t("ad_banner.add") %>
|
||||
</a>
|
||||
<a class="btn btn-info" href="#sort-images-modal" data-toggle="modal">Order</a>
|
||||
</div>
|
||||
<%= content_tag :div, paginate(@images), class: "pagination pagination-centered" %>
|
||||
</div>
|
||||
<!-- image order modal -->
|
||||
<div id="sort-images-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>Order Images</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="order-list">
|
||||
<% @banner.ad_images.not_expired.asc(:sort_number).each do |image| %>
|
||||
<li class="order-list-image" data-image-id="<%= image.id.to_s %>">
|
||||
<i class="icons-list-2"></i>
|
||||
<img src="<%= image.exchange_item == "1" ? image.file.thumb.url : image.youtube_thumb %>"/>
|
||||
<h4><%= image.title %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
|
||||
<button class="btn btn-primary" id="save-image-order-btn">Save changes</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
var sortUpdated = false;
|
||||
$("#sort-images-modal").on("shown",function(){
|
||||
$(".order-list").sortable({
|
||||
update : function(){
|
||||
sortUpdated = true;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$("#save-image-order-btn").on("click",function(){
|
||||
if(sortUpdated){
|
||||
var ids = [];
|
||||
$(".order-list-image").each(function(i,image){
|
||||
ids.push($(image).data("image-id"));
|
||||
})
|
||||
$.ajax({
|
||||
url : "/admin/ad_banner/save_image_order",
|
||||
data : {"ids" : ids, "banner_id" : "<%= @banner.id.to_s %>"},
|
||||
dataType : "json",
|
||||
type : "post"
|
||||
}).done(function(){
|
||||
alert("Order saved. Please refresh the page to see the changes.");
|
||||
$("#sort-images-modal").modal("hide");
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
|
|
@ -7,10 +7,11 @@
|
|||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "validator" %>
|
||||
<% end %>
|
||||
|
||||
<%#= f.error_messages %>
|
||||
|
||||
|
||||
<!-- Input Area -->
|
||||
<div class="input-area">
|
||||
|
||||
|
@ -139,9 +140,9 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="exchange_item_2" style="display:none">
|
||||
<!-- <div id="exchange_item_2" style="display:none">
|
||||
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -159,7 +160,7 @@
|
|||
<div class="tab-content language-area">
|
||||
|
||||
<% @site_in_use_locales.each_with_index do |locale, i| %>
|
||||
|
||||
|
||||
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
|
||||
|
||||
<!-- Content -->
|
||||
|
@ -187,7 +188,6 @@
|
|||
<input type="hidden" name="referer_url" value="<%= request.referer %>">
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
window.onload=chg(document.getElementById("ad_image_exchange_item").value);
|
||||
|
||||
|
@ -198,7 +198,9 @@
|
|||
{
|
||||
document.getElementById("exchange_item_"+i).style.display = "none";
|
||||
}
|
||||
document.getElementById("exchange_item_"+a).style.display = "";
|
||||
<% if !@ad_image.new_record? %>
|
||||
document.getElementById("exchange_item_"+<%= @ad_image.exchange_item %>).style.display = "";
|
||||
<% end %>
|
||||
}
|
||||
|
||||
function checkSelect()
|
||||
|
|
|
@ -6,6 +6,7 @@ locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_l
|
|||
|
||||
scope "(:locale)", locale: Regexp.new(locales.join("|")) do
|
||||
namespace :admin do
|
||||
post "/ad_banner/save_image_order", to: "ad_banners#save_image_order"
|
||||
resources :ad_banners
|
||||
resources :ad_images
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue