archive1/app/views/admin/archive_files/categories_order.html.erb

56 lines
1.6 KiB
Plaintext

<% all_locales = I18n.available_locales %>
<% count = all_locales.length %>
<script>
$('form[name="category_sort_number_form"]').submit(function(){
var eles = $('form[name="category_sort_number_form"]').serialize().split('&')
var keys=[],values=[]
for (var ele in eles){
var temp = ele.split('=')
keys.push(temp[0])
values.push(temp[1])
}
if (navigator.onLine) {
$.ajax({
url : "/admin/archive_files/categories_order",
dataType : "json",
type : "post",
data:{form_sort_data:[keys,values]},
success:function(data){
location.reload();
},
error:function(){
alert('Your server has some problem, please try again later!')
}
})
} else {
alert('Please connect the network and try again later!')
}
return false;
})
</script>
<form method="post" action="/admin/archive_files/categories_order" name="category_sort_number_form" >
<table>
<thead style='line-height: 3;'>
<tr style="text-align: center;">
<td><%= t('archive.category') %></td>
<td><%= t('archive.sort_number') %></td>
</tr>
</thead>
<tbody style='line-height: 4;'>
<% @cats.each do |cat| %>
<tr>
<td style='padding-right: 10px;'>
<% all_locales.each_with_index do |locale,index| %>
<%= "#{cat[0][:title][locale]}" %>
<%= index!=(count-1) ? "/" : ":" %>
<% end %>
</td>
<td>
<input style='margin: 0;' type="number" name="sort_number-<%= cat[0].id %>" value="<%= cat[1].to_s %>">
</td>
</tr>
<% end %>
</tbody>
</table>
<input type="submit" value="<%= t('archive.save') %>">
</form>