FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
atom/src/pane-element.coffee at master · feicc/atom · GitHub
feicc
/
atom
Public
forked from
atom/atom
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Pull requests
53
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
atom
/
src
/
pane-element.coffee
Copy path
More file actions
More file actions
Latest commit
History
History
History
131 lines (100 loc) · 3.98 KB
Breadcrumbs
atom
/
src
/
pane-element.coffee
Copy path
File metadata and controls
131 lines (100 loc) · 3.98 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
path
=
require
'
path
'
{
CompositeDisposable
}
=
require
'
event-kit
'
class
PaneElement
extends
HTMLElement
attached
:
false
createdCallback
:
->
@attached
=
false
@subscriptions
=
new
CompositeDisposable
@inlineDisplayStyles
=
new
WeakMap
@
initializeContent
()
@
subscribeToDOMEvents
()
attachedCallback
:
->
@attached
=
true
@
focus
()
if
@model
.
isFocused
()
detachedCallback
:
->
@attached
=
false
initializeContent
:
->
@
setAttribute
'
class
'
,
'
pane
'
@
setAttribute
'
tabindex
'
,
-
1
@
appendChild
@itemViews
=
document
.
createElement
(
'
div
'
)
@itemViews
.
setAttribute
'
class
'
,
'
item-views
'
subscribeToDOMEvents
:
->
handleFocus
=
(
event
)
=>
@model
.
focus
()
unless
@isActivating
or
@model
.
isDestroyed
()
or
@
contains
(
event
.
relatedTarget
)
if
event
.
target
is
this
and
view
=
@
getActiveView
()
view
.
focus
()
event
.
stopPropagation
()
handleBlur
=
(
event
)
=>
@model
.
blur
()
unless
@
contains
(
event
.
relatedTarget
)
handleDragOver
=
(
event
)
->
event
.
preventDefault
()
event
.
stopPropagation
()
handleDrop
=
(
event
)
=>
event
.
preventDefault
()
event
.
stopPropagation
()
@
getModel
().
activate
()
pathsToOpen
=
Array
::
map
.
call
event
.
dataTransfer
.
files
, (
file
)
->
file
.
path
@applicationDelegate
.
open
({pathsToOpen})
if
pathsToOpen
.
length
>
0
@
addEventListener
'
focus
'
, handleFocus,
true
@
addEventListener
'
blur
'
, handleBlur,
true
@
addEventListener
'
dragover
'
, handleDragOver
@
addEventListener
'
drop
'
, handleDrop
initialize
:
(
@model
, {
@views
,
@applicationDelegate
})
->
throw
new
Error
(
"
Must pass a views parameter when initializing PaneElements
"
)
unless
@views
?
throw
new
Error
(
"
Must pass an applicationDelegate parameter when initializing PaneElements
"
)
unless
@applicationDelegate
?
@subscriptions
.
add
@model
.
onDidActivate
(
@activated
.
bind
(
this
))
@subscriptions
.
add
@model
.
observeActive
(
@activeStatusChanged
.
bind
(
this
))
@subscriptions
.
add
@model
.
observeActiveItem
(
@activeItemChanged
.
bind
(
this
))
@subscriptions
.
add
@model
.
onDidRemoveItem
(
@itemRemoved
.
bind
(
this
))
@subscriptions
.
add
@model
.
onDidDestroy
(
@paneDestroyed
.
bind
(
this
))
@subscriptions
.
add
@model
.
observeFlexScale
(
@flexScaleChanged
.
bind
(
this
))
this
getModel
:
->
@model
activated
:
->
@isActivating
=
true
@
focus
()
unless
@
hasFocus
()
#
Don't steal focus from children.
@isActivating
=
false
activeStatusChanged
:
(
active
)
->
if
active
@classList
.
add
(
'
active
'
)
else
@classList
.
remove
(
'
active
'
)
activeItemChanged
:
(
item
)
->
delete
@dataset
.
activeItemName
delete
@dataset
.
activeItemPath
return
unless
item
?
hasFocus
=
@
hasFocus
()
itemView
=
@views
.
getView
(item)
if
itemPath
=
item
.
getPath
?
()
@dataset
.
activeItemName
=
path
.
basename
(itemPath)
@dataset
.
activeItemPath
=
itemPath
unless
@itemViews
.
contains
(itemView)
@itemViews
.
appendChild
(itemView)
for
child
in
@itemViews
.
children
if
child
is
itemView
@
showItemView
(child)
if
@attached
else
@
hideItemView
(child)
itemView
.
focus
()
if
hasFocus
showItemView
:
(
itemView
)
->
inlineDisplayStyle
=
@inlineDisplayStyles
.
get
(itemView)
if
inlineDisplayStyle
?
itemView
.
style
.
display
=
inlineDisplayStyle
else
itemView
.
style
.
display
=
'
'
hideItemView
:
(
itemView
)
->
inlineDisplayStyle
=
itemView
.
style
.
display
unless
inlineDisplayStyle
is
'
none
'
@inlineDisplayStyles
.
set
(itemView, inlineDisplayStyle)
if
inlineDisplayStyle
?
itemView
.
style
.
display
=
'
none
'
itemRemoved
:
({item, index, destroyed})
->
if
viewToRemove
=
@views
.
getView
(item)
viewToRemove
.
remove
()
paneDestroyed
:
->
@subscriptions
.
dispose
()
flexScaleChanged
:
(
flexScale
)
->
@style
.
flexGrow
=
flexScale
getActiveView
:
->
@views
.
getView
(
@model
.
getActiveItem
())
hasFocus
:
->
this
is
document
.
activeElement
or
@
contains
(
document
.
activeElement
)
module
.
exports
=
PaneElement
=
document
.
registerElement
'
atom-pane
'
,
prototype
:
PaneElement
.
prototype
Back
|
FazBrowse Home
|
New Git URL