Saving settings works ok
This commit is contained in:
parent
79c34273c8
commit
9531230f6e
|
@ -26,7 +26,21 @@ class UserController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
@res = {}
|
||||
check = check_auth(params)
|
||||
|
||||
if check == true
|
||||
user = User.find_by_vkid(params[:mid])
|
||||
unless params[:username].nil? or params[:email].nil?
|
||||
user.name = params[:username]
|
||||
user.email = params[:email]
|
||||
user.save
|
||||
end
|
||||
@res[:username] = user.name
|
||||
@res[:email] = user.email
|
||||
end
|
||||
|
||||
render :json => @res
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -57,6 +57,8 @@ Beathaven::Application.routes.draw do
|
|||
# match ':controller(/:action(/:id(.:format)))'
|
||||
|
||||
match 'user/auth' => 'user#auth'
|
||||
match 'user/update' => 'user#update'
|
||||
|
||||
match 'artist/autocomplete' => 'artist#autocomplete'
|
||||
match 'artist/(:name)/' => 'artist#data', :constraints => { :name => /[^\/]*/ }
|
||||
end
|
||||
|
|
|
@ -14,14 +14,14 @@
|
|||
<script type="text/javascript" charset="utf-8" src="/javascripts/jquery/jquery.autocomplete.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/jquery/jquery.contentchange.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/layout.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/vkontakte.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/session.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/ajax.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/search.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/settings.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/pages.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/audio.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/player.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/vkontakte.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="/javascripts/beathaven/session.js"></script>
|
||||
<script type="text/javascript" charset="windows-1251" src="http://vkontakte.ru/js/api/openapi.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -88,5 +88,5 @@ $(function(){
|
|||
Ajax.loadArtistData($(this).html());
|
||||
return false;
|
||||
});
|
||||
$(window).bind('hashchange', Ajax.detectPage);
|
||||
//$(window).bind('hashchange', Ajax.detectPage);
|
||||
})
|
|
@ -91,5 +91,6 @@ var Pages = {
|
|||
$('#data-container .inner').html(data);
|
||||
yaCounter7596904.hit(Ajax.getAnchor(), 'Settings', Ajax.referer);
|
||||
Ajax.setTitle('Settings');
|
||||
$('.settings-container .tabs .tab').first().trigger('click');
|
||||
}
|
||||
}
|
|
@ -1,13 +1,42 @@
|
|||
var Settings = {
|
||||
|
||||
getAccountInfo: function(callback) {
|
||||
Session.query('/user/update', {}, callback);
|
||||
},
|
||||
|
||||
saveAccountInfo: function(params, callback) {
|
||||
Session.query('/user/update', params, callback);
|
||||
},
|
||||
|
||||
loadFormData: function(form) {
|
||||
if (form == 'account') {
|
||||
this.getAccountInfo(function(data){
|
||||
$('.settings-container .form input[name$="username"]').val(data.username);
|
||||
$('.settings-container .form input[name$="email"]').val(data.email);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('.settings').live('click', function() {
|
||||
Ajax.loadSettingsPage();
|
||||
})
|
||||
});
|
||||
|
||||
$('.settings-container .tabs .tab').live('click', function(){
|
||||
if (!$(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'));
|
||||
}
|
||||
});
|
||||
|
||||
$('.settings-container .form input').live('blur', function(){
|
||||
params = {
|
||||
'username': $('.settings-container .form input[name$="username"]').first().val(),
|
||||
'email': $('.settings-container .form input[name$="email"]').first().val(),
|
||||
};
|
||||
Settings.saveAccountInfo(params, function(){
|
||||
console.log('saved');
|
||||
});
|
||||
})
|
|
@ -1,11 +1,12 @@
|
|||
<div class="settings-container">
|
||||
<div class="tabs">
|
||||
<div class="left-space"></div>
|
||||
<div class="tab active">Account</div>
|
||||
<div class="tab" data-fieldset="account">Account</div>
|
||||
<div class="middle-space"></div>
|
||||
<div class="tab">Music</div>
|
||||
</div>
|
||||
<div class="form-container">
|
||||
<div class="form-container"></div>
|
||||
<div class="forms">
|
||||
<div class="account">
|
||||
<div class="form">
|
||||
<div class="field">
|
||||
<div class="label">Username:</div>
|
||||
|
@ -17,4 +18,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -81,4 +81,8 @@
|
|||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
width: 300px;
|
||||
}
|
||||
.settings-container .forms {
|
||||
display: none;
|
||||
}
|
Loading…
Reference in New Issue