registered-sites/app/views/admin/registered_sites/announcement.erb

100 lines
3.0 KiB
Plaintext

<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css" />
<script type="text/javascript">
$('div#index_table').ready(function(){
$("#detail_div").dialog({
autoOpen: false,
modal: true,
show: "blind",
hide: "explode",
maxHeight: 500,
width: '50em',
close:function(){
see_flag = false
},
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
}
});
})
function get_watch_list(item) {
$.ajax({
url : "<%= get_watch_list_admin_registered_sites_path %>",
dataType : "json",
data: {data: item},
type : "post",
error: function(){
alert('init upload process failed, please try again later.')
},
success: function(data){
var html_data = '<table><tbody>'
$(data).each(function(i,v){
var par1;
if (v[0][1] == ''){
par1 = v[0][0]
}else{
par1 = '<a target="_blank" href="http://' + v[0][1]+'">'+v[0][0]+'</a>&nbsp;:'
}
html_data = html_data + "<tr><td>"+ par1+"</td><td>"+v[1]+"</td></tr>"
})
html_data = html_data + '</tbody></table'
$("#detail_div").html(html_data)
$("#detail_div").dialog("open")
}
})
}
</script>
<div id="index_table">
<div id="detail_div">
</div>
<button style="margin-bottom: 1em;" onclick="window.location.href='/admin/registered_sites/new/edit_annc'">
<%= t('site_annc.new') %>
</button>
<table class="table main-list">
<thead>
<tr class="sort-header">
<th style="width: 50%;">
<%= t('site_annc.title') %>(中文/英文)
</th>
<th style="width: 20%;">
<%= t('site_annc.watch_list_count') %>
</th>
<th style="width: 30%;">
<%= t('site_annc.see_more_link') %>
</th>
</tr>
</thead>
<tbody>
<% @site_anncs.each do |site_annc| %>
<tr>
<td>
<%= site_annc[:title][:zh_tw].to_s.html_safe %>
/
<%= site_annc[:title][:en].to_s.html_safe %>
<div class="quick-edit" style="display: flex;">
<a href="/admin/registered_sites/<%= site_annc.id.to_s %>/edit_annc" style="margin-right: 1em;">
<%= t(:edit) %></a>
<a href="/admin/registered_sites/<%= site_annc.id.to_s %>/delete_annc">delete</a>
</div>
</td>
<td>
<a style="cursor: pointer;" onclick="get_watch_list('<%= site_annc.id %>')">
<%= site_annc.watch_list.count %>
</a>
</td>
<td>
<%= link_to site_annc.see_more_link.to_s,site_annc.see_more_link.to_s %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%=
content_tag :div, class: "bottomnav clearfix" do
content_tag :div, paginate(@site_anncs), class: "pagination pagination-centered"
end
%>
</div>