Saving settings works ok
This commit is contained in:
parent
79c34273c8
commit
9531230f6e
|
@ -26,7 +26,21 @@ class UserController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
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
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -57,6 +57,8 @@ Beathaven::Application.routes.draw do
|
||||||
# match ':controller(/:action(/:id(.:format)))'
|
# match ':controller(/:action(/:id(.:format)))'
|
||||||
|
|
||||||
match 'user/auth' => 'user#auth'
|
match 'user/auth' => 'user#auth'
|
||||||
|
match 'user/update' => 'user#update'
|
||||||
|
|
||||||
match 'artist/autocomplete' => 'artist#autocomplete'
|
match 'artist/autocomplete' => 'artist#autocomplete'
|
||||||
match 'artist/(:name)/' => 'artist#data', :constraints => { :name => /[^\/]*/ }
|
match 'artist/(:name)/' => 'artist#data', :constraints => { :name => /[^\/]*/ }
|
||||||
end
|
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.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/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/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/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/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/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/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/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/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>
|
<script type="text/javascript" charset="windows-1251" src="http://vkontakte.ru/js/api/openapi.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -88,5 +88,5 @@ $(function(){
|
||||||
Ajax.loadArtistData($(this).html());
|
Ajax.loadArtistData($(this).html());
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$(window).bind('hashchange', Ajax.detectPage);
|
//$(window).bind('hashchange', Ajax.detectPage);
|
||||||
})
|
})
|
|
@ -91,5 +91,6 @@ var Pages = {
|
||||||
$('#data-container .inner').html(data);
|
$('#data-container .inner').html(data);
|
||||||
yaCounter7596904.hit(Ajax.getAnchor(), 'Settings', Ajax.referer);
|
yaCounter7596904.hit(Ajax.getAnchor(), 'Settings', Ajax.referer);
|
||||||
Ajax.setTitle('Settings');
|
Ajax.setTitle('Settings');
|
||||||
|
$('.settings-container .tabs .tab').first().trigger('click');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,42 @@
|
||||||
var Settings = {
|
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() {
|
$('.settings').live('click', function() {
|
||||||
Ajax.loadSettingsPage();
|
Ajax.loadSettingsPage();
|
||||||
})
|
});
|
||||||
|
|
||||||
$('.settings-container .tabs .tab').live('click', function(){
|
$('.settings-container .tabs .tab').live('click', function(){
|
||||||
if (!$(this).hasClass('active')) {
|
if (!$(this).hasClass('active')) {
|
||||||
$('.settings-container .tabs .tab').removeClass('active');
|
$('.settings-container .tabs .tab').removeClass('active');
|
||||||
$(this).addClass('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,19 +1,21 @@
|
||||||
<div class="settings-container">
|
<div class="settings-container">
|
||||||
<div class="tabs">
|
<div class="tabs">
|
||||||
<div class="left-space"></div>
|
<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="middle-space"></div>
|
||||||
<div class="tab">Music</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-container">
|
<div class="form-container"></div>
|
||||||
<div class="form">
|
<div class="forms">
|
||||||
<div class="field">
|
<div class="account">
|
||||||
<div class="label">Username:</div>
|
<div class="form">
|
||||||
<div class="value"><input name="username" type="text"/></div>
|
<div class="field">
|
||||||
</div>
|
<div class="label">Username:</div>
|
||||||
<div class="field">
|
<div class="value"><input name="username" type="text"/></div>
|
||||||
<div class="label">Email:</div>
|
</div>
|
||||||
<div class="value"><input name="email" type="text"/></div>
|
<div class="field">
|
||||||
|
<div class="label">Email:</div>
|
||||||
|
<div class="value"><input name="email" type="text"/></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -81,4 +81,8 @@
|
||||||
-webkit-border-radius: 3px;
|
-webkit-border-radius: 3px;
|
||||||
-moz-border-radius: 3px;
|
-moz-border-radius: 3px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
}
|
width: 300px;
|
||||||
|
}
|
||||||
|
.settings-container .forms {
|
||||||
|
display: none;
|
||||||
|
}
|
Loading…
Reference in New Issue