Skip to content

Instantly share code, notes, and snippets.

@jakecraige
Created September 9, 2013 19:23
Show Gist options
  • Save jakecraige/6500250 to your computer and use it in GitHub Desktop.
Save jakecraige/6500250 to your computer and use it in GitHub Desktop.
( () ->
#Protects views where angular is not loaded from errors
if typeof angular == 'undefined'
return
module = angular.module 'NativeNavigation', []
module.factory 'NativeNavigation', () ->
goTo = (path, transition = 'slideFromRight') ->
webView = new steroids.views.WebView(path)
animation = new steroids.Animation({
transition: transition
})
steroids.layers.push({
view: webView
animation: animation
navigationBar: false
})
goToPreloaded = (webView, transition = 'slideFromRight') ->
animation = new steroids.Animation({
transition: transition
})
steroids.layers.push({
view: webView
animation: animation
navigationBar: false
})
back = ->
steroids.layers.pop()
preload = (identifier, url) ->
view = new steroids.views.WebView(url)
view.preload { id: identifier },
onSuccess: ->
debug "Preloaded view with id: " + identifier
onFailure: (msg) ->
if msg.errorDescription is "A preloaded layer with this identifier already exists"
view.id = identifier
else
alert msg.errorDescription
console.log 'failure preloading view'
view
openModal = (url) ->
modal = new steroids.views.WebView({ location: url })
steroids.modal.show(modal)
closeModal = ->
steroids.modal.hide()
openPreloadedModal = (modal) ->
steroids.modal.show(modal)
{ # return functions
goTo: goTo
back: back
preload: preload
goToPreloaded: goToPreloaded
openModal: openModal
closeModal: closeModal
openPreloadedModal: openPreloadedModal
}
)()
@jakecraige
Copy link
Author

For use with Appgyver's Steroids. WIP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment