77 lines
2.7 KiB
Plaintext
77 lines
2.7 KiB
Plaintext
|
<!-- <%= type.classify %> -->
|
||
|
<%
|
||
|
relation_field = "#{f.object_name}_#{type.pluralize}"
|
||
|
records = f.object.send(relation_field)
|
||
|
%>
|
||
|
<div class="tab-pane fade <%= @active_class %>" id="<%=type%>">
|
||
|
<!-- Add -->
|
||
|
<div class="add-target">
|
||
|
<% records.each do |record| %>
|
||
|
<%= f.fields_for relation_field, record do |f| %>
|
||
|
<%= render :partial => "backup_form_block", :locals=>{:f=>f} %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</div>
|
||
|
<p class="add-btn">
|
||
|
<%= hidden_field_tag "#{relation_field}_count", records.count %>
|
||
|
<a class="btn btn-primary add_backup_setting <%=type%>" href="#"><%= t("client_management.add_backup_setting") %></a>
|
||
|
</p>
|
||
|
</div>
|
||
|
<style type="text/css">
|
||
|
.block_remove_btn{
|
||
|
color: red;
|
||
|
margin-right: 0.3em;
|
||
|
background: transparent;
|
||
|
border: 1px solid red;
|
||
|
margin-bottom: 1em;
|
||
|
padding: 0.4em 0.8em;
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
.block_remove_btn:hover{
|
||
|
font-size: 1.3em;
|
||
|
top: 0.3em;
|
||
|
position: relative;
|
||
|
}
|
||
|
.backup_form_block{
|
||
|
border: 0.3em solid #666;
|
||
|
margin-bottom: 0.5em;
|
||
|
padding-bottom: 1em;
|
||
|
}
|
||
|
.main-forms fieldset .form-actions{
|
||
|
background: #fff;
|
||
|
}
|
||
|
</style>
|
||
|
<script type="text/javascript">
|
||
|
$(document).ready(function(){
|
||
|
$(document).on('click', ".add_backup_setting.<%=type%>", function(){
|
||
|
var _this = $(this);
|
||
|
var new_id = _this.prev().attr('value');
|
||
|
var old_id = new RegExp("new_<%=relation_field%>", "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 'backup_form_block', f, relation_field) %>").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','.backup_timers',function(){
|
||
|
var _this = $(this);
|
||
|
_this.not('.hasDatepicker').ui_timepicker({timeFormat: 'HH:mm'});
|
||
|
_this.trigger('focus');
|
||
|
})
|
||
|
$(document).on('click','.block_remove_btn',function(){
|
||
|
var backup_form_block = $(this).parents('.backup_form_block').eq(0);
|
||
|
if(backup_form_block.hasClass("new_record")){
|
||
|
backup_form_block.remove()
|
||
|
}else{
|
||
|
if(window.confirm('<%=t("client_management.are_you_sure_to_delete")%>')){
|
||
|
backup_form_block.addClass('hide');
|
||
|
backup_form_block.find('.should_destroy').val('true');
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
})
|
||
|
|
||
|
</script>
|