See #56. Add "Beautification in progress" view.
This commit is contained in:
parent
05ee8f22b3
commit
6b2b306b9d
|
@ -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)
|
||||
|
|
|
@ -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 @
|
Loading…
Reference in New Issue