119 lines
6.1 KiB
Plaintext
119 lines
6.1 KiB
Plaintext
<script type="text/javascript" language="javascript">
|
|
//搜索列表
|
|
function g(o){return document.getElementById(o);}
|
|
function HoverLi(n){
|
|
//如果有N个标签,就将i<=N;
|
|
for(var i=1;i<=7;i++){
|
|
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('syllabus')
|
|
}else if(n == 4){
|
|
search('course')
|
|
}else if(n == 5){
|
|
search('attachment')
|
|
}else if(n == 6){
|
|
search('project')
|
|
}else if(n == 7){
|
|
search('memo')
|
|
}
|
|
}
|
|
|
|
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%>' == 'syllabus'){
|
|
HoverLi(3)
|
|
$("#searchContent_3").html('<%= escape_javascript(render :partial => 'search_syllabus_results',:locals => {:syllabuses=>@syllabuses})%>');
|
|
}else if('<%= @search_type%>' == 'course'){
|
|
HoverLi(4)
|
|
$("#searchContent_4").html('<%= escape_javascript(render :partial => 'search_course_results',:locals => {:courses=>@courses})%>');
|
|
}else if('<%= @search_type%>' == 'attachment'){
|
|
HoverLi(5)
|
|
$("#searchContent_5").html('<%= escape_javascript(render :partial => 'search_attachment_results',:locals => {:attachments=>@attachments})%>');
|
|
}else if('<%= @search_type%>' == 'project'){
|
|
HoverLi(6)
|
|
$("#searchContent_6").html('<%= escape_javascript(render :partial => 'search_project_results',:locals => {:projects=>@projects})%>');
|
|
}else if('<%= @search_type%>' == 'memo')
|
|
{
|
|
HoverLi(7)
|
|
$("#searchContent_7").html('<%= escape_javascript(render :partial => 'search_memo_results',:locals => {:memos=>@memos})%>');
|
|
}
|
|
})
|
|
//如果要做成点击后再转到请将<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">(<%=@syllabus_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 style="font-weight:normal;"><font id="searchNum_4" class="numRed">(<%=@course_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">(<%= @attach_count%>)</font></span></a></li>
|
|
<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">(<%= @project_count%>)</font></span></a></li>
|
|
<li id="searchBaner_7" onclick="HoverLi(7);on_click_search(7);"><a href="javascript:void(0);" id="searchType_7" class="fontGrey2 f14">帖子<span class="numRed" style="font-weight:normal;"><font id="searchNum_7" class="numRed">(<%= @memo_count%>)</font></span></a></li>
|
|
<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">
|
|
|
|
</div>
|
|
<div id="searchContent_6" class="undis">
|
|
|
|
</div>
|
|
<div id="searchContent_7" class="undis">
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|