adbanner-test/app/views/admin/ad_images/_form.html.erb

304 lines
12 KiB
Plaintext
Raw Normal View History

<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "lib/main-forms" %>
<%= stylesheet_link_tag "lib/fileupload" %>
2022-01-03 11:56:30 +00:00
<%= stylesheet_link_tag "banner/jplayer.blue.monday.min" %>
<% 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" %>
2022-01-03 11:56:30 +00:00
<%= javascript_include_tag "banner/jquery.jplayer.min" %>
<% end %>
<style type="text/css">
.fileupload .video-thumbnail{
max-height: none;
display: inline-block;
width: 30em;
height: 20em;
}
</style>
<%#= f.error_messages %>
<!-- Input Area -->
<div class="input-area">
<!-- Module -->
2014-08-14 11:54:21 +00:00
<div class="tab-content">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
2021-04-10 09:12:40 +00:00
<div class="control-group">
2021-04-10 09:12:40 +00:00
<label class="control-label muted"><%= t(:type) %></label>
<div class="controls">
2021-04-10 09:12:40 +00:00
<div><%= t("choose_type") %></div>
<%=
select_tag "ad_image[exchange_item]", options_for_select(@item,@item_choose), prompt: t('select')
%>
</div>
</div>
<input type="hidden" name="ad_image[banner_id]" value="<%= @ad_banner.id.to_s %>">
<div id="exchange_item_1" style="display:none">
<!-- Images Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:image) %></label>
<div class="controls">
<div><%= t("ad_banner.best_size") %>: <%= @ad_banner.width %>px X <%= @ad_banner.height %>px</div>
<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.url %>
<% else %>
2022-01-05 07:52:40 +00:00
<img src="/annc_url?url=http://www.placehold.it/200x80/EFEFEF/AAAAAA&text=<%= @ad_banner.width %>x<%= @ad_banner.height %>" />
2021-04-10 09:12:40 +00:00
<% 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, accept: "image/*" %>
2021-04-10 09:12:40 +00:00
</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>
2014-08-14 11:54:21 +00:00
</div>
</div>
</div>
</div>
2021-04-10 09:12:40 +00:00
<div id="exchange_item_2" style="display:none">
<div class="control-group input-title">
<label class="control-label muted"><%= t(:youtube) %></label>
<div class="controls">
<div><%= 'ex. https://www.youtube.com/watch?v=UHF2e3lyPVU' %></div>
<%= f.text_field :youtube, placeholder: t(:youtube), class: 'input-block-level' %>
</div>
</div>
</div>
<div id="exchange_item_3" style="display:none">
2021-10-22 15:31:10 +00:00
<!-- Video Upload -->
<div class="control-group">
<label class="control-label muted"><%= t(:video) %></label>
<div class="controls">
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @ad_image.file.file %>" data-provides="fileupload">
<div class="fileupload-new video-thumbnail thumbnail pull-left">
2021-10-22 15:31:10 +00:00
<%= render partial: "jplayer",locals:{i: 1,file_name: f.object["video_file"],file_url: f.object.video_file.url,file_webm_url: (f.object.video_file_webm.url rescue nil),not_ready: true } %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<span class="btn btn-file">
<span class="fileupload-new"><%= t("ad_banner.select_video") %></span>
<span class="fileupload-exists"><%= t(:change) %></span>
<%= f.file_field :video_file, accept: "video/mp4,video/x-m4v,video/ogg,video/webm" %>
</span>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
2022-01-05 07:52:40 +00:00
<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 class="control-group">
<label class="control-label muted"><%= t("ad_banner.video_snapshot") %></label>
<div class="controls">
<div><%= t("ad_banner.best_size") %>: <%= @ad_banner.width %>px X <%= @ad_banner.height %>px</div>
<div class="fileupload fileupload-new clearfix <%= 'fileupload-edit' if @ad_image.video_snapshot.file %>" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @ad_image.video_snapshot.file %>
<%= image_tag @ad_image.video_snapshot.url %>
<% else %>
<img src="/annc_url?url=http://www.placehold.it/200x80/EFEFEF/AAAAAA&text=<%= @ad_banner.width %>x<%= @ad_banner.height %>" />
<% 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 :video_snapshot, accept: "image/*" %>
</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>
2021-10-22 15:31:10 +00:00
<div class="control-group">
<label for="first_name" class="control-label muted" function="field_label">
<%= t("ad_banner.auto_convert_video")%>
</label>
<div class="controls">
<label class="checkbox">
<%= f.check_box :auto_convert_video %>
</label>
</div>
</div>
</div>
2014-08-14 11:54:21 +00:00
<!-- Title-->
<div class="control-group">
<label for="first_name" class="control-label muted" function="field_label"><%= t("title")%></label>
<div class="controls add-input">
<div class="input-append">
<div class="tab-content">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="tab-pane fade <%= ( i == 0 ) ? "active in" : '' %>" 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 %>
</div>
<% end %>
</div>
<div class="btn-group" data-toggle="buttons-radio">
<% @site_in_use_locales.each_with_index do |locale, i| %>
<a class="btn <%= ( i == 0 ) ? "active" : '' %>" href="#title_<%= locale %>" data-toggle="tab"><%= t(locale.to_s) %></a>
<% end %>
</div>
</div>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:start_date) %></label>
<div class="controls">
2015-09-15 08:13:02 +00:00
<%= f.datetime_picker :postdate, :no_label => true, :new_record => @ad_image.new_record? %>
</div>
</div>
<!-- Date Time Picker -->
<div class="control-group">
<label class="control-label muted"><%= t(:end_date) %></label>
<div class="controls">
2015-09-15 08:13:02 +00:00
<%= f.datetime_picker :deadline, :no_label => true, :new_record => @ad_image.new_record? %>
</div>
</div>
<!-- Link -->
<div class="control-group">
<label class="control-label muted"><%= t(:link) %></label>
<div class="controls">
2014-08-14 11:54:21 +00:00
<%= f.text_field :out_link, placeholder: t('ad_banner.enter_url') %>
</div>
</div>
<div class="control-group">
2014-08-14 11:54:21 +00:00
<label class="control-label muted"><%= t('ad_banner.type') %></label>
<div class="controls">
2014-08-14 11:54:21 +00:00
<%= f.select :link_open, AdImage::LINK_OPEN_TYPES.map{|a| [t("ad_banner.#{a}"), a]} %>
</div>
</div>
2016-05-18 08:29:39 +00:00
<!-- language-selection -->
<div class="control-group">
<label class="control-label muted"><%= t(:select_language) %></label>
<div class="controls">
<% @site_in_use_locales.each do |locale| %>
<label class="checkbox">
<%= check_box_tag "ad_image[language_enabled][]", locale, (@ad_image.language_enabled.include?(locale.to_s) rescue false) %>
<%= t(locale.to_s) %>
</label>
<% end %>
</div>
</div>
</div>
</div>
<!-- Language Tabs -->
<ul class="nav nav-pills language-nav">
2014-07-21 03:11:08 +00:00
<% @site_in_use_locales.each_with_index do |locale, i| %>
<li class="<%= 'active' if i == 0 %>">
<a data-toggle="tab" href=".<%= locale %>"><%= t(locale.to_s) %></a>
</li>
<% end %>
</ul>
<!-- Language -->
<div class="tab-content language-area">
2014-07-21 03:11:08 +00:00
<% @site_in_use_locales.each_with_index do |locale, i| %>
<div class="<%= locale %> tab-pane fade <%= ( i == 0 ) ? "in active" : '' %>">
<!-- Content -->
<div class="control-group input-content">
2014-08-14 11:54:21 +00:00
<label class="control-label muted"><%= t(:description) %> (<%= t(locale.to_s) %>)</label>
<div class="controls">
<div class="textarea">
<%= 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>
</div>
</div>
<% end %>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
2014-08-14 11:54:21 +00:00
<input type="hidden" name="referer_url" value="<%= request.referer %>">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
</div>
<script type="text/javascript">
var form = new FormValidator($("#new_ad_image"));
2021-04-10 09:12:40 +00:00
$("div#exchange_item_" + $("#ad_image_exchange_item").val()).show();
$("#ad_image_exchange_item").on("change",function(){
$("div[id*=exchange_item]").hide();
$("div#exchange_item_" + $(this).val()).show();
})
function checkSelect()
{
if(document.getElementById("ad_image_exchange_item").value == "")
{
alert("<%= t('ad_banner.please_choose_exchange_item') %>");
2021-04-10 09:12:40 +00:00
return false;
}
return true;
}
$(document).ready(function(){
2022-10-04 05:14:34 +00:00
jplayer_ready_func_1();
$('#ad_image_video_file').change(function(){
var file = this.files ? this.files[0] : null;
var value = this.value;
if(file || value){
var file_name = file ? file.name : value.split(/[\/\\]/).last();
var type = get_video_type(file_name);
var file_url = window.URL ? window.URL.createObjectURL(file) : "file://"+ value;
$("#jquery_jplayer_1").parents('.fileupload-new').css('display','');
$("#jquery_jplayer_1").jPlayer('destroy');
jPlayer_1_data["title"] = file_name;
jPlayer_1_data[type] = file_url;
$("#jquery_jplayer_1").jPlayer(jPlayer_1);
}
})
$('#exchange_item_3 [data-dismiss="fileupload"]').on("click",function(){
$("#jquery_jplayer_1").parents('.fileupload-new').css('display','none');
})
})
</script>