Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
5128a5764647f236e3f9ea3da4afbc0a15e7245a
1 parent
3d4234fd
rebuild common
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
23 deletions
public/js/common/README.md
public/js/common.js → public/js/common/index.js
public/js/common/footer.js → public/js/common/return-top.js
public/js/common/README.md
0 → 100644
View file @
5128a57
# common使用规范
## 页面公共使用的前端资源
### header为页面通用头部
### return-top为返回页面顶部(通用,除个人中心页面)
*
returnTopShowOrNot 是否显示返回顶部的按钮
### index暴露一些通用api,通过require('path/to/common')引用即可
*
cookie 获取cookie
*
setCookie 设置cookie
*
queryString 解析url query
**请按需require**
。此处与之前的项目不一样,接口将不直接暴露到window,需通过require去获取暴露的方法。
\ No newline at end of file
...
...
public/js/common.js → public/js/common
/index
.js
View file @
5128a57
/**
* 页面公共逻辑和接口
* @author: xuqi<qi.xu@yoho.cn>
* @date: 201
5/11/23
* @date: 201
7/7/5
*/
function
cookie
(
name
)
{
...
...
@@ -56,8 +56,8 @@ function queryString() {
return
vars
;
}
window
.
cookie
=
cookie
;
window
.
setCookie
=
setCookie
;
window
.
queryString
=
queryString
;
module
.
exports
=
{
cookie
:
cookie
,
// 获取cookie
setCookie
:
setCookie
,
// 设置cookie
queryString
:
queryString
// query参数解析
};
...
...
public/js/common/
footer
.js → public/js/common/
return-top
.js
View file @
5128a57
/**
* 公共底部
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/4
* [公共底部]返回页面顶部
* @author: xuqi<qi.xu@yoho.cn>
* @date: 2016/07/05
*/
var
$
=
require
(
'yoho-jquery'
);
var
$returnTop
=
$
(
'.return-top'
);
function
rePosReturn
()
{
function
showOrNot
()
{
if
(
$
(
window
).
height
()
>
$
(
document
).
height
())
{
$returnTop
.
addClass
(
'hide'
);
}
// 只在窗口高度大于文档高度的时候,隐藏返回顶部
// else {
// $returnTop.removeClass('hide');
// }
}
// 返回顶部
$returnTop
.
click
(
function
()
{
$
(
'html,body'
).
animate
({
scrollTop
:
0
...
...
@@ -33,10 +28,4 @@ $(window).scroll(function() {
}
});
// 如果初始是隐藏的,监听图片加载,重新确定return-top的高度
if
(
$returnTop
.
hasClass
(
'hide'
))
{
$
(
'img'
).
load
(
rePosReturn
);
}
// 暴露给有可能通AJAX改变内容的页面去用
window
.
rePosReturnTop
=
rePosReturn
;
exports
.
posReturnTop
=
showOrNot
;
...
...
Please
register
or
login
to post a comment