Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大大大太阳yt
driver.js
提交
76a51580
D
driver.js
项目概览
大大大太阳yt
/
driver.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
driver.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76a51580
编写于
3月 10, 2018
作者:
K
Kamran Ahmed
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rendering of buttons
上级
fa4fbb83
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
11 deletion
+77
-11
assets/scripts/src/constants.js
assets/scripts/src/constants.js
+1
-0
assets/scripts/src/popover.js
assets/scripts/src/popover.js
+59
-9
assets/scripts/src/sholo.js
assets/scripts/src/sholo.js
+10
-1
assets/styles/scss/demo.scss
assets/styles/scss/demo.scss
+6
-0
index.html
index.html
+1
-1
未找到文件。
assets/scripts/src/constants.js
浏览文件 @
76a51580
...
...
@@ -15,6 +15,7 @@ export const CLASS_POPOVER_FOOTER = 'sholo-popover-footer';
export
const
CLASS_CLOSE_BTN
=
'
sholo-close-btn
'
;
export
const
CLASS_NEXT_STEP_BTN
=
'
sholo-next-btn
'
;
export
const
CLASS_PREV_STEP_BTN
=
'
sholo-prev-btn
'
;
export
const
CLASS_BTN_DISABLED
=
'
sholo-disabled
'
;
// language=HTML
export
const
POPOVER_HTML
=
`
...
...
assets/scripts/src/popover.js
浏览文件 @
76a51580
import
Element
from
'
./element
'
;
import
{
CLASS_POPOVER_DESCRIPTION
,
CLASS_BTN_DISABLED
,
CLASS_CLOSE_BTN
,
CLASS_NEXT_STEP_BTN
,
CLASS_POPOVER_DESCRIPTION
,
CLASS_POPOVER_FOOTER
,
CLASS_POPOVER_TIP
,
CLASS_POPOVER_TITLE
,
CLASS_POPOVER_TITLE
,
CLASS_PREV_STEP_BTN
,
ID_POPOVER
,
OVERLAY_PADDING
,
POPOVER_HTML
,
}
from
'
./constants
'
;
...
...
@@ -12,12 +14,20 @@ import {
* Popover that is displayed on top of the highlighted element
*/
export
default
class
Popover
extends
Element
{
constructor
(
options
=
{
padding
:
OVERLAY_PADDING
,
},
window
,
document
)
{
constructor
(
options
,
window
,
document
)
{
super
();
this
.
options
=
options
;
this
.
options
=
Object
.
assign
({
isFirst
:
true
,
isLast
:
true
,
totalCount
:
1
,
currentIndex
:
0
,
doneBtnText
:
'
Done
'
,
closeBtnText
:
'
Close
'
,
nextBtnText
:
'
Next →
'
,
prevBtnText
:
'
← Previous
'
,
},
options
);
this
.
window
=
window
;
this
.
document
=
document
;
...
...
@@ -36,6 +46,10 @@ export default class Popover extends Element {
this
.
tipNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_TIP
}
`
);
this
.
titleNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_TITLE
}
`
);
this
.
descriptionNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_DESCRIPTION
}
`
);
this
.
footerNode
=
popover
.
querySelector
(
`.
${
CLASS_POPOVER_FOOTER
}
`
);
this
.
nextBtnNode
=
popover
.
querySelector
(
`.
${
CLASS_NEXT_STEP_BTN
}
`
);
this
.
prevBtnNode
=
popover
.
querySelector
(
`.
${
CLASS_PREV_STEP_BTN
}
`
);
this
.
closeBtnNode
=
popover
.
querySelector
(
`.
${
CLASS_CLOSE_BTN
}
`
);
}
/**
...
...
@@ -75,12 +89,16 @@ export default class Popover extends Element {
.
className
=
CLASS_POPOVER_TIP
;
}
/**
* Shows the popover at the given position
* @param position
*/
show
(
position
)
{
this
.
reset
();
// Set the title and descriptions
this
.
titleNode
.
inner
Text
=
this
.
options
.
title
;
this
.
descriptionNode
.
inner
Text
=
this
.
options
.
description
;
this
.
titleNode
.
inner
HTML
=
this
.
options
.
title
;
this
.
descriptionNode
.
inner
HTML
=
this
.
options
.
description
;
// Position the popover around the given position
switch
(
this
.
options
.
position
)
{
...
...
@@ -101,6 +119,37 @@ export default class Popover extends Element {
this
.
autoPosition
(
position
);
break
;
}
this
.
renderButtons
();
}
/**
* Enables, disables buttons, sets the text and
* decides if to show them or not
*/
renderButtons
()
{
this
.
nextBtnNode
.
innerHTML
=
this
.
options
.
nextBtnText
;
this
.
prevBtnNode
.
innerHTML
=
this
.
options
.
prevBtnText
;
this
.
closeBtnNode
.
innerHTML
=
this
.
options
.
closeBtnText
;
// If there was only one item, hide the buttons
if
(
this
.
options
.
totalCount
===
1
)
{
this
.
footerNode
.
style
.
display
=
'
none
'
;
return
;
}
this
.
footerNode
.
style
.
display
=
'
block
'
;
if
(
this
.
options
.
isFirst
)
{
this
.
prevBtnNode
.
classList
.
add
(
CLASS_BTN_DISABLED
);
}
else
{
this
.
prevBtnNode
.
classList
.
remove
(
CLASS_BTN_DISABLED
);
}
if
(
this
.
options
.
isLast
)
{
this
.
nextBtnNode
.
innerHTML
=
this
.
options
.
doneBtnText
;
}
else
{
this
.
nextBtnNode
.
innerHTML
=
this
.
options
.
nextBtnText
;
}
}
/**
...
...
@@ -168,6 +217,7 @@ export default class Popover extends Element {
/**
* Automatically positions the popover around the given position
* such that the element and popover remain in view
* @todo add the left and right positioning decisions
* @param elementPosition
*/
autoPosition
(
elementPosition
)
{
...
...
assets/scripts/src/sholo.js
浏览文件 @
76a51580
...
...
@@ -183,8 +183,17 @@ export default class Sholo {
}
let
popover
=
null
;
const
popoverOptions
=
Object
.
assign
({},
this
.
options
,
elementOptions
.
popover
||
{});
if
(
elementOptions
.
popover
&&
elementOptions
.
popover
.
description
)
{
const
popoverOptions
=
Object
.
assign
(
{},
this
.
options
,
elementOptions
.
popover
,
{
totalCount
:
steps
.
length
,
currentIndex
:
index
,
isFirst
:
index
===
0
,
isLast
:
index
===
steps
.
length
-
1
,
},
);
popover
=
new
Popover
(
popoverOptions
,
this
.
window
,
this
.
document
);
}
...
...
assets/styles/scss/demo.scss
浏览文件 @
76a51580
...
...
@@ -119,6 +119,12 @@ div#sholo-popover-item {
margin
:
10px
0
0
;
}
a
.sholo-disabled
{
color
:
#808080
;
cursor
:
default
;
pointer-events
:
none
;
}
.sholo-close-btn
{
float
:
left
;
}
...
...
index.html
浏览文件 @
76a51580
...
...
@@ -69,7 +69,7 @@
popover
:
{
title
:
'
Adding Introductions
'
,
description
:
'
You can use it to add popovers on top of the website
'
,
position
:
'
left
'
position
:
'
left
'
,
},
},
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录