added base image selection for the height

This commit is contained in:
Harry Bomrah 2015-11-13 01:06:56 +08:00
parent 495e1c14db
commit 1cf8011ca3
5 changed files with 16 additions and 7 deletions

View File

@ -34,6 +34,7 @@ class AdBannersController < ApplicationController
"title" => adbanner.title, "title" => adbanner.title,
"banner-height" => adbanner.height, "banner-height" => adbanner.height,
"banner-width" => adbanner.width, "banner-width" => adbanner.width,
"base_image" => (adbanner.base_image - 1),
"timeout" => (adbanner.timeout * 1000), "timeout" => (adbanner.timeout * 1000),
"more" => "More" "more" => "More"
}, },

View File

@ -10,6 +10,7 @@ class Banner
field :title, type: String field :title, type: String
field :timeout, type: Integer, default: 5 field :timeout, type: Integer, default: 5
field :width, type: Integer field :width, type: Integer
field :base_image, type: Integer, default: 1
has_many :ad_images , dependent: :delete has_many :ad_images , dependent: :delete
@ -32,6 +33,6 @@ class Banner
end end
def data_attribute_hash 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
end end

View File

@ -14,10 +14,8 @@
<span class="help-block"><%= t('ad_banner.number_milliseconds') %></span> <span class="help-block"><%= t('ad_banner.number_milliseconds') %></span>
<%= f.label :size, t('ad_banner.size') %> <%= f.label :size, t('ad_banner.size') %>
<span class="banner_set">W</span> <span class="banner_set">Base Image</span>
<%= 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 :base_image, in: 1..1, class: 'input-mini', onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;", id: 'base_image' %>
<span class="banner_set">H</span>
<%= f.number_field :height, in: 10..3000, 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.label :category_id, t('ad_banner.categories') %>
<%= f.select :category_id, @categories, {} %> <%= f.select :category_id, @categories, {} %>

View File

@ -238,6 +238,7 @@
data-id="<%= banner.id.to_s %>" data-id="<%= banner.id.to_s %>"
data-fx="<%= banner.ad_fx %>" 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" class="open-slide"
href="#"> href="#">
<div class="ad-banner-edit-btn"> <div class="ad-banner-edit-btn">

View File

@ -44,3 +44,11 @@
<% end %> <% end %>
<%= render 'layouts/delete_modal', delete_options: @delete_options %> <%= render 'layouts/delete_modal', delete_options: @delete_options %>
<script type="text/javascript">
$(document).ready(function(){
$.pageslide.openCallback(function(form,element){
form.find("#base_image").attr("max",element.data("max"));
})
})
</script>