Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
zhangxiaoru
9 years ago
Commit
65676a437ad61649974f8192887e81491b1a2fc8
1 parent
8ef3a674
搜索按钮功能添加
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
3 deletions
doraemon/views/partial/header.hbs
public/js/header.js
doraemon/views/partial/header.hbs
View file @
65676a4
...
...
@@ -84,8 +84,9 @@
<ul
class=
"search-suggest"
></ul>
<div
class=
"search-2016"
>
<form
action=
"//search.yohobuy.com"
method=
"get"
id=
"search-form"
>
<input
type=
"text"
name=
"query"
class=
"search-key"
autocomplete=
"off"
>
<a
class=
"search-btn"
></a>
<input
type=
"hidden"
id=
"defaultsearch"
>
<input
class=
"search-key"
type=
"text"
name=
"query"
id=
"query-key"
autocomplete=
"off"
x-webkit-speech=
""
lang=
"zh-CN"
x-webkit-grammar=
"builtin:translate"
value=
""
onfocus=
"if(this.value==this.defaultValue){this.value='';this.style.color='#333'}"
onblur=
"if(this.value==''){this.value=this.defaultValue;this.style.color='#999'}"
maxlength=
"30"
>
<a
class=
"search-btn"
href=
"javascript:submitSearch();"
></a>
</form>
</div>
<div
class=
"go-cart"
>
...
...
public/js/header.js
View file @
65676a4
...
...
@@ -28,7 +28,10 @@ var thirdLineNum = 9,
requestFrame
;
var
logoAngle
=
0
,
loopTime
=
500
;
loopTime
=
500
,
keyword
=
''
,
link
=
''
,
reg
=
/^
[\^\!\+\-\(\)\:\[\]\\\{\}\~\*\?\|\&\;\/]{0,}
$/g
;
var
dataLayer
=
[];
...
...
@@ -705,4 +708,32 @@ function actionCover() {
}
}
window
.
submitSearch
=
function
()
{
var
$keywordinput
=
$
(
'#query-key'
).
val
();
var
$defaultsearch
=
$
(
'#defaultsearch'
).
val
();
var
column
=
'Search'
;
var
postition
=
'Head Search'
;
var
event
=
'Search'
;
var
$formatkeyword
,
$formatkeywordinput
;
$formatkeyword
=
$
.
trim
(
keyword
.
toLowerCase
());
$formatkeywordinput
=
$
.
trim
(
$keywordinput
.
toLowerCase
());
getSource
(
column
,
postition
,
event
);
if
(
link
!==
''
&&
keyword
!==
''
&&
$formatkeyword
===
$formatkeywordinput
)
{
location
.
href
=
link
.
replace
(
'\''
,
''
);
}
else
{
if
(
reg
.
test
(
$keywordinput
)
&&
$keywordinput
!==
''
)
{
location
.
href
=
'http://search.yohobuy.com/error?query='
+
$keywordinput
+
'&result=error'
;
}
else
{
if
(
$keywordinput
===
''
)
{
$
(
'#query-key'
).
val
(
$defaultsearch
);
}
$searchForm
.
submit
();
return
false
;
}
}
};
actionCover
();
...
...
Please
register
or
login
to post a comment