registered-sites/app/views/admin/customization_logs/_form.html.erb

115 lines
4.1 KiB
Plaintext

<% 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/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<!-- Input Area -->
<div class="input-area">
<!-- Language -->
<div class="tab-content language-area">
<!-- site domain and title -->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:domain) %></label>
<div class="controls">
<a href="http://<%= @site.site_domain %>/" target="_blank"><%= @site.title.nil? ? @site.site_domain : @site.title %></a>
</div>
</div>
<!-- Title-->
<div class="control-group input-title">
<label class="control-label muted"><%= t(:title) %></label>
<div class="controls">
<%= f.text_field :title, class: "input-block-level", placeholder: t(:title) %>
</div>
</div>
<!-- Content -->
<div class="control-group input-content">
<label class="control-label muted"><%= t(:content) %></label>
<div class="controls">
<div class="textarea">
<%= f.cktext_area :content, rows: 5, class: "input-block-level" %>
</div>
</div>
</div>
</div>
<!-- File -->
<div class="control-group">
<label class="control-label muted"><%= t(:file_) %></label>
<div class="controls">
<!-- Exist -->
<% if @log && !@log.site_log_files.blank? %>
<div class="exist">
<% @log.site_log_files.each_with_index do |file, i| %>
<%= f.fields_for :site_log_files, file do |f| %>
<%= render :partial => 'form_file', :object => file, :locals => {:f => f, :i => i} %>
<% end %>
<% end %>
<hr>
</div>
<% end %>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'plugin_file_field_count', @log.site_log_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">
<%= get_referer_url[:action] rescue "" %>
<%= f.submit t('submit'), class: 'btn btn-primary' %>
<input type="hidden" name="referer_url" value="<%= get_referer_url %>">
<input type="hidden" name="site_log[registered_site_id]" value="<%= @site.id.to_s %>">
<% if params[:action] == "new" %>
<input type="hidden" name="site_log[create_user_id]" value="<%= current_user.id.to_s %>">
<% else %>
<input type="hidden" name="site_log[update_user_id]" value="<%= current_user.id.to_s %>">
<% end %>
<%= link_to t('cancel'), admin_customization_logs_path, :class=>"btn" %>
</div>
<script>
$('.main-forms').find('.add-on').tooltip().end().on('click', '.trigger, .delete_file, .remove_existing_record', function() {
if($(this).hasClass('trigger')) {
var new_id = $(this).prev().attr('value');
console.log(new_id);
var old_id = new RegExp("new_site_log_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, :site_log_files) %>").replace(old_id, new_id));
} else if($(this).hasClass('delete_file')) {
$(this).parents('.input-prepend').remove();
} else if($(this).hasClass('remove_existing_record')) {
if(confirm("<%= I18n.t(:sure?)%>")){
$(this).children('.should_destroy').attr('value', 1);
$(this).parents('.start-line').hide();
}
}
});
</script>