Add octicons to TreeView add/move dialog

This commit is contained in:
Kevin Sawicki
2013-01-11 12:19:25 -08:00
parent e2cf4256a8
commit cd365bc6c5
4 changed files with 47 additions and 14 deletions

View File

@@ -660,7 +660,7 @@ describe "TreeView", ->
expect(addDialog.prompt.text()).toContain 'Error'
expect(addDialog.prompt.text()).toContain 'already exists'
expect(addDialog.prompt).toHaveClass('error')
expect(addDialog).toHaveClass('error')
expect(addDialog.hasParent()).toBeTruthy()
describe "when the path with a trailing '/' is changed and confirmed", ->
@@ -700,7 +700,7 @@ describe "TreeView", ->
expect(addDialog.prompt.text()).toContain 'Error'
expect(addDialog.prompt.text()).toContain 'already exists'
expect(addDialog.prompt).toHaveClass('error')
expect(addDialog).toHaveClass('error')
expect(addDialog.hasParent()).toBeTruthy()
describe "when 'core:cancel' is triggered on the add dialog", ->
@@ -764,7 +764,7 @@ describe "TreeView", ->
extension = fs.extension(filePath)
fileNameWithoutExtension = fs.base(filePath, extension)
expect(moveDialog).toExist()
expect(moveDialog.prompt.text()).toBe "Enter the new path for the file:"
expect(moveDialog.prompt.text()).toBe "Enter the new path for the file."
expect(moveDialog.miniEditor.getText()).toBe(project.relativize(filePath))
expect(moveDialog.miniEditor.getSelectedText()).toBe fs.base(fileNameWithoutExtension)
expect(moveDialog.miniEditor.isFocused).toBeTruthy()
@@ -814,7 +814,7 @@ describe "TreeView", ->
expect(moveDialog.prompt.text()).toContain 'Error'
expect(moveDialog.prompt.text()).toContain 'already exists'
expect(moveDialog.prompt).toHaveClass('error')
expect(moveDialog).toHaveClass('error')
expect(moveDialog.hasParent()).toBeTruthy()
describe "when 'core:cancel' is triggered on the move dialog", ->

View File

@@ -7,10 +7,12 @@ module.exports =
class Dialog extends View
@content: ({prompt} = {}) ->
@div class: 'tree-view-dialog', =>
@div prompt, outlet: 'prompt'
@div outlet: 'prompt', class: 'prompt', =>
@span prompt, outlet: 'promptText'
@subview 'miniEditor', new Editor(mini: true)
initialize: ({path, @onConfirm, select} = {}) ->
initialize: ({path, @onConfirm, select, iconClass} = {}) ->
@prompt.addClass(iconClass) if iconClass
@miniEditor.focus()
@on 'core:confirm', => @onConfirm(@miniEditor.getText())
@on 'core:cancel', => @cancel()
@@ -33,5 +35,5 @@ class Dialog extends View
$('.tree-view').focus()
showError: (message) ->
@prompt.text(message)
@prompt.flashError()
@promptText.text(message)
@flashError()

View File

@@ -210,9 +210,10 @@ class TreeView extends ScrollView
oldPath = entry.getPath()
dialog = new Dialog
prompt: "Enter the new path for the file:"
prompt: "Enter the new path for the file."
path: @rootView.project.relativize(oldPath)
select: true
iconClass: 'move'
onConfirm: (newPath) =>
newPath = @rootView.project.resolve(newPath)
directoryPath = fs.directory(newPath)
@@ -221,7 +222,7 @@ class TreeView extends ScrollView
fs.move(oldPath, newPath)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
dialog.showError("Error: #{e.message}. Try a different path")
@rootView.append(dialog)
@@ -246,16 +247,17 @@ class TreeView extends ScrollView
relativeDirectoryPath += '/' if relativeDirectoryPath.length > 0
dialog = new Dialog
prompt: "Enter the path for the new file/directory. Directories end with '/':"
prompt: "Enter the path for the new file/directory. Directories end with a '/'."
path: relativeDirectoryPath
select: false
iconClass: 'add'
onConfirm: (relativePath) =>
endsWithDirectorySeparator = /\/$/.test(relativePath)
path = @rootView.project.resolve(relativePath)
try
if fs.exists(path)
pathType = if fs.isFile(path) then "file" else "directory"
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path:")
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path.")
else if endsWithDirectorySeparator
fs.makeTree(path)
dialog.cancel()
@@ -266,7 +268,7 @@ class TreeView extends ScrollView
@rootView.open(path)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
dialog.showError("Error: #{e.message}. Try a different path")
@rootView.append(dialog)

View File

@@ -94,10 +94,39 @@
bottom: 0;
width: 100%;
background-color: #333;
color: white;
border: 2px solid #222;
-webkit-box-shadow: 0 0 3px 3px rgba(0, 0, 0, .5);
z-index: 99;
padding: 5px;
}
.tree-view-dialog .prompt {
padding-bottom: 3px;
font-size: 12px;
line-height: 16px;
color: #aaa;
}
.tree-view-dialog .prompt span {
position: relative;
top: -1px;
}
.tree-view-dialog .prompt:before {
font-family: 'Octicons Regular';
font-size: 16px;
width: 16px;
height: 16px;
margin-right: 3px;
-webkit-font-smoothing: antialiased;
}
.tree-view-dialog .prompt.add:before {
content: "\f086";
}
.tree-view-dialog .prompt.move:before {
content: "\f03e";
}
.tree-view .directory .header .name,