52 lines
1.1 KiB
CoffeeScript
Raw Normal View History

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