Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
818640bf
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
818640bf
编写于
1月 08, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up Checkbox widget
上级
757968eb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
91 deletion
+110
-91
src/vs/base/browser/ui/checkbox/checkbox.ts
src/vs/base/browser/ui/checkbox/checkbox.ts
+54
-55
src/vs/base/browser/ui/findinput/findInput.ts
src/vs/base/browser/ui/findinput/findInput.ts
+39
-24
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+17
-12
未找到文件。
src/vs/base/browser/ui/checkbox/checkbox.ts
浏览文件 @
818640bf
...
...
@@ -6,77 +6,81 @@
'
use strict
'
;
import
'
vs/css!./checkbox
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
Builder
=
require
(
'
vs/base/browser/builder
'
)
;
import
mouse
=
require
(
'
vs/base/browser/mouseEvent
'
)
;
import
keyboard
=
require
(
'
vs/base/browser/keyboardEvent
'
)
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
IDisposable
,
disposeAll
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
DomUtils
from
'
vs/base/browser/dom
'
;
var
$
=
Builder
.
$
;
export
interface
ICheckboxOpts
{
actionClassName
:
string
;
title
:
string
;
isChecked
:
boolean
;
onChange
:
()
=>
void
;
}
export
class
Checkbox
{
export
class
Checkbox
implements
IDisposable
{
private
actionClassName
:
string
;
private
title
:
string
;
public
isChecked
:
boolean
;
private
onChange
:
()
=>
void
;
private
listenersToRemove
:
{
():
void
;
}[];
private
_opts
:
ICheckboxOpts
;
private
_toDispose
:
IDisposable
[];
public
domNode
:
HTMLElement
;
constructor
(
actionClassName
:
string
,
title
:
string
,
isChecked
:
boolean
,
onChange
:
()
=>
void
)
{
this
.
actionClassName
=
actionClassName
;
this
.
title
=
title
;
this
.
isChecked
=
isChecked
;
this
.
onChange
=
onChange
;
private
_checked
:
boolean
;
this
.
listenersToRemove
=
[];
constructor
(
opts
:
ICheckboxOpts
)
{
this
.
_opts
=
opts
;
this
.
_checked
=
this
.
_opts
.
isChecked
;
this
.
_toDispose
=
[];
this
.
domNode
=
document
.
createElement
(
'
div
'
);
this
.
domNode
.
title
=
title
;
this
.
render
();
$
(
this
.
domNode
).
attr
({
'
aria-checked
'
:
'
false
'
,
'
aria-label
'
:
this
.
title
,
'
tabindex
'
:
0
,
'
role
'
:
'
checkbox
'
});
$
(
this
.
domNode
).
on
(
'
click
'
,
(
e
:
MouseEvent
)
=>
{
var
ev
=
new
mouse
.
StandardMouseEvent
(
e
);
this
.
isChecked
=
!
this
.
isChecked
;
this
.
render
();
this
.
onChange
();
this
.
domNode
.
title
=
this
.
_opts
.
title
;
this
.
domNode
.
className
=
this
.
_className
();
this
.
domNode
.
tabIndex
=
0
;
this
.
domNode
.
setAttribute
(
'
role
'
,
'
checkbox
'
);
this
.
domNode
.
setAttribute
(
'
aria-checked
'
,
String
(
this
.
_checked
));
this
.
domNode
.
setAttribute
(
'
aria-label
'
,
this
.
_opts
.
title
);
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
domNode
,
'
click
'
,
(
e
:
MouseEvent
)
=>
{
var
ev
=
new
StandardMouseEvent
(
e
);
this
.
_checked
=
!
this
.
_checked
;
this
.
domNode
.
className
=
this
.
_className
();
this
.
_opts
.
onChange
();
ev
.
preventDefault
();
}
,
this
.
listenersToRemove
);
}
)
);
$
(
this
.
domNode
).
on
(
'
keydown
'
,
(
browserEvent
:
KeyboardEvent
)
=>
{
var
keyboardEvent
=
new
keyboard
.
StandardKeyboardEvent
(
browserEvent
);
this
.
_toDispose
.
push
(
DomUtils
.
addDisposableListener
(
this
.
domNode
,
'
keydown
'
,
(
browserEvent
:
KeyboardEvent
)
=>
{
var
keyboardEvent
=
new
StandardKeyboardEvent
(
browserEvent
);
if
(
keyboardEvent
.
keyCode
===
KeyCode
.
Space
||
keyboardEvent
.
keyCode
===
KeyCode
.
Enter
)
{
this
.
isChecked
=
!
this
.
isC
hecked
;
this
.
render
();
this
.
onChange
();
this
.
_checked
=
!
this
.
_c
hecked
;
this
.
domNode
.
className
=
this
.
_className
();
this
.
_opts
.
onChange
();
keyboardEvent
.
preventDefault
();
}
},
this
.
listenersToRemove
);
}));
}
public
dispose
():
void
{
this
.
_toDispose
=
disposeAll
(
this
.
_toDispose
);
}
public
focus
():
void
{
this
.
domNode
.
focus
();
}
p
rivate
render
():
void
{
this
.
domNode
.
className
=
this
.
className
()
;
p
ublic
get
checked
():
boolean
{
return
this
.
_checked
;
}
public
set
Checked
(
newIsChecked
:
boolean
):
void
{
this
.
isC
hecked
=
newIsChecked
;
$
(
this
.
domNode
).
attr
(
'
aria-checked
'
,
this
.
isChecked
);
this
.
render
();
public
set
checked
(
newIsChecked
:
boolean
)
{
this
.
_c
hecked
=
newIsChecked
;
this
.
domNode
.
setAttribute
(
'
aria-checked
'
,
String
(
this
.
_checked
)
);
this
.
domNode
.
className
=
this
.
_className
();
}
private
className
():
string
{
return
'
custom-checkbox
'
+
this
.
actionClassName
+
'
'
+
(
this
.
isC
hecked
?
'
checked
'
:
'
unchecked
'
);
private
_
className
():
string
{
return
'
custom-checkbox
'
+
this
.
_opts
.
actionClassName
+
'
'
+
(
this
.
_c
hecked
?
'
checked
'
:
'
unchecked
'
);
}
public
width
():
number
{
...
...
@@ -85,16 +89,11 @@ export class Checkbox {
public
enable
():
void
{
this
.
domNode
.
tabIndex
=
0
;
this
.
domNode
.
setAttribute
(
'
aria-disabled
'
,
String
(
false
));
}
public
disable
():
void
{
this
.
domNode
.
tabIndex
=
-
1
;
this
.
domNode
.
setAttribute
(
'
aria-disabled
'
,
String
(
true
));
}
public
destroy
():
void
{
this
.
listenersToRemove
.
forEach
((
element
)
=>
{
element
();
});
this
.
listenersToRemove
=
[];
}
}
\ No newline at end of file
}
src/vs/base/browser/ui/findinput/findInput.ts
浏览文件 @
818640bf
...
...
@@ -74,9 +74,9 @@ export class FindInput {
}
public
destroy
():
void
{
this
.
regex
.
d
estroy
();
this
.
wholeWords
.
d
estroy
();
this
.
caseSensitive
.
d
estroy
();
this
.
regex
.
d
ispose
();
this
.
wholeWords
.
d
ispose
();
this
.
caseSensitive
.
d
ispose
();
this
.
listenersToRemove
.
forEach
((
element
)
=>
{
element
();
});
...
...
@@ -144,29 +144,29 @@ export class FindInput {
}
public
getCaseSensitive
():
boolean
{
return
this
.
caseSensitive
.
isC
hecked
;
return
this
.
caseSensitive
.
c
hecked
;
}
public
setCaseSensitive
(
value
:
boolean
):
void
{
this
.
caseSensitive
.
setChecked
(
value
)
;
this
.
caseSensitive
.
checked
=
value
;
this
.
setInputWidth
();
}
public
getWholeWords
():
boolean
{
return
this
.
wholeWords
.
isC
hecked
;
return
this
.
wholeWords
.
c
hecked
;
}
public
setWholeWords
(
value
:
boolean
):
void
{
this
.
wholeWords
.
setChecked
(
value
)
;
this
.
wholeWords
.
checked
=
value
;
this
.
setInputWidth
();
}
public
getRegex
():
boolean
{
return
this
.
regex
.
isC
hecked
;
return
this
.
regex
.
c
hecked
;
}
public
setRegex
(
value
:
boolean
):
void
{
this
.
regex
.
setChecked
(
value
)
;
this
.
regex
.
checked
=
value
;
this
.
setInputWidth
();
}
...
...
@@ -193,23 +193,38 @@ export class FindInput {
}
});
this
.
regex
=
new
Checkbox
.
Checkbox
(
'
regex
'
,
NLS_REGEX_CHECKBOX_LABEL
+
appendRegexLabel
,
false
,
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
this
.
regex
=
new
Checkbox
.
Checkbox
({
actionClassName
:
'
regex
'
,
title
:
NLS_REGEX_CHECKBOX_LABEL
+
appendRegexLabel
,
isChecked
:
false
,
onChange
:
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
}
});
this
.
wholeWords
=
new
Checkbox
.
Checkbox
(
'
whole-word
'
,
NLS_WHOLE_WORD_CHECKBOX_LABEL
+
appendWholeWordsLabel
,
false
,
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
this
.
wholeWords
=
new
Checkbox
.
Checkbox
({
actionClassName
:
'
whole-word
'
,
title
:
NLS_WHOLE_WORD_CHECKBOX_LABEL
+
appendWholeWordsLabel
,
isChecked
:
false
,
onChange
:
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
}
});
this
.
caseSensitive
=
new
Checkbox
.
Checkbox
(
'
case-sensitive
'
,
NLS_CASE_SENSITIVE_CHECKBOX_LABEL
+
appendCaseSensitiveLabel
,
false
,
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
this
.
caseSensitive
=
new
Checkbox
.
Checkbox
({
actionClassName
:
'
case-sensitive
'
,
title
:
NLS_CASE_SENSITIVE_CHECKBOX_LABEL
+
appendCaseSensitiveLabel
,
isChecked
:
false
,
onChange
:
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
this
.
validate
();
}
});
this
.
setInputWidth
();
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
818640bf
...
...
@@ -451,7 +451,7 @@ class PatternInput {
}
public
destroy
():
void
{
this
.
pattern
.
d
estroy
();
this
.
pattern
.
d
ispose
();
this
.
listenersToRemove
.
forEach
((
element
)
=>
{
element
();
});
...
...
@@ -523,11 +523,11 @@ class PatternInput {
}
public
isGlobPattern
():
boolean
{
return
this
.
pattern
.
isC
hecked
;
return
this
.
pattern
.
c
hecked
;
}
public
setIsGlobPattern
(
value
:
boolean
):
void
{
this
.
pattern
.
setChecked
(
value
)
;
this
.
pattern
.
checked
=
value
;
this
.
setInputWidth
();
}
...
...
@@ -550,15 +550,20 @@ class PatternInput {
}
});
this
.
pattern
=
new
Checkbox
(
'
pattern
'
,
nls
.
localize
(
'
patternDescription
'
,
"
Use Glob Patterns
"
),
false
,
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
if
(
this
.
isGlobPattern
())
{
this
.
showGlobHelp
();
}
else
{
this
.
inputBox
.
hideMessage
();
this
.
pattern
=
new
Checkbox
({
actionClassName
:
'
pattern
'
,
title
:
nls
.
localize
(
'
patternDescription
'
,
"
Use Glob Patterns
"
),
isChecked
:
false
,
onChange
:
()
=>
{
this
.
onOptionChange
(
null
);
this
.
inputBox
.
focus
();
this
.
setInputWidth
();
if
(
this
.
isGlobPattern
())
{
this
.
showGlobHelp
();
}
else
{
this
.
inputBox
.
hideMessage
();
}
}
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录