解决不能搜0的功能
This commit is contained in:
parent
f781742961
commit
8172516aff
|
@ -6,7 +6,7 @@ class StoresController < ApplicationController
|
||||||
|
|
||||||
def search
|
def search
|
||||||
name = params[:name] ||= ''
|
name = params[:name] ||= ''
|
||||||
redirect_to stores_path, :notice => l(:field_course_un) if name.blank?
|
(redirect_to stores_path, :notice => l(:label_sumbit_empty);return) if name.blank?
|
||||||
# 按文件名搜索
|
# 按文件名搜索
|
||||||
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%").
|
resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{name}%").
|
||||||
reorder("created_on DESC")
|
reorder("created_on DESC")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div style="margin: 10px 5%;">
|
<div style="margin: 10px 5%;">
|
||||||
<%= form_tag( search_stores_path, method: 'post') do %>
|
<%= form_tag( search_stores_path, method: 'post') do %>
|
||||||
<%= text_field_tag 'name', params[:name], size:"100", placeholder:'请输入要搜索的关键字', :class => 'blueinputbar', :required => true %>
|
<%= text_field_tag 'name', params[:name], size:"100", placeholder:'请输入要搜索的关键字', name: "name", :class => 'blueinputbar'%>
|
||||||
<%= submit_tag l(:label_search), :class => "enterprise"%>
|
<%= submit_tag l(:label_search), :class => "enterprise"%>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
|
@ -32,6 +32,23 @@
|
||||||
<% reset_cycle; end %>
|
<% reset_cycle; end %>
|
||||||
</div>
|
</div>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
|
function validate_required(field,alerttxt)
|
||||||
|
{
|
||||||
|
with (field)
|
||||||
|
{
|
||||||
|
if (value==null||value=="")
|
||||||
|
{alert(alerttxt);$.find('form').attr("data-submitted",'');return false}
|
||||||
|
else {return true}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_form(thisform) {
|
||||||
|
with (thisform)
|
||||||
|
{
|
||||||
|
if (validate_required(name,"name must be filled out!")==false)
|
||||||
|
{name.focus();return false}
|
||||||
|
}
|
||||||
|
}
|
||||||
$(document).ready(function($) {
|
$(document).ready(function($) {
|
||||||
$('.download_icon').find("a").attr("target", "_blank");
|
$('.download_icon').find("a").attr("target", "_blank");
|
||||||
$('.download_icon').each(function(){
|
$('.download_icon').each(function(){
|
||||||
|
|
|
@ -34,32 +34,49 @@
|
||||||
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
jQuery.fn.highlight = function(pat) {
|
jQuery.fn.highlight = function(pat) {
|
||||||
function innerHighlight(node, pat) {
|
function innerHighlight(node, pat) {
|
||||||
var skip = 0;
|
var skip = 0;
|
||||||
if (node.nodeType == 3) {
|
if (node.nodeType == 3) {
|
||||||
var pos = node.data.toUpperCase().indexOf(pat);
|
var pos = node.data.toUpperCase().indexOf(pat);
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
var spannode = document.createElement('span');
|
var spannode = document.createElement('span');
|
||||||
spannode.className = 'highlight';
|
spannode.className = 'highlight';
|
||||||
var middlebit = node.splitText(pos);
|
var middlebit = node.splitText(pos);
|
||||||
var endbit = middlebit.splitText(pat.length);
|
var endbit = middlebit.splitText(pat.length);
|
||||||
var middleclone = middlebit.cloneNode(true);
|
var middleclone = middlebit.cloneNode(true);
|
||||||
spannode.appendChild(middleclone);
|
spannode.appendChild(middleclone);
|
||||||
middlebit.parentNode.replaceChild(spannode, middlebit);
|
middlebit.parentNode.replaceChild(spannode, middlebit);
|
||||||
skip = 1;
|
skip = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
|
||||||
else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
|
for (var i = 0; i < node.childNodes.length; ++i) {
|
||||||
for (var i = 0; i < node.childNodes.length; ++i) {
|
i += innerHighlight(node.childNodes[i], pat);
|
||||||
i += innerHighlight(node.childNodes[i], pat);
|
}
|
||||||
}
|
}
|
||||||
|
return skip;
|
||||||
|
}
|
||||||
|
return this.each(function() {
|
||||||
|
innerHighlight(this, pat.toUpperCase());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
function validate_required(field,alerttxt)
|
||||||
|
{
|
||||||
|
with (field)
|
||||||
|
{
|
||||||
|
if (value==null||value=="")
|
||||||
|
{alert(alerttxt);return false}
|
||||||
|
else {return true}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_form(thisform) {
|
||||||
|
with (thisform)
|
||||||
|
{
|
||||||
|
if (validate_required(name,"name must be filled out!")==false)
|
||||||
|
{name.focus();return false}
|
||||||
}
|
}
|
||||||
return skip;
|
|
||||||
}
|
}
|
||||||
return this.each(function() {
|
|
||||||
innerHighlight(this, pat.toUpperCase());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
$(document).ready(function($) {
|
$(document).ready(function($) {
|
||||||
$('.cb span').highlight('<%=params[:name]%>');
|
$('.cb span').highlight('<%=params[:name]%>');
|
||||||
|
|
||||||
|
|
|
@ -1585,5 +1585,6 @@ en:
|
||||||
label_tags_forum: Call forum
|
label_tags_forum: Call forum
|
||||||
label_memo_locked: 'Topic is locked'
|
label_memo_locked: 'Topic is locked'
|
||||||
label_downloads_list: enter file list.
|
label_downloads_list: enter file list.
|
||||||
|
label_sumbit_empty: search bar need container.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1789,4 +1789,5 @@ zh:
|
||||||
label_joined_contest: 参与了竞赛
|
label_joined_contest: 参与了竞赛
|
||||||
label_contest_user: 参赛人:
|
label_contest_user: 参赛人:
|
||||||
label_contest_reason: 参赛宣言:
|
label_contest_reason: 参赛宣言:
|
||||||
label_notification: 通知
|
label_notification: 通知
|
||||||
|
label_sumbit_empty: 搜索内容不能为空
|
Loading…
Reference in New Issue