2011-09-07 23:47:11 +00:00
|
|
|
class window.Ajax
|
2011-09-09 22:13:02 +00:00
|
|
|
|
|
|
|
referer: false
|
2011-11-26 21:16:10 +00:00
|
|
|
previous_page: null
|
2011-09-09 22:13:02 +00:00
|
|
|
|
2011-11-27 09:56:10 +00:00
|
|
|
showSpinner: ->
|
|
|
|
$('#artist-load-spinner').show()
|
|
|
|
false
|
|
|
|
|
|
|
|
hideSpinner: ->
|
|
|
|
$('#artist-load-spinner').hide()
|
|
|
|
false
|
|
|
|
|
2011-09-09 22:13:02 +00:00
|
|
|
setArchor: (anchor) ->
|
|
|
|
@referer = this.getAnchor()
|
|
|
|
window.location.hash = '#' +anchor
|
|
|
|
|
|
|
|
getAnchor: () ->
|
|
|
|
window.location.hash.substring 1;
|
|
|
|
|
|
|
|
setTitle: (title) ->
|
2011-09-26 10:12:33 +00:00
|
|
|
if title?
|
|
|
|
document.title = title+ ' @ BeatHaven'
|
|
|
|
else
|
|
|
|
document.title ='BeatHaven'
|
2011-09-09 22:13:02 +00:00
|
|
|
|
|
|
|
go: (url) ->
|
|
|
|
this.setArchor url
|
|
|
|
false
|
2011-06-27 18:41:36 +00:00
|
|
|
|
2011-09-09 22:13:02 +00:00
|
|
|
detectPage: () ->
|
2011-11-26 21:16:10 +00:00
|
|
|
return false if @previous_page == _ajax.getAnchor()
|
|
|
|
@previous_page = _ajax.getAnchor()
|
2011-11-27 09:56:10 +00:00
|
|
|
path = _ajax.getAnchor()
|
|
|
|
if path == "/"
|
|
|
|
path = "/greetings/"
|
2011-11-26 21:16:10 +00:00
|
|
|
|
2011-11-27 09:56:10 +00:00
|
|
|
log "Ajax controller is detecting page for #{path} ..."
|
2011-11-26 21:30:43 +00:00
|
|
|
|
2011-11-27 09:56:10 +00:00
|
|
|
if m = path.match /\/artist\/(.+)\//
|
2011-09-09 22:13:02 +00:00
|
|
|
_search.loadArtistData m[1]
|
2011-11-27 09:56:10 +00:00
|
|
|
else if path.match /\/settings\//
|
2011-09-14 19:51:51 +00:00
|
|
|
_settings.loadSettingsPage()
|
2011-09-09 22:13:02 +00:00
|
|
|
else
|
2011-11-27 09:56:10 +00:00
|
|
|
this.showSpinner()
|
|
|
|
_session.query path, {}, (response) ->
|
|
|
|
_page.render response
|
|
|
|
_ajax.hideSpinner()
|
2011-11-27 12:37:51 +00:00
|
|
|
if _session.getUser().id?
|
2011-11-27 18:17:09 +00:00
|
|
|
$('.authorized-action').show()
|
2011-11-27 12:37:51 +00:00
|
|
|
else
|
2011-11-27 18:17:09 +00:00
|
|
|
$('.authorized-action').hide()
|
2011-11-27 09:56:10 +00:00
|
|
|
false
|
2011-09-09 22:13:02 +00:00
|
|
|
false
|
2011-06-27 18:41:36 +00:00
|
|
|
|
2011-06-27 20:43:54 +00:00
|
|
|
$(window).bind 'hashchange', ->
|
2011-09-14 19:51:51 +00:00
|
|
|
_ajax.detectPage()
|
2011-09-09 22:13:02 +00:00
|
|
|
false
|