<div class="homepageRightBanner">
  <div class="NewsBannerName"><%= title_for_message(params[:type]) %></div>
  <ul class="resourcesSelect">
    <li class="resourcesSelected"><a href="javascript:void(0);" class="resourcesIcon"></a>
      <ul class="newsType">
        <li><%= link_to "全部",user_message_path(User.current), :class => "resourcesGrey" %></li>
        <li><%= link_to "未读消息", user_message_path(User.current, :type => 'unviewed'), :class => "resourcesGrey" %></li>
        <li><%= link_to "用户申请", user_message_path(User.current, :type => 'apply'), :class => "resourcesGrey" %></li>
        <%# 课程相关消息 %>
        <li><%= link_to "作业消息", user_message_path(User.current, :type => 'homework'), :class => "resourcesGrey" %></li>
        <li><%= link_to "课程讨论",user_message_path(User.current, :type => 'course_message'), :class => "resourcesGrey"  %></li>
        <li><%= link_to "课程通知",user_message_path(User.current, :type => 'course_news'), :class => "resourcesGrey"  %></li>
        <!--<li><%#= link_to "通知回复", user_message_path(User.current, :type => 'course_news_reply'), :class => "resourcesGrey" %></li>-->
        <!--<li><%#= link_to "课程问卷", user_message_path(User.current, :type => 'poll'), :class => "resourcesGrey"  %></a></li>-->
        <!--<li><%#= link_to "作品评阅", user_message_path(User.current, :type => 'works_reviewers'), :class => "resourcesGrey"  %></li>-->
        <!--<li><%#= link_to "作品讨论", user_message_path(User.current, :type => 'works_reply'), :class => "resourcesGrey"  %></li>-->
        <%# 项目相关消息 %>
        <li><%= link_to "项目任务", user_message_path(User.current, :type => 'issue'), :class => "resourcesGrey"  %></li>
        <!--<li><%#= link_to "问题更新", user_message_path(User.current, :type => 'issue_update'), :class => "resourcesGrey"  %></li>-->
        <!--<li><%#= link_to "项目讨论区", user_message_path(User.current, :type => 'forge_message'), :class => "resourcesGrey"  %></li>-->
        <!--<li><%#= link_to "项目新闻", user_message_path(User.current, :type => 'forge_news'), :class => "resourcesGrey"  %></li>-->
        <!--<li><%#= link_to "新闻回复", user_message_path(User.current, :type => 'forge_news_reply'), :class => "resourcesGrey"  %></li>-->
        <%# 项目相关消息 %>
        <li><%= link_to "贴吧帖子", user_message_path(User.current, :type => 'forum'), :class => "resourcesGrey"  %></li>
        <%# 系统贴吧 %>
        <li><%= link_to "用户留言",user_message_path(User.current, :type => 'user_feedback'), :class => "resourcesGrey"  %></li>
        <%# 系统消息 %>
        <li><%= link_to "系统消息", user_system_messages_path(User.current), :class => "resourcesGrey" %></li>
      </ul>
    </li>
  </ul>
</div>
<div class="resources mt10" id="users_setting">
  <div>
    <% if @message_alls.count >0 || @user_system_messages.count >0 %>
        <% if params[:type].nil? || params[:type] == "unviewed" %>
            <div class="newsReadSetting">
              有&nbsp;<span class="c_red"><%= unviewed_message(@user) %></span>&nbsp;条未读
              <% unless (unviewed_message(@user) == 0 || User.current != @user) %>
                  <a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
              <% end %>
            </div>
        <% end %>
        <%# 系统消息 %>
        <% if params[:type] != 'system_messages' %>
            <% @user_system_messages.each do |usm| %>
                <ul class="homepageNewsList fl">
                  <li class="homepageNewsPortrait fl">
                    <a href="javascript:void(0);"><div class="navHomepageLogo fl"><%= image_tag("/images/logo.png", width: "30px", height: "30px", class: "mt3") %></div></a>
                  </li>
                  <li class="homepageNewsPubType fl">
                    <span class="newsBlue homepageNewsPublisher">Trustie平台</span><span class="homepageNewsType fl">发布新消息：</span>
                  </li>
                  <span style="color: red;float: left">【系统消息】</span>
                  <li class="homepageSystenMessageContent fl">

                    <%= link_to usm.subject.blank? ? (usm.content.nil? ? usm.description.html_safe : usm.content.html_safe) : usm.subject, user_system_messages_path(User.current),
                                :id => "content_link_#{usm.id}",
                                :onmouseover =>"message_titile_show($(this),event);",
                                :onmouseout => "message_titile_hide($(this));"
                    %>
                  </li>
                  <div style="display:none;" class="message_title_red system_message_style">
                    <% unless usm.subject.blank? %>
                        <p><strong>标题：</strong><%= usm.subject %></p>
                    <% end %>
                    <% if (!usm.description.blank?) || (!usm.content.blank?) %>
                        <div class="fl"><strong>内容：</strong></div><div class="ml36"><%= usm.description.nil? ? usm.content.html_safe : usm.description.html_safe %></div>
                    <% end %>
                  </div>
                  <li class="homepageNewsTime fl"><%= time_tag(usm.created_at).html_safe %> </li>
                </ul>
            <% end %>
        <% end %>
        <!--总消息列表-->
        <% unless @message_alls.nil? %>
            <% @message_alls.each do |ma| %>
                <%# 课程消息 %>
                <%= render :partial => 'users/user_message_course', :locals => {:ma => ma}  %>

                <!--项目消息-->
                <%= render :partial => 'users/user_message_forge', :locals => {:ma => ma}  %>

                <!--公共贴吧-->
                <%= render :partial => 'users/user_message_forum', :locals => {:ma => ma}  %>

                <!--用户留言-->
                <%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma}  %>

            <% end %>
            <ul class="wlist" style=" border:none; padding-top: 15px;">
              <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%>
            </ul>
        <% end %>
        <!--项目消息-->
    <% else %>
        <div class="flash notice">您目前还没有相关消息！</div>
    <% end %>
    <div class="cl"></div>
  </div>
</div>

<script>
    function message_titile_show(obj,e)
    {
        obj.parent().next("div").show();
        obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute");
    }
    function message_titile_hide(obj)
    {
        obj.parent().next("div").hide();
    }

    function show_more_system_messages(list,content, id2, id3) {
        $(list).toggleClass("show_more_li");
        $(content).toggleClass("show_more_system_message");
        var information = $(id2);
        var val = information.attr("value");
        if (val == "show_more") {
            $(id2).text("[收起]");
            information.attr("value", "hide_more");
            information.attr("style", "color:#3ca5c6");
        }
        else {
            $(id2).text("[展开]");
            information.attr("value", "show_more");
            information.attr("style", "color:#0781b4;");
        }
    }
</script>










