2015-11-26 09:57:53 +08:00
|
|
|
<script type="text/javascript" language="javascript">
|
|
|
|
//搜索列表
|
|
|
|
function g(o){return document.getElementById(o);}
|
|
|
|
function HoverLi(n){
|
|
|
|
//如果有N个标签,就将i<=N;
|
2015-12-07 14:31:05 +08:00
|
|
|
for(var i=1;i<=6;i++){
|
2015-11-26 09:57:53 +08:00
|
|
|
g('searchBaner_'+i).className='searchBannerNormal';
|
|
|
|
g('searchContent_'+i).className='undis';g('searchNum_'+i).className="numRed";
|
|
|
|
g('searchType_'+i).className="fontGrey2 f14";
|
|
|
|
}
|
|
|
|
g('searchContent_'+n).className='dis';
|
|
|
|
g('searchBaner_'+n).className='searchBannerActive';
|
|
|
|
g('searchNum_'+n).className="c_red";
|
|
|
|
g('searchType_'+n).className="fontGrey3 f14";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function on_click_search(n){
|
|
|
|
if(n == 1){
|
|
|
|
search('all')
|
|
|
|
//$("#searchContent_1").html('<%#= escape_javascript(render :partial => 'search_all_results',:locals => {:alls=> @results})%>');
|
|
|
|
}else if( n == 2){
|
|
|
|
//$("#searchContent_2").html('<%#= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>');
|
|
|
|
search('user')
|
|
|
|
}else if(n == 3){
|
|
|
|
search('course')
|
|
|
|
}else if(n == 4){
|
|
|
|
search('attachment')
|
|
|
|
}else if(n == 5){
|
|
|
|
search('project')
|
2015-12-07 14:31:05 +08:00
|
|
|
}else if(n == 6){
|
|
|
|
search('memo')
|
2015-11-26 09:57:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function search(type){
|
|
|
|
$.ajax({
|
|
|
|
url:'<%= url_for(:controller => 'welcome',:action=>'search')%>' +'?q=<%= @name %>&search_type='+type,
|
|
|
|
type:'get',
|
|
|
|
success:function(data){
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
$(function(){
|
|
|
|
if('<%= @search_type%>' == 'all'){
|
|
|
|
HoverLi(1)
|
|
|
|
$("#searchContent_1").html('<%= escape_javascript(render :partial => 'search_all_results',:locals => {:all_results=> @alls})%>');
|
|
|
|
}else if('<%= @search_type%>' == 'user'){
|
|
|
|
HoverLi(2)
|
|
|
|
$("#searchContent_2").html('<%= escape_javascript(render :partial => 'search_user_results',:locals => {:users=>@users})%>');
|
|
|
|
}else if('<%= @search_type%>' == 'course'){
|
|
|
|
HoverLi(3)
|
|
|
|
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
|
|
|
|
}else if('<%= @search_type%>' == 'attachment'){
|
|
|
|
HoverLi(4)
|
|
|
|
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
|
|
|
|
}else if('<%= @search_type%>' == 'project'){
|
|
|
|
HoverLi(5)
|
|
|
|
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
|
2015-12-07 14:31:05 +08:00
|
|
|
}else if('<%= @search_type%>' == 'memo')
|
|
|
|
{
|
|
|
|
HoverLi(6)
|
|
|
|
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
|
2015-11-26 09:57:53 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
//如果要做成点击后再转到请将<li>中的onmouseover 改成 onclick;
|
|
|
|
//]]>
|
|
|
|
</script>
|
|
|
|
<script>
|
|
|
|
//搜索内容自动撑高到整屏
|
|
|
|
var h1 = $(window).height();
|
|
|
|
var h2 = $(".homepageContentContainer").height();
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<div class="homepageContentContainer">
|
|
|
|
<div class="homepageContent">
|
|
|
|
<div class="blocks mt10 mb10">
|
|
|
|
<ul id="searchBanner">
|
|
|
|
<li id="searchBaner_1" class="searchBannerActive" onclick="HoverLi(1);on_click_search(1);"><a href="javascript:void(0);" id="searchType_1" class="fontGrey3 f14">全部<span style="font-weight:normal;"><font id="searchNum_1" class="c_red">(<%= @total_count%>)</font></span></a></li>
|
|
|
|
<li id="searchBaner_2" onclick="HoverLi(2);on_click_search(2);"><a href="javascript:void(0);" id="searchType_2" class="fontGrey2 f14">用户<span class="numRed" style="font-weight:normal;"><font id="searchNum_2" class="numRed">(<%= @users_count%>)</font></span></a></li>
|
|
|
|
<li id="searchBaner_3" onclick="HoverLi(3);on_click_search(3);"><a href="javascript:void(0);" id="searchType_3" class="fontGrey2 f14">课程<span style="font-weight:normal;"><font id="searchNum_3" class="numRed">(<%=@course_count%>)</font></span></a></li>
|
|
|
|
<li id="searchBaner_4" onclick="HoverLi(4);on_click_search(4);"><a href="javascript:void(0);" id="searchType_4" class="fontGrey2 f14">资源<span class="numRed" style="font-weight:normal;"><font id="searchNum_4" class="numRed">(<%= @attach_count%>)</font></span></a></li>
|
|
|
|
<li id="searchBaner_5" onclick="HoverLi(5);on_click_search(5);"><a href="javascript:void(0);" id="searchType_5" class="fontGrey2 f14">项目<span class="numRed" style="font-weight:normal;"><font id="searchNum_5" class="numRed">(<%= @project_count%>)</font></span></a></li>
|
2015-12-07 14:31:05 +08:00
|
|
|
<li id="searchBaner_6" onclick="HoverLi(6);on_click_search(6);"><a href="javascript:void(0);" id="searchType_6" class="fontGrey2 f14">帖子<span class="numRed" style="font-weight:normal;"><font id="searchNum_6" class="numRed">(<%= @memo_count%>)</font></span></a></li>
|
2015-11-26 09:57:53 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
</ul>
|
|
|
|
<ul id="searchTips" style="display:none;">
|
|
|
|
<span class="fontGrey3">没有搜索到相关的内容!</span>
|
|
|
|
</ul>
|
|
|
|
<div id="searchContent_1">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div id="searchContent_2" class="undis">
|
|
|
|
<%#= render :partial => 'search_user_results',:locals => {:users=>@users}%>
|
|
|
|
</div>
|
|
|
|
<div id="searchContent_3" class="undis">
|
|
|
|
</div>
|
|
|
|
<div id="searchContent_4" class="undis">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div id="searchContent_5" class="undis">
|
|
|
|
|
2015-12-07 14:31:05 +08:00
|
|
|
</div>
|
|
|
|
<div id="searchContent_6" class="undis">
|
|
|
|
|
2015-11-26 09:57:53 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|