列表左边菜单收缩

This commit is contained in:
yuanke 2016-04-27 14:12:56 +08:00
parent 23f48b7189
commit dac717bd97
6 changed files with 60 additions and 17 deletions

View File

@ -2900,7 +2900,7 @@ class UsersController < ApplicationController
@c_sort = 2
end
sort_name = "updated_on"
sort_name = "created_on"
sort_type = @c_sort == 1 ? "asc" : "desc"
if @user.projects.visible.count > 0

View File

@ -73,14 +73,13 @@
<a href="javascript:void(0);" class="homepageLeftMenuMoreIcon" onclick="show_more_course('<%= user_courses4show_user_path(user.id)%>');"></a>
</li>
<% end%>
<div id="user_hide_course">
</div>
<script type="text/javascript">
if(document.getElementsByClassName("coursesLineGrey").length > 0){
$(".user_hide_course").html();
var coursecount = <%= @user.courses.visible.count%>;
var courseshowcount = document.getElementsByClassName("coursesLineGrey").length;
if((coursecount == courseshowcount)&&(coursecount > 5) ){
$("#user_show_more_course").hide();
$('#user_hide_course').show();
}
</script>

View File

@ -1,7 +1,7 @@
<% projects.each do |project|%>
<li class="homepageLeftMenuCoursesLine pr">
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project' and shield_id=#{project.id}").count %>
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "coursesLineGrey hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "projectsLineGrey hidden",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>
<ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>">
<li>
<ul class="subNavMenu boxShadow">
@ -54,3 +54,13 @@
<a href="javascript:void(0);" class="homepageLeftMenuMoreIcon" onclick="show_more_project('<%= user_projects4show_user_path(user.id)%>');"></a>
</li>
<% end%>
<script type="text/javascript">
var projectcount = <%= @user.projects.visible.count%>;
var projectshowcount = document.getElementsByClassName("projectsLineGrey").length;
if((projectcount == projectshowcount)&&(projectcount > 5)){
$("#user_show_more_project").hide();
$('#user_hide_project').show();
}
</script>

View File

@ -227,11 +227,19 @@
end
%>
<%# courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" id="homepageLeftMenuCourses">
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" >
<div class = "leftCoursesList" id="homepageLeftMenuCourses">
<ul>
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>
</ul>
</div>
<% if !courses.empty? %>
<div class="homepageLeftMenuMore" id="user_hide_course">
<a href="javascript:void(0);" class="homepageLeftMenuHideIcon" id="hide_show_courseicon" onclick="leftCourseslistChange();"></a>
</div>
<% end %>
</div>
<div class="homepageLeftMenuBlock">
<%= link_to '项目',{:controller => "users", :action => "user_projectlist", :id => @user.id}, :class => "homepageMenuText" %>
<% if is_current_user%>
@ -251,11 +259,18 @@
%>
<%# projects = @user.projects.visible.select("projects.*, (SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%>
<div class="homepageLeftMenuCourses <%= projects.empty? ? 'none' : ''%>" id="homepageLeftMenuForge">
<div class="homepageLeftMenuCourses <%= projects.empty? ? 'none' : ''%>" >
<div class = "leftProjecsList" id="homepageLeftMenuForge">
<ul>
<%= render :partial => 'layouts/user_projects', :locals => {:projects => projects,:user => @user, :page => 0} %>
</ul>
</div>
<% if !projects.empty? %>
<div class="homepageLeftMenuMore" id="user_hide_project">
<a href="javascript:void(0);" class="homepageLeftMenuHideIcon" id="hide_show_projecticon" onclick="leftProjectslistChange();"></a>
</div>
<% end %>
</div>
<div class="homepageLeftMenuBlock">
<!--<a href="javascript:void(0);" class="homepageMenuText">留言</a>-->
<%= link_to '留言',feedback_path(@user, :host=> Setting.host_user),:class=>'homepageMenuText'%>
@ -338,6 +353,22 @@
$("#courseMenu").mouseleave(function(){
$("#topnav_course_menu").hide();
});
$('#user_hide_course').hide();
function leftCourseslistChange(){
$('#homepageLeftMenuCourses').slideToggle();
$('#hide_show_courseicon').toggleClass("homepageLeftMenuHideIcon");
$('#hide_show_courseicon').toggleClass("homepageLeftMenuMoreIcon");
}
$('#user_hide_project').hide();
function leftProjectslistChange(){
$('#homepageLeftMenuForge').slideToggle();
$('#hide_show_projecticon').toggleClass("homepageLeftMenuHideIcon");
$('#hide_show_projecticon').toggleClass("homepageLeftMenuMoreIcon");
}
</script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -591,9 +591,12 @@ a.homepageImageNumber:hover {color:#269ac9;}
.homepageLeftMenuCoursesLine:hover {background-color:#269ac9;}
a.coursesLineGrey {padding-left:25px; padding-right:25px; color:#808080; display:block;}
a.coursesLineGrey:hover {color:#ffffff;}
a.projectsLineGrey {padding-left:25px; padding-right:25px; color:#808080; display:block;}
a.projectsLineGrey:hover {color:#ffffff;}
.homepageLeftMenuMore {height:18px;}
.homepageLeftMenuMore:hover {background-color:#269ac9;}
.homepageLeftMenuMoreIcon {background:url(../images/homepage_icon.png) -74px -240px no-repeat; display:block; height:18px;}
.homepageLeftMenuHideIcon {background:url(../images/homepage_icon.png) -74px -220px no-repeat;display:block; height:18px;}
.homepageMenuSetting {display:inline-block; background:url(../images/homepage_icon2.png) -190px -365px no-repeat; width:15px; height:15px; margin-top: 16px; margin-right: 15px;}
.homepageMenuSetting:hover {background:url(../images/homepage_icon2.png) -190px -407px no-repeat;}
a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}