From 1cf8011ca3d0108cc4eaa824dc15893ba818fe1e Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Fri, 13 Nov 2015 01:06:56 +0800 Subject: [PATCH] added base image selection for the height --- app/controllers/ad_banners_controller.rb | 1 + app/models/banner.rb | 3 ++- app/views/admin/ad_banners/_form.html.erb | 6 ++---- app/views/admin/ad_banners/_index.html.erb | 3 ++- app/views/admin/ad_banners/index.html.erb | 10 +++++++++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 67d9a85..6fc34fb 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -34,6 +34,7 @@ class AdBannersController < ApplicationController "title" => adbanner.title, "banner-height" => adbanner.height, "banner-width" => adbanner.width, + "base_image" => (adbanner.base_image - 1), "timeout" => (adbanner.timeout * 1000), "more" => "More" }, diff --git a/app/models/banner.rb b/app/models/banner.rb index d16a94b..1583c95 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -10,6 +10,7 @@ class Banner field :title, type: String field :timeout, type: Integer, default: 5 field :width, type: Integer + field :base_image, type: Integer, default: 1 has_many :ad_images , dependent: :delete @@ -32,6 +33,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 diff --git a/app/views/admin/ad_banners/_form.html.erb b/app/views/admin/ad_banners/_form.html.erb index 8d0a54d..3c6ab08 100644 --- a/app/views/admin/ad_banners/_form.html.erb +++ b/app/views/admin/ad_banners/_form.html.erb @@ -14,10 +14,8 @@ <%= t('ad_banner.number_milliseconds') %> <%= f.label :size, t('ad_banner.size') %> - -<%= f.number_field :width, in: 10..3000, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'width' %> - -<%= f.number_field :height, in: 10..3000, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'height' %> + +<%= f.number_field :base_image, in: 1..1, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'base_image' %> <%= f.label :category_id, t('ad_banner.categories') %> <%= f.select :category_id, @categories, {} %> diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb index 90eced5..6f41a91 100644 --- a/app/views/admin/ad_banners/_index.html.erb +++ b/app/views/admin/ad_banners/_index.html.erb @@ -237,7 +237,8 @@ " data-id="<%= banner.id.to_s %>" data-fx="<%= banner.ad_fx %>" - data-form="<%= banner.data_attribute_hash.to_s %>" + data-form="<%= banner.data_attribute_hash.to_s %>" + data-max="<%= (banner.ad_images.blank? ? "1" : banner.ad_images.count) %>" class="open-slide" href="#">
diff --git a/app/views/admin/ad_banners/index.html.erb b/app/views/admin/ad_banners/index.html.erb index 673b1bb..e38bfa4 100644 --- a/app/views/admin/ad_banners/index.html.erb +++ b/app/views/admin/ad_banners/index.html.erb @@ -43,4 +43,12 @@
<% end %> - <%= render 'layouts/delete_modal', delete_options: @delete_options %> \ No newline at end of file + <%= render 'layouts/delete_modal', delete_options: @delete_options %> + + \ No newline at end of file