Bootstrap, Chosen gems. New settings
This commit is contained in:
@@ -39,18 +39,11 @@ class window.Ajax
|
||||
|
||||
if m = path.match /\/artist\/(.+)\//
|
||||
_search.loadArtistData m[1]
|
||||
else if path.match /\/settings\//
|
||||
_settings.loadSettingsPage()
|
||||
else
|
||||
this.showSpinner()
|
||||
_session.query path, {}, (response) ->
|
||||
_page.render response
|
||||
_ajax.hideSpinner()
|
||||
if _session.getUser().id?
|
||||
$('.authorized-action').show()
|
||||
else
|
||||
$('.authorized-action').hide()
|
||||
false
|
||||
false
|
||||
|
||||
$(window).bind 'hashchange', ->
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
//= require jquery/jquery.autocomplete
|
||||
//= require jquery/jplayer/jquery.jplayer.min
|
||||
|
||||
//= require bootstrap-modal
|
||||
//= require chosen-jquery
|
||||
|
||||
//= require vksearch/vkontakte_search
|
||||
|
||||
//= require session
|
||||
|
||||
@@ -15,6 +15,7 @@ class window.Session
|
||||
log "Setting user ..."
|
||||
@user = user
|
||||
log "Hello, #{if user.name? then user.name else "%username%"}!"
|
||||
$('#username').html (if @user.name? then @user.name else '%username%')
|
||||
false
|
||||
|
||||
getUser: ->
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
class window.Settings
|
||||
|
||||
loadSettingsPage: ->
|
||||
unless _session.getUser().id?
|
||||
_ajax.go('/')
|
||||
false
|
||||
_session.secureLoad '/settings/', (data) ->
|
||||
false
|
||||
_ajax.setTitle 'Settings'
|
||||
false
|
||||
|
||||
getAccountInfo: (callback) ->
|
||||
_session.query '/user/update/', {}, callback
|
||||
false
|
||||
@@ -22,45 +13,69 @@ class window.Settings
|
||||
if window.lastfm_popup.closed
|
||||
_session.query '/user/auth', {}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$('#lastfm_username').val(ar.user.lastfm_username)
|
||||
$('.lastfm-connect').hide()
|
||||
if _session.user.lastfm_username not in ["", null]
|
||||
$('#settings .lastfm-off').hide()
|
||||
$('#settings .lastfm-on').show()
|
||||
$('#settings .lastfm-login').text _session.user.lastfm_username
|
||||
false
|
||||
else
|
||||
setTimeout _settings.updateLastfmLogin, 100
|
||||
false
|
||||
|
||||
setFormFields: ->
|
||||
$('#settings input[name="name"]').val _session.user.name
|
||||
$('#settings select[name="lang"] option[value="'+_session.user.lang+'"]').attr("selected", true)
|
||||
$('select#lang').chosen()
|
||||
if _session.user.lastfm_username not in ["", null]
|
||||
$('#settings .lastfm-off').hide()
|
||||
$('#settings .lastfm-on').show()
|
||||
$('#settings .lastfm-login').text _session.user.lastfm_username
|
||||
else
|
||||
$('#settings .lastfm-on').hide()
|
||||
$('#settings .lastfm-off').show()
|
||||
false
|
||||
|
||||
updateSettings: ->
|
||||
this.saveAccountInfo {
|
||||
params:
|
||||
name: $('#settings input[name="name"]').val()
|
||||
lang: $('#settings select[name="lang"]').val()
|
||||
}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$("#settings").modal 'hide'
|
||||
|
||||
|
||||
$('#preferences').live 'click', ->
|
||||
_ajax.go('/settings/');
|
||||
if _session.getUser().id?
|
||||
$("#settings").modal 'show'
|
||||
_settings.setFormFields()
|
||||
false
|
||||
|
||||
$('#settings-tabs li').live 'click', ->
|
||||
if not $(this).hasClass 'active'
|
||||
$('#settings-tabs li').removeClass 'active'
|
||||
$(this).addClass 'active'
|
||||
$('#settings-forms > div').hide()
|
||||
$('#settings-forms > .'+ $(this).find('a').attr('data-tab')).show()
|
||||
$("#settings a.close-btn").live 'click', ->
|
||||
$("#settings").modal 'hide'
|
||||
false
|
||||
|
||||
$('#settings a.save-btn').live 'click', ->
|
||||
_settings.updateSettings()
|
||||
false
|
||||
|
||||
$('.lastfm-connect').live 'click', ->
|
||||
window.lastfm_popup = window.open _session.getUser().lastfm_login_url, "lastfm_popup", "status=1,width=960,height=585"
|
||||
setTimeout _settings.updateLastfmLogin, 100
|
||||
false
|
||||
|
||||
$('#settings-forms form').live 'submit', ->
|
||||
params = {}
|
||||
$(this).find('input, select').each ->
|
||||
if $(this).attr('name')
|
||||
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 }
|
||||
|
||||
$('.lastfm-disconnect').live 'click', ->
|
||||
_settings.saveAccountInfo {
|
||||
params:
|
||||
lastfm_username: ""
|
||||
lastfm_token: ""
|
||||
}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$('#settings .lastfm-on').hide()
|
||||
$('#settings .lastfm-off').show()
|
||||
false
|
||||
false
|
||||
|
||||
$('#settings-forms input[type$="submit"]').live 'mouseup', ->
|
||||
$(this).parent().parent().parent().submit();
|
||||
false
|
||||
|
||||
$('#settings-forms input[type$="checkbox"]').live 'click', (e) ->
|
||||
sorry
|
||||
$ ->
|
||||
$("#settings").modal keyboard: true, backdrop: true
|
||||
false
|
||||
@@ -24,12 +24,10 @@ class window.Vkontakte
|
||||
_session = new Session(response.session)
|
||||
_session.query '/user/auth', {}, (ar) ->
|
||||
log "Authenticating user ..."
|
||||
if ar.newbie
|
||||
if ar.newbie or ar.user.name == ""
|
||||
VK.Api.call 'getVariable', key: 1281, (r) ->
|
||||
_session.query '/user/update', params: { name: r.response }, (ar2) ->
|
||||
_session.setUser ar2.user
|
||||
$('#username')
|
||||
.html (if _session.getUser().name then _session.getUser().name else '%username%')
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
_session.displayAuthorizedContent()
|
||||
@@ -42,9 +40,6 @@ class window.Vkontakte
|
||||
false
|
||||
else
|
||||
_session.setUser ar.user
|
||||
|
||||
$('#username')
|
||||
.html (if _session.getUser().name then _session.getUser().name else '%username%')
|
||||
_session.displayAuthorizedContent()
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
|
||||
Reference in New Issue
Block a user