eremail/app/views/admin/er_emails/_form.html.erb

213 lines
7.6 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<% 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/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<%= f.error_messages %>
<!-- 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>
</ul>
<!-- Module -->
<div class="tab-content module-area">
<!-- Basic Module -->
<div class="tab-pane fade in active" id="basic">
<!-- Category -->
<div class="control-group">
<label class="control-label muted"><%= t(:category) %></label>
<div class="controls">
<%= select_category(f, @module_app) %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t("er_email.mail_sentdate") %></label>
<div class="controls">
<%= f.datetime_picker :mail_sentdate, :no_label => true %>
</div>
</div>
<!-- Mail Group -->
<div class="control-group">
<label class="control-label muted"><%= t("er_email.mail_to") %></label>
<div class="controls">
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_er[email_member_ids][]', email_members: @email_er.email_members} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"></label>
<div class="controls">
<span class="help-block"><%= "#{t("er_email.other_mailaddress")}(#{t("er_email.other_mailaddress_note")})"%> </span>
<%= f.text_area :other_mailaddress, :class=>"span12", :cols=>"25", :rows=>"10" %>
<span class="help-block"><%= "#{t("er_email.mail_to_note")}"%> </span>
</div>
</div>
</div>
</div>
<!-- Language -->
<div class="tab-content language-area">
<!-- English -->
<div class="tab-pane fade in active en">
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t("er_email.mail_subject") %></label>
<div class="controls">
<%= f.text_field :mail_subject, class: "input-block-level", placeholder: t("er_email.mail_subject") %>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t("er_email.mail_content") %></label>
<div class="controls">
<%#= f.text_area :mail_content, :style=>"width:100%", :class => 'ckeditor input-block-level' %>
<%= f.cktext_area :mail_content, rows: 5, class: "input-block-level" %>
</div>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<%= t("er_email.email_file_limit") %>
<!-- Exist -->
<% if @email_er && !@email_er.email_er_files.blank? %>
<div class="exist">
<% @email_er.email_er_files.each_with_index do |email_er_file, i| %>
<%= f.fields_for :email_er_files, email_er_file do |f| %>
<%= render :partial => 'form_file', :object => email_er_file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'email_er_file_field_count', @email_er.email_er_files.count %>
<a id="add_file" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions">
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %>
<%= link_to t('cancel'), admin_er_emails_path, :class=>"btn" %>
</div>
<span id='show_preview'>
<div class="modal hide fade in banner-preview" id="">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t(:preview) %></h3>
</div>
<div class="modal-body">
<iframe id="preview-iframe" src=""></iframe>
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t(:close) %></a>
</div>
</div>
</span>
<% content_for :page_specific_javascript do %>
<script>
$(function() {
$("#main-wrap").after("");
$(document).on('click', '#add_file', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_email_er_files", "g");
var on = $('.language-nav li.active').index();
var le = $(this).parent('.add-btn').prev('.add-target').children('.start-line').length;
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_file', f, :email_er_files) %>").replace(old_id, new_id));
$(this).parent('.add-btn').prev('.add-target').children('.start-line').eq(le).children('.input-append').find('.tab-content').each(function() {
$(this).children('.tab-pane').eq(on).addClass('in active').siblings().removeClass('in active');
});
formTip();
});
$(document).on('click', '.delete_file', function(){
$(this).parents('.input-prepend').remove();
});
$(document).on('click', '.remove_existing_record', function(){
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
});
$('#remind-check').prop('checked') ? '':$('.content-box').addClass('hide')
$('#remind-check').on('change', function() {
$(this).prop('checked') ? $('.content-box').removeClass('hide'):$('.content-box').addClass('hide')
})
$('#button_for_preview').click(function(){
var method = $('.main-forms input[name="_method"]').val();
$('.main-forms input[name="_method"]').val("post");
for ( instance in CKEDITOR.instances )
CKEDITOR.instances[instance].updateElement();
var formData = new FormData( $('.main-forms')[0] );
formData.append("preview_type", ( (method==undefined) ? "new" : "edit" ));
formData.append("email_er_id", '<%= @email_er.id.to_s %>');
$.ajax({
type: "post",
url: '<%= admin_er_email_preview_path %>',
data : formData,
processData: false,
contentType: false
}).done(function(data){
$('.modal-body iframe').attr('src',data);
$('#show_preview .modal').modal();
$('#show_preview .modal').height(function() {
return $(window).height() * 0.7;
});
var slug = data.split('/')[(data.split('/').length-1)];
$('#preview-iframe').on('load', function(){
$.get('/admin/er_email/destroy_preview/'+slug,function(data){
});
});
});
$('.main-forms input[name="_method"]').val(method);
return false;
});
});
</script>
<% end %>