<%= content_for(:header_tags) do %>
    <%= import_ke(enable_at: false, prettify: false, init_activity: true) %>
<% end %>

<script type="text/javascript">
    $(function(){
        $("#RSide").removeAttr("id");
        $("#Container").css("width","1000px");
    });
</script>
<script>
    $(function() {
        sd_create_editor_from_data(<%= @news.id%>,null,"100%", "<%=@news.class.to_s%>");
        showNormalImage('message_description_<%= @news.id %>');
    });
</script>

<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @news.id%>').show();" onmouseout="$('#message_setting_<%= @news.id%>').hide();">
  <div class="postThemeContainer">
    <div class="postDetailPortrait">
      <%= link_to image_tag(url_to_avatar(@news.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@news.author) %>
    </div>
    <div class="postThemeWrap">
      <% if User.current.allowed_to?(:manage_news, @project)%>
          <div class="homepagePostSetting" id="message_setting_<%= @news.id%>" style="display: none">
            <ul>
              <li class="homepagePostSettingIcon">
                <ul class="homepagePostSettiongText">
                  <% if hidden_unproject_infos %>
                      <li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')")  %></li>
                  <% else %>
                      <li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{@news.id}','#{User.current.id}','news')")  %></li>
                  <% end %>
                  <li>
                    <%= link_to(
                                l(:button_edit),
                                {:action => 'edit', :id => @news},
                                :class => 'postOptionLink'
                        ) if User.current.allowed_to?(:manage_news, @project) %>
                  </li>
                  <li>
                    <%= delete_link(
                                news_path(@news),
                                :data => {:confirm => l(:text_are_you_sure)},
                                :class => 'postOptionLink'
                        ) if User.current.allowed_to?(:manage_news, @project) %>
                  </li>
                </ul>
              </li>
            </ul>
          </div>
      <% elsif User.current.logged? %>
          <div class="homepagePostSetting" id="message_setting_<%= @news.id%>" style="display: none">
            <ul>
              <li class="homepagePostSettingIcon">
                <ul class="homepagePostSettiongText">
                  <li><%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{@news.id}','#{User.current.id}','news')")  %></li>
                </ul>
              </li>
            </ul>
          </div>
      <%end%>
      <div class="postDetailTitle fl">
        <a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">新闻: <%= @news.title%></a>
      </div>
      <div class="cl"></div>

      <div class="postDetailCreater">
        <% if @news.try(:author).try(:realname) == ' ' %>
            <%= link_to @news.try(:author), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
        <% else %>
            <%= link_to @news.try(:author).try(:realname), user_path(@news.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
        <% end %>
      </div>
      <div class="postDetailDate mb5"><%= format_time( @news.created_on)%></div>
      <div class="cl"></div>
      <div class="homepagePostIntro memo-content upload_img break_word" id="message_description_<%= @news.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
        <%= @news.description.html_safe%>
      </div>
      <div class="cl"></div>
      <div class="mt10" style="font-weight:normal;">
        <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => @news} %>
      </div>
    </div>
    <div class="cl"></div>
  </div>
  <div class="cl"></div>
  <div class="homepagePostReply">
    <%= render :partial => 'news/news_all_replies', :locals => {:object => @project} %>
  </div>
</div>
<script type="text/javascript">
    $(function(){
        $("#news_submit_comment").one('click',function(){
            submitComment();
        });
        $("#message_description_<%= @news.id %> p,#message_description_<%= @news.id %> span,#message_description_<%= @news.id %> em").each(function(){
            var postContent = $(this).html();
            postContent = postContent.replace(/&nbsp;/g," ");
            postContent= postContent.replace(/ {2}/g,"&nbsp; ");
            postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
            postContent=postContent.replace(/&nbsp;  /g,"&nbsp;&nbsp; ");
            $(this).html(postContent);
        });
        autoUrl('message_description_<%= @news.id %>');
    });
</script>
