Skip to content

Commit

Permalink
Add method to update a single option for the loading page
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdavids8 committed Dec 8, 2014
1 parent 14151a8 commit a28c8f5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/please-wait.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
# If true, we can transition immediately to a new message/HTML
@_readyToShowLoadingHtml = false
# Find the element that displays the loading logo and set the src if supplied
logoElem = @_loadingElem.getElementsByClassName("pg-loading-logo")[0]
logoElem.src = @options.logo if logoElem?
@_logoElem = @_loadingElem.getElementsByClassName("pg-loading-logo")[0]
@_logoElem.src = @options.logo if @_logoElem?
# Add the loading screen to the body
document.body.appendChild(@_loadingElem)
# Add the CSS class that will trigger the initial transitions of the logo/loading HTML
Expand Down Expand Up @@ -133,6 +133,17 @@
else
listener()

updateOption: (option, value) ->
switch option
when 'backgroundColor'
@_loadingElem.style.backgroundColor = value
when 'logo'
@_logoElem.src = value
when 'loadingHtml'
@updateLoadingHtml(value)
else
throw new Error("Unknown option '#{option}'")

updateLoadingHtml: (loadingHtml, immediately=false) ->
unless @_loadingHtmlElem? then throw new Error("The loading template does not have an element of class 'pg-loading-html'")
if immediately
Expand Down

0 comments on commit a28c8f5

Please sign in to comment.