file-manager/app/views/admin/file_managers/settings.html.erb

106 lines
4.3 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.

<%= stylesheet_link_tag 'file_manager/application', media: 'all' %>
<%= javascript_include_tag 'file_manager/file_manager' %>
<style>
.path_setting_block{
border: 1px solid black;
padding: 1em;
position: relative;
}
.remove_btn_old, .remove_btn{
color: red;
float: right;
position: absolute;
right: 0;
top: 0;
background: #ffc3c3;
padding: 0.1em 0.5em;
cursor: pointer;
}
#browse_model .modal-body{
font-size: 1rem;
}
</style>
<div class="modal hide fade in" id="browse_model" tabindex="-1" role="dialog" data-backdrop="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("file_manager.select_folder") %></h3>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<a href="#" class="btn" data-dismiss="modal"><%= t("file_manager.select_current_folder") %></a>
</div>
</div>
</div>
</div>
<h3><%= t('file_manager.path_setting') %></h3>
<%= form_for( @root, url: admin_file_managers_update_settings_path, html: {class: 'form-horizontal'} ) do |f| %>
<% if current_user.is_admin? %>
<div class="control-group">
<%= f.label :disable_path_traversal, t("file_manager.disable_path_traversal") , :class=>"control-label" %>
<div class="controls">
<%= f.check_box :disable_path_traversal %>
</div>
</div>
<% end %>
<% @root.file_manager_settings.each_with_index do |setting, i| %>
<%= f.fields_for :file_manager_settings, setting do |f| %>
<%= render :partial => 'form_setting', object: f.object, locals: {f: f, i: i} %>
<% end %>
<% end %>
<a id="">
</a>
<!-- Add -->
<div class="add-target">
</div>
<p class="add-btn">
<%= hidden_field_tag 'file_manager_settings_count', @root.file_manager_settings.count %>
<a id="add_file_manager_setting" class="trigger btn btn-small btn-primary"><i class="icons-plus"></i> <%= t(:add) %></a>
</p>
<!-- 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 %>">
</div>
<script>
$(document).on('click', '#add_file_manager_setting', function(){
var new_id = $(this).prev().attr('value');
var old_id = new RegExp("new_file_manager_settings", "g");
$(this).prev().attr('value', parseInt(new_id) + 1);
$(this).parent().siblings('.add-target').append(("<%= escape_javascript(add_attribute 'form_setting', f, :file_manager_settings) %>").replace(old_id, new_id).replace('settings_count', $('.path_setting_block').length + 1));
})
$(document).on('click', '.remove_btn_old', function(){
if(window.confirm('<%=t('file_manager.are_you_sure_to_delete')%>')){
$(this).children('.should_destroy').attr('value', 1);
$(this).parent().hide();
}
})
$(document).on('click', '.remove_btn', function(){
if(window.confirm('<%=t('file_manager.are_you_sure_to_delete')%>')){
$(this).parent().remove();
}
})
$(document).on('click', '.browse_path', function(){
var that = $(this)
var path = that.siblings('input').val();
window.current_browse_input = that.siblings('input');
window.current_path = path;
$.get("/xhr/file_manager/" + "?select_mode=true&path="+path).done(function(data){
window.only_select_folder = true;
$("#browse_model .modal-body").html('<h4 class="breadcrumb-index"></h4>'+ data);
$("#browse_model").modal('show');
change_breadcrumb();
}).fail(function(){
alert("No such file or directory!");
that.siblings('input').val('');
});
})
$("#browse_model").on('hidden.bs.modal', function () {
window.current_browse_input.val(window.current_path);
});
</script>
<% end %>