Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
f1018c2e
Commit
f1018c2e
authored
Jan 30, 2018
by
serapath
Committed by
yann300
Feb 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix expand logic on file tab click
parent
e8917724
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
38 deletions
+55
-38
app.js
src/app.js
+7
-13
file-explorer.js
src/app/files/file-explorer.js
+35
-15
fileManager.js
src/app/files/fileManager.js
+13
-10
No files found.
src/app.js
View file @
f1018c2e
...
@@ -498,9 +498,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -498,9 +498,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
fileManager
.
switchFile
(
path
)
fileManager
.
switchFile
(
path
)
},
},
event
:
fileManager
.
event
,
event
:
fileManager
.
event
,
currentFile
:
function
()
{
config
:
config
,
return
config
.
get
(
'currentFile'
)
},
currentContent
:
function
()
{
currentContent
:
function
()
{
return
editor
.
get
(
config
.
get
(
'currentFile'
))
return
editor
.
get
(
config
.
get
(
'currentFile'
))
},
},
...
@@ -516,18 +514,14 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -516,18 +514,14 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
filePanel
.
event
.
register
(
'resize'
,
delta
=>
self
.
_adjustLayout
(
'left'
,
delta
))
filePanel
.
event
.
register
(
'resize'
,
delta
=>
self
.
_adjustLayout
(
'left'
,
delta
))
var
previouslyOpenedFile
=
config
.
get
(
'currentFile'
)
setTimeout
(
function
initOpenFile
()
{
if
(
previouslyOpenedFile
)
{
var
previouslyOpenedFile
=
config
.
get
(
'currentFile'
)
||
'browser/ballot.sol'
config
.
set
(
'currentFile'
,
null
)
filesProviders
[
'browser'
].
get
(
previouslyOpenedFile
,
(
error
,
content
)
=>
{
filesProviders
[
'browser'
].
get
(
previouslyOpenedFile
,
(
error
,
content
)
=>
{
if
(
!
error
&&
content
)
{
if
(
!
error
&&
content
)
fileManager
.
switchFile
(
previouslyOpenedFile
)
fileManager
.
switchFile
(
previouslyOpenedFile
)
else
fileManager
.
switchFile
(
'browser/ballot.sol'
)
}
else
{
fileManager
.
switchFile
()
}
})
})
}
else
{
},
0
)
fileManager
.
switchFile
()
}
// ----------------- Renderer -----------------
// ----------------- Renderer -----------------
var
rendererAPI
=
{
var
rendererAPI
=
{
...
...
src/app/files/file-explorer.js
View file @
f1018c2e
...
@@ -149,6 +149,8 @@ function fileExplorer (appAPI, files) {
...
@@ -149,6 +149,8 @@ function fileExplorer (appAPI, files) {
if
(
explorer
===
files
)
{
if
(
explorer
===
files
)
{
fileFocus
(
newFile
)
fileFocus
(
newFile
)
}
else
{
}
else
{
var
currentFile
=
appAPI
.
config
.
get
(
'currentFile'
)
if
(
currentFile
===
newFile
)
return
unfocus
(
focusElement
)
unfocus
(
focusElement
)
}
}
})
})
...
@@ -157,7 +159,6 @@ function fileExplorer (appAPI, files) {
...
@@ -157,7 +159,6 @@ function fileExplorer (appAPI, files) {
fileEvents
.
register
(
'fileRenamedError'
,
fileRenamedError
)
fileEvents
.
register
(
'fileRenamedError'
,
fileRenamedError
)
fileEvents
.
register
(
'fileAdded'
,
fileAdded
)
fileEvents
.
register
(
'fileAdded'
,
fileAdded
)
var
filepath
=
null
var
textUnderEdit
=
null
var
textUnderEdit
=
null
var
textInRename
=
false
var
textInRename
=
false
...
@@ -332,15 +333,41 @@ function fileExplorer (appAPI, files) {
...
@@ -332,15 +333,41 @@ function fileExplorer (appAPI, files) {
})
})
}
}
function
expandPathTo
(
filePath
,
cb
)
{
var
label
=
self
.
element
.
querySelector
(
`label[data-path="
${
filePath
}
"]`
)
if
(
label
)
cb
()
var
arr
=
filePath
.
split
(
'/'
)
var
filename
=
arr
.
pop
()
var
path
=
arr
.
shift
()
var
fullpath
=
path
expand
(
fullpath
,
path
,
function
next
()
{
path
=
arr
.
shift
()
if
(
path
)
{
fullpath
+=
'/'
+
path
expand
(
fullpath
,
path
,
next
)
}
else
{
var
label
=
self
.
element
.
querySelector
(
`label[data-path$="
${
filename
}
"]`
)
focus
.
call
(
getLiFrom
(
label
),
{})
cb
()
}
})
function
expand
(
path
,
step
,
next
)
{
label
=
self
.
element
.
querySelector
(
`label[data-path="
${
step
}
"]`
)
||
self
.
element
.
querySelector
(
`label[data-path="
${
path
}
"]`
)
if
(
label
)
var
li
=
label
.
parentElement
.
parentElement
.
parentElement
if
(
!
label
||
path
===
step
&&
!
li
.
children
[
1
].
children
.
length
)
{
var
currentTree
=
self
.
treeView
.
nodeAt
(
path
)
var
caret
=
currentTree
.
parentElement
.
firstElementChild
.
firstElementChild
caret
.
click
()
next
()
}
else
next
()
}
}
function
fileFocus
(
path
)
{
function
fileFocus
(
path
)
{
var
filepath
=
appAPI
.
config
.
get
(
'currentFile'
)
if
(
filepath
===
path
)
return
if
(
filepath
===
path
)
return
filepath
=
path
expandPathTo
(
path
,
function
()
{
appAPI
.
config
.
set
(
'currentFile'
,
path
)
})
setTimeout
(
function
focusNode
()
{
// @TODO: fix file tree expand logic to account for async remixd loading logic
var
el
=
getElement
(
filepath
)
expandPathTo
(
el
)
setTimeout
(
function
focusNode
()
{
el
.
click
()
},
0
)
},
0
)
}
}
function
fileRemoved
(
filepath
)
{
function
fileRemoved
(
filepath
)
{
...
@@ -435,13 +462,6 @@ function removeSubtree (files, path, isFolder) {
...
@@ -435,13 +462,6 @@ function removeSubtree (files, path, isFolder) {
if
(
isFolder
)
files
.
remove
(
path
)
if
(
isFolder
)
files
.
remove
(
path
)
}
}
function
expandPathTo
(
li
)
{
while
((
li
=
li
.
parentElement
.
parentElement
)
&&
li
.
tagName
===
'LI'
)
{
var
caret
=
li
.
firstChild
.
firstChild
if
(
caret
.
classList
.
contains
(
'fa-caret-right'
))
caret
.
click
()
// expand
}
}
fileExplorer
.
prototype
.
init
=
function
()
{
fileExplorer
.
prototype
.
init
=
function
()
{
var
self
=
this
var
self
=
this
self
.
files
.
resolveDirectory
(
'/'
,
(
error
,
files
)
=>
{
self
.
files
.
resolveDirectory
(
'/'
,
(
error
,
files
)
=>
{
...
...
src/app/files/fileManager.js
View file @
f1018c2e
...
@@ -47,6 +47,7 @@ class FileManager {
...
@@ -47,6 +47,7 @@ class FileManager {
self
.
switchFile
(
Object
.
keys
(
self
.
tabbedFiles
)[
0
])
self
.
switchFile
(
Object
.
keys
(
self
.
tabbedFiles
)[
0
])
}
else
{
}
else
{
opt
.
editor
.
displayEmptyReadOnlySession
()
opt
.
editor
.
displayEmptyReadOnlySession
()
self
.
opt
.
config
.
set
(
'currentFile'
,
''
)
}
}
return
false
return
false
})
})
...
@@ -98,7 +99,6 @@ class FileManager {
...
@@ -98,7 +99,6 @@ class FileManager {
// Display files that have already been selected
// Display files that have already been selected
refreshTabs
(
newfile
)
{
refreshTabs
(
newfile
)
{
var
self
=
this
if
(
newfile
)
{
if
(
newfile
)
{
this
.
tabbedFiles
[
newfile
]
=
newfile
this
.
tabbedFiles
[
newfile
]
=
newfile
}
}
...
@@ -109,14 +109,14 @@ class FileManager {
...
@@ -109,14 +109,14 @@ class FileManager {
for
(
var
file
in
this
.
tabbedFiles
)
{
for
(
var
file
in
this
.
tabbedFiles
)
{
$filesEl
.
append
(
yo
`<li class="file"><span class="name">
${
file
}
</span><span class="remove"><i class="fa fa-close"></i></span></li>`
)
$filesEl
.
append
(
yo
`<li class="file"><span class="name">
${
file
}
</span><span class="remove"><i class="fa fa-close"></i></span></li>`
)
}
}
var
currentFileOpen
=
!!
this
.
opt
.
config
.
get
(
'currentFile'
)
if
(
currentFileOpen
)
{
var
active
=
$
(
'#files .file'
).
filter
(
function
()
{
var
active
=
$
(
'#files .file'
).
filter
(
function
()
{
return
$
(
this
).
find
(
'.name'
).
text
()
===
self
.
opt
.
config
.
get
(
'currentFile'
)
})
return
$
(
this
).
find
(
'.name'
).
text
()
===
newfile
active
.
addClass
(
'active'
)
})
}
if
(
active
.
length
)
active
.
addClass
(
'active'
)
$
(
'#input'
).
toggle
(
currentFileOpen
)
else
this
.
switchFile
()
$
(
'#output'
).
toggle
(
currentFileOpen
)
// $('#input').toggle(active)
$
(
'#output'
).
toggle
(
active
)
}
}
switchFile
(
file
)
{
switchFile
(
file
)
{
...
@@ -128,12 +128,15 @@ class FileManager {
...
@@ -128,12 +128,15 @@ class FileManager {
if
(
fileList
.
length
)
{
if
(
fileList
.
length
)
{
file
=
fileList
[
0
]
file
=
fileList
[
0
]
if
(
file
)
_switchFile
(
file
)
if
(
file
)
_switchFile
(
file
)
}
else
{
self
.
event
.
trigger
(
'currentFileChanged'
,
[])
}
}
})
})
}
else
_switchFile
(
file
)
}
else
_switchFile
(
file
)
function
_switchFile
()
{
function
_switchFile
(
file
)
{
self
.
saveCurrentFile
()
self
.
saveCurrentFile
()
self
.
opt
.
config
.
set
(
'currentFile'
,
file
)
var
currentFile
=
self
.
opt
.
config
.
get
(
'currentFile'
)
if
(
file
===
currentFile
)
return
self
.
refreshTabs
(
file
)
self
.
refreshTabs
(
file
)
self
.
fileProviderOf
(
file
).
get
(
file
,
(
error
,
content
)
=>
{
self
.
fileProviderOf
(
file
).
get
(
file
,
(
error
,
content
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment