See #56. Add "Beautification in progress" view.

This commit is contained in:
Glavin Wiechert 2014-09-08 00:28:10 -03:00
parent 05ee8f22b3
commit 6b2b306b9d
2 changed files with 51 additions and 12 deletions

View File

@ -12,6 +12,7 @@ fs = null
path = null
strip = null
yaml = null
LoadingView = null
#MessageView = require "./message-view"
findFileResults = {}
@ -116,6 +117,9 @@ getConfigOptionsFromSettings = (langs) ->
options
beautify = ->
LoadingView ? = require "./loading-view"
@loadingView ? = new LoadingView()
@loadingView.show()
forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave")
# Look for .jsbeautifierrc in file and home path, check env variables
getConfig = (startPath) ->
@ -149,9 +153,7 @@ beautify = ->
else
externalOptions = {}
externalOptions
# Get the path to the config file
# All of the options
# Listed in order from default (base) to the one with the highest priority
# Left = Default, Right = Will override the left.
@ -159,9 +161,8 @@ beautify = ->
#
# User's Home path
# Project path
# Asynchronously and callback-style
beautifyCompleted = (text) ->
beautifyCompleted = (text) =>
# console.log 'beautifyCompleted'
if oldText isnt text
# console.log "Replacing current editor's text with new text"
@ -187,8 +188,9 @@ beautify = ->
editor.setScrollTop origScrollTop
return
), 0
else
# else
# console.log "Already Beautiful!"
@loadingView.hide()
return
# console.log 'Beautify time!'
text = undefined
@ -200,7 +202,6 @@ beautify = ->
indent_size: (if softTabs then tabLength else 1)
indent_char: (if softTabs then " " else "\t")
indent_with_tabs: not softTabs
configOptions = getConfigOptionsFromSettings(languages)
editedFilePath = editor.getPath()
projectOptions = getConfig(editedFilePath)

38
lib/loading-view.coffee Normal file
View File

@ -0,0 +1,38 @@
{View} = require "atom"
module.exports =
class LoadingView extends View
@content: ->
@div
class: 'atom-beautify message-panel', =>
@div
class: 'overlay from-top', =>
@div class: "tool-panel panel-bottom", =>
@div class: "inset-panel", =>
@div class: "panel-heading", =>
@div class: 'btn-toolbar pull-right', =>
@button
class: 'btn'
click: 'hide'
'Hide'
@span
class: 'text-primary'
outlet: 'title'
'Atom Beautify'
@div
class: "panel-body padded select-list text-center"
outlet: 'body'
=>
@div =>
@span
class: 'text-center loading loading-spinner-large inline-block'
@div
class: ''
'Beautification in progress.'
hide: (event, element) =>
@detach()
show: =>
if not @.hasParent()
atom.workspaceView.appendToTop @