实现课程搜索

This commit is contained in:
sw 2015-03-17 18:02:46 +08:00
parent ec1ff6dfc3
commit 16872597b6
2 changed files with 45 additions and 6 deletions

View File

@ -17,6 +17,7 @@
<%= call_hook :view_layouts_base_html_head %> <%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'leftside', :media => 'all' %> <%= stylesheet_link_tag 'leftside', :media => 'all' %>
<%= stylesheet_link_tag 'courses', :media => 'all' %> <%= stylesheet_link_tag 'courses', :media => 'all' %>
<%= javascript_include_tag "course" %>
<!-- page specific tags --> <!-- page specific tags -->
<%= yield :header_tags -%> <%= yield :header_tags -%>
</head> </head>
@ -27,14 +28,31 @@
<div id="TopBar"> <div id="TopBar">
<div class="topbar_info02 fl"> <div class="topbar_info02 fl">
<h2><a href="#" target="_blank" class="c_blue">高校课程实践社区 </a></h2> <h2>
<p>当前位置 :<a href="#" target="_blank" >主页</a> ><a href="#" target="_blank"> 课程实践平台</a> ><a href="#" target="_blank"> 分布式计算环境</a></p> <a href="http://<%= Setting.host_course%>" target="_blank" class="c_blue">
<%= l(:label_courses_community)%>
</a>
</h2>
<p>
<%= l(:label_user_location) %> :
<%= link_to l(:field_homepage), home_path %>
>
<a href="http://<%= Setting.host_course%>">
<%=l(:label_courses_management_platform)%>
</a>
>
<%= link_to @course.name, nil %>
</p>
</div> </div>
<div class="search fl"> <div class="search fl">
<form class="search_form" > <%= form_tag({:controller => 'courses', :action => 'search'},:id => "course_search_form", :method => :get, :class => "search_form") do %>
<input type="text" name="serach" placeholder="项目名称、课程名称、昵称、姓名、邮箱" class="search_text fl"> <%= text_field_tag 'name', params[:name], :placeholder => "课程名称", :class => "search_text fl", :onkeyup => "regexName('#{l(:label_search_conditions_not_null)}');" %>
<a href="#" class="search_btn fl f14 c_white" >搜 索</a> <a href="#" onclick="submitSerch('<%= l(:label_search_conditions_not_null) %>');" class="search_btn fl f14 c_white" >
</form> <%= l(:label_search)%>
</a>
<br />
<span id="project_name_span" style="float: left"></span>
<% end %>
</div> </div>
</div><!--TopBar end--> </div><!--TopBar end-->
<div class="cl"></div> <div class="cl"></div>

View File

@ -0,0 +1,21 @@
function regexName(content)
{
var name = $.trim($("#name").val());
if(name.length == 0)
{
$("#project_name_span").text(content);
$("#project_name_span").css('color','#ff0000');
$("#project_name_span").focus();
return false;
}
else
{
$("#project_name_span").text("");
return true;
}
}
function submitSerch(content)
{
if(regexName(content)){$("#course_search_form").submit();}
}