2011-09-07 23:47:11 +00:00
|
|
|
class window.Settings
|
2011-09-09 23:30:03 +00:00
|
|
|
|
2011-09-14 19:51:51 +00:00
|
|
|
loadSettingsPage: ->
|
|
|
|
unless _session.getUser().id?
|
|
|
|
_ajax.go('/')
|
|
|
|
false
|
|
|
|
_session.secureLoad '/settings/', (data) ->
|
|
|
|
false
|
|
|
|
#yaCounter7596904.hit _ajax.getAnchor(), 'Settings', _ajax.referer
|
|
|
|
_ajax.setTitle 'Settings'
|
|
|
|
false
|
|
|
|
|
2011-09-09 23:30:03 +00:00
|
|
|
getAccountInfo: (callback) ->
|
|
|
|
_session.query '/user/update/', {}, callback
|
|
|
|
false
|
|
|
|
|
|
|
|
saveAccountInfo: (params, callback) ->
|
|
|
|
_session.query '/user/update', params, callback
|
|
|
|
false
|
|
|
|
|
|
|
|
updateLastfmLogin: ->
|
|
|
|
if window.lastfm_popup.closed
|
|
|
|
_session.query '/user/auth', {}, (ar) ->
|
|
|
|
_session.setUser ar.user
|
|
|
|
_settings.loadFormData 'lastfm'
|
|
|
|
else
|
|
|
|
setTimeout _settings.updateLastfmLogin, 100
|
|
|
|
false
|
2011-06-27 18:41:36 +00:00
|
|
|
|
|
|
|
|
2011-09-14 19:51:51 +00:00
|
|
|
$('#preferences').live 'click', ->
|
2011-09-09 23:30:03 +00:00
|
|
|
_ajax.go('/settings/');
|
|
|
|
false
|
2011-06-27 18:41:36 +00:00
|
|
|
|
2011-09-12 16:16:13 +00:00
|
|
|
$('#settings-tabs li').live 'click', ->
|
2011-09-09 23:30:03 +00:00
|
|
|
if not $(this).hasClass 'active'
|
2011-09-12 16:16:13 +00:00
|
|
|
$('#settings-tabs li').removeClass 'active'
|
2011-09-09 23:30:03 +00:00
|
|
|
$(this).addClass 'active'
|
2011-09-12 16:16:13 +00:00
|
|
|
$('#settings-forms > div').hide()
|
|
|
|
$('#settings-forms > .'+ $(this).find('a').attr('data-tab')).show()
|
2011-09-09 23:30:03 +00:00
|
|
|
false
|
2011-06-27 18:41:36 +00:00
|
|
|
|
2011-09-14 19:51:51 +00:00
|
|
|
$('.lastfm-connect').live 'click', ->
|
2011-09-09 23:30:03 +00:00
|
|
|
window.lastfm_popup = window.open _session.getUser().lastfm_login_url
|
|
|
|
setTimeout _settings.updateLastfmLogin, 100
|
|
|
|
false
|
2011-09-14 19:51:51 +00:00
|
|
|
|
|
|
|
$('#settings-forms form').live 'submit', ->
|
|
|
|
params = {}
|
|
|
|
$(this).find('input, select').each ->
|
|
|
|
if $(this).attr('name')
|
2011-09-15 05:20:50 +00:00
|
|
|
if $(this).attr('type') is 'checkbox'
|
|
|
|
params[$(this).attr('name')] = ($(this).attr('checked') is 'checked')
|
|
|
|
else
|
|
|
|
params[$(this).attr('name')] = $(this).val()
|
|
|
|
_session.query '/user/update/', { params: params }
|
2011-09-14 19:51:51 +00:00
|
|
|
false
|
|
|
|
|
|
|
|
$('#settings-forms input[type$="submit"]').live 'mouseup', ->
|
|
|
|
$(this).parent().parent().parent().submit();
|
|
|
|
false
|
2011-09-15 05:42:41 +00:00
|
|
|
|
|
|
|
$('#settings-forms input[type$="checkbox"]').live 'click', (e) ->
|
|
|
|
sorry
|
|
|
|
false
|