diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 9a5f80e..1f89adc 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -1,7 +1,7 @@ class AdBannersController < ApplicationController def widget adbanner = Banner.find(OrbitHelper.widget_custom_value) - images = adbanner.ad_images.collect.with_index do |b,i| + images = adbanner.ad_images.can_display.collect.with_index do |b,i| image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url klass = i == 0 ? "active" : "" caption = i == 0 ? '
' : "" diff --git a/app/controllers/admin/ad_banners_controller.rb b/app/controllers/admin/ad_banners_controller.rb index 89c3e35..5d39e51 100644 --- a/app/controllers/admin/ad_banners_controller.rb +++ b/app/controllers/admin/ad_banners_controller.rb @@ -1,8 +1,7 @@ class Admin::AdBannersController < OrbitAdminController - def index - @banners = Banner.order_by(sort).page(params[:page]).per(10) - @table_fields = ["ad_banner.banner_name","ad_banner.effect","ad_banner.transition_interval","ad_banner.transition_speed","ad_banner.size","preview"] + def index + @banners = Banner.all end def show diff --git a/app/controllers/admin/ad_images_controller.rb b/app/controllers/admin/ad_images_controller.rb index 5f6841a..4639b1a 100644 --- a/app/controllers/admin/ad_images_controller.rb +++ b/app/controllers/admin/ad_images_controller.rb @@ -1,5 +1,5 @@ class Admin::AdImagesController < Admin::AdBannersController - def initialize + def initialize super @app_title = "ad_banner" end @@ -12,8 +12,7 @@ class Admin::AdImagesController < Admin::AdBannersController def edit @ad_image = AdImage.find(params[:id]) if can_edit_or_delete?(@ad_image) - @ad_banners = Banner.all - @tags = @module_app.tags || [] + @ad_banner = @ad_image.banner else render_401 end @@ -22,7 +21,7 @@ class Admin::AdImagesController < Admin::AdBannersController def update @ad_image = AdImage.find(params[:id]) if @ad_image.update_attributes(ad_image_params) - redirect_to admin_ad_images_url + redirect_to params['referer_url'] else @ad_banners = Banner.all @tags = @module_app.tags || [] @@ -32,17 +31,16 @@ class Admin::AdImagesController < Admin::AdBannersController def new @ad_image = AdImage.new - @ad_banners = Banner.all + @ad_banner = Banner.find(params[:banner]) @tags = @module_app.tags || [] @ad_image.postdate = Date.today - @ad_image.deadline = Date.today + 30 end def create @ad_image = AdImage.new(ad_image_params) if @ad_image.save - redirect_to admin_ad_images_url + redirect_to params['referer_url'] else @ad_banners = Banner.all @tags = @module_app.tags || [] @@ -54,7 +52,7 @@ class Admin::AdImagesController < Admin::AdBannersController def destroy @ad_image = AdImage.find params[:id] if @ad_image.destroy - redirect_to admin_ad_images_url + redirect_to admin_ad_banners_url end end diff --git a/app/models/ad_image.rb b/app/models/ad_image.rb index 523c915..cb93691 100644 --- a/app/models/ad_image.rb +++ b/app/models/ad_image.rb @@ -20,7 +20,13 @@ class AdImage before_validation :add_http validates :file, presence: true validates :out_link, format: { with: URI::regexp(%w(http https)) }, allow_blank: true - validates :title, presence: true + # 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)} + + def expired? + self.deadline

<%= t('ad_banner.no_ie_10_effect_support') %>

- <%= image_tag "slideshow_preview_A.png", width: 200, height: 80 %> - <%= image_tag "slideshow_preview_B.png", width: 200, height: 80 %> + <%= image_tag "slideshow_preview_A.png", width: "100%", height: 80 %> + <%= image_tag "slideshow_preview_B.png", width: "100%", height: 80 %>
diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb index 9386712..4752f8b 100644 --- a/app/views/admin/ad_banners/_index.html.erb +++ b/app/views/admin/ad_banners/_index.html.erb @@ -1,35 +1,345 @@ - - - - <% @table_fields.each do |f| %> - <%= thead(f) %> - <% end %> - - - - <% @banners.each do |banner| %> - - - - - - - - - <% end %> - -
- <%= banner.title %> -
- <% if can_edit_or_delete?(banner) %> - +<% + height = 140 +%> + +
+<% @banners.each_with_index do |banner,i| %> + <% if (i+1)%3==1 %>
<% end %> +
+
<%= banner.title %>
+
+ <% if !banner.ad_images.can_display.blank? %> + <% banner.ad_images.can_display.each do |image| %> +
+ <% end %> + <% else %> +
+
+ <% end %> + +
+ + + +
+ + + + + + + + + + + +
<%= t("ad_banner.size") %> : <%= banner.size %><%= t("ad_banner.effect") %> : <%= banner.ad_fx %><%= t("ad_banner.transition_interval") %> : <%= banner.timeout %><%= t("ad_banner.transition_speed") %> : <%= banner.speed %>
+
+ +
+
+
+ + <%= t("ad.new_image") %> + + <% banner.ad_images.each_with_index do |image,idx| %> +
+
" style="background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"> + <% if image.expired? %> +
<%= t("ad_banner.expired") %>
+ <% end %> + <% if (image.postdate > Time.now rescue false) %> +
<%= t("start_date")+': '+(format_value image.postdate) %>
+ <% end %> + <%= t(:edit) %> + <%= t(:delete_) %> +
+
+ + + + + + + + + + + + + + + + + +
<%= t("title") %> : <%= image.title %>
<%= t("start_date") %> : <%= format_value image.postdate %>
<%= t("end_date") %> : <%= format_value image.deadline %>
<%= t("link") %> : <%= image.out_link rescue " " %>
+
+
<% end %>
-
<%= banner.ad_fx %><%= banner.timeout %><%= banner.speed %><%= banner.size %><%= banner.preview_link %>
+ + + + <% if ((i+1)%3==0) or (i+1 == @banners.count) %>
<% end %> +<% end %> + + + \ No newline at end of file diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 383edb3..2eed65f 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -8,26 +8,12 @@
-
@@ -51,4 +37,6 @@
- \ No newline at end of file + + +<%= render 'layouts/delete_modal', delete_options: @delete_options %> \ No newline at end of file diff --git a/app/views/admin/ad_banners/index.js.erb b/app/views/admin/ad_banners/index.js.erb index a5e1afa..b6d94bc 100644 --- a/app/views/admin/ad_banners/index.js.erb +++ b/app/views/admin/ad_banners/index.js.erb @@ -1,4 +1,5 @@ -$("#banner_index").html("<%= j render 'index' %>") $.pageslide.close(); +$("#banner_index").html("<%= j render 'index' %>"); +$(".cycle-slideshow").cycle(); openSlide(); preview(); \ No newline at end of file diff --git a/app/views/admin/ad_images/_form.html.erb b/app/views/admin/ad_images/_form.html.erb index 1ae1c97..76665e6 100644 --- a/app/views/admin/ad_images/_form.html.erb +++ b/app/views/admin/ad_images/_form.html.erb @@ -14,40 +14,62 @@
- - - - -
+
+ - +
- +
- <%= f.select :banner_id, @ad_banners.collect{|t| [ t.title, t.id ]} %> +
<%= t("ad_banner.best_size") %>: <%= @ad_banner.width %>px X <%= @ad_banner.height %>px
+
+
+ <% if @ad_image.file.file %> + <%= image_tag @ad_image.file %> + <% else %> + + <% end %> +
+
+ + <%= t(:select_image) %> + <%= t(:change) %> + <%= f.file_field :file %> + + <%= t(:cancel) %> +
+ +
+
+
+
+ + +
+ +
+
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> +
" id="title_<%= locale %>"> + <%= f.fields_for :title_translations do |f| %> + <%= f.text_field locale, :value => (@ad_image.title_translations[locale] rescue nil), :placeholder=>"#{t(locale.to_s)+t("title")}" %> + <% end %> +
+ <% end %> +
+
+ <% @site_in_use_locales.each_with_index do |locale, i| %> + " href="#title_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %> + <% end %> +
+
@@ -67,30 +89,14 @@
-
- - -
- - +
- -
- <% @tags.each do |tag| %> - - <% end %> + +
+ <%= f.text_field :out_link, placeholder: t('ad_banner.enter_url') %>
-
- - -
- -
@@ -100,71 +106,9 @@
- -
- - -
- -
- <%= f.number_field :weight, placeholder: t(:frequency), in: 1..99, maxlength: 2, onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %> - <%= t('ad_banner.enter_number') %> -
-
- -
- - - - - -
- - -
- -
-
-
- <% if @ad_image.file.file %> - <%= image_tag @ad_image.file %> - <% else %> - - <% end %> -
-
- - <%= t(:select_image) %> - <%= t(:change) %> - <%= f.file_field :file %> - - <%= t(:cancel) %> -
- -
-
-
-
- -
-
-