登录、未登录搜索条件选择js

用户主页 show方法改造
This commit is contained in:
sw 2015-08-25 16:01:31 +08:00
parent 44419eff04
commit 0d9a397453
4 changed files with 41 additions and 42 deletions

View File

@ -549,13 +549,11 @@ class UsersController < ApplicationController
end
def show
#if @user == User.current
@user_activities = UserActivity.where("(container_type='Course' and container_id in (select course_id FROM members WHERE user_id=#{@user.id})) or (container_type='Project' and container_id in (SELECT project_id FROM members WHERE user_id=#{@user.id}))").order('created_at desc')
@user_activities = paginateHelper @user_activities,500
#SELECT * FROM user_activities WHERE (container_type='Course' AND container_id IN (SELECT course_id FROM members WHERE user_id=4)) OR (container_type='Project' AND container_id IN (SELECT project_id FROM members WHERE user_id=4))
#else
#end
@page = (params[:page] || -1).to_i + 1
user_project_ids = "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")"
user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids}) or (container_type = 'Course' and container_id in #{user_course_ids})").order('created_at desc').limit(10).offset(@page * 10)
# @user_activities = paginateHelper @user_activities,500
render :layout=>'new_base_user'
end

View File

@ -25,23 +25,18 @@
</form>
<div class="navSearchTypeBox" id="navHomepageSearchType">
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="课程" name="navSearchType" checked/>
</div>
课程
</div>
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="项目" name="navSearchType" />
</div>
项目
</div>
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="用户" name="navSearchType" />
用户
</div>
用户</div>
<div id="navSearchAlert" class="fr mr10">
<span class="c_red">请选择搜索类型</span>
</div>
@ -68,3 +63,12 @@
<div class="newsActive"></div>
</div>
</div>
<script type="text/javascript">
//搜索相关
$("#navHomepageSearch").mouseover(function(){
$("#navHomepageSearchType").show();
}).mouseout(function(){
$("#navHomepageSearchType").hide();
});
</script>

View File

@ -16,23 +16,18 @@
<a href="javascript:void(0);" class="homepageSearchIcon"></a>
</form>
<div class="navSearchTypeBox" id="navHomepageSearchType">
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="课程" name="navSearchType" checked/>
</div>
课程
</div>
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="项目" name="navSearchType" />
</div>
项目
</div>
<div class="fl mr15">
<div class="fl mt5">
<div class="fl mr15 mt5">
<input type="radio" value="用户" name="navSearchType" />
用户
</div>
用户</div>
<div id="navSearchAlert" class="fr mr10">
<span class="c_red">请选择搜索类型</span>
</div>
@ -45,3 +40,12 @@
<a href="javascript:void(0);" class="c_white db">注册</a>
</div>
</div>
<script type="text/javascript">
//搜索相关
$("#navHomepageSearch").mouseover(function(){
$("#navHomepageSearchType").show();
}).mouseout(function(){
$("#navHomepageSearchType").hide();
});
</script>

View File

@ -10,13 +10,6 @@ $(function(){
$("#edit_user_file_btn").hide();
$("#watch_user_btn").hide();
});
//搜索相关
$("#navHomepageSearch").mouseover(function(){
$("#navHomepageSearchType").show();
}).mouseout(function(){
$("#navHomepageSearchType").hide();
});
});
//编辑个人简介