class window.Settings getAccountInfo: (callback) -> _session.query '/user/update/', {}, callback false saveAccountInfo: (params, callback) -> _session.query '/user/update', params, callback false loadFormData: (form) -> if form == 'account' $('.settings-container .form input[name$="username"]').val _session.getUser().name $('.settings-container .form input[name$="email"]').val _session.getUser().email $('.settings-container .form select').val _session.getUser().lang else if form == 'lastfm' if _session.getUser().lastfm_username $('.form-container input[name$="username"]').first().val _session.getUser().lastfm_username 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 $('.settings') .live 'click', -> _ajax.go('/settings/'); false $('.settings-container .tabs .tab').live 'click', -> if not $(this).hasClass 'active' $('.settings-container .tabs .tab').removeClass 'active' $(this).addClass 'active' $('.form-container').html $('.forms .'+ $(this).attr 'data-fieldset').html() _settings.loadFormData $(this).attr 'data-fieldset' false $('.lastfm-connect') .live 'click', -> window.lastfm_popup = window.open _session.getUser().lastfm_login_url setTimeout _settings.updateLastfmLogin, 100 false $('.settings-container .form input, .settings-container .form select').live 'blur', -> active_tab = $('.settings-container .tabs .tab.active').attr 'data-fieldset' if active_tab == 'account' params = username: $('.settings-container .form input[name$="username"]').first().val() email: $('.settings-container .form input[name$="email"]').first().val() lang: $('.settings-container .form select').first().val() lang_changed = params.lang != _session.getUser().lang if lang_changed if not confirm _beathaven.ls 'WINDOW_LANG_RELOAD', params.lang $('.settings-container .form select').val _session.getUser().lang _settings.saveAccountInfo params, -> if lang_changed window.location.reload() $('.header-container .hello .greating span').text (if params.username.length > 0 then params.username else '%username%') false false