changes for ad_banner

This commit is contained in:
chris 2013-10-18 15:25:19 +08:00
parent 19bf2f2be5
commit 92d2af13f2
45 changed files with 500 additions and 794 deletions

View File

@ -0,0 +1 @@
//= require lib/arrow-on-list-edit

View File

@ -23,12 +23,14 @@ function ajax_load_proc(wapper,url,isBanner){
if (textSta == 'success') {
if(isBanner=="true"){
wapper.html(respText);
var banner = banners[banner_index];
$(banner.banner_name+" > img").each(function(){
$(this).load(function(){ banner.image_loaded++; });
});
BannerCycle(banner_index);
banner_index++;
$( '.cycle-slideshow' ).cycle();
// var banner = banners[banner_index];
// $(banner.banner_name+" > img").each(function(){
// $(this).load(function(){banner.image_loaded++; });
// });
// BannerCycle(banner_index);
// banner_index++;
// $( '.cycle-slideshow' ).cycle();
}else{
wapper.html(respText);
}
@ -41,21 +43,26 @@ function ajax_load_proc(wapper,url,isBanner){
function BannerCycle(banner_index){
var banner = banners[banner_index];
// Wait untill all images are loaded
// console.log(banner.image_loaded, $(banner.banner_name+" img").length, banners[banner_index])
if (banner.image_loaded==$(banner.banner_name+" img").length){
$(banner.banner_name).cycle({
delay: -1000,
$(banner.banner_name).cycle({
fx: banner.banner_fx,
timeout: banner.time_to_next,
timeout: banner.timeout,
pager: banner.banner_pager,
speed: banner.banner_speed,
fit: 1,
containerResize: 0,
width: banner.banner_width,
height: banner.banner_height,
pagerAnchorBuilder: function(idx, slide) { return "<li><a href='#'></a></li>"; }
});
}else{
setTimeout("BannerCycle("+banner_index+")",500);
setTimeout("BannerCycle("+banner_index+")",100);
}
}
$(document).ready(function() {
$(document).on('click', '.slideshow img', function()
$(document).on('click', '.cycle-slideshow img', function()
{
if($(this).attr('link_url')!='')
{

View File

@ -67,9 +67,10 @@ $(function() {
fx: bannerEffect,
timeout: bannerTime,
speed: bannerSpeed,
fit: 1,
width: bannerW,
height: bannerH,
});
$(this).find('img').css({
'width': bannerW,
'height': bannerH
});
});
$('#preview').on('hidden', function() {

File diff suppressed because one or more lines are too long

View File

@ -4,4 +4,4 @@
//= require basic/bootstrap
//= require kernel
//= require lib/jquery.preload-min.js
//= require lib/jquery.cycle.all.js
//= require lib/jquery.cycle2.min.js

View File

@ -1,17 +1,17 @@
#banner_nav {
.banner_nav {
position: absolute;
z-index: 10;
bottom: 0;
margin-right: 5px;
right: 0;
}
#banner_nav>li {
.banner_nav>li {
float: left;
display: inline-block;
*display: inline;
}
#banner_nav>li>a {
.banner_nav>li>a {
display:block;
width: 10px;
height: 10px;
@ -25,11 +25,11 @@
text-indent: -9999px;
box-shadow: 0 0 5px rgba(0,0,0,.7);
}
#banner_nav>li>a:hover {
.banner_nav>li>a:hover {
opacity: 1;
filter: alpha(opacity = 100);
}
#banner_nav>li.activeSlide>a {
.banner_nav>li.activeSlide>a {
opacity: 1;
filter: alpha(opacity = 100);
}

View File

@ -1,17 +1,10 @@
class Admin::AdBannersController < OrbitBackendController
open_for_visitor :only => [:index, :show]
open_for_manager :except => [:index,:show,:update,:realtime_preview]
open_for_sub_manager :except => [:index, :show]
def rename
@ad_banner = AdBanner.find(params[:id])
@ad_banner.title = params[:body]
render :json => {:success =>@ad_banner.save!}
end
def destroy
@ad_banner = AdBanner.find(params[:id])
@ad_banner.destroy
redirect_to admin_ad_banners_url
open_for_visitor :only => [:index, :show]
open_for_sub_manager
def index
@ad_banners = AdBanner.all.page(params[:page]).per(10)
end
def show
@ -28,13 +21,10 @@ class Admin::AdBannersController < OrbitBackendController
def create
@ad_banner = AdBanner.new(params[:ad_banner])
if @ad_banner.save
@active = @ad_banner
redirect_to admin_ad_banners_url
#respond_to do |format|
# format.js {render 'new_created_node'}
#end
else
render 'create_error_msg'
@ad_banner = AdBanner.new(params[:ad_banner])
render :new
end
end
@ -45,20 +35,17 @@ class Admin::AdBannersController < OrbitBackendController
def update
@ad_banner = AdBanner.find(params[:id])
@ad_banner.update_attributes(params[:ad_banner])
@ad_banner.save
if @ad_banner.update_attributes(params[:ad_banner])
redirect_to admin_ad_banners_url
else
render :edit
end
end
def destroy
@ad_banner = AdBanner.find(params[:id])
@ad_banner.destroy
redirect_to admin_ad_banners_url
end
def realtime_preview
@ad_banner = AdBanner.find( params[:id] ).preview_clone
@ad_banner.update_attributes(params[:ad_banner])#.update_attributes(params[:ad_images])
end
def index
@ad_banners = AdBanner.all
@active = @ad_banners.first
@tags = get_tags
end
end

View File

@ -1,8 +1,9 @@
class Admin::AdImagesController < Admin::AdBannersController
# before_filter :force_order_for_user
# before_filter :for_app_sub_manager
# before_filter :for_app_manager
before_filter :only => [ :new, :edit ] do
@ad_banners = AdBanner.all
@tags = get_tags
end
def initialize
super
@ -10,53 +11,46 @@ class Admin::AdImagesController < Admin::AdBannersController
end
def index
#@ad_banner = AdBanner.find params[:ad_banner_id]
#@ad_images = @ad_banner.ad_images.all.page(params[:page]).per(10)
@ad_images = AdImage.all.page(params[:page]).per(10)
@ad_images = AdImage.all.page(params[:page]).per(10)
end
def edit
#@ad_banner = AdBanner.find params[:ad_banner_id]
@ad_image = AdImage.find(params[:id])
@tags = get_tags
end
def update
@ad_banner = AdBanner.find params[:ad_banner][:id]
@ad_image = AdImage.find(params[:ad_image][:id])
@ad_image.update_attributes(params[:ad_image])
@ad_banner.ad_images << @ad_image
redirect_to admin_ad_images_path
@ad_image = AdImage.find(params[:id])
if @ad_image.update_attributes(params[:ad_image])
redirect_to admin_ad_images_url
else
@ad_banners = AdBanner.all
@tags = get_tags
render action: :edit
end
end
def new
#ad_banner = AdBanner.find params[:ad_banner_id]
#@ad_image =ad_banner.ad_images.build
@ad_image = AdImage.new
@ad_image.post_date = Date.today
@ad_image.unpost_date = Date.today + 30
@tags = get_tags
#render :action => 'new',:url=> {:ad_banner_id => params.has_key?(:ad_banner_id)? params[:ad_banner_id],nil}
@ad_image.postdate = Date.today
@ad_image.deadline = Date.today + 30
end
def create
@ad_banner = AdBanner.find params[:ad_banner][:id]
@ad_image = AdImage.new params[:ad_image]
@ad_image.to_save = true
@ad_banner.ad_images << @ad_image
@ad_image = AdImage.new(params[:ad_image])
if @ad_image.save
redirect_to admin_ad_images_path
redirect_to admin_ad_images_url
else
@ad_banners = AdBanner.all
@tags = get_tags
@ad_image = AdImage.new(params[:ad_image])
render action: :new
end
end
def destroy
#@ad_banner = AdBanner.find params[:ad_banner_id]
@ad_image = AdImage.find params[:id]
if @ad_image.destroy
flash[:notice] = t('ad.success_destroy_ad_image')
redirect_to admin_ad_images_path
redirect_to admin_ad_images_url
end
end

View File

@ -1,6 +1,7 @@
class Admin::TagsController < OrbitBackendController
include OrbitTag::Merging
open_for_user only: [:index]
open_for_manager
def index

View File

@ -1,31 +0,0 @@
module Admin::AdBannersHelper
def preview_block_ad_images_helper(ad_banner)
printable_ad_images = []
ad_banner.ad_images.each do |ad_image|
if ad_image.display?
ad_image.weight.times do
printable_ad_images << ad_image
end
end
end
printable_ad_images.shuffle!
end
def sub_manager?(ad_banner)
ad_banner.authed_users(:edit).include?(current_user)
end
def show_ad_banner_permission_link(ad_banner)
type = 'edit'
oa = ad_banner.get_object_auth_by_title(type)
if oa.nil?
ad_banner.object_auths.new(title: type ).save
oa = ad_banner.get_object_auth_by_title(type)
end
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa),:class => "btn btn-warning"
end
end

View File

@ -24,13 +24,16 @@ module OrbitBackendHelper
def show_delete_link(object)
if !current_user.nil?
by_object = (object.create_user_id == current_user.id )
by_user = (is_manager? or is_admin?)
by_object or by_user
if object.class.fields.include?('create_user_id')
by_object = (object.create_user_id == current_user.id )
by_user = (is_manager? or is_admin?)
by_object or by_user
else
true
end
else
false
end
end
# def show_bulletin_title_at_index (bulletin)
@ -55,7 +58,7 @@ module OrbitBackendHelper
def is_sort_active?(field)
res = t(field[:translation])
if params[:sort].eql?(field[:sort])
if params[:sort] && params[:sort].eql?(field[:sort])
res << " " + content_tag(:b, nil, class: (params[:direction].eql?('asc') ? "icons-arrow-up-3" : "icons-arrow-down-4 "))
end
res.html_safe
@ -108,12 +111,14 @@ module OrbitBackendHelper
res << status.join(' ')
when 'tags'
sorted_objects = get_sorted_objects(object.tags, 'name') rescue ''
when 'standalone'
res << (field[:need_value] ? eval(field[:display_option]) : field[:display_option])
else
sorted_values = object.send(field[:db_field])
sorted_values = sorted_values.sort if sorted_values.is_a?(Array)
end
res << display_value_from_object(object, sorted_values, field[:display_option]) if sorted_values
res << display_value_from_objects(sorted_objects, field[:model_field], field[:display_option]) if sorted_objects
res << display_value_from_object(object, sorted_values, field[:display_option]).to_s if sorted_values
res << display_value_from_objects(sorted_objects, field[:model_field], field[:display_option]).to_s if sorted_objects
if field[:quick_edit]
res << (content_tag :div, class: "quick-edit" do
content_tag :ul, class: "nav nav-pills" do
@ -131,7 +136,7 @@ module OrbitBackendHelper
concat (content_tag :thead do
(content_tag :tr, class: "sort-header" do
@fields.each do |field|
concat (content_tag :th, "data-hide" => field[:hide], class: "#{field[:header_class]} #{'active' if params[:sort].eql?(field[:sort])}" do
concat (content_tag :th, "data-hide" => field[:hide], class: "#{field[:header_class]} #{'active' if (params[:sort] && params[:sort].eql?(field[:sort]))}" do
if field[:sort]
link_to is_sort_active?(field), url_for({:filter => @filter}.merge(sortable_options(field[:sort]).merge(:sort_options => field[:db_field])))
else
@ -241,6 +246,8 @@ module OrbitBackendHelper
args[:translation] ||= 'tags'
args[:display_option] ||= "content_tag(:span, object.name, class: 'label label-warning')"
@fields << args
elsif !args.blank? && args[:type].eql?('standalone')
@fields << args
end
end
@ -267,7 +274,7 @@ module OrbitBackendHelper
link = (is_manager? || is_sub_manager? rescue nil) && args.has_key?(:link) ? true : false
if paginate || link
@index_footer = content_tag :div, class: "bottomnav clearfix" do
concat content_tag :div, link_to(content_tag(:i, nil, :class => 'icon-plus') + ' ' + t(:add), send(args[:link]), :class => 'btn btn-primary' ), class: "action pull-right" if link
concat content_tag :div, link_to(content_tag(:i, nil, :class => 'icon-plus') + ' ' + t(:add), send(args[:link]), :class => (args[:link_class] || 'btn btn-primary'), data: args[:link_data]), class: "action pull-right" if link
concat content_tag :div, paginate(@objects, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]}), class: "pagination pagination-centered" if paginate
end
end
@ -285,7 +292,7 @@ module OrbitBackendHelper
end
when 'edit'
if authorization && approvable
content_tag :li, link_to(t(quick[:translation] || :edit), eval("#{quick[:link]}('#{object.id}')"), class: quick[:class])
content_tag :li, link_to(t(quick[:translation] || :edit), eval("#{quick[:link]}('#{object.id}')"), class: quick[:class], data: quick[:data])
end
when 'delete'
if show_delete_link(object)
@ -323,7 +330,7 @@ module OrbitBackendHelper
if object.is_a?(klass.constantize)
autorized ||= object.user_can_sub_manage?(current_user)
else
autorized ||= object.category.user_can_sub_manage?(current_user)
autorized ||= object.send(klass.underscore).user_can_sub_manage?(current_user)
end
autorized
end

View File

@ -5,67 +5,27 @@ class AdBanner
include OrbitTag::Taggable
include OrbitModel::Authorizable
field :title
field :transition_msec,type: Integer
field :ad_fx #TODO Design should explain
field :best_size,:default => ''
field :height, type: Integer
field :speed, type: Integer
field :title
field :timeout, type: Integer
field :width, type: Integer
before_save :save_or_destroy
validates_uniqueness_of :title
validates :title , :length => { :minimum => 2 }
has_many :ad_images , dependent: :delete
validates_uniqueness_of :title
validates :title, :length => { :minimum => 2 }
validates :height, :speed, :timeout, :width, :presence => true
FX_TYPES = ["blindX","blindY","blindZ","cover","curtainX","curtainY","fade","fadeZoom","growX","growY","scrollUp","scrollDown","scrollLeft","scrollRight","scrollHorz","scrollVert","shuffle","slideX","slideY","toss","turnUp","turnDown","turnLeft","turnRight","uncover","wipe","zoom"]
attr_writer :transition_sec
AfterObjectAuthUrl = '/panel/page_content/back_end/page_contexts'
APP_NAME = 'ad_banners'
ObjectAuthTitlesOptions = %W{edit}
def pp_object
title
def size
"#{self.width} x #{self.height}"
end
def transition_sec
self.transition_msec/1000 rescue nil
def timeout_in_min
self.timeout*1000 rescue 0
end
def transition_sec=(sec)
self.transition_msec = sec.to_i*1000
end
def preview_clone
preview_banner = self.clone
preview_banner.ad_images = self.ad_images
preview_banner
end
# def new_ad_images(*attrs)
# debugger
# a=1
# attrs[0].each do |attr| #Loop by JSs,Themes,Imgs
# unless attr[:file].nil?
# self.ad_images << AdImage.new(attr)
# end
# end
# end
# def existing_ad_images=(*attrs)
# attrs[0].each do |attr| #Loop by JSs,Themes,Imgs
# ad_image = self.ad_images.find attr[0]
# ad_image.update_attributes(attr[1])
# end
# end
def save_or_destroy
self.ad_images.each do |ad_image|
if ad_image.to_save?
ad_image.save
end
if ad_image.to_destroy?
ad_image.destroy
end
end
end
end

View File

@ -1,53 +1,29 @@
class AdImage
include Mongoid::Document
include Mongoid::Timestamps
include OrbitModel::TimeFrame
include OrbitTag::Taggable
mount_uploader :file, ImageUploader
field :title, localize: true
field :context, localize: true
field :to_save, :type => Boolean
field :to_destroy, :type => Boolean
field :direct_to_after_click,type: Boolean
field :weight ,type: Integer ,default: 1
field :weight, type: Integer, default: 1
field :out_link #the link itself
field :link_open #how will the link be opened
LINK_OPEN_TYPES = ["new_window","local"]
field :post_date,type: Date
field :unpost_date,type: Date
LINK_OPEN_TYPES = ["local", "new_window"]
belongs_to :ad_banner
before_validation :add_http
validates :file, :presence => true
validates :out_link, :format => /^(http|https):\/\/(([a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5})|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(:[0-9]{1,5})?(\/.*)?/i, :allow_blank => true
def display?
if (self.post_date <= Date.today && (self.unpost_date.nil? || self.unpost_date>= Date.today) rescue false)
return true
end
return false
end
def get_delay_time
time = ''
if self.time_to_next.nil?
time = '1000'
else
time = (self.time_to_next.to_i * 1000).to_s
end
time
end
validates :title, :at_least_one => true
protected
def add_http
unless self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//] || self.out_link.blank?
unless self.out_link.blank? || self.out_link[/^http:\/\//] || self.out_link[/^https:\/\//]
self.out_link = 'http://' + self.out_link
end
end

View File

@ -1,39 +0,0 @@
<div class="tab-pane fade <%= "active in" if ad_banner_tab==@active%>" id=<%= ad_banner_tab.title.dehumanize %>>
<% if at_least_module_manager || sub_manager?(ad_banner_tab)%>
<%= form_for ad_banner_tab,:url=> admin_ad_banner_path(ad_banner_tab),:method => :put,:class=>"input-medium" do |f| -%>
<div class="adbanner-setup well">
<!--<p><%#= t("ad.banner_best_size") %></p>-->
<%= f.label :ad_fx, t('ad.ab_fx') %>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<%= f.label :transition_sec, t('ad.transition_sec') %>
<%= f.text_field :transition_sec,:placeholder=>t('ad.sec_place_holder'),:class=> "span3" %> <%= t("ad.trans_unit_sec") %>
<%if at_least_module_manager%>
<%= f.label :best_size, t('ad.best_size') %>
<%= f.text_field :best_size %> Ex: 500px x 300px
<% end -%>
<br>
<%= f.submit t("ad.update_banner"), :class => 'btn' %>
<%= f.submit t("cancel"),:type=>'reset', :class => 'btn' %>
</div>
<% end -%>
<% end -%>
<h3><%= t("ad.picture_list")%></h3>
<div class="adbanner-list">
<%if (at_least_module_manager || ad_banner_tab.cur_user_is_sub_manager_of(:edit) )%>
<%= content_tag :div ,:class=>'adbanner-action' do%>
<%= link_to t("ad.new_image"),new_admin_ad_banner_ad_image_path(ad_banner_tab) ,:class => "btn btn-primary"%>
<%= link_to t(:preview), admin_realtime_preview_ad_banner_path(ad_banner_tab.id) , :class=>'preview_trigger btn btn-success'%>
<% end -%>
<% end -%>
<ul class="clear">
<%= render :partial => "ad_image_update", :collection => ad_banner_tab.ad_images,:as => :ad_image,:locals=>{:ad_banner => ad_banner_tab} %>
</ul>
<% if at_least_module_manager %>
<%= show_ad_banner_permission_link ad_banner_tab%>
<%= link_to t(:delete_),admin_ad_banner_path(ad_banner_tab),:class => 'btn',:method => :delete,:confirm => t('sure?') %>
<% end -%>
<%#= render :partial => 'new_add_banner_file', :object => ad_banner_tab.ad_images.build, :locals => { :field_name => "new_ad_images[]", :f => f, :classes => "r_destroy" } %>
</div>
<%#= render :partial => 'preview_block',:locals=> {:ad_banner =>ad_banner_tab} %>
</div>

View File

@ -1,13 +0,0 @@
<li class="span3">
<%= image_tag ad_image.file rescue nil%>
<p>
<%= ad_image.display? ? "[#{t('ad.showing')}]" : "[#{t('ad.not_showing')}]" %>
<%= "#{ad_image.post_date} ~ #{ad_image.unpost_date}" %>
</p>
<%if at_least_module_manager || sub_manager?(ad_image.ad_banner) %>
<p>
<%= link_to t('edit'),edit_admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn btn-primary' %>
<%= link_to t(:delete_),admin_ad_banner_ad_image_path(ad_banner,ad_image),:class => 'btn',:method => :delete,:confirm => t('sure?') %>
</p>
<% end -%>
</li>

View File

@ -1,31 +1,9 @@
<%= form_for @ad_banner, url: admin_ad_banner_path(@ad_banner) do |f| %>
<%= form_for @ad_banner, url: admin_ad_banner_path(@ad_banner), remote: true do |f| %>
<fieldset>
<legend><%= t("ad_banner.banner") %></legend>
<label><%= t("ad_banner.banner_name") %></label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block"><%= t("ad_banner.banner_name_note") %></span>
<label for="timeout"><%= t("ad_banner.ste") %></label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block"><%= t("ad_banner.ste_note") %></span>
<label><%= t("ad_banner.best_size") %></label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block"><%= t("ad_banner.best_size") %> EX:120x30 </span>
<label><%= t("ad_banner.effect") %></label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
<%= 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(:update_), class: 'btn btn-primary btn-small' %>
</div>
<span class="help-block"><%= t("ad_banner.effect") %></span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:update_), class: 'btn btn-primary btn-small' %>
</fieldset>
<% end %>
<script type="text/javascript">
$('select').on('change', function() {
$(".preview").cycle({
delay: -3000,
fx: $(this).val()
});
});
</script>

View File

@ -0,0 +1,45 @@
<%= flash_messages %>
<%= f.error_messages %>
<%= f.label :title, t('ad_banner.banner_name') %>
<%= f.text_field :title, class: 'input-large', placeholder: t('ad_banner.banner_name') %>
<span class="help-block"><%= t('ad_banner.name_only_english') %></span>
<%= f.label :timeout, t('ad_banner.transition_interval') %>
<%= 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>
<%= f.label :speed, t('ad_banner.transition_speed') %>
<%= 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>
<%= 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;" %>
<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;" %>
<span class="help-block"><%= t('ad_banner.number_milliseconds') %></span>
<%= f.label :ad_fx, t('ad_banner.effect') %>
<%= f.select :ad_fx, AdBanner::FX_TYPES, {}, {class: 'ad_banner_ad_fx'} %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png" %>
<%= image_tag "slideshow_preview_B.png" %>
</div>
<span class="help-block"><%= t('ad_banner.effect') %></span>
<script type="text/javascript">
$(".ad_banner_ad_fx").change(function () {
// bannerTime = $("#pageslide #timeout").val()*1000;
// bannerSpeed = $("#pageslide #speed").val()*1000;
bannerTime = "<%= @ad_banner.timeout_in_min %>"
bannerSpeed = "<%= @ad_banner.speed %>"
bannerTime = parseInt(bannerTime) || 300;
bannerSpeed = parseInt(bannerSpeed) || 300;
slideshow($(this).val(), bannerTime, bannerSpeed);
});
</script>

View File

@ -1,39 +1,63 @@
<%= javascript_include_tag "lib/jquery.cycle.all.js"%>
<% set_default_index do
objects @ad_banners
quick_edit_link type: 'edit',
link: 'edit_admin_ad_banner_path',
class: 'open-slide',
data: {title: t('ad_banner.edit_banner')}
quick_edit_link type: 'detail'
quick_edit_link type: 'delete',
link: 'admin_ad_banner_path'
# can have: title, warning, cancel and submit values
field db_field: 'title',
translation: 'ad_banner.banner_name',
sort: 'title',
quick_edit: true,
header_class: 'span4',
sort: 'title'
field db_field: 'ad_fx',
translation: 'ad_banner.effect',
hide: 'phone',
sort: 'effect'
field db_field: 'timeout',
translation: 'ad_banner.transition_interval',
hide: 'phone',
sort: 'timeout'
field db_field: 'speed',
translation: 'ad_banner.transition_speed',
hide: 'phone',
sort: 'speed'
field db_field: 'size',
translation: 'ad_banner.size',
hide: 'phone',
sort: 'size'
field type: 'standalone',
translation: 'preview',
display_option: "link_to(t(:preview), '#', data: {w: object.width, h: object.height, fx: object.ad_fx, time: object.timeout_in_min, speed: object.speed}, class: 'btn btn-success open-modal')",
need_value: true,
hide: 'phone'
footer link: 'new_admin_ad_banner_path',
link_class: 'btn btn-primary open-slide',
link_data: {title: t('ad_banner.new_banner')}
end %>
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('ad_banner.title') %></th>
<th class="span1"><%= t('ad_banner.transition_msec') %></th>
<th class="span1"><%= t('ad_banner.ad_fx') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @ad_banners.each do |ad_banner| %>
<tr class="with_action">
<td><%= ad_banner.title %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_admin_ad_banner_path(ad_banner), :class => "open-slide" %></li>
<li><%= link_to 'Destroy', admin_ad_banner_path(ad_banner), method: :delete , :confirm => t(:sure?) %></li>
<% end %>
</ul>
</div>
</td>
<td><%= ad_banner.transition_msec %></td>
<td><%= ad_banner.ad_fx%></td>
</tr>
<% end %>
</tbody>
</table>
<%if is_manager? %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), new_admin_ad_banner_path, :class => "btn btn-primary open-slide"%>
</div>
</div>
<%= render 'admin/default_index/index' %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "lib/jquery.cycle.all.js" %>
<%= javascript_include_tag "lib/ad_banner/banner_preview" %>
<% end %>
<div id="preview" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="ModalLabel"><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<div class="preview">
<%= image_tag "slideshow_preview_A.png" %>
<%= image_tag "slideshow_preview_B.png" %>
</div>
</div>
<div class="modal-footer">
</div>
</div>

View File

@ -1,46 +0,0 @@
<div id="new-a-banner" class="modal fade <%= 'active' if @active.nil? %>">
<%= form_for(:ad_banner,:remote => true, :url => admin_ad_banners_path) do |f| %>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t('new.banner') %></h3>
</div>
<div class="modal-body form-horizontal">
<div class="control-group">
<%= f.label :title, t(:title),:class => "control-label" %>
<div class="controls">
<%= f.text_field :title %>
</div>
</div>
<div class="control-group">
<%= f.label :transition_sec, t('ad.transition_sec'),:class => "control-label" %>
<div class="controls">
<%= f.text_field :transition_sec %> <%= t("ad.trans_unit_sec") %>
</div>
</div>
<div class="control-group">
<%= f.label :best_size, t('ad.best_size'),:class => "control-label" %>
<div class="controls">
<%= f.text_field :best_size %> <%= t('ad.best_size_example') %>
</div>
</div>
<div class="control-group">
<%= f.label :ad_fx, t('ad.ab_fx') %>
<div class="controls">
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
</div>
</div>
</div>
<div class="modal-footer">
<span id="ad_banner-modal-info"></span>
<%= f.submit t('submit'), :class=>'btn btn-primary',:remote=>true %>
<a class="btn" data-dismiss="modal"><%= t('cancel')%></a>
</div>
<% end %>
</div>

View File

@ -1,36 +0,0 @@
<% if ad_banner -%>
<div class="modal hide fade in banner-preview" id="slideshow-<%=ad_banner.title.dehumanize%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<p class="ad_banner_slideshow">
<% preview_block_ad_images_helper(ad_banner).each do |ad_image| -%>
<%= image_tag ad_image.file,:alt => (ad_image.title || " "),:time_to_next => ad_banner.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || ad_banner.context || " ")) %>
<% end -%>
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
<div>
<script type="text/javascript" src="/static/kernel.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#slideshow-<%=ad_banner.title.dehumanize%>").on("show", function () {
$("#slideshow-<%=ad_banner.title.dehumanize%>").find(".ad_banner_slideshow").cycle({delay: -1000, fx: "<%= ad_banner.ad_fx.nil?? "fade": ad_banner.ad_fx %>", timeoutFn: getTimeout });
});
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});
});
</script>
</div>
</div>
<% end -%>

View File

@ -1,31 +1,9 @@
<%= form_for(:ad_banner, :url => admin_ad_banners_path) do |f| %>
<fieldset>
<legend><%= t("ad_banner.banner") %></legend>
<label><%= t("ad_banner.banner_name") %></label>
<%= f.text_field :title, :class=>"input-large", :placeholder=>"Banner Name" %>
<span class="help-block"><%= t("ad_banner.banner_name_note") %></span>
<label for="timeout"><%= t("ad_banner.ste") %></label>
<%= f.text_field :transition_sec, :class => 'input-large', :placeholder => 'Time' %>
<span class="help-block"><%= t("ad_banner.ste_note") %></span>
<label><%= t("ad_banner.best_size") %></label>
<%= f.text_field :best_size, :class=>"input-large", :placeholder=>"Banner Size" %>
<span class="help-block"><%= t("ad_banner.best_size") %> EX:120x30 </span>
<label><%= t("ad_banner.effect") %></label>
<%= f.select :ad_fx ,AdBanner::FX_TYPES %>
<div class="preview">
<%= image_tag "slideshow_preview_A.png", :width=>220 %>
<%= image_tag "slideshow_preview_B.png", :width=>220 %>
</div>
<span class="help-block"><%= t("ad_banner.effect") %></span>
<a href="javascript:$.pageslide.close()" class="btn btn-small"><%= t(:cancel) %></a>
<%= f.submit t(:create_), class: 'btn btn-primary btn-small' %>
</fieldset>
<%= form_for @ad_banner, url: admin_ad_banners_path, 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(:create_), class: 'btn btn-primary btn-small' %>
</div>
</fieldset>
<% end %>
<script type="text/javascript">
$('select').on('change', function() {
$(".preview").cycle({
delay: -3000,
fx: $(this).val()
});
});
</script>

View File

@ -1,7 +0,0 @@
<%= f.fields_for field_name, new_add_banner_file do |f| %>
<p class="new_file">
<%= f.file_field :file %>
<%#= render :partial => "ad_image_form", :locals => { :f => f } %>
<%= button_tag '+', :class => "multi_files"%>
</p>
<% end %>

View File

@ -1,29 +0,0 @@
<% if ad_banner -%>
<%= link_to t(:preview),"#slideshow-#{ad_banner.title.dehumanize}",:class=>"btn btn-primary btn-large",:data=>{:toggle=>'modal'} %>
<div class="modal hide fade in banner-preview" id='slideshow-<%=ad_banner.title.dehumanize%>'>
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<p class="ad_banner_slideshow">
<% preview_block_ad_images_helper(ad_banner).each do |ad_image| -%>
<%= image_tag ad_image.file,:alt => (ad_image.title || ' '),:time_to_next => ad_banner.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || ad_banner.context || ' ')) %>
<% end -%>
</p>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal">Close</a>
</div>
</div>
<% end -%>
<script type='text/javascript' src='/static/kernel.js'></script>
<script type='text/javascript'>
$('#slideshow-<%=ad_banner.title.dehumanize%>').on('show', function () {
$('#slideshow-<%=ad_banner.title.dehumanize%>').find(".ad_banner_slideshow").cycle({delay: -1000, fx: '<%= ad_banner.ad_fx.nil?? 'fade': ad_banner.ad_fx %>', timeoutFn: getTimeout });
});
</script>

View File

@ -1 +0,0 @@
$("#ad_banner-modal-info").append("<%= @ad_banner.errors.full_messages.join(',')%>");

View File

@ -1,9 +1,3 @@
<% content_for :right_nav do %>
<div class="searchClear pull-right">
<input id="filter-input" class="search-query input-medium" type="text" placeholder="<%= t('search.tags') %>" value="">
</div>
<% end %>
<div id="tags_index">
<div id="banner_index">
<%= render 'index' %>
</div>

View File

@ -1,3 +1,3 @@
$("#categories_index").html("<%= j render 'index' %>")
$("#banner_index").html("<%= j render 'index' %>")
$.pageslide.close();
openSlide();

View File

@ -1,18 +0,0 @@
$('<%= escape_javascript(content_tag(:li,link_to(@ad_banner.title,"##{@ad_banner.title}",:data=>{:toggle=>"tab"}))) %>').insertBefore("#new_ad_banner_tab_but");
$('<%= escape_javascript(render(:partial => "ad_banner_tab",:locals => {:ad_banner_tab => @ad_banner})) %>').insertAfter($("#ad_banner-tab-content").children(".tab-pane").last());
$('.modal').modal('hide');
$("#ad_banner-modal-info").empty();
$("#new-a-banner form").each(function(){this.reset();});
$('#new-a-banner').unbind();
$('#post-body-content').find(".nav.nav-tabs").children('li.active').removeClass("active");
$("#ad_banner-tab-content").children(".tab-pane").removeClass("active");
$('#post-body-content').find(".nav.nav-tabs").children('li[id!="new_ad_banner_tab_but"]').last().addClass("active");
$("#ad_banner-tab-content").children(".tab-pane").last().addClass("active");
<% if params[:action] && params[:action] =='create'%>
var trigger = $("#ad_banner-tab-content").children(".tab-pane").last().find(".preview_trigger");
new_url = trigger.attr("href").replace(/\/admin\/ad_banners\/.*\/preview/gi,"/admin/ad_banners/<%= @ad_banner.id %>/preview");
trigger.attr("href",new_url);
<% end %>

View File

@ -1,2 +0,0 @@
$('#show_preview').html("<%= escape_javascript(render(:partial => 'modal_preview',:locals => {:ad_banner => @ad_banner})) %>");
var start_modal_with_id = "slideshow-<%=@ad_banner.title.dehumanize%>"

View File

@ -1,104 +1,75 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
<%= stylesheet_link_tag "lib/main-list" %>
<% 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/modal-preview" %>
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Forms -->
<form class="form-horizontal main-forms">
<fieldset>
<%= f.error_messages %>
<!-- Input Area -->
<div class="input-area">
<!-- Input Area -->
<div class="input-area">
<!-- Module Tabs -->
<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>
<li>
<a href="#tag" data-toggle="tab"><%= t(:tags) %></a>
</li>
<li>
<a href="#type" data-toggle="tab"><%= t('ad_banner.type') %></a>
</li>
<li>
<a href="#frequency" data-toggle="tab"><%= t(:frequency) %></a>
</li>
<li>
<a href="#link" data-toggle="tab"><%= t(:link) %></a>
</li>
<li>
<a href="#imageupload" data-toggle="tab"><%= t(:image) %></a>
</li>
</ul>
<!-- Module Tabs -->
<div class="nav-name"><strong>Module</strong></div>
<ul class="nav nav-pills module-nav">
<li class="active">
<a href="#basic" data-toggle="tab">Basic</a>
</li>
<li>
<a href="#status" data-toggle="tab">Status</a>
</li>
<li>
<a href="#tag" data-toggle="tab">Tags</a>
</li>
<li>
<a href="#type" data-toggle="tab">Type</a>
</li>
<li>
<a href="#frequency" data-toggle="tab">Frequency</a>
</li>
<li>
<a href="#link" data-toggle="tab">Link</a>
</li>
<li>
<a href="#imageupload" data-toggle="tab">Images</a>
</li>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t('ad_banner.banner') %></label>
<div class="controls">
<%= f.select :ad_banner_id, @ad_banners.collect{|t| [ t.title, t.id ]} %>
</div>
</div>
<!-- Category -->
<div class="control-group">
<label class="control-label muted">Banner</label>
<div class="controls">
<%= select_tag 'ad_banner[id]',options_from_collection_for_select(AdBanner.all, "id", "title", @ad_image.ad_banner_id) , :class=>"input-medium" %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
<%= f.datetime_picker :postdate, :no_label => true %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
<%= f.datetime_picker :deadline, :no_label => true %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
<%= f.datetime_picker :post_date, :no_label => true %>
</div>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
<%= f.datetime_picker :unpost_date, :no_label => true %>
</div>
</div>
</div>
<!-- Status Module -->
<div class="tab-pane fade" id="status">
<!-- Status -->
<div class="control-group">
<label class="control-label muted">Status</label>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn">
<input type="checkbox" value="1"> Top
</label>
<label class="checkbox inline btn">
<input type="checkbox" value="2"> Hot
</label>
<label class="checkbox inline btn">
<input type="checkbox" value="3"> Hide
</label>
</div>
</div>
</div>
<!-- Tag Module -->
<!-- Tag Module -->
<div class="tab-pane fade" id="tag">
<!-- Tag -->
@ -116,83 +87,83 @@
</div>
<!-- Type Module -->
<div class="tab-pane fade" id="type">
<!-- Type Module -->
<div class="tab-pane fade" id="type">
<!-- Type -->
<div class="control-group">
<label class="control-label muted">Type</label>
<div class="controls">
<%= f.select :link_open ,AdImage::LINK_OPEN_TYPES%>
</div>
</div>
<!-- Type -->
<div class="control-group">
<label class="control-label muted"><%= t('ad_banner.type') %></label>
<div class="controls">
<%= f.select :link_open, AdImage::LINK_OPEN_TYPES.map{|a| [t("ad_banner.#{a}"), a]} %>
</div>
</div>
</div>
</div>
<!-- Frequency Module -->
<div class="tab-pane fade" id="frequency">
<!-- Frequency Module -->
<div class="tab-pane fade" id="frequency">
<!-- Frequency -->
<div class="control-group">
<label class="control-label muted">Frequency</label>
<div class="controls">
<%= f.text_field :weight ,:class=> 'span3',:placeholder=> t('ad.chinese_1') %>
<span class="help-block">Please enter the number</span>
</div>
</div>
<!-- Frequency -->
<div class="control-group">
<label class="control-label muted"><%= t(:frequency) %></label>
<div class="controls">
<%= f.number_field :weight, placeholder: t(:frequency), in: 1..99, maxlength: 2, onkeypress: "if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;" %>
<span class="help-block"><%= t('ad_banner.enter_number') %></span>
</div>
</div>
</div>
</div>
<!-- Link Module -->
<div class="tab-pane fade" id="link">
<!-- Link Module -->
<div class="tab-pane fade" id="link">
<!-- Link -->
<div class="control-group">
<label class="control-label muted">link</label>
<div class="controls">
<%= f.text_field :out_link ,:class=> 'span3',:placeholder=> "URL" %>
<span class="help-block">Please enter the URL</span>
</div>
</div>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls">
<%= f.text_field :out_link, placeholder: t(:url) %>
<span class="help-block"><%= t('ad_banner.enter_url') %></span>
</div>
</div>
</div>
</div>
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Module -->
<div class="tab-pane fade" id="imageupload">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix fileupload-edit" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @ad_image.file %>
<%= image_tag @ad_image.file %>
<% else %>
<%= image_tag "http://www.placehold.it/50x50/EFEFEF/AAAAAA" %>
<%end%>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :file %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_file %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @ad_image.file.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @ad_image.file.file %>
<%= image_tag @ad_image.file %>
<% else %>
<img src="http://www.placehold.it/50x50/EFEFEF/AAAAAA" />
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t(:select_image) %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :file %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
<div class="controls" data-toggle="buttons-checkbox">
<label class="checkbox inline btn btn-danger fileupload-remove">
<%= f.check_box :remove_file %><%= t(:remove) %>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
</div>
<!-- Language Tabs -->
<div class="nav-name"><strong><%= t(:language) %></strong></div>
<ul class="nav nav-pills language-nav">
<% @site_valid_locales.each_with_index do |locale, i| %>
@ -224,8 +195,8 @@
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.fields_for :text_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@ad_image.text_translations[locale] rescue nil) %>
<%= f.fields_for :context_translations do |f| %>
<%= f.cktext_area locale, rows: 5, class: "input-block-level", :value => (@ad_image.context_translations[locale] rescue nil) %>
<% end %>
</div>
</div>
@ -235,23 +206,12 @@
<% end %>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<%= f.hidden_field :id, :value => @ad_image.id %>
<div class="form-actions">
<%= f.submit t("submit"),:class=>"btn btn-primary" %>
<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %>
<!-- <button type="submit" class="btn btn-primary">Save</button>
<button type="button" class="btn">Preview</button>
<button type="button" class="btn">Cancel</button> -->
</div>
</fieldset>
</form>
<!-- Form Actions -->
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>

View File

@ -1,8 +1,5 @@
<%= flash_messages %>
<%= form_for @ad_image, :url => admin_ad_image_path, :html => { :class => 'form' } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<%= form_for @ad_image, url: admin_ad_image_path(@ad_image), html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -1,48 +1,56 @@
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('ad_image.image') %></th>
<th class="span1"><%= t('ad_image.post_date') %></th>
<th class="span1"><%= t('ad_image.unpost_date') %></th>
<th class="span1"><%= t('ad_image.context') %></th>
<th class="span1"><%= t('ad_image.out_link') %></th>
</tr>
</thead>
<tbody id="tbody_locations" class="sort-holder">
<% @ad_images.each do |ad_image| %>
<tr class="with_action">
<td><%= image_tag ad_image.file.thumb %>
<div class="quick-edit">
<ul class="nav nav-pills">
<% if is_admin?%>
<li><%= link_to t(:edit), edit_admin_ad_image_path(ad_image)%></li>
<li><%= link_to 'Destroy', admin_ad_image_path(ad_image), method: :delete , :confirm => t(:sure?) %></li>
<% set_default_index do
objects @ad_images
quick_edit_link type: 'edit',
link: 'edit_admin_ad_image_path'
# quick_edit_link type: 'detail'
quick_edit_link type: 'delete',
link: 'admin_ad_image_path'
# can have: title, warning, cancel and submit values
field type: 'image',
db_field: 'file',
translation: 'preview',
hide: 'phone'
# field type: 'status',
# db_field: @statuses,
# translation: 'status',
# hide: 'phone',
# sort: 'status'
field type: 'associated',
db_field: 'ad_banner',
model_field: 'title',
translation: 'ad_banner.banner',
hide: 'phone',
sort: 'ad_banner'
field db_field: 'title',
translation: 'title',
sort: 'title',
quick_edit: true,
header_class: 'span5',
sort: 'title'
field db_field: 'postdate',
translation: 'start_date',
hide: 'phone',
sort: 'start_date'
field db_field: 'deadline',
translation: 'end_date',
hide: 'phone',
sort: 'end_date'
field db_field: 'out_link',
translation: 'link',
sort: 'link',
display_option: 'link_to value, value'
# filter_field type: 'array',
# values: @statuses,
# translation: 'status'
# filter_field type: 'objects',
# values: @categories,
# translation: 'category',
# object_field: 'title'
# filter_field type: 'objects',
# values: @tags,
# translation: 'tags',
# object_field: 'name'
footer link: 'new_admin_ad_image_path'
end %>
<% end %>
</ul>
</div>
</td>
<td><%= ad_image.post_date %></td>
<td><%= ad_image.unpost_date %></td>
<td><%= ad_image.context %></td>
<td><%=link_to "#{ad_image.out_link}", ad_image.out_link %></td>
</tr>
<% end %>
</tbody>
</table>
<%if is_manager? %>
<!-- footer -->
<div class="bottomnav clearfix">
<div class="action pull-right">
<%= link_to content_tag(:i, nil, class: "icons-plus") + " " + t(:add_new), "#add-banner", :class => "btn btn-primary open-slide"%>
</div>
<div class="pagination pagination-centered">
<%= paginate @ad_images unless @ad_images.blank? %>
</div>
</div>
<div id="add-banner" class="nano" style="display:none">
<%= render 'new' %>
</div>
<% end %>
<%= render 'admin/default_index/index' %>

View File

@ -1,7 +1,5 @@
<%= flash_messages %>
<%= form_for @ad_image, :url => admin_create_ad_image_path, :html => { :class => 'form' ,:multipart => true} do |f| %>
<%= render :partial => "form", :locals => { :f => f } %>
<%= form_for @ad_image, url: admin_ad_images_path, html: {class: "form-horizontal main-forms"} do |f| %>
<fieldset>
<%= render partial: 'form', locals: {f: f} %>
</fieldset>
<% end %>

View File

@ -1,20 +1,9 @@
<div style='position:relative'>
<ul id='banner_nav' class='clear banner_nav-<%= @ad_banner.title.dehumanize %>'></ul>
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class='slideshow'>
<% (images = @ad_banner.ad_images).shuffle.each do |ad_image| %>
<% if ad_image.display? %>
<img src='<%= ad_image.file %>' alt='<%= ad_image.title || ' ' %>' title='<%= ad_image.title || ' ' %>' time_to_next='<%= @ad_banner.transition_msec %>' link_open='<%= ad_image.link_open %>' link_url='<%= ad_image_link(ad_image) %>' style=' <%= 'cursor:pointer;' if !ad_image_link(ad_image).blank? %>'/>
<% end %>
<div id='slideshow-<%= @ad_banner.title.dehumanize %>' class="cycle-slideshow" data-cycle-timeout="<%= @ad_banner.timeout_in_min %>" data-cycle-pager=".banner_nav_<%= @ad_banner.title.dehumanize %>" data-cycle-pager-template="<li><a href='#'></a></li>" data-cycle-pager-active-class="activeSlide" style="z-index: 0">
<% @ad_banner.ad_images.can_display.each do |ad_image| %>
<% link = ad_image_link(ad_image) %>
<%= image_tag ad_image.file, width: @ad_banner.width, height: @ad_banner.height, 'link_open' => ad_image.link_open, 'link_url' => link, style: ('cursor:pointer;' if link.present?) %>
<% end %>
</div>
<ul class='clear banner_nav banner_nav_<%= @ad_banner.title.dehumanize %>'></ul>
</div>
<script type='text/javascript'>
var banner = {"banner_name":"#slideshow-<%= @ad_banner.title.dehumanize %>",
"banner_fx":"<%= @ad_banner.ad_fx.nil? ? 'fade': @ad_banner.ad_fx %>",
"banner_pager":".banner_nav-<%= @ad_banner.title.dehumanize %>",
"image_count":"<%= @ad_banner.ad_images.length %>",
"image_loaded":0,
"time_to_next":<%= @ad_banner.transition_msec %>,
};
banners.push(banner);
</script>

View File

@ -1,4 +1,4 @@
<%if @ad_image && @ad_image.display? %>
<% if @ad_image %>
<h1 class="h1"><%= @ad_image.title %></h1>
<div class="info">
<div class="info1">

View File

@ -1,8 +1,6 @@
<div class="slideshow">
<% @ad_banner.ad_images.shuffle.each do |image| %>
<% if image.display? %>
<div class="slidebanner"><%= image_tag image.file.url, :class => 'slideImg' %></div>
<% end %>
<% @ad_banner.ad_images.can_display.shuffle.each do |image| %>
<div class="slidebanner"><%= image_tag image.file.url, :class => 'slideImg' %></div>
<% end %>
</div>
<div class="newlist clear">

View File

@ -8,10 +8,6 @@
<iframe src=<%= @preview_obj.get_preview_link %> style="width:1024px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(news_bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => news_bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || news_bulletin.context || " ")) %>
<%# end -%>
</p>
</div>
<div class="modal-footer">
@ -23,9 +19,6 @@
<script type="text/javascript">
$(document).ready(function() {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").on("show", function () {
// $("#news_bulletin-<%#=news_bulletin.title.dehumanize%>").find(".news_bulletin_slideshow").cycle({delay: -1000, fx: "<%#= news_bulletin.ad_fx.nil?? "fade": news_bulletin.ad_fx %>", timeoutFn: getTimeout });
// });
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});

View File

@ -75,6 +75,11 @@ module Orbit
config.to_prepare do
Devise::RegistrationsController.layout false
end
# Remove "field_with_errors"
config.action_view.field_error_proc = Proc.new { |html_tag, instance|
html_tag.html_safe
}
end
end
Orbit_Apps = []

View File

@ -46,8 +46,6 @@ Orbit::Application.routes.draw do
match 'ad_banners/:id/preview' => 'ad_banners#realtime_preview',:as => :realtime_preview_ad_banner,:via => :put
match 'ad_banners/:id/rename' => 'ad_banners#rename',:as => :rename_ad_banner,:via => :post
match 'new_ad_image' => 'ad_images#new',:as => :new_ad_image,:via => :get
match 'new_ad_image' => 'ad_images#create',:as => :create_ad_image,:via => :post
resources :ad_images ,:except => [:show]
resources :ad_banners #do

View File

@ -67,11 +67,9 @@ module ParserCommon
res << "<ul id='banner_nav' class='clear banner_nav-#{ad_banner.title.dehumanize}'></ul>"
res << "<div id='slideshow-#{ad_banner.title.dehumanize}' class='slideshow'>"
printable_ad_images = []
ad_banner.ad_images.each do |ad_image|
if ad_image.display?
ad_image.weight.times do
printable_ad_images << ad_image
end
ad_banner.ad_images.can_display.each do |ad_image|
ad_image.weight.times do
printable_ad_images << ad_image
end
end
printable_ad_images.shuffle!
@ -81,7 +79,6 @@ module ParserCommon
res << "alt='#{ad_image.title || ' '}' "
res << "time_to_next='#{ad_banner.transition_msec}' "
res << "link_open='#{ad_image.link_open}' "
# res << "link_url='#{(ad_image.direct_to_after_click?? ad_image.out_link : ad_banner.context) || ' '}' "
res << "link_url='#{(ad_image.out_link)}' "
res << "style='#{'display:none;' if hide} #{'cursor:pointer;' if !ad_image.out_link.blank?}'"
res << "/>"

View File

@ -23,6 +23,7 @@ namespace :new_ui do
migrate_categories
migrate_approval_on_object
migrate_managers
migrate_ad_images_dates
end
# :category_name is optional, depends on the naming of the category model: if no conventional, specify it
@ -38,6 +39,10 @@ namespace :new_ui do
fix_tagged_ids
end
task :migrate_ad_images_dates => :environment do
migrate_ad_images_dates
end
def migrate_categories(args = nil)
if args && args[:app_key] && args[:model_name]
migrate_category(args[:app_key], args[:model_name], args[:category_name])
@ -195,4 +200,17 @@ namespace :new_ui do
end
end
def migrate_ad_images_dates
@db ||= Mongoid.database
collection_ad_image = @db['ad_images']
ad_images = collection_ad_image.find()
ad_images.each do |ad_image|
ad_image['postdate'] = ad_image['post_date']
ad_image['deadline'] = ad_image['unpost_date']
ad_image.delete('post_date')
ad_image.delete('unpost_date')
collection_ad_image.save(ad_image)
end
end
end

View File

@ -4,11 +4,30 @@ en:
ad_banner: Ad Banner
banner: Banner
banner_name: Banner Name
edit_banner: Edit Banner
effect: Effect
enter_number: Please enter a number
enter_url: Please enter the URL
local: Current page
name_only_english: Banner Name can only in English
new_banner: New Banner
new_window: New window
number_milliseconds: Please enter the number of milliseconds
number_seconds: Please enter the number of seconds
size: Size
transition_interval: Transition Interval
transition_speed: Transition Speed
type: Type
banner_name_note: Banner Name only english
ste: Transition Interval
ste_note: Please enter the number of seconds
best_size: Best Size
effect: Effect
all: All
categories: Categories
add: Add

View File

@ -10,10 +10,6 @@
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %> style="width:1024px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %>
<%# end -%>
</p>
</div>
<div class="modal-footer">
@ -41,9 +37,6 @@
<script type="text/javascript">
$(document).ready(function() {
// $("#bulletin-<%#=bulletin.title.dehumanize%>").on("show", function () {
// $("#bulletin-<%#=bulletin.title.dehumanize%>").find(".bulletin_slideshow").cycle({delay: -1000, fx: "<%#= bulletin.ad_fx.nil?? "fade": bulletin.ad_fx %>", timeoutFn: getTimeout });
// });
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});

View File

@ -25,7 +25,6 @@
<% end %>
<div class="nav-name"><strong><%= t(:module) %></strong></div>
<ul class="nav nav-pills module-nav">
<li></li>
<li class="active">
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
</li>
@ -121,7 +120,6 @@
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @bulletin.image.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @bulletin.image.file %>
@ -260,6 +258,7 @@
</div>
</div>
</div>
</div>

View File

@ -11,10 +11,6 @@
<iframe src=<%= panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.category.id ,:preview=>true) %> style="width:1000px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(bulletin).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => bulletin.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || bulletin.context || " ")) %>
<%# end -%>
</p>
</div>
<div class="modal-footer">
@ -27,9 +23,6 @@
<script type="text/javascript">
$(document).ready(function() {
// $("#bulletin-<%#=bulletin.title.dehumanize%>").on("show", function () {
// $("#bulletin-<%#=bulletin.title.dehumanize%>").find(".bulletin_slideshow").cycle({delay: -1000, fx: "<%#= bulletin.ad_fx.nil?? "fade": bulletin.ad_fx %>", timeoutFn: getTimeout });
// });
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});

View File

@ -11,10 +11,6 @@
<iframe src=<%= panel_page_content_back_end_view_path(page_context.page_id, :category_id => page_context.page_context_category.id ,:preview=>true) %> style="width:1000px;height:300px" >
</iframe>
<%# preview_block_ad_images_helper(page_context).each do |ad_image| -%>
<%#= image_tag ad_image.file,:alt => (ad_image.title[locale] || " "),:time_to_next => page_context.transition_msec,:link_open=> ad_image.link_open, :link_url =>((ad_image.out_link || page_context.context || " ")) %>
<%# end -%>
</p>
</div>
<div class="modal-footer">
@ -27,9 +23,6 @@
<script type="text/javascript">
$(document).ready(function() {
// $("#page_context-<%#=page_context.title.dehumanize%>").on("show", function () {
// $("#page_context-<%#=page_context.title.dehumanize%>").find(".page_context_slideshow").cycle({delay: -1000, fx: "<%#= page_context.ad_fx.nil?? "fade": page_context.ad_fx %>", timeoutFn: getTimeout });
// });
$(".modal").on("hidden", function () {
$("#show_preview").remove();
});